2019-12-07 12:05:26 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
local error="$1"
|
|
|
|
|
|
|
|
cat >&2 <<EOF
|
|
|
|
Usage:
|
|
|
|
$0 BRANCH PULL_REQUEST
|
|
|
|
|
|
|
|
Synopsis:
|
|
|
|
Useful script for merging a GitHub pull request with a custom merge commit
|
|
|
|
message.
|
|
|
|
|
|
|
|
Strips "origin" from branch names in title.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
$0 origin/philip/jael-fix 1953
|
|
|
|
|
|
|
|
Yields:
|
|
|
|
|
|
|
|
Merge branch 'philip/jael-fix' (#1953)
|
|
|
|
|
|
|
|
* origin/philip/jael-fix:
|
|
|
|
jael: process all ships in %full update
|
|
|
|
|
|
|
|
Signed-off-by: Jared Tobin <jared@tlon.io>
|
|
|
|
|
|
|
|
Error:
|
|
|
|
-> $error
|
|
|
|
EOF
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
args="$@"
|
|
|
|
|
|
|
|
if [[ -z "$args" ]]; then
|
|
|
|
usage "No arguments specified."
|
|
|
|
fi
|
|
|
|
|
|
|
|
REV=$1
|
|
|
|
PR=$2
|
|
|
|
|
2020-02-14 09:47:18 +03:00
|
|
|
KERNEL_CHANGED=`git diff --name-status $REV -- pkg/arvo/sys`
|
|
|
|
PILLS_CHANGED=`git diff --name-status $REV -- bin`
|
2019-12-07 12:05:26 +03:00
|
|
|
|
2020-02-14 09:47:18 +03:00
|
|
|
if [[ ! -z $KERNEL_CHANGED && -z $PILLS_CHANGED ]]
|
|
|
|
then
|
2020-02-13 17:59:51 +03:00
|
|
|
echo "WARNING: kernel has changed, but pills have not"
|
|
|
|
echo $KERNEL_CHANGED
|
|
|
|
echo
|
2020-02-14 09:47:18 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
TARGET_MSG=$(echo $REV | sed s_origin/__)
|
|
|
|
MERGE_MSG="Merge branch '$TARGET_MSG' (#$PR)"
|
2020-02-13 17:59:51 +03:00
|
|
|
|
|
|
|
read -p "Proceed with merge? (y/n)" -n 1 -r
|
|
|
|
echo
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
git merge --no-ff --signoff --log -m "$MERGE_MSG" $REV
|
|
|
|
fi
|
2019-12-07 12:05:26 +03:00
|
|
|
|