From 49e0efa4c903e99e51cc0aead0e95129165d7fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 18 Jul 2018 14:15:19 +0200 Subject: [PATCH] Run git init only if there is no repo present --- lib/tfw/components/snapshot_provider.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/tfw/components/snapshot_provider.py b/lib/tfw/components/snapshot_provider.py index 65517e8..0ce8133 100644 --- a/lib/tfw/components/snapshot_provider.py +++ b/lib/tfw/components/snapshot_provider.py @@ -21,10 +21,14 @@ class SnapshotProvider: self._branch = 'master' self._branches = [self._branch] - self._init_repo() + self._init_repo_if_needed() - def _init_repo(self): - self._run(('git', 'init')) + def _init_repo_if_needed(self): + if not self._repo_is_initialized(): + self._run(('git', 'init')) + + def _repo_is_initialized(self): + return self._run(('git', 'status')).returncode == 0 def take_snapshot(self): if self._head_detached: