Implement checking whether directories passed exsist

This commit is contained in:
Kristóf Tóth 2018-07-18 14:26:14 +02:00
parent 49e0efa4c9
commit e80782aa6c

View File

@ -3,6 +3,7 @@
from subprocess import run from subprocess import run
from getpass import getuser from getpass import getuser
from os.path import isdir
class SnapshotProvider: class SnapshotProvider:
@ -17,12 +18,18 @@ class SnapshotProvider:
'GIT_COMMITTER_EMAIL': '' 'GIT_COMMITTER_EMAIL': ''
} }
self._check_environment()
self._head_detached = False self._head_detached = False
self._branch = 'master' self._branch = 'master'
self._branches = [self._branch] self._branches = [self._branch]
self._init_repo_if_needed() self._init_repo_if_needed()
def _check_environment(self):
if not isdir(self.gitenv['GIT_DIR']) or not isdir(self.gitenv['GIT_WORK_TREE']):
raise EnvironmentError('Directories "directory" and "git_dir" must exist!')
def _init_repo_if_needed(self): def _init_repo_if_needed(self):
if not self._repo_is_initialized(): if not self._repo_is_initialized():
self._run(('git', 'init')) self._run(('git', 'init'))