Add helper to get the branch which must be checked out before any action takes place
This commit is contained in:
parent
c09f0b302f
commit
c972b5706d
1 changed files with 26 additions and 0 deletions
|
@ -1,5 +1,11 @@
|
|||
use toml::Value;
|
||||
|
||||
use libimagerror::into::IntoError;
|
||||
|
||||
use vcs::git::error::GitHookErrorKind as GHEK;
|
||||
use vcs::git::error::MapErrInto;
|
||||
use vcs::git::result::Result;
|
||||
|
||||
use vcs::git::action::StoreAction;
|
||||
|
||||
pub fn commit_interactive(config: &Value) -> bool {
|
||||
|
@ -32,3 +38,23 @@ pub fn abort_on_repo_init_err(cfg: Option<&Value>) -> bool {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn ensure_branch(cfg: Option<&Value>) -> Result<Option<String>> {
|
||||
match cfg {
|
||||
Some(cfg) => {
|
||||
match cfg.lookup("ensure_branch") {
|
||||
Some(&Value::String(ref s)) => Ok(Some(s.clone())),
|
||||
Some(_) => {
|
||||
warn!("Configuration error, 'ensure_branch' must be a String.");
|
||||
Err(GHEK::ConfigTypeError.into_error())
|
||||
.map_err_into(GHEK::ConfigTypeError)
|
||||
},
|
||||
None => {
|
||||
debug!("No key `ensure_branch'");
|
||||
Ok(None)
|
||||
},
|
||||
}
|
||||
},
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue