Fix check whether we should checkout the ensure_branch

We should test this not at the top of the function, as if we do not have
to check out the ensure_branch, we still have to verify that there
actually is a branch checked out we have to ensure.

What I'm saying is: We might have to be on "master", but we might not
have to check it out if we aren't.

Therefor, this commit moves the location where we check whether we
should checkout the branch.
This commit is contained in:
Matthias Beyer 2016-09-19 09:52:37 +02:00
parent a74b46deed
commit 43bdedea8e

View file

@ -93,10 +93,6 @@ impl Runtime {
use vcs::git::config::ensure_branch;
use vcs::git::config::do_checkout_ensure_branch;
if !do_checkout_ensure_branch(self.config.as_ref()) {
return Ok(())
}
debug!("[GIT {} HOOK]: Ensuring branch checkout", action.uppercase());
let head = try!(self
.repository(action)
@ -131,8 +127,15 @@ impl Runtime {
Ok(())
} else {
debug!("[GIT {} HOOK]: Branch not checked out.", action.uppercase());
if !do_checkout_ensure_branch(self.config.as_ref()) {
Err(GHEK::RepositoryWrongBranchError.into_error())
.map_err_into(GHEK::RepositoryError)
} else {
// Else try to check out the branch...
unimplemented!()
}
}
},
None => Err(GHEK::RepositoryBranchNameFetchingError.into_error())