tj.git-extras/bin/git-setup
Edwin Kofler 3ddc315a76
Format comparisons, functions, and redirections to be consistent (#1201)
* Format comparisons and functions to be consistent

* Add `checkstyle.py` script and add check to CI

* Fix Ruff lints
2025-06-06 11:10:50 +08:00

24 lines
429 B
Bash
Executable file

#!/usr/bin/env bash
COMMIT_MESSAGE='Initial commit'
if [ "$1" = "-m" ]; then
COMMIT_MESSAGE=$2
shift; shift
fi
gitdirexists(){
if [ -d ".git" ]; then
echo ".git directory already exists, aborting"
exit 1
fi
}
dir=$(test -z "$*" && echo "." || echo "$*")
mkdir -p "$dir" \
&& cd "$dir" \
&& gitdirexists \
&& git init \
&& git add . \
&& git commit --allow-empty -m "$COMMIT_MESSAGE"