summaryrefslogtreecommitdiff
path: root/meta/classes
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2015-10-13 15:52:20 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-10-19 17:48:14 +0100
commitbd8ff33cf2439536c6e41cf0ee9dd8fb3b64770a (patch)
tree33b58d62cdce6738c33f4556f34213099f53c8fa /meta/classes
parentcb46e70148c4210071299acc648c10f1c87cd3fd (diff)
downloadopenembedded-core-bd8ff33cf2439536c6e41cf0ee9dd8fb3b64770a.tar.gz
openembedded-core-bd8ff33cf2439536c6e41cf0ee9dd8fb3b64770a.tar.bz2
openembedded-core-bd8ff33cf2439536c6e41cf0ee9dd8fb3b64770a.zip
metadata_scm: rewrite git hash logic
The code to get the git and branch hash for the current commit in a specific repository was quite complex and prone to breakage, replace it with subprocess and git rev-parse. Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/metadata_scm.bbclass23
1 files changed, 12 insertions, 11 deletions
diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass
index 237e61821d..64465faa4c 100644
--- a/meta/classes/metadata_scm.bbclass
+++ b/meta/classes/metadata_scm.bbclass
@@ -65,18 +65,19 @@ def base_get_metadata_svn_revision(path, d):
return revision
def base_get_metadata_git_branch(path, d):
- branch = os.popen('cd %s; git branch 2>&1 | grep "^* " | tr -d "* "' % path).read()
+ import subprocess
- if len(branch) != 0:
- return branch
- return "<unknown>"
+ try:
+ return subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"],
+ cwd=path).strip()
+ except:
+ return "<unknown>"
def base_get_metadata_git_revision(path, d):
- f = os.popen("cd %s; git log -n 1 --pretty=oneline -- 2>&1" % path)
- data = f.read()
- if f.close() is None:
- rev = data.split(" ")[0]
- if len(rev) != 0:
- return rev
- return "<unknown>"
+ import subprocess
+ try:
+ return subprocess.check_output(["git", "rev-parse", "HEAD"],
+ cwd=path).strip()
+ except:
+ return "<unknown>"