PageRenderTime 65ms CodeModel.GetById 59ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/etckeeper/commit.d/50vcs-commit

http://github.com/brinkman83/bashrc
Shell | 41 lines | 38 code | 2 blank | 1 comment | 12 complexity | 6ba810edda5f28ec8ba5d8eaa478aed5 MD5 | raw file
 1#!/bin/sh
 2set -e
 3
 4message="$1"
 5hostname=`hostname -f 2>/dev/null || hostname`
 6
 7if [ "$VCS" = git ] && [ -d .git ]; then
 8	if [ -n "$SUDO_USER" ]; then
 9		export GIT_COMMITTER_NAME="$SUDO_USER"
10		export GIT_COMMITTER_EMAIL="$SUDO_USER@$hostname"
11	fi
12	if [ -n "$message" ]; then
13		git commit $GIT_COMMIT_OPTIONS -m "$message"
14	else
15		git commit $GIT_COMMIT_OPTIONS
16	fi
17elif [ "$VCS" = hg ] && [ -d .hg ]; then
18	if [ -n "$SUDO_USER" ]; then
19		export LOGNAME="$SUDO_USER"
20	fi
21	if [ -n "$message" ]; then
22		hg commit $HG_COMMIT_OPTIONS -m "$message"
23	else
24		hg commit $HG_COMMIT_OPTIONS
25	fi
26elif [ "$VCS" = bzr ] && [ -d .bzr ]; then
27	if [ -n "$SUDO_USER" ]; then
28		export EMAIL="$SUDO_USER <$SUDO_USER@$hostname>"
29	fi
30	if [ -n "$message" ]; then
31		bzr commit $BZR_COMMIT_OPTIONS -m "$message"
32	else
33		bzr commit $BZR_COMMIT_OPTIONS
34	fi
35elif [ "$VCS" = darcs ] && [ -d _darcs ]; then
36	logfile="$( mktemp -t etckeeper-$VCS.XXXXXXXXXX )"
37	printf "%b" "$message" > "$logfile"
38	darcs record $DARCS_COMMIT_OPTIONS --logfile="$logfile"
39	rm -f "$logfile"
40	unset logfile
41fi