File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 33import pathlib
44import os
55import random
6+ import sys
67
78from git_dummy .settings import settings
89
@@ -51,6 +52,24 @@ def main(
5152 if not settings .no_subdir :
5253 settings .git_dir = os .path .join (settings .git_dir , settings .name )
5354
55+ try :
56+ git .Repo (settings .git_dir , search_parent_directories = True )
57+ print (
58+ f"git-dummy error: Git repository already exists at { settings .git_dir } or parent"
59+ )
60+ sys .exit (1 )
61+ except (git .exc .InvalidGitRepositoryError , git .exc .NoSuchPathError ):
62+ try :
63+ git .Repo (pathlib .Path ().cwd (), search_parent_directories = True )
64+ print (
65+ f"git-dummy error: Git repository already exists at { settings .git_dir } or parent"
66+ )
67+ sys .exit (1 )
68+ except git .exc .InvalidGitRepositoryError :
69+ print (
70+ f"git-dummy: Generating dummy Git repo at { settings .git_dir } with { settings .branches } branch(es) and { settings .commits } commit(s)."
71+ )
72+
5473 repo = git .Repo .init (settings .git_dir )
5574 repo .config_writer ().set_value ("init" , "defaultBranch" , "main" ).release ()
5675
You can’t perform that action at this time.
0 commit comments