Skip to content

Commit 5570cda

Browse files
committed
Auto merge of #106320 - jyn514:revert-merge-check, r=jyn514
Revert "Auto merge of #105058 - Nilstrieb:no-merge-commits, r=jyn514" This reverts commit 4839886, reversing changes made to ce85c98. Fixes #106232 (comment). r? `@jyn514`
2 parents 4839886 + 90a10ca commit 5570cda

File tree

18 files changed

+60
-195
lines changed

18 files changed

+60
-195
lines changed

.github/workflows/ci.yml

-15
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ jobs:
7171
uses: actions/checkout@v3
7272
with:
7373
fetch-depth: 2
74-
- name: "checkout the `master` branch for tidy"
75-
uses: actions/checkout@v3
76-
with:
77-
ref: master
78-
fetch-depth: 1
7974
- name: configure the PR in which the error message will be posted
8075
run: "echo \"[CI_PR_NUMBER=$num]\""
8176
env:
@@ -490,11 +485,6 @@ jobs:
490485
uses: actions/checkout@v3
491486
with:
492487
fetch-depth: 2
493-
- name: "checkout the `master` branch for tidy"
494-
uses: actions/checkout@v3
495-
with:
496-
ref: master
497-
fetch-depth: 1
498488
- name: configure the PR in which the error message will be posted
499489
run: "echo \"[CI_PR_NUMBER=$num]\""
500490
env:
@@ -610,11 +600,6 @@ jobs:
610600
uses: actions/checkout@v3
611601
with:
612602
fetch-depth: 2
613-
- name: "checkout the `master` branch for tidy"
614-
uses: actions/checkout@v3
615-
with:
616-
ref: master
617-
fetch-depth: 1
618603
- name: configure the PR in which the error message will be posted
619604
run: "echo \"[CI_PR_NUMBER=$num]\""
620605
env:

Cargo.lock

-5
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,6 @@ dependencies = [
259259
"toml",
260260
]
261261

262-
[[package]]
263-
name = "build_helper"
264-
version = "0.1.0"
265-
266262
[[package]]
267263
name = "bump-stage0"
268264
version = "0.1.0"
@@ -5308,7 +5304,6 @@ dependencies = [
53085304
name = "tidy"
53095305
version = "0.1.0"
53105306
dependencies = [
5311-
"build_helper",
53125307
"cargo_metadata 0.14.0",
53135308
"ignore",
53145309
"lazy_static",

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ members = [
44
"library/std",
55
"library/test",
66
"src/rustdoc-json-types",
7-
"src/tools/build_helper",
87
"src/tools/cargotest",
98
"src/tools/clippy",
109
"src/tools/clippy/clippy_dev",

src/bootstrap/Cargo.lock

-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ dependencies = [
3636
name = "bootstrap"
3737
version = "0.0.0"
3838
dependencies = [
39-
"build_helper",
4039
"cc",
4140
"cmake",
4241
"fd-lock",
@@ -71,10 +70,6 @@ dependencies = [
7170
"regex-automata",
7271
]
7372

74-
[[package]]
75-
name = "build_helper"
76-
version = "0.1.0"
77-
7873
[[package]]
7974
name = "cc"
8075
version = "1.0.73"

src/bootstrap/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ path = "bin/sccache-plus-cl.rs"
3030
test = false
3131

3232
[dependencies]
33-
build_helper = { path = "../tools/build_helper" }
3433
cmake = "0.1.38"
3534
fd-lock = "3.0.8"
3635
filetime = "0.2"

src/bootstrap/format.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use crate::builder::Builder;
44
use crate::util::{output, program_out_of_date, t};
5-
use build_helper::git::get_rust_lang_rust_remote;
65
use ignore::WalkBuilder;
76
use std::collections::VecDeque;
87
use std::path::{Path, PathBuf};
@@ -101,6 +100,35 @@ fn get_modified_rs_files(build: &Builder<'_>) -> Option<Vec<String>> {
101100
)
102101
}
103102

103+
/// Finds the remote for rust-lang/rust.
104+
/// For example for these remotes it will return `upstream`.
105+
/// ```text
106+
/// origin https://github.com/Nilstrieb/rust.git (fetch)
107+
/// origin https://github.com/Nilstrieb/rust.git (push)
108+
/// upstream https://github.com/rust-lang/rust (fetch)
109+
/// upstream https://github.com/rust-lang/rust (push)
110+
/// ```
111+
fn get_rust_lang_rust_remote() -> Result<String, String> {
112+
let mut git = Command::new("git");
113+
git.args(["config", "--local", "--get-regex", "remote\\..*\\.url"]);
114+
115+
let output = git.output().map_err(|err| format!("{err:?}"))?;
116+
if !output.status.success() {
117+
return Err("failed to execute git config command".to_owned());
118+
}
119+
120+
let stdout = String::from_utf8(output.stdout).map_err(|err| format!("{err:?}"))?;
121+
122+
let rust_lang_remote = stdout
123+
.lines()
124+
.find(|remote| remote.contains("rust-lang"))
125+
.ok_or_else(|| "rust-lang/rust remote not found".to_owned())?;
126+
127+
let remote_name =
128+
rust_lang_remote.split('.').nth(1).ok_or_else(|| "remote name not found".to_owned())?;
129+
Ok(remote_name.into())
130+
}
131+
104132
#[derive(serde::Deserialize)]
105133
struct RustfmtConfig {
106134
ignore: Vec<String>,

src/bootstrap/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ use std::path::{Path, PathBuf};
113113
use std::process::Command;
114114
use std::str;
115115

116-
use build_helper::ci::CiEnv;
117116
use channel::GitInfo;
118117
use config::{DryRun, Target};
119118
use filetime::FileTime;
@@ -122,7 +121,7 @@ use once_cell::sync::OnceCell;
122121
use crate::builder::Kind;
123122
use crate::config::{LlvmLibunwind, TargetSelection};
124123
use crate::util::{
125-
exe, libdir, mtime, output, run, run_suppressed, symlink_dir, try_run_suppressed,
124+
exe, libdir, mtime, output, run, run_suppressed, symlink_dir, try_run_suppressed, CiEnv,
126125
};
127126

128127
mod bolt;

src/bootstrap/native.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ use crate::util::get_clang_cl_resource_dir;
2424
use crate::util::{self, exe, output, t, up_to_date};
2525
use crate::{CLang, GitRepo};
2626

27-
use build_helper::ci::CiEnv;
28-
2927
#[derive(Clone)]
3028
pub struct LlvmResult {
3129
/// Path to llvm-config binary.
@@ -219,7 +217,7 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
219217
return false;
220218
}
221219

222-
if CiEnv::is_ci() {
220+
if crate::util::CiEnv::is_ci() {
223221
// We assume we have access to git, so it's okay to unconditionally pass
224222
// `true` here.
225223
let llvm_sha = detect_llvm_sha(config, true);

src/bootstrap/util.rs

+29
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,35 @@ pub enum CiEnv {
255255
GitHubActions,
256256
}
257257

258+
impl CiEnv {
259+
/// Obtains the current CI environment.
260+
pub fn current() -> CiEnv {
261+
if env::var("TF_BUILD").map_or(false, |e| e == "True") {
262+
CiEnv::AzurePipelines
263+
} else if env::var("GITHUB_ACTIONS").map_or(false, |e| e == "true") {
264+
CiEnv::GitHubActions
265+
} else {
266+
CiEnv::None
267+
}
268+
}
269+
270+
pub fn is_ci() -> bool {
271+
Self::current() != CiEnv::None
272+
}
273+
274+
/// If in a CI environment, forces the command to run with colors.
275+
pub fn force_coloring_in_ci(self, cmd: &mut Command) {
276+
if self != CiEnv::None {
277+
// Due to use of stamp/docker, the output stream of rustbuild is not
278+
// a TTY in CI, so coloring is by-default turned off.
279+
// The explicit `TERM=xterm` environment is needed for
280+
// `--color always` to actually work. This env var was lost when
281+
// compiling through the Makefile. Very strange.
282+
cmd.env("TERM", "xterm").args(&["--color", "always"]);
283+
}
284+
}
285+
}
286+
258287
pub fn forcing_clang_based_tests() -> bool {
259288
if let Some(var) = env::var_os("RUSTBUILD_FORCE_CLANG_BASED_TESTS") {
260289
match &var.to_string_lossy().to_lowercase()[..] {

src/ci/github-actions/ci.yml

-6
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ x--expand-yaml-anchors--remove:
103103
with:
104104
fetch-depth: 2
105105

106-
- name: checkout the `master` branch for tidy
107-
uses: actions/checkout@v3
108-
with:
109-
ref: master
110-
fetch-depth: 1
111-
112106
# Rust Log Analyzer can't currently detect the PR number of a GitHub
113107
# Actions build on its own, so a hint in the log message is needed to
114108
# point it in the right direction.

src/tools/build_helper/Cargo.toml

-8
This file was deleted.

src/tools/build_helper/src/ci.rs

-40
This file was deleted.

src/tools/build_helper/src/git.rs

-30
This file was deleted.

src/tools/build_helper/src/lib.rs

-2
This file was deleted.

src/tools/tidy/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2021"
55
autobins = false
66

77
[dependencies]
8-
build_helper = { path = "../build_helper" }
98
cargo_metadata = "0.14"
109
regex = "1"
1110
miropt-test-tools = { path = "../miropt-test-tools" }

src/tools/tidy/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub mod errors;
4848
pub mod extdeps;
4949
pub mod features;
5050
pub mod mir_opt_tests;
51-
pub mod no_merge;
5251
pub mod pal;
5352
pub mod primitive_docs;
5453
pub mod style;

src/tools/tidy/src/main.rs

-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ fn main() {
107107
check!(alphabetical, &compiler_path);
108108
check!(alphabetical, &library_path);
109109

110-
check!(no_merge, ());
111-
112110
let collected = {
113111
drain_handles(&mut handles);
114112

src/tools/tidy/src/no_merge.rs

-72
This file was deleted.

0 commit comments

Comments
 (0)