Skip to content

Instantly share code, notes, and snippets.

@jchadwick
Last active December 2, 2016 05:24
Show Gist options
  • Save jchadwick/fa3919576bed6a802e0c292b45eb2299 to your computer and use it in GitHub Desktop.
Save jchadwick/fa3919576bed6a802e0c292b45eb2299 to your computer and use it in GitHub Desktop.
Lynda.com courseware helpers
#!/bin/bash
gitRepo=$1
repoName=$(echo $1 | sed '$s/.*\/\([^/]*$\)/\1/')
dest="$(dirname $(pwd))/$repoName-sync"
branch="ExerciseFiles"
if [ -d "$dest" ]; then
rm -rf $dest
fi
mkdir $dest
pushd $dest
git clone $gitRepo .
git tag | xargs git push --delete origin
git tag | xargs git tag -d
git branch -D $branch
git checkout --orphan $branch
git reset
git clean -df
popd
for chapter in *
do
pushd $chapter
for folder in $(ls -I artifacts)
do
echo "Syncing $chapter/$folder..."
pushd $folder
pushd $dest
rm -rf *
popd
cp -r . "$dest"
pushd $dest
find -iname desktop.ini -delete
find -iregex .*/images/.* -delete
git add -A .
git commit -am "$chapter/$folder"
git tag "$chapter/$folder"
popd
popd
done
popd
done
pushd $dest
git push -f --tags
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment