Skip to content

Commit a6b63dc

Browse files
committed
try/except for git commands
1 parent b98dc36 commit a6b63dc

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bioproject/{{ cookiecutter.project_slug }}/scripts/workflow_functions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,15 @@ def shipResults(filetup, wdir, enddir, trackdic=None, delete=True):
8080
# Book keeping.
8181
if trackdic:
8282
with open(Path(enddir) / 'README.txt', 'w') as f:
83-
_commit = sp.check_output(['git', 'log', '-n', '1', '--pretty=format:"%H"']).decode().strip('"')
84-
if not _commit:
83+
try:
84+
_commit = sp.check_output(['git', 'log', '-n', '1', '--pretty=format:"%H"']).decode().strip('"')
85+
except sp.CalledProcessError:
8586
_commit = 'unknown'
86-
_remote = sp.check_output(['git', 'config', '--get', 'remote.origin.url']).decode().strip('"').strip('\n')
87+
try:
88+
_remote = sp.check_output(['git', 'config', '--get', 'remote.origin.url']).decode().strip('"').strip('\n')
89+
except sp.CalledProcessError:
90+
_remote = 'unknown'
91+
8792
if not _remote:
8893
_remote = 'unknown'
8994

0 commit comments

Comments
 (0)