From 618a2ede75b6b360974b9c74b046f4bf75bd8e17 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Mon, 16 May 2016 14:36:27 +0300 Subject: oeqa.utils.git: implement GitRepo.get_current_branch() (From OE-Core rev: dcba2302adab47b398f1ce7d09c38828ea9ae426) Signed-off-by: Markus Lehtonen Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- meta/lib/oeqa/utils/git.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'meta/lib/oeqa/utils') diff --git a/meta/lib/oeqa/utils/git.py b/meta/lib/oeqa/utils/git.py index 647465467d..0fc8112321 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 + -- cgit v1.2.3-54-g00ecf