我感动我的单调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更简洁?