summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-02-17 08:50:10 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-02-17 16:21:03 (GMT)
commit8a98a2a49f14b421a9082ea7fb872d3e2ee95495 (patch)
treecc6f0bea7affe985c5b5bf98b731393fe2b2034e
parent3b0463c4cee184ed28d5e69743f5d054ec94873c (diff)
downloadeobuilder-8a98a2a49f14b421a9082ea7fb872d3e2ee95495.zip
eobuilder-8a98a2a49f14b421a9082ea7fb872d3e2ee95495.tar.gz
eobuilder-8a98a2a49f14b421a9082ea7fb872d3e2ee95495.tar.bz2
wipe git clone on errors (#30720)
-rwxr-xr-xeobuilder-ctl60
1 files changed, 42 insertions, 18 deletions
diff --git a/eobuilder-ctl b/eobuilder-ctl
index 023186e..8dcb0bd 100755
--- a/eobuilder-ctl
+++ b/eobuilder-ctl
@@ -3,6 +3,7 @@
import atexit
import re
import shutil
+import subprocess
import sys
import tarfile
import time
@@ -390,6 +391,44 @@ def clean_git_on_exit(git_project_path):
if os.path.exists(changelog_tmp):
os.remove(changelog_tmp)
+def setup_git_tree(project_name, options):
+ git_project_path = os.path.join(settings.GIT_PATH, os.path.basename(project_name))
+ if options.branch.startswith('wip/'):
+ if os.path.exists(git_project_path):
+ shutil.rmtree(git_project_path)
+ if os.path.exists(git_project_path):
+ existing_tree = True
+ os.chdir(git_project_path)
+ try:
+ subprocess.check_call(['git', 'checkout', '--quiet', options.branch])
+ subprocess.check_call(['git', 'reset', '--hard', 'origin/%s' % options.branch])
+ except subprocess.CalledProcessError as e:
+ print >> sys.stderr, e
+ shutil.rmtree(git_project_path)
+ return setup_git_tree(project_name, options)
+ else:
+ existing_tree = False
+ os.chdir(settings.GIT_PATH)
+ if project_name.startswith('/'):
+ call("git clone %s" % project_name)
+ else:
+ call("git clone %s/%s.git" % \
+ (settings.GIT_REPOSITORY_URL, project_name))
+
+ os.chdir(git_project_path)
+ try:
+ subprocess.check_call(['git', 'checkout', '--quiet', options.branch])
+ subprocess.check_call(['git', 'pull'])
+ subprocess.check_call(['git', 'submodule', 'init'])
+ subprocess.check_call(['git', 'submodule', 'update'])
+ except subprocess.CalledProcessError as e:
+ if existing_tree:
+ print >> sys.stderr, e
+ shutil.rmtree(git_project_path)
+ return setup_git_tree(project_name, options)
+ raise
+
+
def main():
options, args = parse_cmdline()
for method in options.cleaning:
@@ -405,13 +444,9 @@ def main():
if options.branch.startswith('origin/'):
# normalize without origin/
options.branch = options.branch[len('origin/'):]
- if options.branch.startswith('wip/'):
- if os.path.exists(git_project_path):
- shutil.rmtree(git_project_path)
- if os.path.exists(git_project_path):
+ existing_tree = os.path.exists(git_project_path)
+ if existing_tree:
os.chdir(git_project_path)
- call("git checkout --quiet %s" % options.branch)
- call("git reset --hard origin/%s" % options.branch)
last_tag = output("git describe --abbrev=0 --tags --match=v*",
exit_on_error=False)
if last_tag:
@@ -420,18 +455,7 @@ def main():
last_tag = "0.0"
else:
last_tag = "0.0"
- os.chdir(settings.GIT_PATH)
- if project_name.startswith('/'):
- call("git clone %s" % project_name)
- else:
- call("git clone %s/%s.git" % \
- (settings.GIT_REPOSITORY_URL, project_name))
- print "+ Updating git repository and parsing configuration ..."
- os.chdir(git_project_path)
- call("git checkout --quiet %s" % options.branch)
- call("git pull")
- call("git submodule init")
- call("git submodule update")
+ setup_git_tree(project_name, options)
project = get_project_infos(git_project_path, options)
if not os.path.exists(project['lock_path']):