CI: check_mr_settings.py: fix check for same repo (!255)
Do not crash when a MR was made from the same repository, because the "allow_maintainer_to_push" key does not exist in the GitLab API's output. Check first if the "source_project_id" is the same as the "target_project_id", and if it is, do not try to access "allow_maintainer_to_push" at all.
This commit is contained in:
parent
81cee38610
commit
3030c00ba2
1 changed files with 17 additions and 6 deletions
|
@ -77,16 +77,27 @@ def get_mr_settings(path):
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def check_allow_push(settings):
|
def settings_read(settings, key):
|
||||||
""" :returns: True when maintainers are allowed to push to the branch
|
if key not in settings:
|
||||||
(what we want!), False otherwise """
|
print("ERROR: missing '" + key + "' key in settings!")
|
||||||
if "allow_maintainer_to_push" not in settings:
|
|
||||||
print("ERROR: missing 'allow_maintainer_to_push' key in settings!")
|
|
||||||
print("Here are the whole settings for debugging:")
|
print("Here are the whole settings for debugging:")
|
||||||
print("---")
|
print("---")
|
||||||
print(settings)
|
print(settings)
|
||||||
exit(1)
|
exit(1)
|
||||||
return settings["allow_maintainer_to_push"]
|
return settings[key]
|
||||||
|
|
||||||
|
|
||||||
|
def check_allow_push(settings):
|
||||||
|
""" :returns: True when maintainers are allowed to push to the branch
|
||||||
|
(what we want!), False otherwise """
|
||||||
|
|
||||||
|
# Check if source branch is in same repository
|
||||||
|
source = settings_read(settings, "source_project_id")
|
||||||
|
target = settings_read(settings, "target_project_id")
|
||||||
|
if source == target:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return settings_read(settings, "allow_maintainer_to_push")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in a new issue