@@ -23,27 +23,42 @@ issue="$2"
2323backport=" $3 "
2424commit_message=$( git log --format=%B -n 1 $commit )
2525
26- if ! echo $commit_message | grep -q " \[noissue\]"
26+ if ! echo $commit_message | tr ' [:upper:] ' ' [:lower:] ' | grep -q " \[noissue\]"
2727then
28- if ! echo $commit_message | grep -q -E " (fixes|closes).*#$issue "
28+ if ! echo $commit_message | tr ' [:upper:] ' ' [:lower:] ' | grep -q -E " (fixes|closes).*#$issue "
2929 then
3030 echo " Error: issue $issue not detected in commit message." && exit 1
3131 fi
3232fi
3333
34- git cherry-pick --no-commit " $commit "
34+ if [ " $4 " = " --continue" ]
35+ then
36+ echo " Continue after manually resolving conflicts..."
37+ elif [ " $4 " = " " ]
38+ then
39+ if ! git cherry-pick --no-commit " $commit "
40+ then
41+ echo " Please resolve and add merge conflicts and restart this command with appended '--continue'."
42+ exit 1
43+ fi
44+ else
45+ exit 1
46+ fi
3547
3648for file in $( find CHANGES -name " $issue .*" )
3749do
38- git mv " $file " " ${file/ $issue / $backport } "
50+ newfile=" ${file/ $issue / $backport } "
51+ git mv " $file " " $newfile "
52+ sed -i -e " \$ a (backported from #$issue )" " $newfile "
53+ git add " $newfile "
3954done
4055
41- commit_message=" $( printf " $commit_message " | sed -E ' s/(fixes|closes)/backports/' ) "
56+ commit_message=" $( printf " $commit_message " | sed -E ' s/(fixes|closes)/backports/i ' ) "
4257commit_message=" $commit_message
4358
4459fixes #$backport
4560
4661(cherry picked from commit $commit )"
47- git commit -a - m " $commit_message "
62+ git commit -m " $commit_message "
4863
49- printf " \nSuccessfully backported commit $1 ."
64+ printf " \nSuccessfully backported commit $1 .\n "
0 commit comments