Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge PR #153: Suppress errors outside of git repo
  • Loading branch information
smarr committed Oct 1, 2020
2 parents 0ec399a + bdd42ac commit 07fbdf5
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions rebench/environment.py
Expand Up @@ -23,7 +23,8 @@ def _encode_str(out):

def _exec(cmd):
try:
out = subprocess.check_output(cmd)
with open(os.devnull, 'w') as dev_null_f:
out = subprocess.check_output(cmd, stderr=dev_null_f)
except subprocess.CalledProcessError:
return None
return _encode_str(out)
Expand All @@ -38,9 +39,22 @@ def determine_source_details():
return _source

result = dict()
try:
repo_url = subprocess.check_output(['git', 'ls-remote', '--get-url'])
except subprocess.CalledProcessError:

is_git_repo = _exec(['git', 'rev-parse']) is not None
if not is_git_repo:
result['repoURL'] = None
result['branchOrTag'] = None
result['commitId'] = None
result['commitMsg'] = None
result['authorName'] = None
result['committerName'] = None
result['authorEmail'] = None
result['committerEmail'] = None
_source = result
return result

repo_url = _exec(['git', 'ls-remote', '--get-url']) if is_git_repo else None
if repo_url is None:
repo_url = ''

parsed = urlparse(repo_url)
Expand All @@ -59,7 +73,6 @@ def determine_source_details():
result['committerEmail'] = _exec(['git', 'show', '-s', '--format=%cE', 'HEAD'])

_source = result

return result


Expand Down

0 comments on commit 07fbdf5

Please sign in to comment.