Skip to content

Commit

Permalink
Add fallback when sha cannot be determined
Browse files Browse the repository at this point in the history
  • Loading branch information
stefsmeets committed Nov 9, 2023
1 parent 282d8cc commit 816b303
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/duqtools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def parse_logfile(self, *, logfile, debug, **kwargs):
fhandler.setFormatter(escaped_format)
logging.getLogger().addHandler(fhandler)

start_time = datetime.now().astimezone().strftime(
'%Y-%m-%d %H:%M:%S %z')
logger.info('')
logger.info(
'Duqtools starting at '
f'{datetime.now().astimezone().strftime("%Y-%m-%d %H:%M:%S %z")}')
logger.info(f'Duqtools starting at {start_time}')
logger.info('------------------------------------------------')
logger.info('')

Expand Down Expand Up @@ -561,10 +561,10 @@ def cli_version(**kwargs):
try:
repo = git.Repo(Path(__file__), search_parent_directories=True)
sha = repo.head.object.hexsha
except OSError:
pass
else:
string += f' (rev: {sha})'
except (OSError, ValueError):
sha = '???'

string += f' (rev: {sha})'

click.echo(string)

Expand Down

0 comments on commit 816b303

Please sign in to comment.