gitpkgv.bbclass: Use --git-dir option

Avoid redundant shell working directory change by resorting to
'--git-dir' option for git command instead.

Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
niko.mauno@vaisala.com 2019-11-19 08:46:24 +00:00 committed by Khem Raj
parent c3cf73c621
commit 6e3ba47f8c

View File

@ -87,10 +87,8 @@ def get_git_pkgv(d, use_tags):
if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0:
commits = bb.fetch2.runfetchcmd(
"cd %(repodir)s && "
"git rev-list %(rev)s -- 2> /dev/null "
"| wc -l" % vars,
d, quiet=True).strip().lstrip('0')
"git --git-dir=%(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
% vars, d, quiet=True).strip().lstrip('0')
if commits != "":
oe.path.remove(rev_file, recurse=False)
@ -105,9 +103,8 @@ def get_git_pkgv(d, use_tags):
if use_tags:
try:
output = bb.fetch2.runfetchcmd(
"cd %(repodir)s && "
"git describe %(rev)s 2>/dev/null" % vars,
d, quiet=True).strip()
"git --git-dir=%(repodir)s describe %(rev)s 2>/dev/null"
% vars, d, quiet=True).strip()
ver = gitpkgv_drop_tag_prefix(output)
except Exception:
ver = "0.0-%s-g%s" % (commits, vars['rev'][:7])