#!/usr/bin/env bash set -euo pipefail set -x export PATH="/usr/bin:/bin:/usr/local/bin" unset IFS unset PYTHONPATH unset PYTHONHOME unset HTTP_PROXY unset HTTPS_PROXY main() { local org_name local repo_name local course org_name=$(basename "$(dirname "$(pwd)")") repo_name=$(basename "$(pwd)") course=${repo_name%-*} if ! [[ "$course" =~ ^[a-zA-Z0-9_-]+$ ]]; then exit 1 fi local config_repo_path="/home/tt/.cache/$course-config" local grading_repo_path="/home/tt/.cache/$course-joj" local git_user="bot-$course" local git_email="bot-$course@focs.ji.sjtu.edu.cn" local git_server="ssh://git@focs.ji.sjtu.edu.cn:2222" if ! [ -d "$config_repo_path" ]; then git clone "$git_server/$course/$course-config.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 "$git_server/$course/$course-joj.git" "$grading_repo_path" git -C "$grading_repo_path" switch --orphan grading cat >"$grading_repo_path/Readme.md" <"$teapot_config_dir/teapot.env" <