Merge pull request #1 from huaixv/ysyx2204

feat: add shadow branch for tracer
This commit is contained in:
Zihao Yu 2022-03-08 10:40:25 +08:00 committed by GitHub
commit aa59f01da2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View file

@ -5,11 +5,23 @@ STUNAME = 张三
GITFLAGS = -q --author='tracer-ysyx2204 <tracer@ysyx.org>' --no-verify --allow-empty
WORK_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
TRACER_BRANCH = ysyx-tracer
# prototype: git_commit(msg)
define git_commit
-@git add .. -A --ignore-errors
-@while (test -e .git/index.lock); do sleep 0.1; done
-@(echo "> $(1)" && echo $(STUID) $(STUNAME) && uname -a && uptime) | git commit -F - $(GITFLAGS)
-@cd $(YSYX_HOME) && while (test -e .git/index.lock); do sleep 0.1; done; `# wait for other git instances`
-@cd $(YSYX_HOME) && git branch $(TRACER_BRANCH) -q 2>/dev/null || true `# create tracer branch if not existent`
-@cd $(YSYX_HOME) && git worktree add $(TRACER_BRANCH) -q `# check out tracer branch`
-@cd $(YSYX_HOME) && git status --untracked-files -z `# list changed files to copy (w/o quotes)` \
| tr '\000' '\n' `# restore EOL sequence` \
| cut -c 1-3 --complement `# remove status indicator` \
| grep -v '^$(TRACER_BRANCH)/' `# skip tracer worktree` \
| rsync -aq --files-from=- ./ $(TRACER_BRANCH)/ `# call rsync to copy files`
-@cd $(YSYX_HOME) && git -C $(TRACER_BRANCH) add . -A --ignore-errors `# add changes to staging area`
-@cd $(YSYX_HOME) && (echo "> $(1)" && echo $(STUID) $(STUNAME) && uname -a && uptime `# generate commit msg`) \
| git -C $(TRACER_BRANCH) commit -F - $(GITFLAGS) `# commit changes in tracer branch`
-@cd $(YSYX_HOME) && git worktree remove $(TRACER_BRANCH) -f `# remove tracer worktree`
-@sync
endef

View file

@ -66,6 +66,14 @@ case $1 in
sed -i -e "/^export NPC_HOME=.*/d" ~/.bashrc
echo "export NPC_HOME=`readlink -e npc`" >> ~/.bashrc
echo "By default this script will add environment variables into ~/.bashrc."
echo "After that, please run 'source ~/.bashrc' to let these variables take effect."
echo "If you use shell other than bash, please add these environment variables manually."
;;
ysyx)
sed -i -e "/^export YSYX_HOME=.*/d" ~/.bashrc
echo "export YSYX_HOME=`readlink -e .`" >> ~/.bashrc
echo "By default this script will add environment variables into ~/.bashrc."
echo "After that, please run 'source ~/.bashrc' to let these variables take effect."
echo "If you use shell other than bash, please add these environment variables manually."