Gitea-Heatmap-Sync/commit.sh

39 lines
1.0 KiB
Bash
Raw Permalink Normal View History

2020-02-29 22:39:18 -06:00
#!/bin/sh
2020-02-29 22:28:34 -06:00
# usage ./commit.sh https://username:password@git.domain.tld/username/repo.git
git clone $1 target
cd target
git config user.email "10000@daihan.me"
git config user.name "Han Dai"
wget https://gitea.dennx.com/api/v1/users/dennydai/heatmap -O heatmap
2020-02-29 22:39:18 -06:00
heatmap=$(cat heatmap | grep -Eo [0-9]+)
2020-02-29 22:28:34 -06:00
mkdir -p history
column=0 # 0: timestamp, 1: # of contributions
for i in $heatmap
do
if [ $column = 0 ] # timestamp
then column=1
timestamp=$i
else column=0 # # of contributions
synced=0 # synced # of contributions
if [ ! -f history/$timestamp ]
then echo "0" > history/$timestamp
else synced=$(cat history/$timestamp)
fi
for j in $(seq $(expr $synced + 1) $i)
do
echo $j > history/$timestamp
git add . -A
export GIT_AUTHOR_DATE=$timestamp
export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE
git commit -m "Sync Contribution Heatmap from Gitea"
done
fi
done
git push -u origin master