Skip to content

Instantly share code, notes, and snippets.

@lucasreta
Last active December 4, 2020 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasreta/73c66993ee07b5bb2281f8448e309fee to your computer and use it in GitHub Desktop.
Save lucasreta/73c66993ee07b5bb2281f8448e309fee to your computer and use it in GitHub Desktop.
embeddable version of gifeegol.sh for medium article
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $DIR
./cligol/cligol
weekday=`date +"%w"`
today=`date +%Y-%m-%d`
if (( weekday == 6 ))
then
weekday=0
fi
first_col_date=$(date --date="${today} -${weekday} day -364 day" +%Y-%m-%d)
RANDOM=$(date +%s%N | cut -b10-19)
new_branch=branch-$today-$RANDOM
git checkout reset_point
git checkout -b $new_branch
input="cligol/data/board.txt"
while read line || [ -n "$line" ]
do
commit_date=$first_col_date
for i in $line; do
if [ $i -eq 1 ]
then
loop=0
while (( loop < 40 ))
do
GIT_COMMITTER_DATE="$commit_date $((10 + RANDOM % 14)):$((10 + RANDOM % 49)):$((10 + RANDOM % 49))" git commit --date "$commit_date $((10 + RANDOM % 14)):$((10 + RANDOM % 49)):$((10 + RANDOM % 49))" -m "" --allow-empty --allow-empty-message --quiet
((loop++))
done
fi
commit_date=$(date --date="${commit_date} +7 day" +%Y-%m-%d)
done
first_col_date=$(date --date="${first_col_date} +1 day" +%Y-%m-%d)
done < "$input"
git push origin $new_branch
curl -i -u "$USERNAME:$ACCESS_TOKEN" --header "Content-Type: application/json" --request PATCH --data "{\"name\": \"$REPOSITORY\", \"default_branch\": \"$new_branch\"}" "https://api.github.com/repos/$USERNAME/$REPOSITORY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment