Update Makefile
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
HOSTNAME := $(shell hostname)
|
||||
OS := $(shell uname | tr A-Z a-z)
|
||||
ifeq ($(OS), darwin)
|
||||
SEDI := sed -i ''
|
||||
OS := OSX
|
||||
else ifeq ($(OS), linux)
|
||||
SEDI := sed -i
|
||||
OS := linux
|
||||
else
|
||||
$(error Unknown operating system)
|
||||
@@ -19,6 +21,8 @@ remotedir := drwater@serev:/home/www/drwater/$(projtype)/$(pubtype)/$(reponame)/
|
||||
outputdir := $(shell awk -F': *' '/^ *output-dir:/ {print $$2 "/" }' ./_quarto.yml)
|
||||
siteurl := https://drwater.rcees.ac.cn/$(projtype)/$(pubtype)/$(reponame)/@$(branchname)
|
||||
|
||||
branchnames := "TX\|FJ\|YF\|ZY\|WW\|JB\|YY\|YJ\|DYF"
|
||||
|
||||
# Variables for colors and port
|
||||
bcolor := grey
|
||||
port := 4199
|
||||
@@ -130,7 +134,7 @@ pull:
|
||||
current_branch=$$(git rev-parse --abbrev-ref HEAD); \
|
||||
if [ "$$current_branch" = main ]; then \
|
||||
echo "当前分枝为$$current_branch."; \
|
||||
remote_branch=$$(git branch --remote | grep -v 'main' | grep "[A-Z]\{2,\}" | awk '{print $$1}' | sed 's/origin\///' | head -n 1); \
|
||||
remote_branch=$$(git branch --remote | grep -v 'main' | grep $(branchnames) | awk '{print $$1}' | sed 's/origin\///' | head -n 1); \
|
||||
if [ -n "$$remote_branch" ]; then \
|
||||
echo "尝试从远程分枝$$remote_branch 拉取更新..."; \
|
||||
git pull origin $$remote_branch; \
|
||||
@@ -177,7 +181,7 @@ open:
|
||||
|
||||
# Clean unnecessary files
|
||||
clean:
|
||||
@rm -f ./*.spl ./*.aux ./*.bbl ./*.blg ./*.log ./*.tex ./*.bcf ./*.tex.sedbak ./*.fdb_latexmk
|
||||
@rm -f ./*.spl ./*.bbl ./*.blg ./*.log ./*.tex ./*.bcf ./*.tex.sedbak ./*.fdb_latexmk
|
||||
|
||||
# Upload files to server and fix links
|
||||
upload: backupdocx
|
||||
@@ -210,13 +214,13 @@ backupdocx:
|
||||
else \
|
||||
if [ ! -e TC/MS/MS$${datetime}_$${currentcommithash}.docx ]; then \
|
||||
cp www/MS/MS.docx TC/MS/MS$${datetime}_$${currentcommithash}.docx; \
|
||||
echo "备份TC/MS/MS-$${datetime}_$${currentcommithash}.docx完成."; \
|
||||
git add TC/MS/MS-$${datetime}_$${currentcommithash}.docx; \
|
||||
echo "备份TC/MS/MS$${datetime}_$${currentcommithash}.docx完成."; \
|
||||
git add TC/MS/MS$${datetime}_$${currentcommithash}.docx; \
|
||||
if [ "$$(git diff --cached)" ]; then \
|
||||
git commit -m "备份TC/MS/MS-$${datetime}_$${currentcommithash}.docx"; \
|
||||
git commit -m "备份TC/MS/MS$${datetime}_$${currentcommithash}.docx"; \
|
||||
fi; \
|
||||
else \
|
||||
echo "TC/MS/MS-$${datetime}_$${currentcommithash}.docx已存在,无需备份."; \
|
||||
echo "TC/MS/MS$${datetime}_$${currentcommithash}.docx已存在,无需备份."; \
|
||||
fi; \
|
||||
fi;
|
||||
|
||||
@@ -228,8 +232,10 @@ trackchange:
|
||||
| fzf --multi --reverse --preview="echo {}" ); \
|
||||
echo $$hashes; \
|
||||
hash1=$$(echo $$hashes | sed -e 's/) \([a-z0-9]\{7\}:\)/)\n\1/g' | tail -n 1 | awk '{print $$1}' | tr -d ':'); \
|
||||
hash1=$$(git rev-parse --short $${hash1}^); \
|
||||
datetime1=$$(git show -s --format=%ci $$hash1 | sed 's/[-: ]//g' | cut -c3-12); \
|
||||
hash2=$$(echo $$hashes | sed -e 's/) \([a-z0-9]\{7\}:\)/)\n\1/g' | head -n 1 | awk '{print $$1}' | tr -d ':'); \
|
||||
hash2=$$(git rev-parse --short $${hash2}^); \
|
||||
datetime2=$$(git show -s --format=%ci $$hash2 | sed 's/[-: ]//g' | cut -c3-12); \
|
||||
if [ -z "$$hash1" ] || [ -z "$$hash2" ]; then \
|
||||
echo "必须选择两个提交."; \
|
||||
@@ -264,56 +270,55 @@ updvariable:
|
||||
@touch _variables.yml # 如果文件不存在则创建
|
||||
@grep -q '^reponame:' _variables.yml || echo "reponame: $(reponame)" >> _variables.yml
|
||||
@if grep -q '^reponame:' _variables.yml; then \
|
||||
sed -i '' 's/^reponame:.*/reponame: $(reponame)/' _variables.yml; \
|
||||
$(SEDI) 's/^reponame:.*/reponame: $(reponame)/' _variables.yml; \
|
||||
else \
|
||||
echo "reponame: $(reponame)" >> _variables.yml; \
|
||||
fi
|
||||
@grep -q '^projtype:' _variables.yml || echo "projtype: $(projtype)" >> _variables.yml
|
||||
@if grep -q '^projtype:' _variables.yml; then \
|
||||
sed -i '' 's/^projtype:.*/projtype: $(projtype)/' _variables.yml; \
|
||||
$(SEDI) 's/^projtype:.*/projtype: $(projtype)/' _variables.yml; \
|
||||
else \
|
||||
echo "projtype: $(projtype)" >> _variables.yml; \
|
||||
fi
|
||||
@grep -q '^branch:' _variables.yml || echo "branch: $(branchname)" >> _variables.yml
|
||||
@if grep -q '^branch:' _variables.yml; then \
|
||||
sed -i '' 's/^branch:.*/branch: $(branchname)/' _variables.yml; \
|
||||
$(SEDI) 's/^branch:.*/branch: $(branchname)/' _variables.yml; \
|
||||
else \
|
||||
echo "branch: $(branchname)" >> _variables.yml; \
|
||||
fi
|
||||
@grep -q '^pubtype:' _variables.yml || echo "pubtype: $(pubtype)" >> _variables.yml
|
||||
@if grep -q '^pubtype:' _variables.yml; then \
|
||||
sed -i '' 's/^pubtype:.*/pubtype: $(pubtype)/' _variables.yml; \
|
||||
$(SEDI) 's/^pubtype:.*/pubtype: $(pubtype)/' _variables.yml; \
|
||||
else \
|
||||
echo "pubtype: $(pubtype)" >> _variables.yml; \
|
||||
fi
|
||||
@grep -q '^nwAB:' _variables.yml || echo "nwAB: $(nwAB)" >> _variables.yml
|
||||
@if grep -q '^nwAB:' _variables.yml; then \
|
||||
sed -i '' 's/^nwAB:.*/nwAB: $(nwAB)/' _variables.yml; \
|
||||
$(SEDI) 's/^nwAB:.*/nwAB: $(nwAB)/' _variables.yml; \
|
||||
else \
|
||||
echo "nwAB: $(nwAB)" >> _variables.yml; \
|
||||
fi
|
||||
@grep -q '^nwMS:' _variables.yml || echo "nwMS: $(nwMS)" >> _variables.yml
|
||||
@if grep -q '^nwMS:' _variables.yml; then \
|
||||
sed -i '' 's/^nwMS:.*/nwMS: $(nwMS)/' _variables.yml; \
|
||||
$(SEDI) 's/^nwMS:.*/nwMS: $(nwMS)/' _variables.yml; \
|
||||
else \
|
||||
echo "nwMS: $(nwMS)" >> _variables.yml; \
|
||||
fi
|
||||
@grep -q '^figtblMS:' _variables.yml || echo "figtblMS: $(figtblMS)" >> _variables.yml
|
||||
@if grep -q '^figtblMS:' _variables.yml; then \
|
||||
sed -i '' 's/^figtblMS:.*/figtblMS: $(figtblMS)/' _variables.yml; \
|
||||
$(SEDI) 's/^figtblMS:.*/figtblMS: $(figtblMS)/' _variables.yml; \
|
||||
else \
|
||||
echo "figtblMS: $(figtblMS)" >> _variables.yml; \
|
||||
fi
|
||||
@grep -q '^figtblSM:' _variables.yml || echo "figtblSM: $(figtblSM)" >> _variables.yml
|
||||
@if grep -q '^figtblSM:' _variables.yml; then \
|
||||
sed -i '' 's/^figtblSM:.*/figtblSM: $(figtblSM)/' _variables.yml; \
|
||||
$(SEDI) 's/^figtblSM:.*/figtblSM: $(figtblSM)/' _variables.yml; \
|
||||
else \
|
||||
echo "figtblSM: $(figtblSM)" >> _variables.yml; \
|
||||
fi
|
||||
@mkpapervar
|
||||
|
||||
|
||||
|
||||
# Help: list all available commands with descriptions (English and Chinese)
|
||||
help:
|
||||
@echo "Makefile for Quarto Project Automation"
|
||||
|
||||
Reference in New Issue
Block a user