Skip to content

Commit aade620

Browse files
committed
shallow-backup crashes if repo can't be created
Fixes #308
1 parent 5f39a30 commit aade620

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

shallow_backup/git_wrapper.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33
import sys
44
import git
5+
from git import GitCommandError
56
from shutil import move
67
from .printing import *
78
from .config import get_config
@@ -71,8 +72,12 @@ def safe_git_init(dir_path) -> (git.Repo, bool):
7172
"""
7273
if not os.path.isdir(os.path.join(dir_path, ".git")):
7374
print_yellow_bold("Initializing new git repo...")
74-
repo = git.Repo.init(dir_path)
75-
return repo, True
75+
try:
76+
repo = git.Repo.init(dir_path)
77+
return repo, True
78+
except GitCommandError:
79+
print_red_bold("ERROR: We ran into some trouble creating the git repo. Double check that you have write permissions.")
80+
sys.exit(1)
7681
else:
7782
print_yellow_bold("Detected git repo.")
7883
repo = git.Repo(dir_path)

0 commit comments

Comments
 (0)