mirror of
https://github.com/iwata/git-now.git
synced 2026-09-10 07:26:29 -04:00
56 lines
1.3 KiB
Bash
56 lines
1.3 KiB
Bash
usage() {
|
|
echo "usage: git now add [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]"
|
|
echo " [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]"
|
|
echo " [--refresh] [--ignore-errors] [--ignore-missing] [--stat | -s] [--push]"
|
|
echo " [--] [<filepattern>...]"
|
|
}
|
|
|
|
cmd_default() {
|
|
MESSAGE="[${PREFIX}] `date +\"%Y/%m/%d %T\"`"
|
|
if [ $# -eq 0 ]; then
|
|
git add -u
|
|
printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F -
|
|
else
|
|
local is_all=false
|
|
local is_stat=false
|
|
local is_push=false
|
|
local args=()
|
|
|
|
# args loop
|
|
for arg in "$@"
|
|
do
|
|
if [ $arg = "--stat" ] || [ $arg = "-s" ]; then
|
|
is_stat=true
|
|
elif [ $arg = "--all" ]; then
|
|
is_all=true
|
|
elif [ $arg = "--push" ]; then
|
|
is_push=true
|
|
else
|
|
n=${#args[@]}
|
|
args[$n]=$arg
|
|
fi
|
|
done
|
|
|
|
if ! $is_all; then
|
|
git add ${args[@]}
|
|
else
|
|
git add -u
|
|
git add .
|
|
fi
|
|
|
|
if $is_stat; then
|
|
printf "${MESSAGE}\n\n%s" "`git diff --cached --stat`" | git commit -F -
|
|
else
|
|
printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F -
|
|
fi
|
|
$is_push && git push
|
|
fi
|
|
}
|
|
|
|
cmd_help() {
|
|
usage
|
|
exit 0
|
|
}
|
|
|
|
# vim: set ff=unix ft=sh :
|