From: Chris Larson Date: Thu, 4 Nov 2010 04:18:02 +0000 (+0000) Subject: metadata_scm: use rev-parse rather than show-ref X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3d8c448c2bb3ea2c9a92bdb442fb4b39144bae0;p=openembedded.git metadata_scm: use rev-parse rather than show-ref show-ref will show all matching refs, so a "show-ref HEAD" will show not just the local HEAD, but the fetched remote ones as well. This isn't what we want for this function, so change it to use rev-parse with --verify, and also change it to use --short, to shorten the hash to a more palatable length. Signed-off-by: Chris Larson Acked-by: Tim Harvey Acked-by: Khem Raj --- diff --git a/classes/metadata_scm.bbclass b/classes/metadata_scm.bbclass index ffc6a8adfe..f79ea1998f 100644 --- a/classes/metadata_scm.bbclass +++ b/classes/metadata_scm.bbclass @@ -63,14 +63,18 @@ def base_get_metadata_svn_revision(path, d): return revision def base_get_metadata_git_branch(path, d): - branch = os.popen('cd %s; PATH=%s git symbolic-ref HEAD 2>/dev/null' % (path, d.getVar("PATH", 1))).read().rstrip() - - if len(branch) != 0: - return branch.replace("refs/heads/", "") - return "" + try: + rev = oe_run(d, ["git", "symbolic-ref", "HEAD"], cwd=path).rstrip() + except oe.process.CmdError: + rev = "" + else: + rev = rev.replace("refs/heads/", "") + return rev def base_get_metadata_git_revision(path, d): - rev = os.popen("cd %s; PATH=%s git show-ref HEAD 2>/dev/null" % (path, d.getVar("PATH", 1))).read().split(" ")[0].rstrip() - if len(rev) != 0: - return rev - return "" + try: + rev = oe_run(d, ["git", "rev-parse", "--verify", "--short", "HEAD"], + cwd=path).rstrip() + except oe.process.CmdError: + rev = "" + return rev