feat: init repos if dirs not exist
All checks were successful
push / build (push) Successful in 1m50s
All checks were successful
push / build (push) Successful in 1m50s
This commit is contained in:
parent
a909a92cd7
commit
d86ca6f935
|
@ -1,18 +1,43 @@
|
|||
#!/usr/bin/bash
|
||||
set -ex
|
||||
COURSE=$1
|
||||
REPO_PATH=/home/tt/.cache/$COURSE-config
|
||||
GIT_USER=$(whoami)
|
||||
GIT_HOSTNAME=$(hostname -s)
|
||||
GIT_EMAIL="${GIT_USER}@${GIT_HOSTNAME}"
|
||||
git -C $REPO_PATH pull --rebase
|
||||
rsync -r --delete $REPO_PATH/home/tt/.config/ /home/tt/.config
|
||||
joj3-forge convert /home/tt/.config/joj
|
||||
rsync -r --delete /home/tt/.config/joj/ $REPO_PATH/home/tt/.config/joj
|
||||
git -C $REPO_PATH config user.name $GIT_USER
|
||||
git -C $REPO_PATH config user.email $GIT_EMAIL
|
||||
git -C $REPO_PATH add home/tt/.config/joj
|
||||
if ! git -C "$REPO_PATH" diff --staged --quiet; then
|
||||
git -C $REPO_PATH commit -m "chore: joj3-forge convert"
|
||||
git -C $REPO_PATH push
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "error: course name is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COURSE="$1"
|
||||
CONFIG_REPO_PATH="/home/tt/.cache/$COURSE-config"
|
||||
GRADING_REPO_PATH="/home/tt/.cache/$COURSE-joj"
|
||||
GIT_USER="bot-$COURSE"
|
||||
GIT_EMAIL="bot-$COURSE@focs.ji.sjtu.edu.cn"
|
||||
|
||||
if ! [ -d "$CONFIG_REPO_PATH" ]; then
|
||||
git clone "ssh://git@focs.ji.sjtu.edu.cn:2222/$COURSE/$COURSE-joj.git" "$CONFIG_REPO_PATH"
|
||||
fi
|
||||
# TODO: move this into if statement
|
||||
git -C "$CONFIG_REPO_PATH" config user.name "$GIT_USER"
|
||||
git -C "$CONFIG_REPO_PATH" config user.email "$GIT_EMAIL"
|
||||
|
||||
if ! [ -d "$GRADING_REPO_PATH" ]; then
|
||||
git clone "ssh://git@focs.ji.sjtu.edu.cn:2222/$COURSE/$COURSE-joj.git" "$GRADING_REPO_PATH"
|
||||
git -C "$GRADING_REPO_PATH" switch --orphan grading
|
||||
echo "# $COURSE JOJ grading" >"$GRADING_REPO_PATH/Readme.md"
|
||||
echo "This branch is automatically updated by JOJ, **never edit any file in this branch!**" >>"$GRADING_REPO_PATH/Readme.md"
|
||||
git -C "$GRADING_REPO_PATH" add Readme.md
|
||||
git -C "$GRADING_REPO_PATH" commit -m"docs: readme"
|
||||
git -C "$GRADING_REPO_PATH" push -u origin grading
|
||||
fi
|
||||
# TODO: move this into if statement
|
||||
git -C "$GRADING_REPO_PATH" config user.name "$GIT_USER"
|
||||
git -C "$GRADING_REPO_PATH" config user.email "$GIT_EMAIL"
|
||||
|
||||
git -C "$CONFIG_REPO_PATH" pull --rebase
|
||||
rsync -r --delete "$CONFIG_REPO_PATH/home/tt/.config/" /home/tt/.config
|
||||
joj3-forge convert /home/tt/.config/joj
|
||||
rsync -r --delete /home/tt/.config/joj/ "$CONFIG_REPO_PATH/home/tt/.config/joj"
|
||||
git -C "$CONFIG_REPO_PATH" add home/tt/.config/joj
|
||||
if ! git -C "$CONFIG_REPO_PATH" diff --staged --quiet; then
|
||||
git -C "$CONFIG_REPO_PATH" commit -m "chore: joj3-forge convert"
|
||||
git -C "$CONFIG_REPO_PATH" push
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue
Block a user