Skip to content

Commit

Permalink
Don't clone if directory exists and is not empty #69
Browse files Browse the repository at this point in the history
  • Loading branch information
jfaltermeier committed Nov 23, 2023
1 parent 819a61a commit 17e75b6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/git-init/git-init.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def getHostname(repository):
parser.add_argument("checkout", help="The branch/commit id/tag to checkout", type=str)
args = parser.parse_args()

# Check if directory is empty, don't clone if it isn't
if os.path.isdir(args.directory):
if len(os.listdir(args.directory)) > 0:
sys.stdout.write("Clone directory is not empty. Continue without cloning." + NL)
exit(0)

# Set up git credential helper
code = runProcess(["git", "config", "--global", "credential.helper", "store"])
if code != 0:
Expand Down

0 comments on commit 17e75b6

Please sign in to comment.