Skip to content

Commit

Permalink
Compatible with gitlab 13
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbeevip committed Sep 1, 2023
1 parent 6fae3ec commit bff23c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gitlab Bot

This is a Gitlab bot that utilizes [webhooks](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html) to automate certain tasks:
This is a GitLab(13.2+) bot that utilizes [webhooks](https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html) to automate certain tasks:

#### Verify if the submitters email domain during Merge requests.

Expand Down
14 changes: 12 additions & 2 deletions src/merge_request_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,18 @@ async def generate_diff_description_summary(event, gl):
description = event.data["object_attributes"]["description"]
iid = event.data["object_attributes"]["iid"]
if "AI Summary:" not in description:
diff_url = f"/projects/{project_id}/merge_requests/{iid}/diffs"
diffs = await gl.getitem(diff_url)
try:
# Support 15.7+
diff_url = f"/projects/{project_id}/merge_requests/{iid}/diffs"
diffs = await gl.getitem(diff_url)
except Exception as e:
logging.warning(
"Calling API /diffs error, trying to call /changes", e
)
diff_url = f"/projects/{project_id}/merge_requests/{iid}/changes"
changes = await gl.getitem(diff_url)
diffs = changes["changes"]

response_summary = ai_diffs_summary(diffs)

merge_request_post_note_url = (
Expand Down

0 comments on commit bff23c0

Please sign in to comment.