Skip to content

Commit 6592bd8

Browse files
committed
Fix detection of bare git directories
1 parent e9e3b18 commit 6592bd8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bin/github-backup

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,16 @@ def fetch_repository(name,
714714
local_dir,
715715
skip_existing=False,
716716
bare_clone=False):
717-
clone_exists = os.path.exists(os.path.join(local_dir, '.git'))
717+
if bare_clone:
718+
if os.path.exists(local_dir):
719+
clone_exists = subprocess.check_output(['git',
720+
'rev-parse',
721+
'--is-bare-repository'],
722+
cwd=local_dir) == "true\n"
723+
else:
724+
clone_exists = False
725+
else:
726+
clone_exists = os.path.exists(os.path.join(local_dir, '.git'))
718727

719728
if clone_exists and skip_existing:
720729
return
@@ -744,7 +753,7 @@ def fetch_repository(name,
744753
masked_remote_url,
745754
local_dir))
746755
if bare_clone:
747-
git_command = ['git', 'clone', '--bare', remote_url, local_dir]
756+
git_command = ['git', 'clone', '--mirror', remote_url, local_dir]
748757
else:
749758
git_command = ['git', 'clone', remote_url, local_dir]
750759
logging_subprocess(git_command, None)

0 commit comments

Comments
 (0)