rrs/tools: avoid unnecessary checkouts

We don't need to create branches here, and we don't need to actually
check anything out unless we're going to parse, so we can save a bit of
time by not doing so.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-02-27 17:16:12 +13:00
parent 6f34b7fce7
commit 8370c10306
2 changed files with 6 additions and 22 deletions

View File

@ -107,8 +107,7 @@ def maintainer_history(options, logger):
sha1=commit) sha1=commit)
rms.save() rms.save()
branchname = 'maintainer' + commit utils.runcmd("git checkout %s -f" % commit,
utils.runcmd("git checkout %s -b %s -f" % (commit, branchname),
pokypath, logger=logger) pokypath, logger=logger)
lines = [line.strip() for line in open(maintainers_full_path)] lines = [line.strip() for line in open(maintainers_full_path)]
@ -145,9 +144,6 @@ def maintainer_history(options, logger):
logger.debug("%s: Not found maintainer in commit %s set to 'No maintainer'." % \ logger.debug("%s: Not found maintainer in commit %s set to 'No maintainer'." % \
(recipe.pn, rms.sha1)) (recipe.pn, rms.sha1))
utils.runcmd("git checkout master -f", pokypath, logger=logger)
utils.runcmd("git branch -D %s" % (branchname), pokypath, logger=logger)
# set new recipes to no maintainer if don't have one # set new recipes to no maintainer if don't have one
m = Maintainer.objects.get(id = 0) # No Maintainer m = Maintainer.objects.get(id = 0) # No Maintainer
rms = RecipeMaintainerHistory.get_last() rms = RecipeMaintainerHistory.get_last()

View File

@ -34,7 +34,6 @@ fetchdir = settings.LAYER_FETCH_DIR
if not fetchdir: if not fetchdir:
logger.error("Please set LAYER_FETCH_DIR in settings.py") logger.error("Please set LAYER_FETCH_DIR in settings.py")
sys.exit(1) sys.exit(1)
branch_name_tmp = "recipe_upgrades"
# setup bitbake # setup bitbake
bitbakepath = os.path.join(fetchdir, 'bitbake') bitbakepath = os.path.join(fetchdir, 'bitbake')
@ -151,7 +150,7 @@ def do_initial(layerbranch, ct, logger, dry_run):
repodir = os.path.join(fetchdir, urldir) repodir = os.path.join(fetchdir, urldir)
layerdir = os.path.join(repodir, str(layerbranch.vcs_subdir)) layerdir = os.path.join(repodir, str(layerbranch.vcs_subdir))
utils.runcmd("git checkout %s -b %s -f" % (ct, branch_name_tmp), utils.runcmd("git checkout %s" % ct,
repodir, logger=logger) repodir, logger=logger)
utils.runcmd("git clean -dfx", repodir, logger=logger) utils.runcmd("git clean -dfx", repodir, logger=logger)
@ -171,8 +170,6 @@ def do_initial(layerbranch, ct, logger, dry_run):
except DryRunRollbackException: except DryRunRollbackException:
pass pass
utils.runcmd("git checkout master -f", repodir, logger=logger)
utils.runcmd("git branch -D %s" % (branch_name_tmp), repodir, logger=logger)
tinfoil.shutdown() tinfoil.shutdown()
def do_loop(layerbranch, ct, logger, dry_run): def do_loop(layerbranch, ct, logger, dry_run):
@ -181,14 +178,12 @@ def do_loop(layerbranch, ct, logger, dry_run):
repodir = os.path.join(fetchdir, urldir) repodir = os.path.join(fetchdir, urldir)
layerdir = os.path.join(repodir, str(layerbranch.vcs_subdir)) layerdir = os.path.join(repodir, str(layerbranch.vcs_subdir))
utils.runcmd("git checkout %s -b %s -f" % (ct, branch_name_tmp), utils.runcmd("git checkout %s" % ct,
repodir, logger=logger) repodir, logger=logger)
utils.runcmd("git clean -dfx", repodir, logger=logger) utils.runcmd("git clean -dfx", repodir, logger=logger)
fns = _get_recipes_filenames(ct, repodir, layerdir, logger) fns = _get_recipes_filenames(ct, repodir, layerdir, logger)
if not fns: if not fns:
utils.runcmd("git checkout master -f", repodir, logger=logger)
utils.runcmd("git branch -D %s" % (branch_name_tmp), repodir, logger=logger)
return return
(tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath, (tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath,
@ -209,8 +204,6 @@ def do_loop(layerbranch, ct, logger, dry_run):
except DryRunRollbackException: except DryRunRollbackException:
pass pass
utils.runcmd("git checkout master -f", repodir, logger=logger)
utils.runcmd("git branch -D %s" % (branch_name_tmp), repodir, logger=logger)
tinfoil.shutdown() tinfoil.shutdown()
@ -237,14 +230,6 @@ def upgrade_history(options, logger):
repodir = os.path.join(fetchdir, urldir) repodir = os.path.join(fetchdir, urldir)
layerdir = os.path.join(repodir, layerbranch.vcs_subdir) layerdir = os.path.join(repodir, layerbranch.vcs_subdir)
## try to delete temp_branch if exists
try:
utils.runcmd("git checkout origin/master -f", repodir)
utils.runcmd("git branch -D %s" % (branch_name_tmp), repodir,
logger=logger)
except:
pass
commits = utils.runcmd("git log --since='" + since + commits = utils.runcmd("git log --since='" + since +
"' --format='%H' --reverse", repodir, "' --format='%H' --reverse", repodir,
logger=logger) logger=logger)
@ -262,6 +247,9 @@ def upgrade_history(options, logger):
logger.debug("Analysing commit %s ..." % ct) logger.debug("Analysing commit %s ..." % ct)
do_loop(layerbranch, ct, logger, options.dry_run) do_loop(layerbranch, ct, logger, options.dry_run)
if commit_list:
utils.runcmd("git clean -dfx", repodir, logger=logger)
if __name__=="__main__": if __name__=="__main__":
parser = optparse.OptionParser(usage = """%prog [options]""") parser = optparse.OptionParser(usage = """%prog [options]""")