Skip to content

Instantly share code, notes, and snippets.

@troyunverdruss
Created September 26, 2018 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troyunverdruss/97fb380d31b8823dfd5370195cf1c357 to your computer and use it in GitHub Desktop.
Save troyunverdruss/97fb380d31b8823dfd5370195cf1c357 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Handy script to print out how much your branch diverges from master
# to help you reduce pull request size for your reviewers
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
CURRENT_REPO_PATH=$(git rev-parse --show-toplevel)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
printf "Repo: ${CURRENT_REPO_PATH}\n"
printf "Branch: ${CURRENT_BRANCH}\n"
REMOVED=$(git diff master | grep "^-" | grep -v "^---" | wc -l | sed -e 's/[[:space:]]//g')
ADDED=$(git diff master | grep "^+" | grep -v "^+++" | wc -l | sed -e 's/[[:space:]]//g')
printf "${GREEN}+${ADDED} added${NC}, ${RED}-${REMOVED} removed${NC}\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment