Created
September 26, 2018 17:26
-
-
Save troyunverdruss/97fb380d31b8823dfd5370195cf1c357 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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