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

Gitlab integration: 'Diff' button generates incorrect URL (mantis & gitlab domains concatenated) #371

Closed seanm closed 3 years ago

seanm commented 3 years ago

Not sure if I've configured something wrong, or it's a bug, but the 'Diff' button in every changeset has a URL of this form:

https://mantis.example.com/bugs/gitlab.example.com/namespace/project/commit/SHA

when it should be:

https://gitlab.example.com/namespace/project/commit/SHA

Note how the mantis URL (https://mantis.example.com/bugs/) is prepended.

I've looked through the docs and settings, but I don't see anything that explains this... so perhaps it's a bug...

dregad commented 3 years ago

It works just fine for me image

So it's probably something in the way you configured your repo...

Depending on context, this URL is built in one of the SourceGitlab::url_xxx() methods, by concatenating _hubroot and _hubreponame settings, so check what you have for those.

seanm commented 3 years ago

Hi @dregad thanks for your response.

I've poked through the code to try and be sure which variable name corresponds to what in the UI, but I'm not sure. Is this the case:

hub_root -> "GitLab Root" hub_reponame -> "GitLab Repository Name"

In my settings (at plugin.php?page=Source/repo_manage_page) I have:

"URL": blank "GitLab Root": gitlab.example.com "GitLab Repository Name": namespace/project

dregad commented 3 years ago

GitLab Root": gitlab.example.com

If that is indeed the exact value you have in this field, then this is your problem right there.

The plugin builds the Diff button's target as "$t_root/$t_reponame/commit/$t_ref", so in your case, gitlab.example.com/namespace/project/commit/SHA. This is a relative URL, so it is appended to your MantisBT root.

As mentioned on the _repo_updatepage, the plugin expects a full URL to your Gitlab instance, not just a hostname (i.e. including the protocol). You should probably have https://gitlab.example.com here.

seanm commented 3 years ago

If that is indeed the exact value you have in this field, then this is your problem right there.

Indeed that was it. Thanks!

As mentioned on the repo_update_page, the plugin expects a full URL to your Gitlab instance

So it does. Guess I read too fast.

Thanks for #373 !

seanm commented 3 years ago

@dregad do you know of any public projects using mantis with gitlab integration? We might be seeing some mixup of commits and branches and tickets, and it would be handy to look how it's working elsewhere....