mantisbt-plugins / source-integration

Source control integration plugin framework for MantisBT, including support for Github, Gitlab, Bitbucket, Gitea, Gitweb, Cgit, Subversion, Mercurial and more
http://noswap.com/projects/source-integration/
MIT License
181 stars 130 forks source link

Gitea integration #375

Closed zamachuga closed 2 months ago

zamachuga commented 3 years ago

https://gitea.io/en-us/ How to Gitea integration?

lds-lds commented 3 years ago

Hello I also use gitea, and it would be great for us if you implemented source integration for gitea

dregad commented 3 years ago

Contributions are always welcome, feel free to submit a pull request for gitea integration.

fokkersim commented 2 years ago

I currently work on it based on the GitHub Plugin. Its not finished yet but basically working. Code cleanup is needed. Still have some questions and a few unclear points. I hope I can create a repository for it soon. I still need to implement the webhook creation through button clich from the repo configuraton page.

dregad commented 2 years ago

I currently work on it based on the GitHub Plugin

Great news, thanks ! Looking forward to it.

Still have some questions and a few unclear points

Can't help with the Gitea side of things, but if your questions are related to MantisBT or the Source Integration framework, I'll be glad to assist if I can. Just ask !

I hope I can create a repository for it soon

Rather than having it as a standalone repository, I would suggest to bundle your plugin with this one, whenever you're ready.

lds-lds commented 2 years ago

I currently work on it based on the GitHub Plugin.

Oh great :) thanks @fokkersim

fokkersim commented 2 years ago

Can't help with the Gitea side of things, but if your questions are related to MantisBT or the Source Integration framework, I'll be glad to assist if I can. Just ask !

Oh great! On which channel should I contact you? Basically first big question is: Is it normal that the Mantis repository $t_repo->id changes when a "Import Everything" is done? If yes, how to handle this with respect to oauth refresh token usage? The redirect_uri seems to need the repository id as a parameter for the Reply with the code. When the repo id changes the token refresh via oauth fails due to a now wrong redirect_uri.

dregad commented 2 years ago

On which channel should I contact you

Here is fine, or if you prefer https://gitter.im/mantisbt-plugins/source-integration (if I'm on-line you may get faster turnaround)

Is it normal that the Mantis repository $t_repo->id changes when a "Import Everything" is done?

That's just the way the plugin was originally written (long before I took over the project's maintenance). Not sure I would call that normal, though. I agree that changing repo id is confusing at best, and may cause issues.

AFAIK, the idea was to perform the full import into a new, empty repository so the original could be kept and restored in case of errors during the import operation, but I do not think there was any actual intention to change the id; that's probably just a side effect.

how to handle this with respect to oauth refresh token usage? The redirect_uri seems to need the repository id as a parameter for the Reply with the code. When the repo id changes the token refresh via oauth fails due to a now wrong redirect_uri.

I was not aware of any issues with changing repo id until now, but TBH the full import is a feature I rarely use.

fokkersim commented 2 years ago

Making a full import like that makes totally sense to me, but keeping the id would be probably nice?

I was not aware of any issues with changing repo id until now, but TBH the full import is a feature I rarely use.

I think this/my question can be seen best in oauth_authorize.php where the id and the code is required as a parameter to process the further authentication procedure after the initial request. This involves then later on to assign also the authentication token and refresh token to a repository. At the moment I dont see, how this would work with one authentication for all repositories configured in Mantis. Probably something like iterating through all repositories and checking for the application id and populate all repos with the same application id with the same authentication token and refresh token once the oauth procedure is finished? Am I missing smth. here? Basically its not a problem to do the oauth procedure for every repo, it works.

dregad commented 2 years ago

assign also the authentication token and refresh token to a repository [...] I dont see, how this would work with one authentication for all repositories configured in Mantis

I believe this is by design, it was never meant to be a global authentication

fokkersim commented 2 years ago

I believe this is by design, it was never meant to be a global authentication

I never would have had the idea that this could work, if it wouldnt be mentioned in the Github plugin documentation

NOTE: a single OAuth app is sufficient to handle all the GitHub repositories configured in a given MantisBT instance Github doc

fokkersim commented 2 years ago

I found out that this works for github, because github allows redirect_uris to be more felxible than gitea (see last two sentences). So that means for github your could define in github settings redirect_uri = https://mydomain/mantisbt/ and at the same time pass https://mydomain/mantisbt/+SUBDIRECTORY+PARAMS in the authentication request, which makes no issues. This is why a single OAuth app is sufficient for all github repos...

fokkersim commented 2 years ago

I could not work on this for a couple of weeks now. I made a push to my repository https://github.com/fokkersim/SourceGitea maybe it helps. Basics seem to work for me

julian70400 commented 2 months ago

Hello, anybody still works on this ? Actually nothing works with Gitea.

dregad commented 2 months ago

PR #413 proposes an implementation of Gitea support.