From 69a95f60eac28a206a7ea4a4145fd261af94d023 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Sun, 14 Jun 2020 19:13:16 -0400 Subject: [PATCH] Accept optional branch name There's been a recent movement to rename the "master" branch in git repositories to "main" to avoid to potentially problematic word "master". Our `merge-branch` script was hard coded to "master". This PR makes it possible to pass in the name of the branch you wish to merge to. I've defaulted it to "master" for now, but I expect in time this will change. --- bin/git-merge-branch | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/git-merge-branch b/bin/git-merge-branch index 01cd228..c8f8d9d 100755 --- a/bin/git-merge-branch +++ b/bin/git-merge-branch @@ -1,14 +1,20 @@ #!/bin/sh +main_branch="master" + +if [ $# -gt 0 ]; then + main_branch=$1 +fi + set -e git fetch origin -line_count=$(git diff origin/master..master | wc -l) +line_count=$(git diff origin/$main_branch..$main_branch | wc -l) if [ $line_count -gt 0 ]; then - printf "failed: master is not up to date with origin/master\n" + printf "failed: $main_branch is not up to date with origin/$main_branch\n" exit 1 fi -git checkout master +git checkout $main_branch git merge "@{-1}"