Last active
July 27, 2016 12:49
-
-
Save mblarsen/e34b68763a7646e40a485ca36f07c089 to your computer and use it in GitHub Desktop.
Re-zips github repo zipfile so that the first fold is not the repo name but the actual src
This file contains hidden or 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 | |
# Moves Github zipped-repo files into root of zip files | |
# | |
# knockout-master.zip: | |
# | |
# knockout-master/<all files> | |
# | |
# to: | |
# | |
# <all files> | |
# | |
githubZipFix() { | |
OLDWD=`pwd` | |
FILE=`basename $1` | |
FILEPATH=`dirname $1` | |
REALPATH=`cd $FILEPATH ; pwd` | |
REPO=${FILE%.zip} | |
TEMP=$(mktemp -d -t $REPO) | |
echo "Backup file: /tmp/"$FILE | |
# Backup | |
cp $1 "/tmp/"$FILE | |
# Unzip and remove original | |
unzip $1 -d $TEMP > /dev/null || exit 1 | |
rm $1 | |
# Move dires around and zip | |
cd $TEMP | |
mv $REPO/* . | |
rm -rf $REPO || exit 1 | |
zip $REALPATH"/"$FILE -r * > /dev/null || exit 1 | |
cd $OLDWD | |
} | |
alias gfix=githubZipFix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment