Skip to content

Commit 9aa823c

Browse files
committed
replace get_closest_merge_base_commit with get_closest_merge_commit
Signed-off-by: onur-ozkan <[email protected]>
1 parent dc9c5f2 commit 9aa823c

File tree

5 files changed

+15
-53
lines changed

5 files changed

+15
-53
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::path::{Path, PathBuf};
1515
use std::process::Stdio;
1616
use std::{env, fs, str};
1717

18+
use build_helper::git::get_closest_merge_commit;
1819
use serde_derive::Deserialize;
1920

2021
use crate::core::build_steps::tool::SourceType;
@@ -26,8 +27,7 @@ use crate::core::builder::{
2627
use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
2728
use crate::utils::exec::command;
2829
use crate::utils::helpers::{
29-
self, exe, get_clang_cl_resource_dir, get_closest_merge_base_commit, is_debug_info, is_dylib,
30-
symlink_dir, t, up_to_date,
30+
self, exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
3131
};
3232
use crate::{CLang, Compiler, DependencyType, GitRepo, Mode, LLVM_TOOLS};
3333

@@ -127,13 +127,9 @@ impl Step for Std {
127127
// the `rust.download-rustc=true` option.
128128
let force_recompile =
129129
if builder.rust_info().is_managed_git_subrepository() && builder.download_rustc() {
130-
let closest_merge_commit = get_closest_merge_base_commit(
131-
Some(&builder.src),
132-
&builder.config.git_config(),
133-
&builder.config.stage0_metadata.config.git_merge_commit_email,
134-
&[],
135-
)
136-
.unwrap();
130+
let closest_merge_commit =
131+
get_closest_merge_commit(Some(&builder.src), &builder.config.git_config(), &[])
132+
.unwrap();
137133

138134
// Check if `library` has changes (returns false otherwise)
139135
!t!(helpers::git(Some(&builder.src))

src/bootstrap/src/core/build_steps/llvm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::sync::OnceLock;
1616
use std::{env, io};
1717

1818
use build_helper::ci::CiEnv;
19+
use build_helper::git::get_closest_merge_commit;
1920

2021
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2122
use crate::core::config::{Config, TargetSelection};
@@ -153,10 +154,9 @@ pub fn prebuilt_llvm_config(builder: &Builder<'_>, target: TargetSelection) -> L
153154
/// This retrieves the LLVM sha we *want* to use, according to git history.
154155
pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
155156
let llvm_sha = if is_git {
156-
helpers::get_closest_merge_base_commit(
157+
get_closest_merge_commit(
157158
Some(&config.src),
158159
&config.git_config(),
159-
&config.stage0_metadata.config.git_merge_commit_email,
160160
&[
161161
config.src.join("src/llvm-project"),
162162
config.src.join("src/bootstrap/download-ci-llvm-stamp"),

src/bootstrap/src/core/build_steps/tool.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
use std::path::PathBuf;
22
use std::{env, fs};
33

4+
use build_helper::git::get_closest_merge_commit;
5+
46
use crate::core::build_steps::compile;
57
use crate::core::build_steps::toolstate::ToolState;
68
use crate::core::builder;
79
use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
810
use crate::core::config::TargetSelection;
911
use crate::utils::channel::GitInfo;
1012
use crate::utils::exec::{command, BootstrapCommand};
11-
use crate::utils::helpers::{add_dylib_path, exe, get_closest_merge_base_commit, git, t};
13+
use crate::utils::helpers::{add_dylib_path, exe, git, t};
1214
use crate::{gha, Compiler, Kind, Mode};
1315

1416
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
@@ -576,10 +578,9 @@ impl Step for Rustdoc {
576578
&& target_compiler.stage > 0
577579
&& builder.rust_info().is_managed_git_subrepository()
578580
{
579-
let commit = get_closest_merge_base_commit(
581+
let commit = get_closest_merge_commit(
580582
Some(&builder.config.src),
581583
&builder.config.git_config(),
582-
&builder.config.stage0_metadata.config.git_merge_commit_email,
583584
&[],
584585
)
585586
.unwrap();

src/bootstrap/src/core/config/config.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::sync::OnceLock;
1414
use std::{cmp, env, fs};
1515

1616
use build_helper::exit;
17-
use build_helper::git::{output_result, GitConfig};
17+
use build_helper::git::{get_closest_merge_commit, output_result, GitConfig};
1818
use serde::{Deserialize, Deserializer};
1919
use serde_derive::Deserialize;
2020

@@ -24,7 +24,7 @@ pub use crate::core::config::flags::Subcommand;
2424
use crate::core::config::flags::{Color, Flags, Warnings};
2525
use crate::utils::cache::{Interned, INTERNER};
2626
use crate::utils::channel::{self, GitInfo};
27-
use crate::utils::helpers::{self, exe, get_closest_merge_base_commit, output, t};
27+
use crate::utils::helpers::{self, exe, output, t};
2828

2929
macro_rules! check_ci_llvm {
3030
($name:expr) => {
@@ -2686,13 +2686,7 @@ impl Config {
26862686

26872687
// Look for a version to compare to based on the current commit.
26882688
// Only commits merged by bors will have CI artifacts.
2689-
let commit = get_closest_merge_base_commit(
2690-
Some(&self.src),
2691-
&self.git_config(),
2692-
&self.stage0_metadata.config.git_merge_commit_email,
2693-
&[],
2694-
)
2695-
.unwrap();
2689+
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();
26962690
if commit.is_empty() {
26972691
println!("ERROR: could not find commit hash for downloading rustc");
26982692
println!("HELP: maybe your repository history is too shallow?");
@@ -2783,13 +2777,7 @@ impl Config {
27832777
) -> Option<String> {
27842778
// Look for a version to compare to based on the current commit.
27852779
// Only commits merged by bors will have CI artifacts.
2786-
let commit = get_closest_merge_base_commit(
2787-
Some(&self.src),
2788-
&self.git_config(),
2789-
&self.stage0_metadata.config.git_merge_commit_email,
2790-
&[],
2791-
)
2792-
.unwrap();
2780+
let commit = get_closest_merge_commit(Some(&self.src), &self.git_config(), &[]).unwrap();
27932781
if commit.is_empty() {
27942782
println!("error: could not find commit hash for downloading components from CI");
27952783
println!("help: maybe your repository history is too shallow?");

src/bootstrap/src/utils/helpers.rs

-23
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::sync::OnceLock;
1010
use std::time::{Instant, SystemTime, UNIX_EPOCH};
1111
use std::{env, fs, io, str};
1212

13-
use build_helper::git::{get_git_merge_base, output_result, GitConfig};
1413
use build_helper::util::fail;
1514

1615
use crate::core::builder::Builder;
@@ -523,28 +522,6 @@ pub fn git(source_dir: Option<&Path>) -> BootstrapCommand {
523522
git
524523
}
525524

526-
/// Returns the closest commit available from upstream for the given `author` and `target_paths`.
527-
///
528-
/// If it fails to find the commit from upstream using `git merge-base`, fallbacks to HEAD.
529-
pub fn get_closest_merge_base_commit(
530-
source_dir: Option<&Path>,
531-
config: &GitConfig<'_>,
532-
author: &str,
533-
target_paths: &[PathBuf],
534-
) -> Result<String, String> {
535-
let mut git = git(source_dir);
536-
537-
let merge_base = get_git_merge_base(config, source_dir).unwrap_or_else(|_| "HEAD".into());
538-
539-
git.args(["rev-list", &format!("--author={author}"), "-n1", "--first-parent", &merge_base]);
540-
541-
if !target_paths.is_empty() {
542-
git.arg("--").args(target_paths);
543-
}
544-
545-
Ok(output_result(git.as_command_mut())?.trim().to_owned())
546-
}
547-
548525
/// Sets the file times for a given file at `path`.
549526
pub fn set_file_times<P: AsRef<Path>>(path: P, times: fs::FileTimes) -> io::Result<()> {
550527
// Windows requires file to be writable to modify file times. But on Linux CI the file does not

0 commit comments

Comments
 (0)