Skip to content

Commit

Permalink
shallow-backup crashes if repo can't be created
Browse files Browse the repository at this point in the history
Fixes #308
  • Loading branch information
alichtman committed Oct 9, 2023
1 parent 5f39a30 commit aade620
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions shallow_backup/git_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path
import sys
import git
from git import GitCommandError
from shutil import move
from .printing import *
from .config import get_config
Expand Down Expand Up @@ -71,8 +72,12 @@ def safe_git_init(dir_path) -> (git.Repo, bool):
"""
if not os.path.isdir(os.path.join(dir_path, ".git")):
print_yellow_bold("Initializing new git repo...")
repo = git.Repo.init(dir_path)
return repo, True
try:
repo = git.Repo.init(dir_path)
return repo, True
except GitCommandError:
print_red_bold("ERROR: We ran into some trouble creating the git repo. Double check that you have write permissions.")
sys.exit(1)
else:
print_yellow_bold("Detected git repo.")
repo = git.Repo(dir_path)
Expand Down

0 comments on commit aade620

Please sign in to comment.