eobuilder-ctl: do not use git fetch to detect changes in repository (fixes #25204)

This commit is contained in:
Benjamin Dauvergne 2018-07-11 11:52:18 +02:00
parent cc59d05aae
commit 9bfa631d15
1 changed files with 25 additions and 6 deletions

View File

@ -392,7 +392,6 @@ def clean_git_on_exit(git_project_path):
os.remove(changelog_tmp)
def main():
new = 1
options, args = parse_cmdline()
for method in options.cleaning:
clean(method)
@ -417,8 +416,6 @@ def main():
last_tag = last_tag[1:-1]
else:
last_tag = "0.0"
if not output("git fetch", True):
new = 0
else:
last_tag = "0.0"
os.chdir(settings.GIT_PATH)
@ -427,9 +424,6 @@ def main():
else:
call("git clone %s/%s.git" % \
(settings.GIT_REPOSITORY_URL, project_name))
if options.force:
print "+ Warning force a new build"
new = 1
print "+ Updating git repository and parsing configuration ..."
os.chdir(git_project_path)
call("git checkout --quiet %s" % options.branch)
@ -439,6 +433,27 @@ def main():
if not os.path.exists(project['lock_path']):
os.mkdir(project['lock_path'], 0755)
# compare revision between last build and now to determine if something is really new
new = 1
current_revision = output("git rev-parse HEAD", True).strip()
last_branch_revision_file_path = os.path.join(
project['lock_path'],
"%s_%s.last_revision" % (
project['name'],
options.branch.replace('/', '_')))
try:
with open(last_branch_revision_file_path) as f:
last_branch_revision = f.read().strip()
except IOError:
pass
else:
if current_revision == last_branch_revision:
new = 0
if options.force and not new:
print "+ Warning force a new build"
new = 1
for dist in options.distrib:
os.chdir(git_project_path)
call("git checkout --quiet %s" % options.branch)
@ -463,6 +478,10 @@ def main():
with open(last_version_file, 'w+') as f:
f.write(package['version'])
# keep current revision for next build
with open(last_branch_revision_file_path, 'w+') as f:
f.write(current_revision)
if __name__ == "__main__":
main()