1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

buildcfg: get_metadata_git_*: catch also bb.process.NotFoundError

* bb.process.NotFoundError is triggered when e.g. oe.buildcfg.get_metadata_git_branch
  is called on non-existent directory

(From OE-Core rev: 34c1f66c4c689b26a4c3129eb62f4ff9b6ec14be)

Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Martin Jansa
2025-04-15 21:47:26 +02:00
committed by Richard Purdie
parent 706085aaf7
commit f4d8e84fd9
+6 -6
View File
@@ -17,21 +17,21 @@ def get_scmbasepath(d):
def get_metadata_git_branch(path): def get_metadata_git_branch(path):
try: try:
rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path) rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path)
except bb.process.ExecutionError: except (bb.process.ExecutionError, bb.process.NotFoundError):
rev = '<unknown>' rev = '<unknown>'
return rev.strip() return rev.strip()
def get_metadata_git_revision(path): def get_metadata_git_revision(path):
try: try:
rev, _ = bb.process.run('git rev-parse HEAD', cwd=path) rev, _ = bb.process.run('git rev-parse HEAD', cwd=path)
except bb.process.ExecutionError: except (bb.process.ExecutionError, bb.process.NotFoundError):
rev = '<unknown>' rev = '<unknown>'
return rev.strip() return rev.strip()
def get_metadata_git_toplevel(path): def get_metadata_git_toplevel(path):
try: try:
toplevel, _ = bb.process.run('git rev-parse --show-toplevel', cwd=path) toplevel, _ = bb.process.run('git rev-parse --show-toplevel', cwd=path)
except bb.process.ExecutionError: except (bb.process.ExecutionError, bb.process.NotFoundError):
return "" return ""
return toplevel.strip() return toplevel.strip()
@@ -39,21 +39,21 @@ def get_metadata_git_remotes(path):
try: try:
remotes_list, _ = bb.process.run('git remote', cwd=path) remotes_list, _ = bb.process.run('git remote', cwd=path)
remotes = remotes_list.split() remotes = remotes_list.split()
except bb.process.ExecutionError: except (bb.process.ExecutionError, bb.process.NotFoundError):
remotes = [] remotes = []
return remotes return remotes
def get_metadata_git_remote_url(path, remote): def get_metadata_git_remote_url(path, remote):
try: try:
uri, _ = bb.process.run('git remote get-url {remote}'.format(remote=remote), cwd=path) uri, _ = bb.process.run('git remote get-url {remote}'.format(remote=remote), cwd=path)
except bb.process.ExecutionError: except (bb.process.ExecutionError, bb.process.NotFoundError):
return "" return ""
return uri.strip() return uri.strip()
def get_metadata_git_describe(path): def get_metadata_git_describe(path):
try: try:
describe, _ = bb.process.run('git describe --tags --dirty', cwd=path) describe, _ = bb.process.run('git describe --tags --dirty', cwd=path)
except bb.process.ExecutionError: except (bb.process.ExecutionError, bb.process.NotFoundError):
return "" return ""
return describe.strip() return describe.strip()