Fixes and improvements#2
Merged
nickmarden merged 3 commits intonickmarden:so-many-slashesfrom Mar 31, 2026
Merged
Conversation
massawho
commented
Mar 16, 2026
- Improve error reporting
- Fix KeyError: 'group_id'
- Truncate Merge Request titles
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.
Owner
|
Thanks @massawho - I needed these changes too for MyAccident as it turns out :-) |
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.