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
|
#!/usr/bin/bash
|
||||||
set -ex
|
set -ex
|
||||||
COURSE=$1
|
|
||||||
REPO_PATH=/home/tt/.cache/$COURSE-config
|
if [ -z "$1" ]; then
|
||||||
GIT_USER=$(whoami)
|
echo "error: course name is required" >&2
|
||||||
GIT_HOSTNAME=$(hostname -s)
|
exit 1
|
||||||
GIT_EMAIL="${GIT_USER}@${GIT_HOSTNAME}"
|
fi
|
||||||
git -C $REPO_PATH pull --rebase
|
|
||||||
rsync -r --delete $REPO_PATH/home/tt/.config/ /home/tt/.config
|
COURSE="$1"
|
||||||
joj3-forge convert /home/tt/.config/joj
|
CONFIG_REPO_PATH="/home/tt/.cache/$COURSE-config"
|
||||||
rsync -r --delete /home/tt/.config/joj/ $REPO_PATH/home/tt/.config/joj
|
GRADING_REPO_PATH="/home/tt/.cache/$COURSE-joj"
|
||||||
git -C $REPO_PATH config user.name $GIT_USER
|
GIT_USER="bot-$COURSE"
|
||||||
git -C $REPO_PATH config user.email $GIT_EMAIL
|
GIT_EMAIL="bot-$COURSE@focs.ji.sjtu.edu.cn"
|
||||||
git -C $REPO_PATH add home/tt/.config/joj
|
|
||||||
if ! git -C "$REPO_PATH" diff --staged --quiet; then
|
if ! [ -d "$CONFIG_REPO_PATH" ]; then
|
||||||
git -C $REPO_PATH commit -m "chore: joj3-forge convert"
|
git clone "ssh://git@focs.ji.sjtu.edu.cn:2222/$COURSE/$COURSE-joj.git" "$CONFIG_REPO_PATH"
|
||||||
git -C $REPO_PATH push
|
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
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user