|
1 | 1 | use crate::SyncContext; |
2 | 2 | use crate::josh::JoshProxy; |
3 | | -use crate::utils::run_command_at; |
4 | 3 | use crate::utils::{ensure_clean_git_state, prompt}; |
| 4 | +use crate::utils::{get_current_head_sha, run_command_at}; |
5 | 5 | use crate::utils::{run_command, stream_command}; |
6 | 6 | use anyhow::{Context, Error}; |
7 | 7 | use std::path::{Path, PathBuf}; |
@@ -64,7 +64,7 @@ impl GitSync { |
64 | 64 | &self.context.config.construct_josh_filter(), |
65 | 65 | ); |
66 | 66 |
|
67 | | - let orig_head = run_command(["git", "rev-parse", "HEAD"])?; |
| 67 | + let orig_head = get_current_head_sha()?; |
68 | 68 | println!( |
69 | 69 | "previous upstream base: {:?}", |
70 | 70 | self.context.last_upstream_sha |
@@ -137,8 +137,7 @@ This updates the rust-version file to {upstream_sha}."#, |
137 | 137 | }; |
138 | 138 | let num_roots_before = num_roots()?; |
139 | 139 |
|
140 | | - let sha = |
141 | | - run_command(&["git", "rev-parse", "HEAD"]).context("failed to get current commit")?; |
| 140 | + let sha = get_current_head_sha()?; |
142 | 141 |
|
143 | 142 | // The filtered SHA of upstream |
144 | 143 | let incoming_ref = run_command(["git", "rev-parse", "FETCH_HEAD"])?; |
@@ -170,8 +169,7 @@ This merge was created using https://github.com/rust-lang/josh-sync. |
170 | 169 | ]) |
171 | 170 | .context("FAILED to merge new commits, something went wrong")?; |
172 | 171 |
|
173 | | - let current_sha = |
174 | | - run_command(&["git", "rev-parse", "HEAD"]).context("FAILED to get current commit")?; |
| 172 | + let current_sha = get_current_head_sha()?; |
175 | 173 | if current_sha == sha { |
176 | 174 | eprintln!( |
177 | 175 | "No merge was performed, no changes to pull were found. Rolling back the preparation commit." |
@@ -261,7 +259,7 @@ This merge was created using https://github.com/rust-lang/josh-sync. |
261 | 259 | &["git", "fetch", &josh_url, &branch], |
262 | 260 | &std::env::current_dir().unwrap(), |
263 | 261 | )?; |
264 | | - let head = run_command(&["git", "rev-parse", "HEAD"])?; |
| 262 | + let head = get_current_head_sha()?; |
265 | 263 | let fetch_head = run_command(&["git", "rev-parse", "FETCH_HEAD"])?; |
266 | 264 | if head != fetch_head { |
267 | 265 | return Err(anyhow::anyhow!( |
|
0 commit comments