Created
May 2, 2018 12:22
-
-
Save ruden/3a087e95fd81cd35fc0c85a457608ce1 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 | |
DIR_BASE=$(pwd) | |
BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD) | |
CURRENT_COMMIT=$(git log --pretty=format:'%h' -n 1) | |
NEW_FILES=$(git diff --name-only --diff-filter=A master origin/$BRANCH) | |
CHANGED_FILES=$(git diff --name-only --diff-filter=M master origin/$BRANCH) | |
DIR_TMP=$(mktemp -d $BRANCH-$CURRENT_COMMIT.XXXXXXXXX) | |
DIR_NEW_FILES=$DIR_TMP/NEW_FILES | |
DIR_CHANGED_FILES=$DIR_TMP/CHANGED_FILES | |
mkdir $DIR_NEW_FILES $DIR_CHANGED_FILES | |
for file in $NEW_FILES; do | |
cp --parents $file $DIR_NEW_FILES/ | |
done | |
for file in $CHANGED_FILES; do | |
if [ $file != 'build.sh' ]; then | |
if [ $file = 'README.md' ]; then | |
cp --parents $file $DIR_TMP/ | |
mv $DIR_TMP/$file $DIR_TMP/${file%.md}.txt | |
else | |
cp --parents $file $DIR_CHANGED_FILES/ | |
fi | |
fi | |
done | |
cd $DIR_TMP && zip -r ../$BRANCH-$CURRENT_COMMIT.zip . >/dev/null 2>&1 | |
rm -r $DIR_BASE/$DIR_TMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment