Debian Codegraph @

commit.d/50vcs-commit

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 set -e
3
4 cleanupscip-shell shell etckeeper 1.18.23-2 cleanup(). () {
5 if [scip-shell system . . `[`. -n "$logfile" ]; then
6 rmscip-shell system . . rm. -f "$logfile"
7 fi
8 }
9 if [scip-shell system . . `[`. -n "$1" ]; then
10 if command -v mktemp >/dev/nullscip-shell filesystem . . `/dev/null`.; then
11 tempfile="mktemp -t etckeeper-$VCS.XXXXXXXXXX"
12 elif command -v tempfile >/dev/nullscip-shell filesystem . . `/dev/null`.; then
13 tempfile="tempfile"
14 else
15 echoscip-shell system . . echo. "etckeeper warning: can't find tempfile or mktemp" >&2
16 exit 1
17 fi
18
19 trap cleanup EXIT
20 logfile="$($tempfile)"
21 if [scip-shell system . . `[`. "x$1" = "x--stdin" ]; then
22 catscip-shell system . . cat. > "$logfile"
23 else
24 sedscip-shell system . . sed. '1s/^-m \{0,1\}//' >"$logfile" <<-EOF
25 $*
26 EOF
27 fi
28 else
29 logfile=""
30 fi
31
32 hostname=`hostnamescip-shell system . . hostname. 2>/dev/nullscip-shell filesystem . . `/dev/null`. || catscip-shell system . . cat. /etc/hostnamescip-shell filesystem . . `/etc/hostname`.`
33 hostname="${hostname%%.*}"
34 dnsdomainname=`dnsdomainnamescip-shell system . . dnsdomainname. 2>/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.`
35 if [scip-shell system . . `[`. -n "$dnsdomainname" ]; then
36 hostname="$hostname.$dnsdomainname"
37 fi
38
39 ORIG_USER=$USER
40 USER=
41 if [scip-shell system . . `[`. -n "$SUDO_USER" ]; then
42 USER="$SUDO_USER"
43 else
44 # try to check tty ownership, in case user su'd to root
45 TTY="$(ttyscip-shell system . . tty. 2>/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.)"
46 if [scip-shell system . . `[`. -n "$TTY" ] && [scip-shell system . . `[`. -c "$TTY" ]; then
47 USER="$(findscip-shell system . . find. "$TTY" -printf "%u")"
48 fi
49 fi
50
51 if [scip-shell system . . `[`. "$VCS" = git ] && [scip-shell system . . `[`. -d .git ]; then
52 # When not su'd to root, still set environment variables,
53 # since git's own code to determine the author and committer
54 # has several edge cases where it fails and would prevent the
55 # commit.
56 if [scip-shell system . . `[`. -z "$USER" ]; then
57 USER="$(whoamiscip-shell system . . whoami.)"
58 fi
59 if [scip-shell system . . `[`. -n "$USER" ]; then
60 # Use user.name and user.email from the gitconfig belonging
61 # to USER.
62 USER_HOME="$(getentscip-shell system . . getent. passwd "$USER" | cutscip-shell system . . cut. -d: -f6)"
63 if [scip-shell system . . `[`. -n "$USER_HOME" ] && [scip-shell system . . `[`. -e "$USER_HOME/.gitconfig" ]; then
64 if [scip-shell system . . `[`. -z "$GIT_AUTHOR_NAME" ]; then
65 GIT_AUTHOR_NAME="$(gitscip-shell system . . git. config -f "$USER_HOME/.gitconfig" user.name)" || truescip-shell system . . true.
66 export GIT_AUTHOR_NAME
67 fi
68 if [scip-shell system . . `[`. -z "$GIT_AUTHOR_EMAIL" ]; then
69 GIT_AUTHOR_EMAIL="$(gitscip-shell system . . git. config -f "$USER_HOME/.gitconfig" user.email)" || truescip-shell system . . true.
70 export GIT_AUTHOR_EMAIL
71 fi
72 fi
73 if [scip-shell system . . `[`. -z "$GIT_AUTHOR_NAME" ] || [scip-shell system . . `[`. -z "$GIT_AUTHOR_EMAIL" ]; then
74 if [scip-shell system . . `[`. -n "$USER_HOME" ] && [scip-shell system . . `[`. -e "$USER_HOME/.config/git/config" ]; then
75 if [scip-shell system . . `[`. -z "$GIT_AUTHOR_NAME" ]; then
76 GIT_AUTHOR_NAME="$(gitscip-shell system . . git. config -f "$USER_HOME/.config/git/config" user.name)" || truescip-shell system . . true.
77 export GIT_AUTHOR_NAME
78 fi
79 if [scip-shell system . . `[`. -z "$GIT_AUTHOR_EMAIL" ]; then
80 GIT_AUTHOR_EMAIL="$(gitscip-shell system . . git. config -f "$USER_HOME/.config/git/config" user.email)" || truescip-shell system . . true.
81 export GIT_AUTHOR_EMAIL
82 fi
83 fi
84 fi
85
86 if [scip-shell system . . `[`. -z "$GIT_COMMITTER_EMAIL" ]; then
87 GIT_COMMITTER_EMAIL="$(gitscip-shell system . . git. config --global user.email)" || truescip-shell system . . true.
88 export GIT_COMMITTER_EMAIL
89 fi
90 if [scip-shell system . . `[`. -z "$GIT_AUTHOR_NAME" ]; then
91 GIT_AUTHOR_NAME="$USER"
92 export GIT_AUTHOR_NAME
93 fi
94 if [scip-shell system . . `[`. -z "$GIT_AUTHOR_EMAIL" ]; then
95 GIT_AUTHOR_EMAIL="$USER@$hostname"
96 export GIT_AUTHOR_EMAIL
97 fi
98 if [scip-shell system . . `[`. -z "$GIT_COMMITTER_EMAIL" ]; then
99 GIT_COMMITTER_EMAIL=`whoamiscip-shell system . . whoami.`"@$hostname"
100 export GIT_COMMITTER_EMAIL
101 fi
102 fi
103
104 # gc ten times more frequently than the default
105 # (unless some other config is set)
106 GIT_GC_OPTIONS=
107 if ! gitscip-shell system . . git. config gc.auto >/dev/nullscip-shell filesystem . . `/dev/null`.; then
108 GIT_GC_OPTIONS="-c gc.auto=670"
109 fi
110
111 if [scip-shell system . . `[`. -n "$logfile" ]; then
112 gitscip-shell system . . git. $GIT_GC_OPTIONS commit $GIT_COMMIT_OPTIONS -F "$logfile"
113 else
114 gitscip-shell system . . git. $GIT_GC_OPTIONS commit $GIT_COMMIT_OPTIONS
115 fi
116 elif [scip-shell system . . `[`. "$VCS" = hg ] && [scip-shell system . . `[`. -d .hg ]; then
117 if [scip-shell system . . `[`. -n "$USER" ]; then
118 LOGNAME="$USER"
119 export LOGNAME
120 fi
121 if [scip-shell system . . `[`. -z "$HGUSER" ]; then
122 HGUSER="$USER@$hostname"
123 export HGUSER
124 fi
125 if [scip-shell system . . `[`. -n "$logfile" ]; then
126 hg commit $HG_COMMIT_OPTIONS -l "$logfile"
127 else
128 hg commit $HG_COMMIT_OPTIONS
129 fi
130 elif [scip-shell system . . `[`. "$VCS" = bzr ] && [scip-shell system . . `[`. -d .bzr ]; then
131 if [scip-shell system . . `[`. -z "$EMAIL" ] && [scip-shell system . . `[`. -n "$USER" ]; then
132 EMAIL="$USER <$USER@$hostname>"
133 export EMAIL
134 else
135 bzrscip-shell system . . bzr. whoami >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || export EMAIL="$ORIG_USER <$ORIG_USER@$hostname>"
136 fi
137 if [scip-shell system . . `[`. -n "$logfile" ]; then
138 bzrscip-shell system . . bzr. commit $BZR_COMMIT_OPTIONS -F "$logfile"
139 else
140 bzrscip-shell system . . bzr. commit --quiet $BZR_COMMIT_OPTIONS
141 fi
142 elif [scip-shell system . . `[`. "$VCS" = darcs ] && [scip-shell system . . `[`. -d _darcs ]; then
143 if [scip-shell system . . `[`. -z "$USER" ]; then
144 USER=root
145 fi
146 if [scip-shell system . . `[`. -n "$logfile" ]; then
147 darcs record --author="$USER" $DARCS_COMMIT_OPTIONS --logfile="$logfile"
148 else
149 darcs record --author="$USER" $DARCS_COMMIT_OPTIONS
150 fi
151 fi