Skip to content

Commit a1922c0

Browse files
committed
Make the error nicer if the working directory is not clean
1 parent 8675869 commit a1922c0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl GitSync {
6565
.to_owned()
6666
};
6767

68-
ensure_clean_git_state(self.verbose);
68+
ensure_clean_git_state(self.verbose)?;
6969

7070
// Make sure josh is running.
7171
let josh = self
@@ -248,7 +248,7 @@ After you fix the conflicts, `git add` the changes and run `git merge --continue
248248
}
249249

250250
pub fn rustc_push(&self, username: &str, branch: &str) -> anyhow::Result<()> {
251-
ensure_clean_git_state(self.verbose);
251+
ensure_clean_git_state(self.verbose)?;
252252

253253
let base_upstream_sha = self.context.last_upstream_sha.clone().unwrap_or_default();
254254

src/utils.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ fn run_command_inner<'a, Args: AsRef<[&'a str]>>(
6969
}
7070

7171
/// Fail if there are files that need to be checked in.
72-
pub fn ensure_clean_git_state(verbose: bool) {
72+
pub fn ensure_clean_git_state(verbose: bool) -> anyhow::Result<()> {
7373
let read = run_command(
7474
["git", "status", "--untracked-files=no", "--porcelain"],
7575
verbose,
7676
)
7777
.expect("cannot figure out if git state is clean");
78-
assert!(read.is_empty(), "working directory must be clean");
78+
if !read.is_empty() {
79+
Err(anyhow::anyhow!("working directory must be clean"))
80+
} else {
81+
Ok(())
82+
}
7983
}
8084

8185
pub fn get_current_head_sha(verbose: bool) -> anyhow::Result<String> {

0 commit comments

Comments
 (0)