-
-
Save Lauszus/4668818 to your computer and use it in GitHub Desktop.
Download all files using git including submodules and then zip the repo
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/sh -e | |
# Script to automaticly download a project including all submodules | |
# It then updates all submodules and removes all files related to git | |
# It then zips it, so it's ready to upload | |
# | |
# It takes the ssh url to the git repository as an argument for instance: | |
# git://github.com/TKJElectronics/BalancingRobotArduino.git | |
if [ $# = 1 ] | |
then | |
dir="$(cd "$(dirname "$0")" && pwd)" | |
echo "Working path:" $dir | |
name=$(echo $(echo $1 | rev | cut -d'/' -f 1 | rev) | cut -d'.' -f 1) | |
echo "\nClone Project:" $name "\n" | |
git clone --recursive $1 | |
echo "\nUpdate submodules\n" | |
cd $name | |
git submodule foreach --recursive git pull origin master | |
echo "\nRemove git files" | |
find . -name .git | xargs rm -rf | |
find . -name .gitmodules | xargs rm -rf | |
find . -name .gitignore | xargs rm -rf | |
echo "Rename USB Host Library" | |
var=$(find . -name USB_Host_Shield_2.0 -type d) | |
if [ -n "$var" ] | |
then | |
echo "Path:" $var | |
cd "$var" | |
cd ../ | |
mv USB_Host_Shield_2.0 USB_Host_Shield_20 | |
else | |
echo "USB Host Library directory not found" | |
fi | |
echo "ZIP folder" | |
cd "$dir" | |
zip -r -q $name $name | |
echo "Done!" | |
else | |
echo "\nYou have to put the ssh url to the git repository as an argument" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment