summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Peres <martin.peres@linux.intel.com>2015-09-07 13:00:34 +0300
committerMartin Peres <martin.peres@linux.intel.com>2015-09-07 16:54:30 +0300
commit2d48618d29f8a1a101c04a277362fe3fd330080a (patch)
tree9aa23e560d0b0d4fb0b9eb752874a005da9b0040
parent35b6a235f23867939ce2dd3ae100927511152931 (diff)
utils/reorder_commits_by_date: Add a tool to reorder commits by date
It is useful for visualizing bisect reports
-rwxr-xr-xutils/reorder_commits_by_date.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/utils/reorder_commits_by_date.py b/utils/reorder_commits_by_date.py
new file mode 100755
index 0000000..cd12492
--- /dev/null
+++ b/utils/reorder_commits_by_date.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+
+from ezbench import *
+import subprocess
+import argparse
+import shutil
+import sys
+import os
+
+# Start by checking what the user wants to monitor!
+parser = argparse.ArgumentParser()
+parser.add_argument("--path", "-p", help="Repository path")
+parser.add_argument("log_folder")
+args = parser.parse_args()
+
+if len(args.path) == 0:
+ print ("You need to specify a path to the git repo using -p.")
+ exit(1)
+
+commits_path = os.path.abspath(args.log_folder + "/commit_list")
+commits_sav_path = commits_path + ".sav"
+
+if os.path.exists(commits_sav_path):
+ shouldAbort = input("The backup commit list file '{}' already exists and will be deleted.\nAbort? (y/N)".format(commits_sav_path)).lower() == 'y'
+ if shouldAbort:
+ exit(0)
+ print()
+shutil.copyfile(commits_path, commits_sav_path)
+
+report = genPerformanceReport(args.log_folder, False)
+
+f = open(commits_path, 'w')
+
+# Move to the repo's list
+os.chdir(args.path)
+
+for commit in report.commits:
+ gitCommandLine = ["/usr/bin/git", "show", "--format=%ct", "--date=local", "-s", commit.sha1]
+ commit.date = subprocess.check_output(gitCommandLine).decode().split(' ')[0]
+
+commits = sorted(report.commits, key=lambda commit: commit.date)
+
+for commit in commits:
+ val = "{full_name}\n".format(full_name=commit.full_name)
+ f.write(val)
+ print(val, end="")