Skip to content

Instantly share code, notes, and snippets.

@ruden
Created May 2, 2018 12:22
Show Gist options
  • Save ruden/3a087e95fd81cd35fc0c85a457608ce1 to your computer and use it in GitHub Desktop.
Save ruden/3a087e95fd81cd35fc0c85a457608ce1 to your computer and use it in GitHub Desktop.
#!/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