-
Notifications
You must be signed in to change notification settings - Fork 1
/
cdd-shared
42 lines (36 loc) · 949 Bytes
/
cdd-shared
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
#!/usr/bin/env sh
export CDD_COMMIT_MSG
CDD_COMMIT_MSG=$(git rev-parse --show-toplevel)/CDD_COMMIT_MSG
get_editor() {
editor=$(git config core.editor)
if [ -z "$editor" ]; then
editor=$GIT_EDITOR
if [ -z "$editor" ]; then
# shellcheck disable=2153
editor=${EDITOR:-vi}
if [ -z "$editor" ]; then
editor=/usr/bin/editor
if [ -z "$editor" ]; then
echo "Could not find an editor."
echo "Please specify an editor for git, e.g."
echo "git config --global core.editor /usr/bin/editor"
exit 1
fi
fi
fi
fi
}
check_msg() {
if [ ! -f "$CDD_COMMIT_MSG" ]; then
echo "$CDD_COMMIT_MSG is not a regular file."
exit 1
fi
if [ ! -w "$CDD_COMMIT_MSG" ]; then
echo "$CDD_COMMIT_MSG exists but is not writable."
exit 1
fi
if [ ! -r "$CDD_COMMIT_MSG" ]; then
echo "$CDD_COMMIT_MSG exists but is not readable."
exit 1
fi
}