我感動我的單調DVCS與git。在我的構建設置中,我有qmake獲取當前版本和當前分支(因爲這些分支是基於buildbot構建的),因此它可以用作定義。
exists(_MTN):DEFINES += BUILDREVISION=\\\"$$system(mtn automate get_base_revision_id)\\\"
else:DEFINES += BUILDREVISION=\\\"NOT \
BUILT \
FROM \
SOURCE \
REPOSITORY\\\"
# Check which branch we are building
exists(_MTN):DEFINES += BUILDBRANCH=\\\"$$system(mtn au get_option branch)\\\"
else:DEFINES += BUILDBRANCH=\\\"UNKNOWN\\\"
在混帳我可以這樣做:
exists(.git):DEFINES += BUILDREVISION=\\\"$$system(git rev-parse HEAD)\\\"
else:DEFINES += BUILDREVISION=\\\"NOT \
BUILT \
FROM \
SOURCE \
REPOSITORY\\\"
# Check which branch we are building
exists(.git):DEFINES += BUILDBRANCH=\\\"$$system(git show-branch --current)\\\"
else:DEFINES += BUILDBRANCH=\\\"UNKNOWN\\\"
我的問題是,「混帳秀分支--current」具有與它的提交信息,並在一個新的行字符,這我的編譯器不喜歡。我怎樣才能讓git更簡潔?