mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 22:01:55 +00:00
Fix restore_snapshot() choking on timestamps before initial commit
This commit is contained in:
parent
3d2e3e7db3
commit
e383be0149
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user