2024-01-05 16:43:00 +00:00
|
|
|
#/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Environment Variables:
|
|
|
|
# NEMU_HOME
|
|
|
|
set -x
|
|
|
|
|
|
|
|
STUID=ysyx_22040000
|
|
|
|
STUNAME=李心杨
|
|
|
|
|
|
|
|
TRACER=tracer-ysyx
|
|
|
|
GITFLAGS="-q --author=$TRACER<tracer@ysyx.org> --no-verify --allow-empty"
|
|
|
|
|
|
|
|
WORK_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
2024-01-05 16:48:34 +00:00
|
|
|
WORK_INDEX=.git/index.${WORK_BRANCH}
|
2024-01-05 16:43:00 +00:00
|
|
|
TRACER_BRANCH=$TRACER
|
|
|
|
|
2024-01-05 16:48:34 +00:00
|
|
|
LOCK_DIR=.git/
|
2024-01-05 16:43:00 +00:00
|
|
|
|
|
|
|
git_soft_checkout () {
|
|
|
|
git checkout --detach -q && git reset --soft $1 -q -- && git checkout $1 -q -- ;
|
|
|
|
}
|
|
|
|
|
|
|
|
git_commit () {
|
|
|
|
# create tracer branch if not existent
|
|
|
|
git branch $TRACER_BRANCH -q 2>/dev/null || true
|
|
|
|
# backup git index
|
|
|
|
cp -a .git/index $WORK_INDEX
|
|
|
|
# switch to tracer branch
|
|
|
|
git_soft_checkout "$TRACER_BRANCH"
|
|
|
|
# add files to commit
|
|
|
|
git add . -A --ignore-errors
|
|
|
|
# generate commit msg, commit changes in tracer branch
|
|
|
|
printf "> $1 \n $STUID $STUNAME \n $(uname -a) \n $(uptime)\n" | git commit -F - $GITFLAGS
|
|
|
|
git_soft_checkout "$WORK_BRANCH"
|
|
|
|
mv $WORK_INDEX .git/index
|
|
|
|
}
|
|
|
|
|
|
|
|
git_commit $1
|
|
|
|
|