randallli 72162dce8a [Release] Merge script checks for synced develop and master branches before attempting to merge them.
Reviewers: O1 Material components iOS, ajsecord

Reviewed By: O1 Material components iOS, ajsecord

Subscribers: ajsecord

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1638
2016-09-20 16:23:47 -04:00

58 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright 2016-present the Material Components for iOS authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Performs the final merge operations into master and develop for the current release.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; pushd $DIR >> /dev/null
MDC_ROOT="$(git rev-parse --show-toplevel | tail -n1)"; popd >> /dev/null
cd $MDC_ROOT
if [[ `git status --porcelain` ]]; then
echo
echo " Refusing to merge the release due to presence of local changes."
echo " Resolve the following before continuing again:"
echo
git status
exit 1
fi
check_sync_of_branch() {
git fetch
git checkout $1 2> /dev/null || git checkout -b $1 origin/$1
if [ $(git log $1..origin/$1 --oneline | wc -l) != "0" ]; then
echo
echo " Your local $1 branch is behind origin/$1."
echo " Refusing to continue until you've rebased off of origin/$1."
echo
echo " git rebase origin/$1"
exit 1
fi
}
merge_to_branch() {
check_sync_of_branch $1
git merge --no-ff release-candidate -m "Merge branch 'release-candidate'" \
|| { echo "Failed to merge cleanly."; exit 1; }
}
check_sync_of_branch develop
check_sync_of_branch master
merge_to_branch develop
merge_to_branch master