File: commit

package info (click to toggle)
grhino 0.16.0-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,612 kB
  • ctags: 1,290
  • sloc: cpp: 10,608; sh: 3,120; xml: 1,099; makefile: 440; perl: 337; sed: 27
file content (128 lines) | stat: -rwxr-xr-x 2,956 bytes parent folder | download | duplicates (2)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh
# commit
# Copyright (c) 2000, 2002 Kriang Lerdsuwanakij
# email:	lerdsuwa@users.sourceforge.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#
# Set temporary filenames
#

PACKAGE=grhino
DIFF_FILE="/tmp/$PACKAGE-cvs-diff-$USER"
LOG_FILE="/tmp/$PACKAGE-cvs-log-$USER"
CHLOG_FILE="/tmp/$PACKAGE-cvs-chlog-$USER"
RPCP_IN_FILE="/tmp/$PACKAGE-rpcp-in-$USER"
RPCP_OUT_FILE="/tmp/$PACKAGE-rpcp-out-$USER"

#
# Sanitiy check, abort if fail
#

# Must run this script from package root directory
scripts/dircheck || exit 0

# Clean up previous results, if any
rm -f $DIFF_FILE || exit 0
rm -f $LOG_FILE || exit 0
rm -f $CHLOG_FILE || exit 0
rm -f $RPCP_IN_FILE || exit 0
rm -f $RPCP_OUT_FILE || exit 0

#
# Get diff file
#

cvs diff -cp "$@" &> $DIFF_FILE
if grep "^cvs diff: I know nothing about" $DIFF_FILE; then

	# Errors are already shown during grep, exit
	rm -f $DIFF_FILE
	exit 0

elif grep '^diff -c -p' $DIFF_FILE; then

	# Changes detected
	true
elif grep 'no comparison available' $DIFF_FILE; then

	# Files added or deleted
	true
else

	# Report errors or no changes then exit
	cat $DIFF_FILE
	rm -f $DIFF_FILE
	exit 0
fi

#
# Prepare ChangeLog template
#

# Create date stamp
date +"%Y-%m-%d" | tr -d \\n\\r > $LOG_FILE

# Get user name and email from scripts/commit-template using $USER
echo "  $USER" > $RPCP_IN_FILE
echo "" >> $RPCP_IN_FILE
echo "" >> $RPCP_IN_FILE
echo "" >> $RPCP_IN_FILE
scripts/rpcp scripts/commit-template $RPCP_IN_FILE $RPCP_OUT_FILE
cat $RPCP_OUT_FILE >> $LOG_FILE

#
# Edit ChangeLog
#

$EDITOR $LOG_FILE $DIFF_FILE

#
# Commit
#

if grep ':' $LOG_FILE; then
		# Use $* here so that it is expanded to only one argument
	if test -z "$*"; then

		# No arguments present in the command line, commit all file
		cp ChangeLog $CHLOG_FILE \
		 && cat $LOG_FILE $CHLOG_FILE > ChangeLog \
		 && cvs commit -F $LOG_FILE "$@"
	else

		# Commit only ChangeLog and files given in the command line
		cp ChangeLog $CHLOG_FILE \
		 && cat $LOG_FILE $CHLOG_FILE > ChangeLog \
		 && cvs commit -F $LOG_FILE ChangeLog "$@"
	fi

	# Cleanup
	rm -f $DIFF_FILE $LOG_FILE $CHLOG_FILE
	rm -f $RPCP_IN_FILE $RPCP_OUT_FILE
	rm -f $DIFF_FILE~ $LOG_FILE~

	exit 0
else

	# Cleanup
	rm -f $DIFF_FILE $LOG_FILE $CHLOG_FILE
	rm -f $RPCP_IN_FILE $RPCP_OUT_FILE
	rm -f $DIFF_FILE~ $LOG_FILE~

	exit 1
fi