When the container running `git clone` is killed it will leave the .git
directory in unusable state which then leads in the following errors:
if [ -d .git ]; then git checkout -f master; git branch --set-upstream-to origin/master; else exit 0; fi
error: pathspec 'master' did not match any file(s) known to git.
fatal: branch 'master' does not exist
Fix it by removing .git completely if this happens, otherwise it might
simply leave shared build directory in the unusable state.
Signed-off-by: Petr Štetiar <ynezz@true.cz>
factory.addStep(ShellCommand(
name = "gitcheckout",
description = "Ensure that Git HEAD is sane",
- command = "if [ -d .git ]; then git checkout -f %s; git branch --set-upstream-to origin/%s; else exit 0; fi" %(repo_branch, repo_branch),
+ command = "if [ -d .git ]; then git checkout -f %s && git branch --set-upstream-to origin/%s || rm -fr .git; else exit 0; fi" %(repo_branch, repo_branch),
haltOnFailure = True))
# check out the source