gitlab bridge doesn't support self-hosted GitLab instance

Labels: area/bridge

Timeline

felsgaertner (felsgaertner) opened (edited)

Hi,

is there a way to specify the API URL of a self hosted GitLab (CE) instance? I specified --url=<internal project url>, but the API call was sent to "https://gitlab.com/api/v4/projects".

May be you should take the host name from the specified --url value.

Thanks.

felsgaertner (felsgaertner) commented

Related to #259

Michael Muré (MichaelMure) commented

hu, that's a good point. @A-Hilaly can you have a look ?

Michael Muré (MichaelMure) changed the title from gitlab bridge doesn't support self-hosted GitLab instance to gitlab bridge doesn't support self-hosted GitLab instance

Amine (a-hilaly) commented

Good suggestion 👍🏼, i think we need to store a new key/value to implement this

On Thu 28 Nov 2019 at 14:52, Michael Muré notifications@github.com wrote:

hu, that's a good point. @A-Hilaly https://github.com/A-Hilaly can you have a look ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MichaelMure/git-bug/issues/264?email_source=notifications&email_token=ACTET3POVGOLMT4UQTHS55TQV7EKDA5CNFSM4JSUWBMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFMVJII#issuecomment-559502497, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACTET3OUP7A4SGGGQ2VRGFTQV7EKDANCNFSM4JSUWBMA .

felsgaertner (felsgaertner) commented

As far as I understand, the bridge target URL has to be stored in any way.
So why not just run a regular expression to get server fqdn and project namespace?

For example

  • HTTPS = https?://((?:[\w-.]+.)+\w+):([\w-./]+)
  • SSH = @((?:[\w-.]+.)+\w+):([\w-./]+).git

Amine (a-hilaly) commented

Yes we'll have to store the hosted Gitlab URL, so you users don't have to provide the URL at each pull/push operation.

HTTPS = https?://((?:[\w-.]+.)+\w+):([\w-./]+) SSH = @((?:[\w-.]+.)+\w+):([\w-./]+).git

We do almost do the same thing with Github URLs. I think this is exactly what we need to validate the Gitlab URL before storing/using it

Michael Muré (MichaelMure) added label area/bridge

felsgaertner (felsgaertner) commented

If you need a tester, just drop me a link to project and branch.

Michael Muré (MichaelMure) closed the bug

Michael Muré (MichaelMure) commented

@felsgaertner it should be working now with the master branch, can you give it a try ?

felsgaertner (felsgaertner) commented (edited)

I tested with this version:

> git log -2
commit e96d8e6771086e20639a16abf6af30f2faa006a0 (HEAD -> master, origin/master, origin/HEAD)
Merge: ef6801a f6b4830
Author: Michael Mur<C3><A9> <batolettre@gmail.com>
Date:   Tue Dec 10 21:13:54 2019 +0100

    Merge pull request #274 from MichaelMure/gitlab-bridge

    bridge/gitlab: support self-hosted GitLab instance

commit f6b4830c0b68f3b5c616236bc9d51943765c8b4a
Author: amine <hilalyamine@gmail.com>
Date:   Tue Dec 10 20:30:29 2019 +0100

    bridge/gitlab: support self-hosted GitLab instance

Results (Windows 10):

> git bug bridge configure
[1]: github
[2]: gitlab
[3]: launchpad-preview
target: 2
name [default]: test
You can generate a new token by visiting https://gitlab.com/profile/personal_access_tokens.
Choose 'Create personal access token' and set the necessary access scope for your repository.

'api' access scope: to be able to make api calls

Enter token: Sxxxxxxxxxxxxxxxxxx-
Error: project validation: Get /api/v4/projects/: unsupported protocol scheme ""

> git bug bridge configure --name=test --target=gitlab --url=https://private.instance/username/semrel-changelog-mr --token=Sxxxxxxxxxxxxxxxxxx-
Error: project validation: Get /api/v4/projects/username%2Fsemrel-changelog-mr: unsupported protocol scheme ""

Michael Muré (MichaelMure) opened the bug

Amine (a-hilaly) commented

I just opened #280, currently it's working with the official gitlab url. Now a prompt for base url is triggered if --base-url is empty @felsgaertner can you please test the PR with your gitlab instance ?

Michael Muré (MichaelMure) commented

It should be good now

Michael Muré (MichaelMure) closed the bug