Provides direct link to the PR when toolstate is changed.
Fix rust-lang-nursery/rust-toolstate#1.
This commit is contained in:
parent
b1f8e6fb06
commit
1acd3789bb
@ -17,6 +17,7 @@ import json
|
|||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import collections
|
import collections
|
||||||
|
import textwrap
|
||||||
|
|
||||||
# List of people to ping when the status of a tool changed.
|
# List of people to ping when the status of a tool changed.
|
||||||
MAINTAINERS = {
|
MAINTAINERS = {
|
||||||
@ -38,7 +39,12 @@ def read_current_status(current_commit, path):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def update_latest(current_commit, relevant_pr_number, current_datetime):
|
def update_latest(
|
||||||
|
current_commit,
|
||||||
|
relevant_pr_number,
|
||||||
|
relevant_pr_url,
|
||||||
|
current_datetime
|
||||||
|
):
|
||||||
'''Updates `_data/latest.json` to match build result of the given commit.
|
'''Updates `_data/latest.json` to match build result of the given commit.
|
||||||
'''
|
'''
|
||||||
with open('_data/latest.json', 'rb+') as f:
|
with open('_data/latest.json', 'rb+') as f:
|
||||||
@ -50,8 +56,13 @@ def update_latest(current_commit, relevant_pr_number, current_datetime):
|
|||||||
}
|
}
|
||||||
|
|
||||||
slug = 'rust-lang/rust'
|
slug = 'rust-lang/rust'
|
||||||
message = '📣 Toolstate changed by {}!\n\nTested on commit {}@{}.\n\n' \
|
message = textwrap.dedent('''\
|
||||||
.format(relevant_pr_number, slug, current_commit)
|
📣 Toolstate changed by {}!
|
||||||
|
|
||||||
|
Tested on commit {}@{}.
|
||||||
|
Direct link to PR: <{}>
|
||||||
|
|
||||||
|
''').format(relevant_pr_number, slug, current_commit, relevant_pr_url)
|
||||||
anything_changed = False
|
anything_changed = False
|
||||||
for status in latest:
|
for status in latest:
|
||||||
tool = status['tool']
|
tool = status['tool']
|
||||||
@ -90,13 +101,21 @@ if __name__ == '__main__':
|
|||||||
cur_commit_msg = sys.argv[2]
|
cur_commit_msg = sys.argv[2]
|
||||||
save_message_to_path = sys.argv[3]
|
save_message_to_path = sys.argv[3]
|
||||||
|
|
||||||
relevant_pr_match = re.search('#[0-9]+', cur_commit_msg)
|
relevant_pr_match = re.search('#([0-9]+)', cur_commit_msg)
|
||||||
if relevant_pr_match:
|
if relevant_pr_match:
|
||||||
relevant_pr_number = 'rust-lang/rust' + relevant_pr_match.group(0)
|
number = relevant_pr_match.group(1)
|
||||||
|
relevant_pr_number = 'rust-lang/rust#' + number
|
||||||
|
relevant_pr_url = 'https://github.com/rust-lang/rust/pull/' + number
|
||||||
else:
|
else:
|
||||||
relevant_pr_number = '<unknown PR>'
|
relevant_pr_number = '<unknown PR>'
|
||||||
|
relevant_pr_url = '<unknown>'
|
||||||
|
|
||||||
message = update_latest(cur_commit, relevant_pr_number, cur_datetime)
|
message = update_latest(
|
||||||
|
cur_commit,
|
||||||
|
relevant_pr_number,
|
||||||
|
relevant_pr_url,
|
||||||
|
cur_datetime
|
||||||
|
)
|
||||||
if message:
|
if message:
|
||||||
print(message)
|
print(message)
|
||||||
with open(save_message_to_path, 'w') as f:
|
with open(save_message_to_path, 'w') as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user