Skip to content

Commit

Permalink
Fix GitlabCommentReporter raise unhandled exception if no merge reque…
Browse files Browse the repository at this point in the history
…st has been found
  • Loading branch information
1vm0 committed Feb 3, 2022
1 parent f84f4fb commit 27f9350
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions megalinter/reporters/GitlabCommentReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ def produce_report(self):
gitlab_repo = config.get("CI_PROJECT_NAME")
gitlab_project_id = config.get("CI_PROJECT_ID")
gitlab_merge_request_id = config.get("CI_MERGE_REQUEST_ID", "")
if (
gitlab_merge_request_id == ""
and config.get("CI_OPEN_MERGE_REQUESTS", "") != ""
):
gitlab_merge_request_id = (
config.get("CI_OPEN_MERGE_REQUESTS", "missing!missing")
.split(",")[0]
.split("!")[1]
)
if gitlab_merge_request_id == "":
if config.get("CI_OPEN_MERGE_REQUESTS", "") != "":
gitlab_merge_request_id = (
config.get("CI_OPEN_MERGE_REQUESTS", "missing!missing")
.split(",")[0]
.split("!")[1]
)
else:
logging.info(
"[Gitlab Comment Reporter] No merge request has been found, so no comment has been posted"
)
return

gitlab_server_url = config.get("CI_SERVER_URL", self.gitlab_server_url)
action_run_url = config.get("CI_JOB_URL", "")
p_r_msg = build_markdown_summary(self, action_run_url)
Expand Down

0 comments on commit 27f9350

Please sign in to comment.