Open
Conversation
c1bc653 to
0f73794
Compare
…binary mode, the default buffer size will be used
… info; change logging to debug
0f73794 to
ff8d050
Compare
Enhance error reporting by capturing and logging subprocess output on failure. This ensures that the specific reasons for Git command failures (such as GitLab pre-receive hook rejections) are visible in the logs. Before this change, the script would only report that a command failed with "exit status 1," leaving the actual cause a mystery. Now, it provides the full context needed for debugging.
Rename key `group` to `group_id` of self.gitlab hashmap to avoid
exception below
Traceback (most recent call last):
File ".../venv/github2gitlab/bin/github2gitlab", line 25, in <module>
sys.exit(GitHub2GitLab.factory(sys.argv[1:]).run())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../venv/github2gitlab/github2gitlab/main.py", line 163, in run
if self.add_project():
^^^^^^^^^^^^^^^^^^
File ".../venv/github2gitlab/github2gitlab/main.py", line 321, in add_project
if g['group_id']:
~^^^^^^^^^^^^
KeyError: 'group_id'
Truncate Merge Request titles to 255 characters to comply with GitLab API limits. This prevents crashes when syncing GitHub Pull Requests with very long titles and ensures stable comparisons during updates. 1. Creation Logic (sync): Truncates the GitHub pull request title to 255 characters when creating a new Merge Request on GitLab. This prevents the initial ValueError you encountered. 2. Update Logic (field_update): Ensures that if a title is updated later (e.g., someone renames the PR on GitHub), the new title sent to GitLab is also truncated to 255 characters. 3. Comparison Logic (field_equal): Truncates both the GitHub and GitLab titles before comparing them. This is crucial because it prevents the script from thinking the titles are different just because one is 300 characters (on GitHub) and the other is 255 characters (on GitLab), which would otherwise cause an infinite loop of unnecessary update attempts.
Fixes and improvements
The groups API query used per_page=10000, which GitLab silently caps at 100. On instances with more than 100 groups, the target namespace may not appear in results, causing group_id to stay None and project creation to fall back to the user's personal namespace. Fix: add search= parameter using the leaf component of the namespace so the API filters server-side, making pagination irrelevant.
Fix group lookup failing on large GitLab instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This was a small basket of fixes I needed to make to enable migration in an enterprise scenario:
/