diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml index d38cc0e8a17f..51e0a40d46f2 100644 --- a/.github/workflows/post-merge.yml +++ b/.github/workflows/post-merge.yml @@ -29,7 +29,7 @@ jobs: sleep 60 # Get closest bors merge commit - PARENT_COMMIT=`git rev-list --author='bors ' -n1 --first-parent HEAD^1` + PARENT_COMMIT=`git rev-list --author='122020455+rust-bors\[bot\]@users.noreply.github.com' -n1 --first-parent HEAD^1` echo "Parent: ${PARENT_COMMIT}" # Find PR for the current commit diff --git a/src/build_helper/src/git.rs b/src/build_helper/src/git.rs index 42d9b00f004a..1fdc2ddb4cfc 100644 --- a/src/build_helper/src/git.rs +++ b/src/build_helper/src/git.rs @@ -152,6 +152,14 @@ pub fn has_changed_since(git_dir: &Path, base: &str, paths: &[&str]) -> bool { }) } +const LEGACY_BORS_EMAIL: &str = "bors@rust-lang.org"; + +/// Escape characters from the git user e-mail, so that git commands do not interpret it as regex +/// special characters. +fn escape_email_git_regex(text: &str) -> String { + text.replace("[", "\\[").replace("]", "\\]").replace(".", "\\.") +} + /// Returns the latest upstream commit that modified `target_paths`, or `None` if no such commit /// was found. fn get_latest_upstream_commit_that_modified_files( @@ -182,9 +190,15 @@ fn get_latest_upstream_commit_that_modified_files( "-n1", &upstream, "--author", - git_config.git_merge_commit_email, + &escape_email_git_regex(git_config.git_merge_commit_email), ]); + // Also search for legacy bors account, before we accrue enough commits to + // have changes to all relevant file paths done by new bors. + if git_config.git_merge_commit_email != LEGACY_BORS_EMAIL { + git.args(["--author", LEGACY_BORS_EMAIL]); + } + if !target_paths.is_empty() { git.arg("--").args(target_paths); } @@ -229,11 +243,17 @@ pub fn get_closest_upstream_commit( git.args([ "rev-list", "--author-date-order", - &format!("--author={}", config.git_merge_commit_email), + &format!("--author={}", &escape_email_git_regex(config.git_merge_commit_email),), "-n1", base, ]); + // Also search for legacy bors account, before we accrue enough commits to + // have changes to all relevant file paths done by new bors. + if config.git_merge_commit_email != LEGACY_BORS_EMAIL { + git.args(["--author", LEGACY_BORS_EMAIL]); + } + let output = output_result(&mut git)?.trim().to_owned(); if output.is_empty() { Ok(None) } else { Ok(Some(output)) } } diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 044f5a8fff32..691b8b8deb81 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -312,16 +312,6 @@ else command=(/checkout/src/ci/run.sh) fi -if isCI; then - # Get some needed information for $BASE_COMMIT - # - # This command gets the last merge commit which we'll use as base to list - # deleted files since then. - BASE_COMMIT="$(git log --author=bors@rust-lang.org -n 2 --pretty=format:%H | tail -n 1)" -else - BASE_COMMIT="" -fi - SUMMARY_FILE=github-summary.md touch $objdir/${SUMMARY_FILE} @@ -359,7 +349,6 @@ docker \ --env RUST_CI_OVERRIDE_RELEASE_CHANNEL \ --env CI_JOB_NAME="${CI_JOB_NAME-$image}" \ --env CI_JOB_DOC_URL="${CI_JOB_DOC_URL}" \ - --env BASE_COMMIT="$BASE_COMMIT" \ --env DIST_TRY_BUILD \ --env PR_CI_JOB \ --env OBJDIR_ON_HOST="$objdir" \ diff --git a/src/stage0 b/src/stage0 index 66b652a844f3..226f1d6f645e 100644 --- a/src/stage0 +++ b/src/stage0 @@ -1,7 +1,7 @@ dist_server=https://static.rust-lang.org artifacts_server=https://ci-artifacts.rust-lang.org/rustc-builds artifacts_with_llvm_assertions_server=https://ci-artifacts.rust-lang.org/rustc-builds-alt -git_merge_commit_email=bors@rust-lang.org +git_merge_commit_email=122020455+rust-bors[bot]@users.noreply.github.com nightly_branch=main # The configuration above this comment is editable, and can be changed