From 5130ab9f21c87fe30e06b34bea502effd0595c44 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 21 Feb 2019 14:26:56 +0000 Subject: [PATCH] utils: Move getcomparisonbranch() to common function library Signed-off-by: Richard Purdie --- scripts/build-perf-test-wrapper | 22 +++------------------- scripts/utils.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/scripts/build-perf-test-wrapper b/scripts/build-perf-test-wrapper index 5707586..e949f05 100755 --- a/scripts/build-perf-test-wrapper +++ b/scripts/build-perf-test-wrapper @@ -23,6 +23,8 @@ import subprocess import sys import datetime +import utils + parser = utils.ArgParser(description='Run a build performance test and process the results.') parser.add_argument('-b', '--branch', @@ -159,24 +161,6 @@ if args.publish_dir: os.makedirs(args.publish_dir, exist_ok=True) subprocess.check_call("cp -r %s/* %s" % (results_tmpdir, args.publish_dir), shell=True) -# -# Figure out which branch we might need to compare against -# -def getcomparisionbranch(ourconfig, reponame, branchname): - print("Working off %s:%s\n" % (reponame, branchname)) - base = None - basebranch = None - if "/" in reponame: - reponame = reponame.rsplit("/", 1)[1] - if reponame.endswith(".git"): - reponame = reponame[:-4] - if (reponame + ":" + branchname) in utils.getconfig("BUILD_HISTORY_FORKPUSH", ourconfig): - base = utils.getconfig("BUILD_HISTORY_FORKPUSH", ourconfig)[reponame + ":" + branchname] - if base: - baserepo, basebranch = base.split(":") - print("Comparing to %s\n" % (basebranch)) - return basebranch - # Commit results to git if git_repo: print("\nArchiving results in " + git_repo) @@ -198,7 +182,7 @@ if git_repo: extraopts = " --branch %s --commit %s" % (branch, gitrevfull) if args.repo and args.branch: - comparebranch = getcomparisionbranch(ourconfig, args.repo, args.branch) + comparebranch = utils.getcomparisonbranch(ourconfig, args.repo, args.branch) if comparebranch: extraopts = extraopts + " --branch2 %s" % (comparebranch) diff --git a/scripts/utils.py b/scripts/utils.py index acdb1a5..d23b106 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -344,3 +344,21 @@ class ArgParser(argparse.ArgumentParser): sys.stderr.write('error: %s\n' % message) self.print_help() sys.exit(2) + +# +# Figure out which branch we might need to compare against +# +def getcomparisonbranch(ourconfig, reponame, branchname): + print("Working off %s:%s\n" % (reponame, branchname)) + base = None + basebranch = None + if "/" in reponame: + reponame = reponame.rsplit("/", 1)[1] + if reponame.endswith(".git"): + reponame = reponame[:-4] + if (reponame + ":" + branchname) in getconfig("BUILD_HISTORY_FORKPUSH", ourconfig): + base = getconfig("BUILD_HISTORY_FORKPUSH", ourconfig)[reponame + ":" + branchname] + if base: + baserepo, basebranch = base.split(":") + print("Comparing to %s\n" % (basebranch)) + return basebranch