Skip to content

Commit 3a5a816

Browse files
authored
Rollup merge of rust-lang#131331 - onur-ozkan:131296, r=Kobzol
Revert "warn_old_master_branch" check See rust-lang#131296 (comment). Reverts rust-lang#130121 and rust-lang#129584. Fixes rust-lang#131296 and rust-lang#131324.
2 parents 690332a + 1e5c4cb commit 3a5a816

File tree

3 files changed

+1
-68
lines changed

3 files changed

+1
-68
lines changed

src/bootstrap/src/core/build_steps/format.rs

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ fn get_modified_rs_files(build: &Builder<'_>) -> Result<Option<Vec<String>>, Str
9393
if !verify_rustfmt_version(build) {
9494
return Ok(None);
9595
}
96+
9697
get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &["rs"])
9798
}
9899

src/bootstrap/src/core/sanity.rs

-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use std::ffi::{OsStr, OsString};
1313
use std::path::PathBuf;
1414
use std::{env, fs};
1515

16-
use build_helper::git::warn_old_master_branch;
17-
1816
use crate::Build;
1917
#[cfg(not(feature = "bootstrap-self-test"))]
2018
use crate::builder::Builder;
@@ -382,6 +380,4 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
382380
if let Some(ref s) = build.config.ccache {
383381
cmd_finder.must_have(s);
384382
}
385-
386-
warn_old_master_branch(&build.config.git_config(), &build.config.src);
387383
}

src/tools/build_helper/src/git.rs

-64
Original file line numberDiff line numberDiff line change
@@ -196,67 +196,3 @@ pub fn get_git_untracked_files(
196196
.collect();
197197
Ok(Some(files))
198198
}
199-
200-
/// Print a warning if the branch returned from `updated_master_branch` is old
201-
///
202-
/// For certain configurations of git repository, this remote will not be
203-
/// updated when running `git pull`.
204-
///
205-
/// This can result in formatting thousands of files instead of a dozen,
206-
/// so we should warn the user something is wrong.
207-
pub fn warn_old_master_branch(config: &GitConfig<'_>, git_dir: &Path) {
208-
if crate::ci::CiEnv::is_ci() {
209-
// this warning is useless in CI,
210-
// and CI probably won't have the right branches anyway.
211-
return;
212-
}
213-
// this will be overwritten by the actual name, if possible
214-
let mut updated_master = "the upstream master branch".to_string();
215-
match warn_old_master_branch_(config, git_dir, &mut updated_master) {
216-
Ok(branch_is_old) => {
217-
if !branch_is_old {
218-
return;
219-
}
220-
// otherwise fall through and print the rest of the warning
221-
}
222-
Err(err) => {
223-
eprintln!("warning: unable to check if {updated_master} is old due to error: {err}")
224-
}
225-
}
226-
eprintln!(
227-
"warning: {updated_master} is used to determine if files have been modified\n\
228-
warning: if it is not updated, this may cause files to be needlessly reformatted"
229-
);
230-
}
231-
232-
pub fn warn_old_master_branch_(
233-
config: &GitConfig<'_>,
234-
git_dir: &Path,
235-
updated_master: &mut String,
236-
) -> Result<bool, Box<dyn std::error::Error>> {
237-
use std::time::Duration;
238-
*updated_master = updated_master_branch(config, Some(git_dir))?;
239-
let branch_path = git_dir.join(".git/refs/remotes").join(&updated_master);
240-
const WARN_AFTER: Duration = Duration::from_secs(60 * 60 * 24 * 10);
241-
let meta = match std::fs::metadata(&branch_path) {
242-
Ok(meta) => meta,
243-
Err(err) => {
244-
let gcd = git_common_dir(&git_dir)?;
245-
if branch_path.starts_with(&gcd) {
246-
return Err(Box::new(err));
247-
}
248-
std::fs::metadata(Path::new(&gcd).join("refs/remotes").join(&updated_master))?
249-
}
250-
};
251-
if meta.modified()?.elapsed()? > WARN_AFTER {
252-
eprintln!("warning: {updated_master} has not been updated in 10 days");
253-
Ok(true)
254-
} else {
255-
Ok(false)
256-
}
257-
}
258-
259-
fn git_common_dir(dir: &Path) -> Result<String, String> {
260-
output_result(Command::new("git").arg("-C").arg(dir).arg("rev-parse").arg("--git-common-dir"))
261-
.map(|x| x.trim().to_string())
262-
}

0 commit comments

Comments
 (0)