代码拉取完成,页面将自动刷新
##
# :namespace buildVersion
#
# :remarks Queries git for version specific info and automaticly generates version.h
#
# :author mikeh@blur.com
# :author Blur Studio
# :date 05/11/15
#
import sys
import re
import datetime
from subprocess import Popen, PIPE
def interrogateGit(arguments, regex):
p = Popen(arguments, stdout=PIPE)
ret, err = p.communicate()
if err:
sys.exit(err)
match = re.match(regex, ret)
if not match:
print 'Unable to find match'
print [ret]
print regex
sys.exit(2)
return match
gitVersion = interrogateGit(
['git', 'describe', '--long'],
r'v(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)-\d+-(?P<rev>[\w]+)'
)
data = gitVersion.groupdict()
revCount = interrogateGit(['git', 'rev-list', 'HEAD', '--count'], r'\d+')
data['revCount'] = revCount.group(0)
time = datetime.datetime.now()
data['datetime'] = time.strftime('%Y/%m/%d %H:%M:%S')
with open('version_h_template.txt') as r:
text = r.read()
with open('version.h', 'w') as v:
output = text.format(**data)
v.write(output)
sys.exit(0)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。