blob: 3dc906a3b3618c7c671dfc7ce50b54cb44450ed5 (
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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
#!/bin/bash
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# gamerlay-review - Automates the Gentoo GamerLay Overlay commit process
# Released into the public domain.
source /etc/init.d/functions.sh
BLUE=$BRACKET
BOLD=$'\e[0;01m'
DARKGREEN=$'\e[32m'
GREEN=$GOOD
LIGHTBLUE=$HILITE
RED=$BAD
YELLOW=$WARN
tmpdir="/tmp/$(basename ${0}).$$"
patchset=${tmpdir}/$(basename ${0})-patchset.patch
changes=""
opt_norepoman=0
opt_quiet=0
opt_verbose=0
fatal() {
eerror "!!! Error: $*"
}
die() {
fatal $*
exit 1
}
eend_or_die() {
eend $1 || exit $?
}
usage() {
cat <<EOF
${BOLD}Usage:${NORMAL} ${LIGHTBLUE}gamerlay-review${NORMAL} [ ${GREEN}options${NORMAL} ] ${BLUE}message${NORMAL}
${GREEN}options${NORMAL}:
${BOLD}--help, -h${NORMAL} Show help
${BOLD}--norepoman, -p${NORMAL} Skip repoman check
${BOLD}--quiet, -q${NORMAL} Don't ask for confirmation
${BOLD}--verbose, -v${NORMAL} Show detailed information during commit
${BLUE}message${NORMAL}:
Commit message describing changes.
EOF
exit ${1:-0}
}
git_command() {
local errlog=${tmpdir}/error.log
local git_command_stdout=""
local retval=""
if [ $opt_verbose == 1 ]; then
einfo "${FUNCNAME[0]}: $*"
fi
if [ "$1" = "-o" ]; then
shift; git_command_stdout=$1; shift
git $* 2>${errlog} >$git_command_stdout || retval=$?
else
git $* 2>${errlog} >/dev/null || retval=$?
fi
if [ -n "$retval" ]; then
fatal "${FUNCNAME[0]}: $* failed"
return $retval
fi
}
git_checkout() {
git_command checkout ${1}
}
while [ $# > 0 ]; do
case "${1}" in
--help|-h)
usage ;;
--norepoman|-p)
opt_norepoman=1
shift ;;
--quiet|-q)
opt_quiet=1
shift ;;
--verbose|-v)
opt_verbose=1
shift ;;
-*)
usage 1 ;;
*)
break ;;
esac
done
if [ -z "$*" ]; then
die "You must give a commit message, see gamerlay-review -h for more details"
fi
if [ $opt_norepoman = 0 ]; then
ebegin "Running repoman"
repoman full || fatal "Please fix repoman QA errors before continue"
eend_or_die $?
fi
mkdir -p ${tmpdir}
ebegin "Computing differences between the two working branches"
changes=$(git diff --summary master)
git_command -o ${patchset} diff --patch-with-stat --full-index master
eend_or_die $?
git_checkout master || exit $?
ebegin "Synchronizing devel and stable branches"
git_command apply --whitespace=nowarn ${patchset}
eend_or_die $?
rm -rf Documentation/ scripts/
ebegin "Adding local changes to the working stable branch"
git_command add "*" || set $?
[ $1 = 0 ] && git_command commit -a -m "$*"
eend_or_die $?
echo
echo "${DARKGREEN}The following local changes will be pushed to the stable branch on the repository:${NORMAL}"
echo
echo ${changes}
if [ $opt_quiet = 0 ]; then
echo
echo -n "${BOLD}Commit changes?${NORMAL} [${GREEN}Yes${NORMAL}/${RED}No${NORMAL}] "
read choice
echo
case "$choice" in
y*|Y*|"")
;;
*)
echo "Quitting."
echo
exit 1 ;;
esac
fi
git_checkout devel || exit $?
ebegin "Adding a tag to the working devel branch"
git_command tag -a Reviewed_up_$(data +%Y_%m_%d) -m "Reviewed up $(data +%Y/%m/%d)" || set $?
[ $1 = 0 ] && git_command push
eend_or_die $?
ebegin "Pushing working copy of the stable branch to the repository"
git_command push
eend $?
rm -rf ${tmpdir}
|