Created
January 4, 2015 17:45
-
-
Save 5sw/ae6b72cd74137017712f to your computer and use it in GitHub Desktop.
Put daily Handmade Hero source code in git
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 | |
repo="HandmadeHero" | |
source="source" | |
if [ ! -d "$repo" ] | |
then | |
git init "$repo" | |
fi | |
cd "$repo" | |
folders=($(ls "../$source" | sort)) | |
last_tag=$(git tag | sort | tail -n 1) | |
if [ -z "$last_tag" ] | |
then | |
last_day="0" | |
else | |
last_day="${last_tag:3:3}" | |
fi | |
for i in "${folders[@]}" | |
do | |
day="${i:18:3}" | |
folder="../$source/$i" | |
tag="day$day" | |
if [ "$day" -gt "$last_day" ] | |
then | |
cp -a "$folder/"* . | |
git add . | |
git commit -am "Importing code for day $day" && | |
git tag "$tag" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've improved a bit you're script:
https://gist.github.com/nsenica/cbc5a4975666d7b02164
It supports incremental updates, and "gitignores" the sources files.