Skip to content

Commit 8245142

Browse files
authored
Merge pull request #4 from rust-lang/improvements
Handle newline in `rust-version` and mention this repo in merge commit message
2 parents c904139 + 232ab78 commit 8245142

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/bin/rustc_josh_sync.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ fn load_context(config_path: &Path, rust_version_path: &Path) -> anyhow::Result<
125125
.context("cannot load config. Run the `init` command to initialize it.")?;
126126
let rust_version = std::fs::read_to_string(&rust_version_path)
127127
.inspect_err(|err| eprintln!("Cannot load rust-version file: {err:?}"))
128+
.map(|version| version.trim().to_string())
128129
.map(Some)
129130
.unwrap_or_default();
130131
Ok(SyncContext {

src/sync.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ impl GitSync {
8686
// We pass `--no-verify` to avoid running git hooks.
8787
// We do this before the merge so that if there are merge conflicts, we have
8888
// the right rust-version file while resolving them.
89-
std::fs::write(&self.context.last_upstream_sha_path, &upstream_sha).with_context(|| {
89+
std::fs::write(
90+
&self.context.last_upstream_sha_path,
91+
&format!("{upstream_sha}\n"),
92+
)
93+
.with_context(|| {
9094
anyhow::anyhow!(
9195
"cannot write upstream SHA to {}",
9296
self.context.last_upstream_sha_path.display()
@@ -143,10 +147,12 @@ This updates the rust-version file to {upstream_sha}."#,
143147
let merge_message = format!(
144148
r#"Merge ref '{upstream_head_short}' from {UPSTREAM_REPO}
145149
146-
Pull recent changes from {UPSTREAM_REPO} via Josh.
150+
Pull recent changes from https://github.com/{UPSTREAM_REPO} via Josh.
147151
148152
Upstream ref: {upstream_sha}
149153
Filtered ref: {incoming_ref}
154+
155+
This merge was created using https://github.com/rust-lang/josh-sync.
150156
"#,
151157
upstream_head_short = &upstream_sha[..12],
152158
);

0 commit comments

Comments
 (0)