-
Notifications
You must be signed in to change notification settings - Fork 4
/
ciall
executable file
·141 lines (126 loc) · 3.24 KB
/
ciall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh
#==============================================================================
# ciall
# File ID: dd770008-300f-11df-b5fc-90e6ba3022ac
#
# Commit all files in current directory tree to Git.
#
# Author: Øyvind A. Holm <sunny@sunbase.org>
# License: GNU General Public License version 2 or later.
#==============================================================================
progname=ciall
VERSION=0.4.0
opt_store_empty_dirs=0
opt_edit=0
opt_help=0
opt_quiet=0
opt_verbose=0
opt_yes=0
while test -n "$1"; do
case "$1" in
-d|--store-empty-dirs) opt_store_empty_dirs=1; shift ;;
-e|--edit) opt_edit=1; shift ;;
-h|--help) opt_help=1; shift ;;
-q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
-v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
-y|--yes) opt_yes=1; shift ;;
--version) echo $progname $VERSION; exit 0 ;;
--) shift; break ;;
*)
if printf '%s\n' "$1" | grep -q ^-; then
echo "$progname: $1: Unknown option" >&2
exit 1
else
break
fi
break ;;
esac
done
opt_verbose=$(($opt_verbose - $opt_quiet))
if test "$opt_help" = "1"; then
test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
cat <<END
Commit all files in current directory tree to Git.
Usage: $progname [options]
Options:
-e, --edit
Edit the log message in your favourite editor, using the value of
the EDITOR environment variable.
-d, --store-empty-dirs
Also store empty directories in ".emptydirs".
-h, --help
Show this help.
-q, --quiet
Be more quiet. Can be repeated to increase silence.
-v, --verbose
Increase level of verbosity. Can be repeated.
-y, --yes
Answer "yes" to commit prompt, commit automatically.
--version
Print version information.
END
exit 0
fi
unset opt_str
test "$opt_store_empty_dirs" = "1" && {
opt_str=-d
test "$(git config --get ciall.noemptydirs)" = "true" && {
echo $progname: -d option not allowed here >&2
exit 1
}
echo -n $progname: Executing git-store-dirs... >&2
git store-dirs || {
echo git-store-dirs error >&2;
exit 1;
}
echo DONE >&2
}
besafe=n
test "$opt_yes" = "1" && { besafe=y; opt_str=-y; }
echo $progname: git status 1... >&2
LC_ALL=C git status . | grep "^nothing to commit" && {
echo $progname: Nothing to do here.
exit 0
}
unset logmsg
test ! -z "$1" && logmsg="$*"
echo $progname: git status 2... >&2
git status .
echo
echo "Log message: $opt_str '$logmsg'"
until test "$besafe" = "y"; do
echo -n "Press 'y' + Enter to commit all new changes " >&2
echo -n or \'n\' to abort... >&2
read besafe
test "$besafe" = "n" && exit 0;
done
if test "$opt_edit" = "1"; then
if test -z "$EDITOR"; then
echo -n "$progname: The EDITOR environment variable " >&2
echo is not defined >&2
exit 1
fi
tmpmsgfile=/tmp/$(date +%s)-$$.tmp
$EDITOR $tmpmsgfile
logmsg=$(cat $tmpmsgfile)
test -z "$logmsg" && {
echo $progname: No text entered in editor, aborting. >&2
exit 1
}
fi
echo $progname: git status 3... >&2
LC_ALL=C git status . | grep "^nothing to commit" || (
echo $progname: git add --all .
git add --all . && (
echo $progname: git commit >&2
git commit -m "$logmsg$(
echo
echo
suuid -t $progname -c "$logmsg" -wa
)"
)
)
echo ========== git status ==========
git status
exit 0
# vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :