From d9d6599532f61b631add2e61c757ba4f1863822b Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Tue, 25 Aug 2009 23:18:48 +0200 Subject: scripts/gamerlay-review: Clean-up and finish the script (still experimental !) --- scripts/gamerlay-review | 159 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 141 insertions(+), 18 deletions(-) (limited to 'scripts') diff --git a/scripts/gamerlay-review b/scripts/gamerlay-review index 106bbce..3dc906a 100755 --- a/scripts/gamerlay-review +++ b/scripts/gamerlay-review @@ -1,35 +1,158 @@ -#!/bin/sh +#!/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. -. /etc/init.d/functions.sh +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}/gamerlay-patchset.patch -review_msg="Reviewed up $(date "+%Y/%m/%d %H:%M")" -have_binaries="" -exclude_list="" +patchset=${tmpdir}/$(basename ${0})-patchset.patch +changes="" +opt_norepoman=0 +opt_quiet=0 +opt_verbose=0 + +fatal() { + eerror "!!! Error: $*" +} die() { - eerror $1 + fatal $* exit 1 } +eend_or_die() { + eend $1 || exit $? +} + +usage() { +cat < ${patchset} \ - || die "Diff between devel and stable branches failed" + 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 $? -git checkout master || die "Switch to stable branch failed" -# Why --exclude=Documentation/ or --exclude=scripts/ doesn't work ? -# WTF ? -git apply --whitespace=nowarn ${exclude_list} ${patchset} \ - || die "Unable to apply patchset" -#FIXME: Use --exclude option, when an alternative would be found rm -rf Documentation/ scripts/ -repoman commit -m ${review_msg} -einfo "${review_msg}...commited" +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} -- cgit v1.2.3-18-g5258