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>
This commit is contained in:
parent
59668f2a03
commit
3aac11076e
|
@ -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>"
|
||||
|
|
Loading…
Reference in New Issue