summaryrefslogtreecommitdiff
path: root/backflip
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@linaro.org>2015-06-16 19:23:36 +0200
committerYvan Roux <yvan.roux@linaro.org>2015-06-21 18:27:42 +0200
commit585908e46594b4b2c09cb23ef0ddf36ebdb0b92f (patch)
tree37108b4a43a4597ffb15a4733fc5cff03d6c5dc0 /backflip
parenta2dd1364422e884372faa1bca048c22f4485eb02 (diff)
Add option -x to execute backflip in batch mode.
With this option backflip completes the backport if the cherry-picking of the revision succeeds (i.e creates the branch, commits, requests review). Every step performed is logged into a file named backport-$REV.log, and if the backport failed the suffix .ko is added to this file name. Change-Id: I8b1dfa14de34ae71b96ae37d8c04d697f093d368
Diffstat (limited to 'backflip')
-rwxr-xr-xbackflip118
1 files changed, 77 insertions, 41 deletions
diff --git a/backflip b/backflip
index 9b57d83..5697742 100755
--- a/backflip
+++ b/backflip
@@ -19,9 +19,11 @@ EMAIL=`git config user.email`
EDITOR="${EDITOR:-vim}"
STACKED=false
CMPTOOL="meld"
+INTERACTIVE=true
+COLOR=true
# Arguments
-while getopts "b:r:v:" options
+while getopts "b:r:v:x" options
do
case $options in
r ) REF_BRANCH=$OPTARG
@@ -32,23 +34,29 @@ do
v ) VERSION=$OPTARG
REF_BRANCH=linaro-local/gcc-${VERSION}-integration-branch
;;
+ x ) INTERACTIVE=false
+ COLOR=false
+ ;;
esac
done
shift $(($OPTIND - 1))
REV=$1
commitfile=./backport-${REV}.msg
+logfile=./backport-${REV}.log
if [ -z ${DEV_BRANCH+x} ]; then
DEV_BRANCH=${REF_BRANCH}
fi
# Style
-NC='\e[0m'
-red='\e[0;31m'
-blue='\e[1;34m'
-green='\e[0;32m'
-bold='\e[1m'
+if $COLOR; then
+ NC='\e[0m'
+ red='\e[0;31m'
+ blue='\e[1;34m'
+ green='\e[0;32m'
+ bold='\e[1m'
+fi
lines=`perl -E 'say "-" x 80'`
# ==============================================================================
@@ -90,9 +98,11 @@ forge_entry() {
| awk '$1 ~ /^2.*$/ {print "\t"$0} $1 !~ /^2.*$/ {print $0}' >> $2.$1.frag
print_info "${bold}Forged ChangeLog entry:${NC}"
cat $2.$1.frag
- ask "${bold}Edit ChangeLog entry [N/y] ?" user_edit
- if [ "$user_edit" == "y" ]; then
- "$EDITOR" $2.$1.frag
+ if $INTERACTIVE; then
+ ask "${bold}Edit ChangeLog entry [N/y] ?" user_edit
+ if [ "$user_edit" == "y" ]; then
+ "$EDITOR" $2.$1.frag
+ fi
fi
cat $2.$REV.frag >> ${commitfile}
}
@@ -138,6 +148,10 @@ if ! which $CMPTOOL > /dev/null ; then
ask "Enter tool name: " CMPTOOL
fi
+if ! $INTERACTIVE; then
+ exec >${logfile} 2>&1
+fi
+
echo -e "${blue}${lines}"
print_info "Backport will de done on top of branch: ${bold}$DEV_BRANCH${NC}"
print_info "Reference branch used for review is: ${bold}$REF_BRANCH${NC}"
@@ -151,9 +165,13 @@ print_step "Finding SHA1"
# ==============================================================================
SHA1=`git log --format=format:"%H" --grep=trunk@${REV} master`
print_info "${NC}SVN rev ${bold}${1}${NC} SHA1: ${bold}${SHA1}${NC}"
-ask "${bold}View the commit [N/y] ?" user_view
-if [ "$user_view" == "y" ]; then
- git show $SHA1
+if $INTERACTIVE; then
+ ask "${bold}View the commit [N/y] ?" user_view
+ if [ "$user_view" == "y" ]; then
+ git show $SHA1
+ fi
+else
+ git show $SHA1
fi
# ==============================================================================
@@ -180,15 +198,24 @@ done
print_step "Status Checking"
# ==============================================================================
git status
-ask "${bold}Open a Shell [N/y] ?" user_shell
-if [ "$user_shell" == "y" ]; then
+if $INTERACTIVE; then
+ ask "${bold}Open a Shell [N/y] ?" user_shell
+ if [ "$user_shell" == "y" ]; then
open_shell
+ fi
+else
+ git status --porcelain | grep "^UU" && \
+ { mv ${logfile} ${logfile}.ko; clean 1; }
fi
# ==============================================================================
print_step "Verification"
# ==============================================================================
-compare $SHA1
+if $INTERACTIVE; then
+ compare $SHA1
+else
+ print_info "None in batch mode."
+fi
# ==============================================================================
print_step "Branch/Commit/Push/Review"
@@ -198,39 +225,48 @@ if $STACKED; then
else
bname=${FNAME}-${VERSION}-backport-${1}
fi
-ask "${bold}Create backport branch [Y/n] ?" user_bc
-if [ "$user_bc" != "n" ]; then
- ask "${bold}Change name (${blue}${bname}${NC}${bold}) [N/y] ?" user_bname
- if [ "$user_bname" == "y" ]; then
- ask "${bold}Enter name :" bname
- fi
- git checkout -b ${bname} ${DEV_BRANCH}
- ask "${bold}Commit backport [Y/n] ?" user_commit
- if [ "$user_commit" != "n" ]; then
- if $STACKED; then
- git commit --amend
- else
- git commit -F ${commitfile}
+if $INTERACTIVE; then
+ ask "${bold}Create backport branch [Y/n] ?" user_bc
+ if [ "$user_bc" != "n" ]; then
+ ask "${bold}Change name (${blue}${bname}${NC}${bold}) [N/y] ?" user_bname
+ if [ "$user_bname" == "y" ]; then
+ ask "${bold}Enter name :" bname
fi
+ git checkout -b ${bname} ${DEV_BRANCH}
- echo
- print_info "If you want to stack another backport on top of this one"
- print_info "you can stop here, and invoke backflip with command:"
- print_info "${bold}backflip -b ${bname} REV_NUMBER${NC}"
- print_info "The next steps are only needed for review and validation.\n"
+ ask "${bold}Commit backport [Y/n] ?" user_commit
+ if [ "$user_commit" != "n" ]; then
+ if $STACKED; then
+ git commit --amend
+ else
+ git commit -F ${commitfile}
+ fi
- ask "${bold}Create patch [Y/n] ?" user_patch
- if [ "$user_patch" != "n" ]; then
- git format-patch -o ../ --suffix=.${bname}.patch -1
- fi
+ echo
+ print_info "If you want to stack another backport on top of this one"
+ print_info "you can stop here, and invoke backflip with command:"
+ print_info "${bold}backflip -b ${bname} REV_NUMBER${NC}"
+ print_info "The next steps are only needed for review and validation.\n"
+
+ ask "${bold}Create patch [Y/n] ?" user_patch
+ if [ "$user_patch" != "n" ]; then
+ git format-patch -o ../ --suffix=.${bname}.patch -1
+ fi
- ask "${bold}Request review (amend commit) [Y/n] ?" user_review
- if [ "$user_review" != "n" ]; then
- git review $REF_BRANCH
- git checkout $DEV_BRANCH
+ ask "${bold}Request review [Y/n] ?" user_review
+ if [ "$user_review" != "n" ]; then
+ git review $REF_BRANCH
+ fi
fi
fi
+else
+ print_info "Create backport branch."
+ git checkout -b ${bname} ${DEV_BRANCH}
+ print_info "Commit backport."
+ git commit -F ${commitfile}
+ print_info "Request review."
+ git review $REF_BRANCH
fi
# ==============================================================================