mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 07:01:33 +00:00
Implement restore_snapshot latest commit on branch detection
This commit is contained in:
parent
782df25bee
commit
cbb807dfb4
@ -10,6 +10,7 @@ from uuid import uuid4
|
||||
from dateutil import parser as dateparser
|
||||
|
||||
|
||||
# TODO: gitignore
|
||||
class SnapshotProvider:
|
||||
def __init__(self, directory, git_dir):
|
||||
self._classname = self.__class__.__name__
|
||||
@ -125,6 +126,9 @@ class SnapshotProvider:
|
||||
|
||||
def restore_snapshot(self, date):
|
||||
commit = self._get_commit_from_timestamp(date)
|
||||
branch = self._last_valid_branch
|
||||
if commit == self._latest_commit_on_branch(branch):
|
||||
commit = branch
|
||||
self._checkout(commit)
|
||||
|
||||
def _get_commit_from_timestamp(self, date):
|
||||
@ -153,6 +157,14 @@ class SnapshotProvider:
|
||||
self.__last_valid_branch = self._branch
|
||||
return self.__last_valid_branch
|
||||
|
||||
def _latest_commit_on_branch(self, branch):
|
||||
return self._get_stdout((
|
||||
'git', 'log',
|
||||
'-n', '1',
|
||||
'--pretty=format:%H',
|
||||
branch
|
||||
))
|
||||
|
||||
@property
|
||||
def all_timelines(self):
|
||||
return self._branches
|
||||
|
Loading…
Reference in New Issue
Block a user