Merge ~emmabrostrom/ols-jenkaas:pre-merge-bot-comment into ols-jenkaas:main

Proposed by Emma Brostrom
Status: Merged
Merged at revision: 85d0e704f852a446183dad50ee6bdd13211e7240
Proposed branch: ~emmabrostrom/ols-jenkaas:pre-merge-bot-comment
Merge into: ols-jenkaas:main
Diff against target: 38 lines (+7/-11)
1 file modified
olsjenkaas/commands.py (+7/-11)
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini Approve
Review via email: mp+464146@code.launchpad.net

Commit message

Revert!

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/olsjenkaas/commands.py b/olsjenkaas/commands.py
2index 8cace19..9db0a23 100644
3--- a/olsjenkaas/commands.py
4+++ b/olsjenkaas/commands.py
5@@ -816,26 +816,22 @@ class PreMergeGitProposals(Command):
6 return most_recent_commit
7
8 @staticmethod
9- def is_pre_merge_ci_comment_match(comment_body):
10- matches = re.findall(
11- r".*[pre-merge ci\w].*revision [0-9a-z]{40}",
12- comment_body,
13- )
14- return bool(matches)
15-
16- @staticmethod
17 def get_most_recent_commit_seen_by_bot(proposal):
18 comment_collection = proposal.all_comments
19 bot_author_link = "https://api.launchpad.net/devel/~otto-copilot"
20 bot_comments = [
21- comment.message_body
22+ comment
23 for comment in comment_collection
24 if comment.author_link == bot_author_link
25- and PreMergeGitProposals.is_pre_merge_ci_comment_match(comment.message_body)
26 ]
27 try:
28 most_recent_bot_comment = bot_comments[-1]
29- commit_hash = most_recent_bot_comment.split()[-1]
30+ # Find revision number in last bot comment
31+ matches = re.findall(
32+ r".*[pre-merge ci\w].*revision [0-9a-z]{40}",
33+ most_recent_bot_comment.message_body,
34+ )
35+ commit_hash = str(matches[0]).split()[-1]
36 return commit_hash
37 # If no bot comment or revision number found
38 except IndexError:

Subscribers

People subscribed via source and target branches