ValentinFrancois / python-gitlab-submodule

List project submodules and get the commits they point to with python-gitlab
Apache License 2.0
3 stars 4 forks source link

Handle gitlab server with custom platform #24

Closed Xibutox closed 6 months ago

Xibutox commented 10 months ago

Hello, I am using your code too fetch some data from my local Gitlab server. The thing is that line 68 in the file submodule_to_project.py the parsed.platform is hard coded 'gitlab' but on my local server this name isn't 'gitlab' but 'base'. There is two way to fix my problem, the dirty way : replace the "or" by a "and' inside the if. You can also set a parameter to this function and depending one to give the name of the gitlab platform.

Here is the part of the code i am talking about :

    # giturlparse.GitUrlParsed.platform is too permissive and will be set to
    # 'gitlab' for some non-gitlab urls, for instance:
    # https://opensource.ncsa.illinois.edu/bitbucket/scm/u3d/3dutilities.git
    if (parsed.platform != 'gitlab'
            or all([host not in parsed.host for host in gitlab_hosts])):

        logger.warning(f'submodule git url is not hosted on gitlab: {url}')
        return None

Thanks in advance for any response.

ValentinFrancois commented 9 months ago

Hi! Did you try passing self_managed_gitlab_host='base'? It's meant to solve exactly this problem (see https://github.com/ValentinFrancois/python-gitlab-submodule/blob/main/gitlab_submodule/submodule_to_project.py#L62).

Xibutox commented 9 months ago

Hello,

Thank you for your answer. I am actually using this variable but my problem isn't the gitlab host. I already specified mine : self_managed_gitlab_host='custom-gitlab' which is actually working but my problem is the platform.

I add the following print to the code to help explaining my problem :

    if (parsed.platform != 'gitlab'
            or all([host not in parsed.host for host in gitlab_hosts])):

        print(f'submodule git url is not hosted on gitlab: {url}')
        print(f'Host : {parsed.host}')
        print(f'gitlab_hosts var : {gitlab_hosts}')
        print(f'Platform : {parsed.platform}')
        return None

With this code, i end up having this :

submodule git url is not hosted on gitlab: http://custom-gitlab/namescape/... Host : custom-gitlab gitlab_hosts var : ['gitlab', 'custom-gitlab'] Platform : base

Has you can see the parsed.platform is not 'gitlab' so it end up always passing in the if statement. My problem isn't the host name, it's plaform's name. It would be perfect to have a variable "self_managed_gitlab_platform" which works like "self_managed_gitlab_host" but for platform's name.

ValentinFrancois commented 6 months ago

Hello,

sorry for the very long waiting time. I think I understand your issue now, and it should be fixed in this version: https://github.com/ValentinFrancois/python-gitlab-submodule/releases/tag/0.2.5

Please let me know if it works.

Xibutox commented 6 months ago

Hello, thank you for the fix, it works perfectly with my usecase now.