Skip to content

Commit 05448c2

Browse files
Kobzolcuviper
authored andcommitted
Update bors e-mail lookup
(cherry picked from commit 138cc27)
1 parent 2827b1b commit 05448c2

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

.github/workflows/post-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
sleep 60
3030
3131
# Get closest bors merge commit
32-
PARENT_COMMIT=`git rev-list --author='bors <bors@rust-lang.org>' -n1 --first-parent HEAD^1`
32+
PARENT_COMMIT=`git rev-list --author='122020455+rust-bors\[bot\]@users.noreply.github.com' -n1 --first-parent HEAD^1`
3333
echo "Parent: ${PARENT_COMMIT}"
3434
3535
# Find PR for the current commit

src/build_helper/src/git.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ pub fn has_changed_since(git_dir: &Path, base: &str, paths: &[&str]) -> bool {
152152
})
153153
}
154154

155+
const LEGACY_BORS_EMAIL: &str = "bors@rust-lang.org";
156+
157+
/// Escape characters from the git user e-mail, so that git commands do not interpret it as regex
158+
/// special characters.
159+
fn escape_email_git_regex(text: &str) -> String {
160+
text.replace("[", "\\[").replace("]", "\\]").replace(".", "\\.")
161+
}
162+
155163
/// Returns the latest upstream commit that modified `target_paths`, or `None` if no such commit
156164
/// was found.
157165
fn get_latest_upstream_commit_that_modified_files(
@@ -182,9 +190,15 @@ fn get_latest_upstream_commit_that_modified_files(
182190
"-n1",
183191
&upstream,
184192
"--author",
185-
git_config.git_merge_commit_email,
193+
&escape_email_git_regex(git_config.git_merge_commit_email),
186194
]);
187195

196+
// Also search for legacy bors account, before we accrue enough commits to
197+
// have changes to all relevant file paths done by new bors.
198+
if git_config.git_merge_commit_email != LEGACY_BORS_EMAIL {
199+
git.args(["--author", LEGACY_BORS_EMAIL]);
200+
}
201+
188202
if !target_paths.is_empty() {
189203
git.arg("--").args(target_paths);
190204
}
@@ -229,11 +243,17 @@ pub fn get_closest_upstream_commit(
229243
git.args([
230244
"rev-list",
231245
"--author-date-order",
232-
&format!("--author={}", config.git_merge_commit_email),
246+
&format!("--author={}", &escape_email_git_regex(config.git_merge_commit_email),),
233247
"-n1",
234248
base,
235249
]);
236250

251+
// Also search for legacy bors account, before we accrue enough commits to
252+
// have changes to all relevant file paths done by new bors.
253+
if config.git_merge_commit_email != LEGACY_BORS_EMAIL {
254+
git.args(["--author", LEGACY_BORS_EMAIL]);
255+
}
256+
237257
let output = output_result(&mut git)?.trim().to_owned();
238258
if output.is_empty() { Ok(None) } else { Ok(Some(output)) }
239259
}

src/stage0

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dist_server=https://static.rust-lang.org
22
artifacts_server=https://ci-artifacts.rust-lang.org/rustc-builds
33
artifacts_with_llvm_assertions_server=https://ci-artifacts.rust-lang.org/rustc-builds-alt
4-
git_merge_commit_email=bors@rust-lang.org
4+
git_merge_commit_email=122020455+rust-bors[bot]@users.noreply.github.com
55
nightly_branch=main
66

77
# The configuration above this comment is editable, and can be changed

0 commit comments

Comments
 (0)