[buildbot] phase1: fix gitcheckout with corrupted .git

LEDE Commits lede-commits at lists.infradead.org
Sat Mar 6 07:07:48 GMT 2021


ynezz pushed a commit to buildbot.git, branch master:
https://git.openwrt.org/976b2fd5170db09a34985d8d479a6d45dc214787

commit 976b2fd5170db09a34985d8d479a6d45dc214787
Author: Petr Štetiar <ynezz at true.cz>
AuthorDate: Tue Feb 9 22:21:15 2021 +0100

    phase1: fix gitcheckout with corrupted .git
    
    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 at true.cz>
---
 phase1/master.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/phase1/master.cfg b/phase1/master.cfg
index 7186f5a..2cba85e 100644
--- a/phase1/master.cfg
+++ b/phase1/master.cfg
@@ -710,7 +710,7 @@ for target in targets:
 	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



More information about the lede-commits mailing list