Skip to content

Commit ae428e2

Browse files
committed
check if the deploy directory is empty or not
An empty deploy directory would generate unexpected results: * It may wipe out gh-pages branch, usually we don't expect that. * In a newly cloned repo, if the folder does not exist, script would get error like: fatal: This operation must be run in a work tree The error is from line "git --work-tree "$deploy_directory" reset --mixed --quiet" * If remote branch does not exist, 'deploy.sh -s' would also get wrong result. To improve it, check if the directory is not empty in the beginning.
1 parent 055c589 commit ae428e2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

deploy.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ while : ; do
2424
fi
2525
done
2626

27+
if ! find "$deploy_directory" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then
28+
echo "Deploy dir '$deploy_directory' is empty, please make sure it has content." >&2
29+
exit 1
30+
fi
31+
2732
#echo expanded commands as they are executed (for debugging)
2833
function enable_expanded_output {
2934
if [ $verbose ]; then

0 commit comments

Comments
 (0)