Gitea-Heatmap-Sync/commit.sh
Han Dai 31fbb60079
All checks were successful
continuous-integration/drone/push Build is passing
fix grep unrecognized option: P
2020-02-29 23:39:18 -05:00

39 lines
1.0 KiB
Bash

#!/bin/sh
# 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
heatmap=$(cat heatmap | grep -Eo [0-9]+)
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