Skip to content

Instantly share code, notes, and snippets.

@5sw
Created January 4, 2015 17:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 5sw/ae6b72cd74137017712f to your computer and use it in GitHub Desktop.
Save 5sw/ae6b72cd74137017712f to your computer and use it in GitHub Desktop.
Put daily Handmade Hero source code in git
#!/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
@MattWoelk
Copy link

Here's a fork that takes in a argument for a zip file, and does some things differently: https://gist.github.com/MattWoelk/32d1681bc69e0d0d06ee

@nsenica
Copy link

nsenica commented Mar 31, 2015

I've improved a bit you're script:
https://gist.github.com/nsenica/cbc5a4975666d7b02164

It supports incremental updates, and "gitignores" the sources files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment