Skip to content

Commit

Permalink
[tsmeta/layers] Do better check for valid git repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
mochel-timesys committed Mar 10, 2020
1 parent d33fcaf commit 9ea41a7
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions classes/tsmeta.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -605,15 +605,32 @@ def tsmeta_git_branch_info(d, path):
def _run_git(_git_cmd, _arg_list = []):
_args = ' '.join(_arg_list)
_cmd = ' '.join([_git_cmd, _args])
bb.debug(2, 'Command: %s' % _cmd)
# bb.plain('Command: %s' % _cmd)
try:
git_out, _ = bb.process.run(_cmd, cwd=path)
bb.debug(2, 'git output: %s' % git_out)
# bb.plain('git output: %s' % git_out)
except bb.process.ExecutionError as ex:
bb.debug(1, 'git Failed: %s -- %s' % (_cmd, ex))
git_out = ""
return oe.utils.squashspaces(git_out)

def _repo_config():
_git_config_cmd = ' '.join([
'git',
'config'
])
_local_list_args = [
'-l',
'--local'
]
_local_config = _run_git(_git_config_cmd, _local_list_args)
# cfg_dict = {}
# for _entry in _local_config.split():
# _name, _value = _entry.split('=', 2)
# cfg_dict[_name] = _value
# bb.plain("git Config for %s: %s" % (path, cfg_dict))
return _local_config

def _head_revision():
_git_log_cmd = ' '.join([
'git',
Expand All @@ -625,7 +642,7 @@ def tsmeta_git_branch_info(d, path):
'--format=\'%H\''
]
_rev = _run_git(_git_log_cmd, _log_args)
bb.debug(2, 'Path: %s, Revision: %s' %(path, _rev))
# bb.plain('Path: %s, Revision: %s' %(path, _rev))
return _rev

def _branch_name(_rev):
Expand Down Expand Up @@ -656,7 +673,7 @@ def tsmeta_git_branch_info(d, path):
_str in _name for _str in [ '(no branch)', '(HEAD detached' ]
]):
_name = "detached"
bb.debug(2, "Path: %s, Branch Name: %s" %(path, _name))
# bb.plain("Path: %s, Branch Name: %s" %(path, _name))
return _name

def _get_remote_list():
Expand Down Expand Up @@ -718,6 +735,10 @@ def tsmeta_git_branch_info(d, path):
_remote_url = _run_git(_git_cmd_ls_remote, _remote_args)
return _remote_url

r_config = _repo_config()
if not r_config:
return {}

b_rev = _head_revision()
b_name = _branch_name(b_rev)
b_remote, b_upstream = _upstream_branch(b_rev)
Expand Down

0 comments on commit 9ea41a7

Please sign in to comment.