-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommit-tree
executable file
·51 lines (45 loc) · 1.03 KB
/
commit-tree
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
#!/bin/sh -eu
SHIT_PATH=$(dirname "$0")
. $SHIT_PATH/common.sh
tree="$1"
shift
parents=
while getopts p: opt
do
case $opt in
p)
parents="$(printf "%s" "$OPTARG" | tr -s , ' ')"
;;
?)
printf "Usage: %s [-p <parents...>]\n" "$0" >&2
exit 1
;;
esac
done
# TODO: Read from git config
if [ -z "$GIT_AUTHOR_NAME" ]
then
printf "GIT_AUTHOR_NAME unset\n"
exit 1
fi
if [ -z "$GIT_AUTHOR_EMAIL" ]
then
printf "GIT_AUTHOR_EMAIL unset\n"
exit 1
fi
GIT_COMMITTER_NAME=${GIT_COMMITTER_NAME:-$GIT_AUTHOR_NAME}
GIT_COMMITTER_EMAIL=${GIT_COMMITTER_EMAIL:-$GIT_AUTHOR_EMAIL}
GIT_AUTHOR_DATE=${GIT_AUTHOR_DATE:-$(date -u +'%s +0000')}
GIT_COMMITTER_DATE=${GIT_COMMITTER_DATE:-$(date -u +'%s +0000')}
printf "tree %s\n" "$tree"
for parent in $parents
do
printf "parent %s\n" "$parent"
done
printf "author %s <%s> %s\n" \
"$GIT_AUTHOR_NAME" "$GIT_AUTHOR_EMAIL" "$GIT_AUTHOR_DATE"
printf "committer %s <%s> %s\n" \
"$GIT_COMMITTER_NAME" "$GIT_COMMITTER_EMAIL" "$GIT_COMMITTER_DATE"
printf "\n"
printf 'Enter your comment message:\n' >&2
cat