feat: add check git status
This commit is contained in:
@@ -17,11 +17,19 @@ impl Command for CommandImpl {
|
|||||||
let dir = sub_arg_matches.value_of("dir");
|
let dir = sub_arg_matches.value_of("dir");
|
||||||
let has_remote_cannotbe_fetched = util_git::git_fetch_dry_run(dir)?;
|
let has_remote_cannotbe_fetched = util_git::git_fetch_dry_run(dir)?;
|
||||||
if !has_remote_cannotbe_fetched {
|
if !has_remote_cannotbe_fetched {
|
||||||
warning!("Git repo has not fetched codes");
|
failure!("Git repo has not fetched codes");
|
||||||
return Ok(-2); // fetch check failed
|
return Ok(-2); // fetch check failed
|
||||||
}
|
}
|
||||||
let git_status = util_git::git_status(dir)?;
|
let git_status = util_git::git_status(dir)?;
|
||||||
if git_status.contains("Changes not staged for commit") || git_status.contains("Changes to be committed")
|
let git_status_local_unpush_messages = vec![
|
||||||
|
"Changes not staged for commit",
|
||||||
|
"Changes to be committed",
|
||||||
|
"Your branch is ahead of"
|
||||||
|
];
|
||||||
|
if git_status_local_unpush_messages.iter().find(|m| git_status.contains(**m)).is_some() {
|
||||||
|
failure!("Git repo has un-push changes");
|
||||||
|
return Ok(-3);
|
||||||
|
}
|
||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user