Skip to content

Commit

Permalink
remove git absolute git dir (only worked in git 2.13 or later)
Browse files Browse the repository at this point in the history
  • Loading branch information
asampat3090 committed Apr 12, 2018
1 parent fb8e4cb commit 9ece01f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
26 changes: 5 additions & 21 deletions datmo/controller/code/driver/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,11 @@ def __init__(self, filepath, execpath, remote_url=None):

@property
def is_initialized(self):
if os.path.isdir(os.path.join(self.filepath, ".git")):
try:
git_dir = self.get_absolute_git_dir()
except:
git_dir = ""
if os.path.join(self.filepath, ".git") in git_dir:
if self.exists_code_refs_dir():
if self.check_gitignore_exists():
self._is_initialized = True
return self._is_initialized
if os.path.isdir(os.path.join(self.filepath, ".git")) and \
self.exists_code_refs_dir() and \
self.check_gitignore_exists():
self._is_initialized = True
return self._is_initialized
self._is_initialized = False
return self._is_initialized

Expand Down Expand Up @@ -316,17 +311,6 @@ def reset(self, git_commit):
str(e)))
return True

def get_absolute_git_dir(self):
try:
git_dir = subprocess.check_output([self.execpath,"rev-parse", "--absolute-git-dir"],
cwd=self.filepath)
git_dir = git_dir.decode().strip()
except Exception as e:
raise GitExecutionException(_("error",
"controller.code.driver.git.get_absolute_git_dir",
str(e)))
return git_dir

def check_git_work_tree(self):
try:
git_work_tree_exists = subprocess.check_output([self.execpath,"rev-parse", "--is-inside-work-tree"],
Expand Down
6 changes: 0 additions & 6 deletions datmo/controller/code/driver/test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,6 @@ def test_reset(self):
result = self.git_code_manager.reset(git_commit=commit_id)
assert result == True

def test_get_absolute_git_dir(self):
self.git_code_manager.init()
result = self.git_code_manager.get_absolute_git_dir()
assert os.path.join(self.git_code_manager.filepath,
".git") in result

def test_check_git_work_tree(self):
self.git_code_manager.init()
result = self.git_code_manager.check_git_work_tree()
Expand Down

0 comments on commit 9ece01f

Please sign in to comment.