Skip to content

Commit ccbc473

Browse files
committed
fixup! Implement sync subcommand in clippy_dev
1 parent ff5a352 commit ccbc473

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

clippy_dev/src/sync.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use std::process::exit;
66

77
use xshell::{Shell, cmd};
88

9-
const JOSH_FILTER: &str = ":rev(2efebd2f0c03dabbe5c3ad7b4ebfbd99238d1fb2:prefix=src/tools/clippy):/src/tools/clippy";
9+
const JOSH_FILTER: &str = ":rev(53d3bc02ed90eba01c5dbc5b2d0c4cabb67ffb4d:prefix=src/tools/clippy):/src/tools/clippy";
1010
const JOSH_PORT: &str = "42042";
11+
const TOOLCHAIN_TOML: &str = "rust-toolchain.toml";
12+
const UTILS_README: &str = "clippy_utils/README.md";
1113

1214
fn start_josh() -> impl Drop {
1315
// Create a wrapper that stops it on drop.
@@ -90,28 +92,37 @@ pub fn rustc_pull() {
9092
const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
9193

9294
let sh = Shell::new().expect("failed to create shell");
93-
// sh.change_dir(clippy_project_root());
9495

9596
assert_clean_repo(&sh);
9697

9798
// Update rust-toolchain file
9899
let date = Utc::now().format("%Y-%m-%d").to_string();
99-
let update = &mut update_text_region_fn(
100+
let toolchain_update = &mut update_text_region_fn(
100101
"# begin autogenerated nightly\n",
101102
"# end autogenerated nightly",
102103
|dst| {
103104
writeln!(dst, "channel = \"nightly-{date}\"").unwrap();
104105
},
105106
);
107+
let readme_update = &mut update_text_region_fn(
108+
"<!-- begin autogenerated nightly -->\n",
109+
"<!-- end autogenerated nightly -->",
110+
|dst| {
111+
writeln!(dst, "```\nnightly-{date}\n```").unwrap();
112+
},
113+
);
106114

107115
let mut updater = FileUpdater::default();
108-
updater.update_file("rust-toolchain.toml", update);
109-
updater.update_file("clippy_utils/README.md", update);
116+
updater.update_file(TOOLCHAIN_TOML, toolchain_update);
117+
updater.update_file(UTILS_README, readme_update);
110118

111119
let message = format!("Bump nightly version -> {date}");
112-
cmd!(sh, "git commit rust-toolchain --no-verify -m {message}")
113-
.run()
114-
.expect("FAILED to commit rust-toolchain file, something went wrong");
120+
cmd!(
121+
sh,
122+
"git commit --no-verify -m {message} -- {TOOLCHAIN_TOML} {UTILS_README}"
123+
)
124+
.run()
125+
.expect("FAILED to commit rust-toolchain.toml file, something went wrong");
115126

116127
let commit = rustc_hash();
117128

@@ -160,7 +171,6 @@ pub(crate) const PUSH_PR_DESCRIPTION: &str = "Sync from Clippy commit:";
160171

161172
pub fn rustc_push(rustc_path: String, github_user: &str, branch: &str, force: bool) {
162173
let sh = Shell::new().expect("failed to create shell");
163-
// sh.change_dir(clippy_project_root());
164174

165175
assert_clean_repo(&sh);
166176

@@ -200,7 +210,6 @@ pub fn rustc_push(rustc_path: String, github_user: &str, branch: &str, force: bo
200210
let _josh = start_josh();
201211

202212
// Do the actual push.
203-
// sh.change_dir(clippy_project_root());
204213
println!("Pushing Clippy changes...");
205214
cmd!(
206215
sh,

0 commit comments

Comments
 (0)