Browse Source

Add the git branch name to results.json (#3317)

Michael Hixson 7 years ago
parent
commit
b7af13f591
1 changed files with 4 additions and 0 deletions
  1. 4 0
      toolset/benchmark/benchmarker.py

+ 4 - 0
toolset/benchmark/benchmarker.py

@@ -875,6 +875,9 @@ class Benchmarker:
     def __get_git_repository_url(self):
     def __get_git_repository_url(self):
         return subprocess.check_output('git config --get remote.origin.url', shell=True).strip()
         return subprocess.check_output('git config --get remote.origin.url', shell=True).strip()
 
 
+    def __get_git_branch_name(self):
+        return subprocess.check_output('git rev-parse --abbrev-ref HEAD', shell=True).strip()
+
     ############################################################
     ############################################################
     # __finish
     # __finish
     ############################################################
     ############################################################
@@ -995,6 +998,7 @@ class Benchmarker:
                 self.results['git'] = dict()
                 self.results['git'] = dict()
                 self.results['git']['commitId'] = self.__get_git_commit_id()
                 self.results['git']['commitId'] = self.__get_git_commit_id()
                 self.results['git']['repositoryUrl'] = self.__get_git_repository_url()
                 self.results['git']['repositoryUrl'] = self.__get_git_repository_url()
+                self.results['git']['branchName'] = self.__get_git_branch_name()
             except Exception as e:
             except Exception as e:
                 logging.debug('Could not read local git repository, which is fine. The error was: %s', e)
                 logging.debug('Could not read local git repository, which is fine. The error was: %s', e)
                 self.results['git'] = None
                 self.results['git'] = None