2007-03-10 11:30:03 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2008-12-28 16:55:48 +00:00
|
|
|
import os.path, re, sys, textwrap
|
2007-03-10 11:30:03 +00:00
|
|
|
|
|
|
|
class Version(object):
|
|
|
|
_rules = ur"^(\d+\.\d+\.\d+)\.(\d+)$"
|
|
|
|
_re = re.compile(_rules)
|
|
|
|
|
|
|
|
def __init__(self, version):
|
|
|
|
self.complete = version
|
|
|
|
match = self._re.match(version)
|
|
|
|
if match is None:
|
|
|
|
raise RuntimeError
|
|
|
|
self.release = match.group(1)
|
|
|
|
self.patch = int(match.group(2))
|
|
|
|
|
|
|
|
class GenPatch(object):
|
|
|
|
def __init__(self, path, repo, version):
|
|
|
|
self.path = path
|
|
|
|
self.repo = repo
|
|
|
|
self.version = version
|
|
|
|
|
|
|
|
def __call__(self):
|
2007-03-24 10:11:19 +00:00
|
|
|
base = self.version.complete
|
|
|
|
patch = base + '.patch'
|
|
|
|
log = base + '.log'
|
|
|
|
series = base + '.series'
|
|
|
|
|
2007-03-10 11:30:03 +00:00
|
|
|
if self.version.patch == 1:
|
|
|
|
tag_in = "v%s" % self.version.release
|
|
|
|
else:
|
|
|
|
tag_in = "v%s.%d" % (self.version.release, self.version.patch - 1)
|
|
|
|
tag_out = "v%s" % self.version.complete
|
|
|
|
print tag_in, tag_out
|
|
|
|
|
2007-03-24 10:11:19 +00:00
|
|
|
f = os.popen("cd %s; git diff %s %s | filterdiff -p 1 -x Makefile > %s" % (self.repo, tag_in, tag_out, os.path.join(self.path, patch)))
|
|
|
|
if f.close() is not None:
|
|
|
|
raise RuntimeError
|
|
|
|
|
2007-06-26 10:27:56 +00:00
|
|
|
f = os.popen("cd %s; git log --pretty=oneline -r %s..%s^" % (self.repo, tag_in, tag_out))
|
2007-03-24 10:11:19 +00:00
|
|
|
out = file(os.path.join(self.path, log), 'w')
|
2007-03-10 11:30:03 +00:00
|
|
|
out.write(" * Add stable release %s:\n" % self.version.complete)
|
|
|
|
for line in f:
|
|
|
|
line = line.strip()
|
|
|
|
if not line:
|
|
|
|
continue
|
|
|
|
hash, log = line.split(' ', 1)
|
2008-12-28 16:55:48 +00:00
|
|
|
log = textwrap.wrap(log, 74)
|
|
|
|
log = '\n '.join(log)
|
2007-03-10 11:30:03 +00:00
|
|
|
out.write(" - %s\n" % log)
|
2007-03-24 10:11:19 +00:00
|
|
|
if f.close() is not None:
|
|
|
|
raise RuntimeError
|
|
|
|
|
|
|
|
out = file(os.path.join(self.path, series), 'w')
|
|
|
|
out.write("+ bugfix/all/stable/%s\n" % patch)
|
|
|
|
out.close()
|
2007-03-10 11:30:03 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
path = os.path.realpath(os.path.dirname(sys.argv[0]))
|
|
|
|
repo = sys.argv[1]
|
|
|
|
for i in sys.argv[2:]:
|
|
|
|
GenPatch(path, repo, Version(i))()
|