Fix restore_snapshot() choking on timestamps before initial commit

This commit is contained in:
Kristóf Tóth 2018-08-03 11:55:51 +02:00
parent 3d2e3e7db3
commit e383be0149

View File

@ -129,13 +129,24 @@ class SnapshotProvider:
self._checkout(commit)
def _get_commit_from_timestamp(self, date):
return self._get_stdout((
commit = self._get_stdout((
'git', 'rev-list',
'--date=iso',
'-n', '1',
f'--before="{date.isoformat()}"',
self._last_valid_branch
))
if not commit:
commit = self._get_oldest_parent_of_head()
return commit
def _get_oldest_parent_of_head(self):
return self._get_stdout((
'git',
'rev-list',
'--max-parents=0',
'HEAD'
))
@property
def _last_valid_branch(self):