Created
December 22, 2016 15:46
-
-
Save in8finity/5230f51a399c73ad9ddffd549c5f65c9 to your computer and use it in GitHub Desktop.
Interactive bash script to find diffs only in files from your feature between stage with multiple features.
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 | |
STAGING_BRANCH=staging | |
DEVELOP_BRANCH=develop | |
BRANCH_NAME=`git branch --list | fzf` | |
COMMON_PARENT_COMMIT_HASH=`git merge-base $BRANCH_NAME $DEVELOP_BRANCH` | |
FILES_LIST=`comm -12 <(git diff $BRANCH_NAME $STAGING_BRANCH --name-only) <(git diff $COMMON_PARENT_COMMIT_HASH $BRANCH_NAME --name-only)` | |
function diff_or_die { | |
if [ -z $1 ]; then | |
exit | |
fi | |
git diff $STAGING_BRANCH $BRANCH_NAME -- $1 | |
} | |
function ask_for_diff { | |
while true; do | |
local SELECTED_FILE=$(printf '%s\n' "${FILES_LIST[@]}" | fzf) | |
diff_or_die $SELECTED_FILE | |
done | |
} | |
ask_for_diff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment