diff options
author | Ross Burton <ross.burton@intel.com> | 2015-10-13 15:52:20 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-19 17:57:58 +0100 |
commit | 3aac11076e22ac4fea48f5404110bb959547a9fe (patch) | |
tree | a400c598c3e09ed0d7c52ae1aaf7de0fa2572cb5 /meta | |
parent | 59668f2a037d5b05298bd6f3f7bf807d8a48380e (diff) | |
download | poky-3aac11076e22ac4fea48f5404110bb959547a9fe.tar.gz |
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.
(From OE-Core rev: bd8ff33cf2439536c6e41cf0ee9dd8fb3b64770a)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/metadata_scm.bbclass | 23 |
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): | |||
65 | return revision | 65 | return revision |
66 | 66 | ||
67 | def base_get_metadata_git_branch(path, d): | 67 | def base_get_metadata_git_branch(path, d): |
68 | branch = os.popen('cd %s; git branch 2>&1 | grep "^* " | tr -d "* "' % path).read() | 68 | import subprocess |
69 | 69 | ||
70 | if len(branch) != 0: | 70 | try: |
71 | return branch | 71 | return subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], |
72 | return "<unknown>" | 72 | cwd=path).strip() |
73 | except: | ||
74 | return "<unknown>" | ||
73 | 75 | ||
74 | def base_get_metadata_git_revision(path, d): | 76 | def base_get_metadata_git_revision(path, d): |
75 | f = os.popen("cd %s; git log -n 1 --pretty=oneline -- 2>&1" % path) | 77 | import subprocess |
76 | data = f.read() | ||
77 | if f.close() is None: | ||
78 | rev = data.split(" ")[0] | ||
79 | if len(rev) != 0: | ||
80 | return rev | ||
81 | return "<unknown>" | ||
82 | 78 | ||
79 | try: | ||
80 | return subprocess.check_output(["git", "rev-parse", "HEAD"], | ||
81 | cwd=path).strip() | ||
82 | except: | ||
83 | return "<unknown>" | ||