Skip to content

Instantly share code, notes, and snippets.

@zdennis
Created February 17, 2020 17:12
Show Gist options
  • Save zdennis/85cd889f05bead3f097a4b09304647dd to your computer and use it in GitHub Desktop.
Save zdennis/85cd889f05bead3f097a4b09304647dd to your computer and use it in GitHub Desktop.
look for unmerged commits for a rails5/integration branch
#!/usr/bin/env bash
# A simple front-end for running git unmerged in a project-specific way.
#
# ## Options
#
# -l for local comparing against local branches. The default is to compare against remote branches.
#
INCLUDE_BRANCH_CONVENTION="rails5/"
INTEGRATION_BRANCH="origin/rails5/integration"
LOCAL_INTEGRATION_BRANCH="rails5/integration"
LOCAL_OR_REMOTE="-r"
if [[ " $* " == *" -l "* ]]; then
INTEGRATION_BRANCH=$LOCAL_INTEGRATION_BRANCH
LOCAL_OR_REMOTE=""
fi
if [[ " $* " == *" -li "* ]]; then
INTEGRATION_BRANCH=$LOCAL_INTEGRATION_BRANCH
fi
BRANCHES_TO_COMPARE_AGAINST=`git branch $LOCAL_OR_REMOTE | grep -v $INTEGRATION_BRANCH | grep $INCLUDE_BRANCH_CONVENTION | ruby -e "puts STDIN.readlines.join(',').gsub(/\s+|\*/, '')"`
git unmerged --upstream $INTEGRATION_BRANCH --only $BRANCHES_TO_COMPARE_AGAINST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment