summaryrefslogtreecommitdiffstats
path: root/scripts/automerge7.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automerge7.sh')
-rwxr-xr-xscripts/automerge7.sh40
1 files changed, 27 insertions, 13 deletions
diff --git a/scripts/automerge7.sh b/scripts/automerge7.sh
index bc3a7be0a4..079dec7eea 100755
--- a/scripts/automerge7.sh
+++ b/scripts/automerge7.sh
@@ -1,10 +1,17 @@
#!/bin/bash
-FROM=7.0
-TO=7.1
+IGNORE=7.0
+FROM=7.1
+TO=master
+IGNORE_HEAD=origin/$IGNORE
FROM_HEAD=origin/$FROM
PUSH="origin HEAD:refs/for/$TO"
+EMAIL_AUTHOR=
+if [ "$1" = "email" ]
+then
+ EMAIL_AUTHOR=1
+fi
show() {
sCommit=$1
@@ -20,7 +27,7 @@ merge() {
if [ "$mCommit" == "" ]
then
echo "merge() missing commit id"
- exit 1
+ exit 2
fi
# echo "merge($mCommit)"
@@ -30,7 +37,7 @@ merge() {
then
echo "Merge failed for commit $mCommit"
echo "Manual merge is needed"
- exit 2
+ exit 3
fi
# Add a change id using git hook
git commit --amend --no-edit
@@ -43,7 +50,7 @@ pushMerged() {
if [ "$?" != "0" ]
then
echo "Push failed!"
- exit 2
+ exit 4
fi
}
@@ -59,7 +66,7 @@ maybe_commit_and_push() {
if [ "$cpCommitMsg" == "" ]
then
echo "Internal error, no commit message passed to maybe_commit_and_push()"
- exit 1;
+ exit 5
fi
# echo "maybe_commit_and_push: Merging $cpCommit"
merge $cpCommit
@@ -80,13 +87,13 @@ if [ "$nothingToCommit" == "" ]
then
git status
echo "Can not merge when there are unstaged changes."
- exit 1;
+ exit 6
fi
git checkout $TO
git fetch
-pending=`git log $TO..$FROM_HEAD --reverse|grep "^commit "|sed "s/commit //"`
+pending=`git log $TO..$FROM_HEAD ^$IGNORE_HEAD --reverse|grep "^commit "|sed "s/commit //"`
pendingCommit=
pendingCommitMessage=
@@ -94,7 +101,7 @@ for commit in $pending
do
echo "Checking $commit..."
mergeDirective=`git log -n 1 --format=%B $commit|grep "^Merge:"|sed "s/Merge: //"`
- commitMsg=`git log -n 1 --format=oneline --abbrev-commit $commit`
+ commitMsg=`git log -n 1 --format=oneline --abbrev-commit $commit | sed 's/\\\\/\\\\\\\\/g'` #Multiple levels of unescaping, sed just changes \ to \\
if [ "$mergeDirective" == "" ]
then
if can_merge $commit
@@ -107,10 +114,17 @@ do
pendingCommit=
pendingCommitMessage=
echo
- echo "Stopping merge because $commit because of merge conflicts"
+ echo "Stopping merge at $commit because of merge conflicts"
echo "The following commit must be manually merged."
show $commit
- exit 3
+
+ if [ "$EMAIL_AUTHOR" = "1" ]
+ then
+ author=`git show --format=%aE -s $commit`
+ echo "Email sent to $author"
+ (show $commit ; echo ; git merge $commit) |mail -s "Merge of your commit $commit to $TO failed" $author
+ fi
+ exit 7
fi
elif [ "$mergeDirective" == "no" ]
then
@@ -134,7 +148,7 @@ do
echo "Stopping merge at $commit (merge: manual)"
echo "The following commit must be manually merged."
show $commit
- exit 3
+ exit 8
else
maybe_commit_and_push $pendingCommit "$pendingCommitMessage"
pendingCommit=
@@ -143,7 +157,7 @@ do
echo "Commit $commit contains an unknown merge directive, Merge: $mergeDirective"
echo "Stopping merge."
show $commit
- exit 3
+ exit 9
fi
done