[oe-commits] [openembedded-core] 28/50: oeqa.utils.git: implement GitRepo.get_current_branch()

git at git.openembedded.org git at git.openembedded.org
Thu Aug 25 22:04:44 UTC 2016


rpurdie pushed a commit to branch master
in repository openembedded-core.

commit dcba2302adab47b398f1ce7d09c38828ea9ae426
Author: Markus Lehtonen <markus.lehtonen at linux.intel.com>
AuthorDate: Mon May 16 14:36:27 2016 +0300

    oeqa.utils.git: implement GitRepo.get_current_branch()
    
    Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/lib/oeqa/buildperf/base.py | 7 ++-----
 meta/lib/oeqa/utils/git.py      | 8 ++++++++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py
index 6a8d9fe..adc3da3 100644
--- a/meta/lib/oeqa/buildperf/base.py
+++ b/meta/lib/oeqa/buildperf/base.py
@@ -116,12 +116,9 @@ class BuildPerfTestResult(unittest.TextTestResult):
             if not rev:
                 rev = self.repo.rev_parse('HEAD')
             if not branch:
-                try:
-                    # Strip 11 chars, i.e. 'refs/heads' from the beginning
-                    branch = self.repo.run_cmd(['symbolic-ref', 'HEAD'])[11:]
-                except GitError:
+                branch = self.repo.get_current_branch()
+                if not branch:
                     log.debug('Currently on detached HEAD')
-                    branch = None
         return str(rev), str(branch)
 
     def addSuccess(self, test):
diff --git a/meta/lib/oeqa/utils/git.py b/meta/lib/oeqa/utils/git.py
index 6474654..0fc8112 100644
--- a/meta/lib/oeqa/utils/git.py
+++ b/meta/lib/oeqa/utils/git.py
@@ -46,4 +46,12 @@ class GitRepo(object):
             # Revision does not exist
             return None
 
+    def get_current_branch(self):
+        """Get current branch"""
+        try:
+            # Strip 11 chars, i.e. 'refs/heads' from the beginning
+            return self.run_cmd(['symbolic-ref', 'HEAD'])[11:]
+        except GitError:
+            return None
+
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list