Skip to content
Snippets Groups Projects
Unverified Commit 9ac0bdb7 authored by Pablo Correa Gomez's avatar Pablo Correa Gomez
Browse files

mrhlpr: do not approve if the logged-in user is the same as the author

As it will fail, and that's annoying!

Fixes #18
parent c889a3cf
No related branches found
No related tags found
1 merge request!42mrhlpr: do not approve if the logged-in user is the same as the author
Pipeline #185148 passed
......@@ -468,10 +468,11 @@ def finish(
git.push_head(remote_local, status.source_branch)
gl = gitlab_api.Gitlab(url="https://gitlab.com", private_token=gitlab_token)
gl.auth()
project = gl.projects.get(origin.project_id)
mr = project.mergerequests.get(mr_id)
if skip_approve:
print("Skipping approval per request...")
if skip_approve or (gl.user and mr.author and gl.user.id == mr.author.get("id")):
print("Skipping approval...")
else:
print("Approving MR...")
try:
......@@ -479,7 +480,6 @@ def finish(
# For some reason, approve fails with auth error if already approved...
except gitlab_api.GitlabAuthenticationError as e:
approved_by_ids = [ap["id"] for ap in mr.approval_state.get().rules[0]["approved_by"]]
gl.auth()
if gl.user is None:
raise e
if gl.user.id not in approved_by_ids:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment