Skip to content

Commit a4c317e

Browse files
committed
Be more cheerful and helpful
1 parent ab5fc7f commit a4c317e

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

src/tools/publish_toolstate.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@
3434
'rust-by-example': '@steveklabnik @marioidival @projektir',
3535
}
3636

37+
REPOS = {
38+
'miri': 'https://github.com/solson/miri',
39+
'clippy-driver': 'https://github.com/rust-lang/rust-clippy',
40+
'rls': 'https://github.com/rust-lang/rls',
41+
'rustfmt': 'https://github.com/rust-lang/rustfmt',
42+
'book': 'https://github.com/rust-lang/book',
43+
'nomicon': 'https://github.com/rust-lang-nursery/nomicon',
44+
'reference': 'https://github.com/rust-lang-nursery/reference',
45+
'rust-by-example': 'https://github.com/rust-lang/rust-by-example',
46+
}
47+
3748

3849
def read_current_status(current_commit, path):
3950
'''Reads build status of `current_commit` from content of `history/*.tsv`
@@ -50,7 +61,7 @@ def issue(
5061
maintainers,
5162
relevant_pr_number,
5263
relevant_pr_user,
53-
msg,
64+
pr_reviewer,
5465
):
5566
# Open an issue about the toolstate failure.
5667
gh_url = 'https://api.github.com/repos/rust-lang/rust/issues'
@@ -60,15 +71,16 @@ def issue(
6071
gh_url,
6172
json.dumps({
6273
'body': '''\
63-
@{}: your PR ({}) broke {}
74+
Hello, this is your friendly neighborhood mergebot.
75+
After merging PR {}, I observed that the tool {} no longer builds.
76+
A follow-up PR to the repository {} is needed to fix the fallout.
6477
65-
If you have the time it would be great if you could open a PR against {} that
66-
fixes the fallout from your PR.
78+
cc @{}, do you think you would have time to do the follow-up work? If so, that would be great!
6779
68-
{}
80+
cc @{}, the PR reviewer, and @rust-lang/compiler -- nominating for prioritization.
6981
70-
'''.format(relevant_pr_user, relevant_pr_number, tool, tool, msg),
71-
'title': '💔 {}'.format(tool),
82+
'''.format(relevant_pr_number, tool, REPOS[tool], relevant_pr_user, pr_reviewer),
83+
'title': '`{}` no longer builds after {}'.format(tool, relevant_pr_number),
7284
'assignees': assignees,
7385
'labels': ['T-compiler', 'I-nominated'],
7486
}),
@@ -84,6 +96,7 @@ def update_latest(
8496
relevant_pr_number,
8597
relevant_pr_url,
8698
relevant_pr_user,
99+
pr_reviewer,
87100
current_datetime
88101
):
89102
'''Updates `_data/latest.json` to match build result of the given commit.
@@ -108,7 +121,7 @@ def update_latest(
108121
for status in latest:
109122
tool = status['tool']
110123
changed = False
111-
failures = ''
124+
build_failed = False
112125

113126
for os, s in current_status.items():
114127
old = status[os]
@@ -128,11 +141,10 @@ def update_latest(
128141
.format(title, MAINTAINERS.get(tool))
129142
# only create issues for build failures. Other failures can be spurious
130143
if new == 'build-fail':
131-
failures += title
132-
failures += '\n'
144+
build_failed = True
133145

134-
if failures != '':
135-
issue(tool, MAINTAINERS.get(tool), relevant_pr_number, relevant_pr_user, failures)
146+
if build_failed:
147+
issue(tool, MAINTAINERS.get(tool), relevant_pr_number, relevant_pr_user, pr_reviewer)
136148

137149
if changed:
138150
status['commit'] = current_commit
@@ -156,23 +168,26 @@ def update_latest(
156168
github_token = sys.argv[4]
157169

158170
# assume that PR authors are also owners of the repo where the branch lives
159-
relevant_pr_match = re.search('Auto merge of #([0-9]+) - ([^:]+)', cur_commit_msg)
171+
relevant_pr_match = re.search('Auto merge of #([0-9]+) - ([^:]+):[^,]+ r=([^\s]+)', cur_commit_msg)
160172
if relevant_pr_match:
161173
number = relevant_pr_match.group(1)
162174
relevant_pr_user = relevant_pr_match.group(2)
163175
relevant_pr_number = 'rust-lang/rust#' + number
164176
relevant_pr_url = 'https://github.com/rust-lang/rust/pull/' + number
177+
pr_reviewer = relevant_pr_match.group(3)
165178
else:
166179
number = '-1'
167180
relevant_pr_user = '<unknown user>'
168181
relevant_pr_number = '<unknown PR>'
169182
relevant_pr_url = '<unknown>'
183+
pr_reviewer = '<unknown reviewer>'
170184

171185
message = update_latest(
172186
cur_commit,
173187
relevant_pr_number,
174188
relevant_pr_url,
175189
relevant_pr_user,
190+
pr_reviewer,
176191
cur_datetime
177192
)
178193
if not message:

0 commit comments

Comments
 (0)