about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-02 19:22:20 +0000
committerbors <bors@rust-lang.org>2023-08-02 19:22:20 +0000
commit6e6d39a4f502ee7a1e60fb4f7faffa485f9dedd4 (patch)
treeb488f28d3fb90c4187d0e7c6694cde8bc2bbad7c /src/tools
parent20747af8940cf683970e76ec9a433305940c05f3 (diff)
parent7c12b2e6367713a00623780a50cf08a5edb3427f (diff)
downloadrust-6e6d39a4f502ee7a1e60fb4f7faffa485f9dedd4.tar.gz
rust-6e6d39a4f502ee7a1e60fb4f7faffa485f9dedd4.zip
Auto merge of #114345 - lqd:revert-113588, r=RalfJung
Revert #113588 to fix bootstrap timings

This reverts #113588 which seems to have broken perf's bootstrap timings via some git issue

https://github.com/rust-lang/rust/pull/114318#issuecomment-1660807886 show a newly broken benchmark, the error at the time was

```
fatal: Path 'src/ci/channel' exists on disk, but not in 'e62323df22ecf9c163023132d17b7114f68b72e8'.
       thread 'main' panicked at 'command did not execute successfully: cd "/home/collector/rustc-perf/rust" && "git" "show" "e62323df22ecf9c163023132d17b7114f68b72e8:src/ci/channel"
       expected success, got: exit status: 128', config.rs:1786:27
```

If this lands, it will reopen #101907 and annoy miri, but it could actually be an issue that would appear during the next bootstrap bump, not just rustc-perf today.

r? `@ghost`
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/build_helper/src/git.rs38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/tools/build_helper/src/git.rs b/src/tools/build_helper/src/git.rs
index f20b7a2b4d7..66876e02c19 100644
--- a/src/tools/build_helper/src/git.rs
+++ b/src/tools/build_helper/src/git.rs
@@ -78,22 +78,13 @@ pub fn rev_exists(rev: &str, git_dir: Option<&Path>) -> Result<bool, String> {
 /// We will then fall back to origin/master in the hope that at least this exists.
 pub fn updated_master_branch(git_dir: Option<&Path>) -> Result<String, String> {
     let upstream_remote = get_rust_lang_rust_remote(git_dir)?;
-    for upstream_master in [format!("{upstream_remote}/master"), format!("origin/master")] {
-        if rev_exists(&upstream_master, git_dir)? {
-            return Ok(upstream_master);
-        }
+    let upstream_master = format!("{upstream_remote}/master");
+    if rev_exists(&upstream_master, git_dir)? {
+        return Ok(upstream_master);
     }
 
-    Err(format!("Cannot find any suitable upstream master branch"))
-}
-
-pub fn get_git_merge_base(git_dir: Option<&Path>) -> Result<String, String> {
-    let updated_master = updated_master_branch(git_dir)?;
-    let mut git = Command::new("git");
-    if let Some(git_dir) = git_dir {
-        git.current_dir(git_dir);
-    }
-    Ok(output_result(git.arg("merge-base").arg(&updated_master).arg("HEAD"))?.trim().to_owned())
+    // We could implement smarter logic here in the future.
+    Ok("origin/master".into())
 }
 
 /// Returns the files that have been modified in the current branch compared to the master branch.
@@ -103,13 +94,20 @@ pub fn get_git_modified_files(
     git_dir: Option<&Path>,
     extensions: &Vec<&str>,
 ) -> Result<Option<Vec<String>>, String> {
-    let merge_base = get_git_merge_base(git_dir)?;
+    let Ok(updated_master) = updated_master_branch(git_dir) else {
+        return Ok(None);
+    };
 
-    let mut git = Command::new("git");
-    if let Some(git_dir) = git_dir {
-        git.current_dir(git_dir);
-    }
-    let files = output_result(git.args(["diff-index", "--name-only", merge_base.trim()]))?
+    let git = || {
+        let mut git = Command::new("git");
+        if let Some(git_dir) = git_dir {
+            git.current_dir(git_dir);
+        }
+        git
+    };
+
+    let merge_base = output_result(git().arg("merge-base").arg(&updated_master).arg("HEAD"))?;
+    let files = output_result(git().arg("diff-index").arg("--name-only").arg(merge_base.trim()))?
         .lines()
         .map(|s| s.trim().to_owned())
         .filter(|f| {