
gitinfo2
我將 TeXLive 2017 中的套件 (2.0.7) 與套件 (v1.1c) 一起使用ifthen
,以便將 Git 元資料包含在我的文件中:
\documentclass{article}
\usepackage[local]{gitinfo2}
\usepackage{ifthen}
\begin{document}
commit \gitAbbrevHash
\ifthenelse{\equal{\gitBranch}{master}}{}{ on branch \gitBranch}%
\ifthenelse{\equal{\gitDirty}{}}{}{ with local changes}
\end{document}
目的是應該列印分支的名稱,但前提是它不是主分支。因此,對於這個例子,我只期望“commit e78b91e”。然而,結果是「在分支主機上提交 e78b91e」。
換句話說, 的測試\gitBranch
總是評估為假(而 的測試\gitDirty
工作正常)。我缺什麼?
這是文件的內容gitHeadLocal.gin
:
\usepackage[%
shash={e78b91e},
lhash={e78b91e0e8582d75273ad4f04bda5ae3c52055bd},
authname={Abcd Efgh},
authemail={[email protected]},
authsdate={2018-02-19},
authidate={2018-02-19 20:00:05 +0100},
authudate={1519066805},
commname={Abcd Efgh},
commemail={[email protected]},
commsdate={2018-02-19},
commidate={2018-02-19 20:02:01 +0100},
commudate={1519066921},
refnames={ (HEAD -> master)},
firsttagdescribe={e78b91e},
reltag={e78b91e}
]{gitexinfo}
答案1
如果套餐設定
\gitBranch=\long macro: ->\detokenize \expandafter {\bcut }
然後,如果您嘗試測試當前檔案名,您會遇到相同的問題,因為\jobname
字元都是 catcode 12(如標點符號)而不是 catcode 11(字母),但是您可以使用相同的\detokenize
e-tex 原語來獲取catcode 12 測試字串,測試\detokenize{master}
而不是master
。