branchsync.sh revision a4fe161bd396dd0593cc66480c4118f28d54e4c8
#
# Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
#
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# branchsync:
# pull in changes from a main BIND 9 release branch to a subscription
# branch (e.g., from v9_9 to v9_9_sub). This excludes commits from the
# 'tinderbox' user (copyright updates and doc regeneration) because those
# will be taken care of in the subscription branch itself.
#
# Most of the time, changes in the main branch will cherry-pick cleanly
# into the subscription branch. When one fails, we reset to the last
# commit that went cleanly, and send mail -- or, if running in interactive
# mode, we stop and allow the user to resolve conflicts.
#
# NOTE: This does not push changes to the repository; currently that's up
# to the caller.
#
# Usage:
# branchsync.sh [ -i ] [ -c ]
# -i: interactive mode (don't reset and send mail)
# -c: continue (conflicts are resolved; edit message and commit)
# restore the copyrights and api files
# restore the generated documentation
# don't update the EXCLUDED file
fi
}
cat <<EOF > $1.new
SOURCEBRANCH=$2
LASTHASH=$3
EOF
}
}
# skip the commit if we're only updating branchsync.dat
return
fi
# pull in the log message from the cherry-picked commit
git log -1 --pretty=format:%s%n%b $2 > orig_commit_msg.tmp
tail -n +2 orig_commit_msg.tmp > remainder.tmp
echo $firstline > commit_msg.tmp
# commit
}
if [ ! -f branchsync.dat ]; then
echo "$0: branchsync data file not found"
exit 0
fi
# check arguments
case $1 in
;;
;;
*) if [ $# -ne 0 ]; then
echo "Usage: $0 [ -i ] [ -c ]" 1>&2
exit 1
fi
;;
esac
if [ -z "$continuing" ]; then
if [ -n "$status" ]; then
echo "Work tree is not clean. Clean up, or run with -c:"
echo "$status"
exit 1
fi
# make sure both branches are synced to the source repository
fi
# loop through commits looking for ones that should be cherry-picked
while read hash; do
# cherry-pick was clean
# restore the files that we don't want updated automatically
# note which hash we're merging
# fix the commit message, and commit
# move on to the next commit
continue
# interactive mode -- wait for user to fix things
# first restore the files that we don't want updated automatically
# note which hash we're merging
else
# noninteractive mode
# reset everything
# build mail message
cat << EOF > /tmp/branchmsg.$$
Attempt to cherry pick ${hash}
to $BRANCH failed.
Commit message of change was:
`git log -1 --pretty=format:%s%n%b ${hash}`
EOF
# send mail
fi
break
done
}