-
-
Save MattWoelk/32d1681bc69e0d0d06ee to your computer and use it in GitHub Desktop.
Take a Handmade Hero .zip and make it a git repo, with one commit for each day.
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 | |
# This script makes a HandmadeHero directory and populates it as a git repo with the supplied .zip file. | |
# Example: ./hh_to_git.sh handmade_hero_065_source.zip | |
args=("$@") | |
if [ ${#args[@]} -ne 1 ] | |
then | |
echo "Need one argument: the source zip file." | |
exit | |
fi | |
source=$(readlink -f "${args[0]}") | |
repo="HandmadeHero" | |
mkdir -p "$repo" | |
rm -rf "$repo/.git" | |
cd "$repo" | |
git init | |
unzip -o "$source" -d ./sources | |
folders="$(ls "./sources" | sort)" | |
while read -r folder; do | |
base=$(basename "$folder") | |
day="${base:18:3}" | |
echo "FOLDER $folder" | |
tag="day$day" | |
unzip -o "./sources/$folder" | |
git add . | |
git commit -am "Importing code for day $day" && git tag "$tag" | |
done <<< "$folders" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment