1
Fork 0

Revert "Rollup merge of #129584 - lolbinarycat:old-upstream-warning, r=albertlarsan68"

This reverts commit 776187d2c9, reversing
changes made to 7d015575ad.
This commit is contained in:
onur-ozkan 2024-10-06 19:01:12 +03:00
parent dd0bcf5185
commit 1e5c4cb0a2
3 changed files with 1 additions and 46 deletions

View file

@ -93,6 +93,7 @@ fn get_modified_rs_files(build: &Builder<'_>) -> Result<Option<Vec<String>>, Str
if !verify_rustfmt_version(build) { if !verify_rustfmt_version(build) {
return Ok(None); return Ok(None);
} }
get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &["rs"]) get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &["rs"])
} }

View file

@ -13,8 +13,6 @@ use std::ffi::{OsStr, OsString};
use std::path::PathBuf; use std::path::PathBuf;
use std::{env, fs}; use std::{env, fs};
use build_helper::git::warn_old_master_branch;
use crate::Build; use crate::Build;
#[cfg(not(feature = "bootstrap-self-test"))] #[cfg(not(feature = "bootstrap-self-test"))]
use crate::builder::Builder; use crate::builder::Builder;
@ -382,14 +380,4 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
if let Some(ref s) = build.config.ccache { if let Some(ref s) = build.config.ccache {
cmd_finder.must_have(s); cmd_finder.must_have(s);
} }
// this warning is useless in CI,
// and CI probably won't have the right branches anyway.
if !build_helper::ci::CiEnv::is_ci() {
if let Err(e) = warn_old_master_branch(&build.config.git_config(), &build.config.src)
.map_err(|e| e.to_string())
{
eprintln!("unable to check if upstream branch is old: {e}");
}
}
} }

View file

@ -196,37 +196,3 @@ pub fn get_git_untracked_files(
.collect(); .collect();
Ok(Some(files)) Ok(Some(files))
} }
/// Print a warning if the branch returned from `updated_master_branch` is old
///
/// For certain configurations of git repository, this remote will not be
/// updated when running `git pull`.
///
/// This can result in formatting thousands of files instead of a dozen,
/// so we should warn the user something is wrong.
pub fn warn_old_master_branch(
config: &GitConfig<'_>,
git_dir: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
use std::time::Duration;
const WARN_AFTER: Duration = Duration::from_secs(60 * 60 * 24 * 10);
let updated_master = updated_master_branch(config, Some(git_dir))?;
let branch_path = git_dir.join(".git/refs/remotes").join(&updated_master);
match std::fs::metadata(branch_path) {
Ok(meta) => {
if meta.modified()?.elapsed()? > WARN_AFTER {
eprintln!("warning: {updated_master} has not been updated in 10 days");
} else {
return Ok(());
}
}
Err(err) => {
eprintln!("warning: unable to check if {updated_master} is old due to error: {err}")
}
}
eprintln!(
"warning: {updated_master} is used to determine if files have been modified\n\
warning: if it is not updated, this may cause files to be needlessly reformatted"
);
Ok(())
}