Yvan Roux | a165c8f | 2017-10-11 13:46:27 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Maxim Kuvyrkov | 82ab953 | 2018-03-07 14:27:36 +0000 | [diff] [blame^] | 3 | export GIT_WORK_TREE=$(pwd) |
Yvan Roux | a165c8f | 2017-10-11 13:46:27 +0200 | [diff] [blame] | 4 | export GIT_DIR="$GIT_WORK_TREE"/.git |
| 5 | |
| 6 | NC='\e[0m' |
| 7 | red='\e[0;31m' |
| 8 | blue='\e[1;34m' |
| 9 | bold='\e[1m' |
| 10 | |
| 11 | msg() { echo -n -e "${blue}** ${NC}${bold}$1${NC}" ; } |
| 12 | ask() { msg "$1 " ; eval "read $2"; } |
| 13 | |
| 14 | VERSION="$1" |
| 15 | BRANCH="gcc-${VERSION}-branch" |
| 16 | DATE=$(date +"%Y-%m") |
| 17 | MBRANCH="Merge-$BRANCH-$DATE" |
| 18 | msg "Updating repo\n" |
| 19 | git remote update |
| 20 | ask "Creating branch: $MBRANCH [Enter]" |
| 21 | git checkout -b $MBRANCH origin/$BRANCH |
| 22 | |
| 23 | msg "Last branch merge commit:\n" |
| 24 | git --no-pager log -n 1 --grep="Merge branches/$BRANCH" --pretty=medium origin/linaro/$BRANCH |
| 25 | |
| 26 | REV=$(git log -n 1 --grep="Merge branches/$BRANCH" --format="%s" origin/linaro/$BRANCH) |
| 27 | REV=${REV##* } |
| 28 | REV=${REV%%.} |
| 29 | BSHA1=$(git log -n 1 --format="%h" --grep="$BRANCH@$REV" origin/$BRANCH) |
| 30 | MREV=$(git log -n 1 --format="%b" origin/$BRANCH | grep git-svn-id) |
| 31 | MSHA1=$(git log -n 1 --format="%h" origin/$BRANCH) |
| 32 | MREV=${MREV##*@} |
| 33 | MREV=${MREV%% *} |
| 34 | |
Maxim Kuvyrkov | 5ebe69f | 2018-03-07 14:22:03 +0000 | [diff] [blame] | 35 | msg "Remove all rebase entries up to and including ${red}$BSHA1$\n" |
Yvan Roux | a165c8f | 2017-10-11 13:46:27 +0200 | [diff] [blame] | 36 | msg "Keep first line as 'pick' and squash remaining ones (s/^pick/squash/)\n" |
| 37 | msg "Last commit to merge should be ${red}$MSHA1$\n" |
| 38 | msg "Branch merge commit message should be:\n" |
| 39 | msg "Merge branches/$BRANCH rev $MREV.\n" |
| 40 | ask "Start rebasing [Press key]" |
| 41 | |
| 42 | git rebase -i origin/linaro-local/gcc-${VERSION}-integration-branch |
| 43 | |
| 44 | if [ $? -ne 0 ]; then |
| 45 | msg "Fix the conflicts and continue the rebase with:\n" |
| 46 | msg "git rebase --continue\n" |
| 47 | msg "Fix ownership with command:\n" |
| 48 | msg "git commit --amend --reset-author\n" |
| 49 | else |
| 50 | ask "Fix ownership [Press key]" |
| 51 | git commit --amend --reset-author |
| 52 | fi |