Skip to content

Instantly share code, notes, and snippets.

@unakatsuo
Created October 14, 2014 11:40
Show Gist options
  • Save unakatsuo/777a0fcc8ac4c8dab8d1 to your computer and use it in GitHub Desktop.
Save unakatsuo/777a0fcc8ac4c8dab8d1 to your computer and use it in GitHub Desktop.
Find modified files under the watching path between two git branches.
#!/bin/bash
set -ue
WATCH_PATH="config/db/migrations/"
MASTER_BRANCH="$1"
WORK_BRANCH="$2"
join -1 4 -2 4 -a 2 <(git ls-tree $MASTER_BRANCH -- $WATCH_PATH) <(git ls-tree $WORK_BRANCH -- $WATCH_PATH) | \
awk '$4 != $7 {print $1 " is changed"; found++; } END{ if (found > 0){ exit 1; } }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment