Get branch of detached commit when archiving perf results
Change-Id: Iad052eceb53c6efc51f31c159d880d2a946d3199
diff --git a/tools/historic_run.py b/tools/historic_run.py
index cef478a..648e31d 100755
--- a/tools/historic_run.py
+++ b/tools/historic_run.py
@@ -57,9 +57,15 @@
return self.__str__()
def branch(self):
- result = subprocess.check_output(
- ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('utf-8')
- return result.strip()
+ branches = subprocess.check_output(
+ ['git', 'branch', '--contains', 'HEAD',
+ '-r']).decode('utf-8').strip().splitlines()
+ if len(branches) != 1:
+ return 'main'
+ branch = branches[0].strip()
+ if 'main' in branch:
+ return 'main'
+ return branch[branch.find('/') + 1:]
def hash(self):
return self.git_hash