| #!/bin/bash |
| |
| export GIT_WORK_TREE=$(pwd) |
| export GIT_DIR="$GIT_WORK_TREE"/.git |
| |
| NC='\e[0m' |
| red='\e[0;31m' |
| blue='\e[1;34m' |
| bold='\e[1m' |
| |
| msg() { echo -n -e "${blue}** ${NC}${bold}$1${NC}" ; } |
| ask() { msg "$1 " ; eval "read $2"; } |
| |
| VERSION="$1" |
| BRANCH="gcc-${VERSION}-branch" |
| DATE=$(date +"%Y-%m") |
| MBRANCH="Merge-$BRANCH-$DATE" |
| msg "Updating repo\n" |
| git remote update |
| ask "Creating branch: $MBRANCH [Enter]" |
| git checkout -b $MBRANCH origin/$BRANCH |
| |
| msg "Last branch merge commit:\n" |
| git --no-pager log -n 1 --grep="Merge branches/$BRANCH" --pretty=medium origin/linaro/$BRANCH |
| |
| REV=$(git log -n 1 --grep="Merge branches/$BRANCH" --format="%s" origin/linaro/$BRANCH) |
| REV=${REV##* } |
| REV=${REV%%.} |
| BSHA1=$(git log -n 1 --format="%h" --grep="$BRANCH@$REV" origin/$BRANCH) |
| MREV=$(git log -n 1 --format="%b" origin/$BRANCH | grep git-svn-id) |
| MSHA1=$(git log -n 1 --format="%h" origin/$BRANCH) |
| MREV=${MREV##*@} |
| MREV=${MREV%% *} |
| |
| msg "Remove all rebase entries up to and including ${red}$BSHA1$\n" |
| msg "Keep first line as 'pick' and squash remaining ones (s/^pick/squash/)\n" |
| msg "Last commit to merge should be ${red}$MSHA1$\n" |
| msg "Branch merge commit message should be:\n" |
| msg "Merge branches/$BRANCH rev $MREV.\n" |
| ask "Start rebasing [Press key]" |
| |
| git rebase -i origin/linaro-local/gcc-${VERSION}-integration-branch |
| |
| if [ $? -ne 0 ]; then |
| msg "Fix the conflicts and continue the rebase with:\n" |
| msg "git rebase --continue\n" |
| msg "Fix ownership with command:\n" |
| msg "git commit --amend --reset-author\n" |
| else |
| ask "Fix ownership [Press key]" |
| git commit --amend --reset-author |
| fi |