Skip to content

Commit 36e1eea

Browse files
committed
Write rust-version with a newline and trim it when loading it
1 parent c904139 commit 36e1eea

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
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: 5 additions & 1 deletion
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()

0 commit comments

Comments
 (0)