Add helper to check whether to try to checkout the ensure_branch branch

This commit is contained in:
Matthias Beyer 2016-07-16 18:00:42 +02:00
parent 7ed44cc1b8
commit a356a96a99

View file

@ -58,3 +58,21 @@ pub fn ensure_branch(cfg: Option<&Value>) -> Result<Option<String>> {
}
}
pub fn do_checkout_ensure_branch(cfg: Option<&Value>) -> bool {
cfg.map(|cfg| {
match cfg.lookup("try_checkout_ensure_branch") {
Some(&Value::Boolean(b)) => b,
Some(_) => {
warn!("Configuration error, 'try_checkout_ensure_branch' must be a Boolean (true|false).");
warn!("Assuming 'true' now.");
true
},
None => {
debug!("No key `try_checkout_ensure_branch' - Assuming 'true'");
true
},
}
})
.unwrap_or(false)
}