File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 2
2
from pathlib import Path
3
3
import sys
4
4
import git
5
+ from git import GitCommandError
5
6
from shutil import move
6
7
from .printing import *
7
8
from .config import get_config
@@ -71,8 +72,12 @@ def safe_git_init(dir_path) -> (git.Repo, bool):
71
72
"""
72
73
if not os .path .isdir (os .path .join (dir_path , ".git" )):
73
74
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 )
76
81
else :
77
82
print_yellow_bold ("Detected git repo." )
78
83
repo = git .Repo (dir_path )
You can’t perform that action at this time.
0 commit comments