File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #! /bin/sh
2- # Create a git repo on github
3- # Put this script inside
4- # Update USERNAME
5- # Run this script
6- # Push
1+ #! /usr/bin/env bash
2+
3+ if [ -z " ${GITLAB_USERNAME} " ]; then
4+ echo " USERNAME is not set"
5+ exit 1
6+ fi
7+ if [ -z " ${REPOSITORY} " ]; then
8+ echo " REPOSITORY is not set"
9+ exit 1
10+ fi
11+ if [ -z " ${GITHUB_USERNAME} " ]; then
12+ echo " GITHUB_USERNAME is not set"
13+ exit 1
14+ fi
15+ if [ -z " ${GITHUB_EMAIL} " ]; then
16+ echo " GITHUB_EMAIL is not set"
17+ exit 1
18+ fi
19+
20+ cd " $( mktemp -d) "
21+ dir_path=" $( pwd) "
22+ trap " rm -rf ${dir_path} " EXIT
23+ git clone " ${REPOSITORY} " " repo"
24+ cd " repo"
25+
26+ git config user.name " ${GITHUB_USERNAME} "
27+ git config user.email " ${GITHUB_EMAIL} "
728
829PRE_COMMIT_MSG=' auto: '
9- USERNAME=' QuentinN42'
1030
1131function modif(){
1232 cat changes | grep -q " true" && echo " false" > changes || echo " true" > changes
1333}
1434
15- todo=" $( curl -s " https://gitlab.com/users/${USERNAME } /calendar.json" | jq -rc ' . | to_entries | .[] | "\(.key)-\(range(.value)+1)"' ) "
35+ todo=" $( curl -s " https://gitlab.com/users/${GITLAB_USERNAME } /calendar.json" | jq -rc ' . | to_entries | .[] | "\(.key)-\(range(.value)+1)"' ) "
1636already_done=" $( git log --pretty=' format:%s' | grep -E " ^${PRE_COMMIT_MSG} " | sed " s/^${PRE_COMMIT_MSG} //" ) "
1737
1838export IFS=$' \n '
2242 if [[ ! $already_done =~ $x ]]; then
2343 modif
2444 git add changes
25- git commit -s -m " ${PRE_COMMIT_MSG}${x} " --date=" $( date -d " $( echo " ${x} " | cut -d- -f-3) " ) "
45+ commit_date=" $( date -d " $( echo " ${x} " | cut -d- -f-3) " ' +%Y-%m-%d %H:%M:%S' ) "
46+ GIT_COMMITTER_DATE=" ${commit_date} " git commit -s -m " ${PRE_COMMIT_MSG}${x} " --date " ${commit_date} "
2647 fi
2748done
You can’t perform that action at this time.
0 commit comments