Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for incorrect assumption in Gitlab code (support request 21760) #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion repo_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ def get_repos(origin: Origin, scm_token: str, scm_org: str = None, scm_url: str
else:
gl = gitlab.Gitlab(private_token=scm_token)

g_id = gl.groups.list(search=scm_org)[0].id
g_list = gl.groups.list(search=scm_org)
# we need the id with the shortest URL (which is not always the first entry in the list as the original code assumes),
# certain (Gitlab) environments have
# https://scm_url/groups/scm_org/
# https://scm_url/groups/scm_org/discussions ...
length_url = 1234567891234 # a really, really long URL
for group in g_list:
if len(group.web_url) < length_url:
length_url = len(group.web_url)
g_id = group.id

group = gl.groups.get(g_id)
repos = normalize_gitlab(group.projects.list(include_subgroups=True))

Expand Down