summaryrefslogtreecommitdiff
path: root/commit.d/50vcs-commit
blob: 1f4ab03c1e9a16d93891773be75473b1e417ca89 (plain)
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
#!/bin/sh
set -e

message="$1"
hostname=`hostname -f`

if [ "$VCS" = git ] && [ -d .git ]; then
	if [ -n "$SUDO_USER" ]; then
		export GIT_COMMITTER_NAME="$SUDO_USER"
		export GIT_COMMITTER_EMAIL="$SUDO_USER@$hostname"
	fi
	if [ -n "$message" ]; then
		git commit $GIT_COMMIT_OPTIONS -m "$message"
	else
		git commit $GIT_COMMIT_OPTIONS
	fi
elif [ "$VCS" = hg ] && [ -d .hg ]; then
	if [ -n "$SUDO_USER" ]; then
		export LOGNAME="$SUDO_USER"
	fi
	if [ -n "$message" ]; then
		hg commit $HG_COMMIT_OPTIONS -m "$message"
	else
		hg commit $HG_COMMIT_OPTIONS
	fi
elif [ "$VCS" = bzr ] && [ -d .bzr ]; then
	if [ -n "$SUDO_USER" ]; then
		export EMAIL="$SUDO_USER <$SUDO_USER@$hostname>"
	fi
	if [ -n "$message" ]; then
		bzr commit $BZR_COMMIT_OPTIONS -m "$message"
	else
		bzr commit $BZR_COMMIT_OPTIONS
	fi
elif [ "$VCS" = darcs ] && [ -d _darcs ]; then
	logfile="$( mktemp -t etckeeper-$VCS.XXXXXXXXXX )"
	printf "%b" "$message" > "$logfile"
	darcs record $DARCS_COMMIT_OPTIONS --logfile="$logfile"
	rm -f "$logfile"
	unset logfile
fi