3 Script to prepare the release of Gaudi. 5 @author Marco Clemencic 12 from subprocess
import check_output, CalledProcessError
17 Ensure we have a usable version of Git (>= 1.7.9.1). 20 * https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/1.7.9.1.txt 21 * https://github.com/git/git/commit/36ed1913e1d5de0930e59db6eeec3ccb2bd58bd9 23 version = check_output([
'git',
'--version']).split()[-1]
26 'bad version of git found: %s (1.7.9.1 required)' % version)
29 _VK_RE = re.compile(
r'(\d+|\D+)')
34 Key function to be passes to list.sort() to sort strings 38 int(i)
if i[0]
in '0123456789' else i
for i
in _VK_RE.split(x)
if i
44 Return the latest Gaudi tag (of the format "v*r*..."). 46 logging.info(
'looking for latest tag')
48 logging.debug(
'using command %r', cmd)
49 output = check_output(cmd)
50 vers_exp = re.compile(
r'^v\d+r\d+(p\d+)?$')
51 tags = [tag
for tag
in output.splitlines()
if vers_exp.match(tag)]
53 tags.sort(key=versionKey)
54 logging.info(
'found %s', tags[-1])
56 logging.info(
'no valid tag found')
61 Return the release notes (in the old LHCb format) extracted from git 62 commits for a given path. 65 'git',
'log',
'--first-parent',
'--date=short',
66 '--pretty=format:! %ad - commit %h%n%n%w(80,1,3)- %s%n%n%b%n' 69 cmd.append(
'{0}..{1}'.
format(from_tag, branch
or ''))
74 logging.info(
'preparing release notes for %s%s', path,
75 ' since ' + from_tag
if from_tag
else '')
76 logging.debug(
'using command %r', cmd)
78 out = check_output(cmd).replace(
'\r',
'')
81 def add_contributors(match):
87 '--pretty=format:%aN',
88 '{0}^1..{0}^2'.
format(match.group(1)),
90 return ' - {0} (commit {1})'.
format(
', '.join(sorted(authors)),
92 except CalledProcessError:
95 out = re.sub(
r' - commit ([0-9a-f]+)', add_contributors, out)
101 Smartly prepend the content of notes to the release.notes file in path. 103 notes_filename = os.path.join(path,
'doc',
'release.notes')
104 logging.info(
'updating %s', notes_filename)
105 from itertools
import takewhile, dropwhile
107 def dropuntil(predicate, iterable):
108 return dropwhile(
lambda x:
not predicate(x), iterable)
110 with open(notes_filename)
as notes_file:
111 orig_data = iter(list(notes_file))
112 header = takewhile(str.strip, orig_data)
113 with open(notes_filename,
'w')
as notes_file:
114 notes_file.writelines(header)
115 notes_file.write(
'\n')
116 notes_file.writelines(l.rstrip() +
'\n' for l
in notes.splitlines())
117 notes_file.write(
'\n')
118 notes_file.writelines(
119 dropuntil(re.compile(
r'^!?============').match, orig_data))
123 title =
' %s %s ' % (pkg, version)
124 letf_chars = (78 - len(title)) / 2
125 right_chars = 78 - letf_chars - len(title)
126 separator = (
'=' * letf_chars) + title + (
'=' * right_chars)
131 logging.basicConfig(level=logging.DEBUG)
132 os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
134 for l
in open(
'toolchain.cmake'):
135 m = re.match(
r'^\s*set\(\s*heptools_version\s+(\S*)\s*\)', l)
137 HEPToolsVers = m.group(1)
138 print "Using HEPTools", HEPToolsVers
141 logging.error(
'Cannot find HEPTools version')
146 for dirpath, dirnames, filenames
in os.walk(os.curdir):
147 if 'CMakeLists.txt' in filenames
and dirpath != os.curdir:
152 dirname
for dirname
in dirnames
153 if (
not dirname.startswith(
'build.')
and dirname !=
'cmake' 160 old_version = latest_tag.split(
'_')[-1]
161 new_version = raw_input((
"The old version of the project is %s, " 162 "which is the new one? ") % old_version)
166 for pkgdir
in all_subdirs():
170 pkgdir, latest_tag,
'master'))
174 for l
in open(
'CMakeLists.txt'):
175 if l.strip().startswith(
'gaudi_project'):
176 l =
'gaudi_project(Gaudi %s)\n' % new_version
178 open(
'CMakeLists.txt',
"w").writelines(out)
181 if __name__ ==
'__main__':
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
def releaseNotes(path=os.curdir, from_tag=None, branch=None)
def tag_bar(pkg, version=None)
def updateReleaseNotes(path, notes)