✏️ 编辑:changelog
路径:
/virtual/bigbrother/public_html/edream-c.com/cr/SCRIPTS/changelog
大小:1.59 KB · 修改:2013-09-22 08:34:42 · 权限:0755 · 可写
← 返回目录
👁 查看
⬇ 下载
#!/usr/bin/python # -*- python -*- import os import re def pairs(a): previous = a[0] for i in a[1:]: yield previous, i previous = i f = os.popen('git tag', 'r') versions = [i.strip() for i in f] f.close() versions.sort(key = lambda x: [int(i) for i in x.split('.')]) versions.insert(0, '7236ceb319fb02e34394c091964c214510c735b2') versions.reverse() for a, b in pairs(versions): f = os.popen('git log %s..%s' % (b, a), 'r') state = '' logs = [] last_date = None for line in f: if line.startswith('commit'): continue if line.startswith('Author'): continue if line.startswith('Date'): first_date = re.sub('[+][0-9][0-9][0-9][0-9]', '', line[5:].strip()) first_date = re.sub('[0-9][0-9]:[0-9][0-9]:[0-9][0-9] ', '', first_date) if last_date is None: last_date = first_date state = 'date' continue if line == '\n': if state == 'date': state = 'title' continue line = line.strip(' \n') if line == '': continue if state == 'title': if line.startswith('Merge: ') or line.startswith('Merge branch'): pass else: logs.append('* ' + line) state = '' continue logs.append(' ' + line) print '\n' + '-'*79 print first_date, b, ' ===> ', last_date, a print '-'*79 print '\n'.join(logs) f.close()
💾 保存
取消
保存为 UTF-8,换行统一为 LF