ysyx-workbench/Makefile

32 lines
1.6 KiB
Makefile
Raw Normal View History

2022-02-21 04:22:27 +00:00
STUID = ysyx_22040000
STUNAME = 张三
# DO NOT modify the following code!!!
GITFLAGS = -q --author='tracer-ysyx2204 <tracer@ysyx.org>' --no-verify --allow-empty
2022-02-25 09:45:35 +00:00
WORK_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
TRACER_BRANCH = ysyx-tracer
2022-02-21 04:22:27 +00:00
# prototype: git_commit(msg)
define git_commit
2022-02-25 09:45:35 +00:00
-@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`
2022-02-21 04:22:27 +00:00
-@sync
endef
_default:
@echo "Please run 'make' under subprojects."
.PHONY: _default