Update release script
This commit is contained in:
parent
5f9058dbd4
commit
bd3273021b
@ -229,27 +229,48 @@ def release(args):
|
|||||||
if not fmt_repo.update('-b', branch, fmt_repo_url):
|
if not fmt_repo.update('-b', branch, fmt_repo_url):
|
||||||
clean_checkout(fmt_repo, branch)
|
clean_checkout(fmt_repo, branch)
|
||||||
|
|
||||||
# Update the date in the changelog.
|
# Update the date in the changelog and extract the version and the first
|
||||||
|
# section content.
|
||||||
changelog = 'ChangeLog.md'
|
changelog = 'ChangeLog.md'
|
||||||
changelog_path = os.path.join(fmt_repo.dir, changelog)
|
changelog_path = os.path.join(fmt_repo.dir, changelog)
|
||||||
first_section = True
|
is_first_section = True
|
||||||
code_block = False
|
first_section = []
|
||||||
changes = ''
|
for i, line in enumerate(fileinput.input(changelog_path, inplace=True)):
|
||||||
for line in fileinput.input(changelog_path, inplace=True):
|
if i == 0:
|
||||||
m = re.match(r'# (.*) - TBD', line)
|
version = re.match(r'# (.*) - TBD', line).group(1)
|
||||||
if m:
|
|
||||||
version = m.group(1)
|
|
||||||
line = version + ' - ' + datetime.date.today().isoformat() + '\n'
|
line = version + ' - ' + datetime.date.today().isoformat() + '\n'
|
||||||
|
elif not is_first_section:
|
||||||
|
pass
|
||||||
elif line.startswith('#'):
|
elif line.startswith('#'):
|
||||||
first_section = False
|
is_first_section = False
|
||||||
elif first_section:
|
else:
|
||||||
changes_line = line
|
first_section.append(line)
|
||||||
if re.match(r'^\s*```', line):
|
|
||||||
code_block = not code_block
|
|
||||||
elif not code_block and line != '\n':
|
|
||||||
changes_line = line.rstrip() + ' '
|
|
||||||
changes += changes_line
|
|
||||||
sys.stdout.write(line)
|
sys.stdout.write(line)
|
||||||
|
if first_section[0] == '\n':
|
||||||
|
first_section.pop(0)
|
||||||
|
|
||||||
|
changes = ''
|
||||||
|
code_block = False
|
||||||
|
stripped = False
|
||||||
|
for line in first_section:
|
||||||
|
if re.match(r'^\s*```', line):
|
||||||
|
code_block = not code_block
|
||||||
|
changes += line
|
||||||
|
stripped = False
|
||||||
|
continue
|
||||||
|
if code_block:
|
||||||
|
changes += line
|
||||||
|
continue
|
||||||
|
if line == '\n':
|
||||||
|
changes += line
|
||||||
|
if stripped:
|
||||||
|
changes += line
|
||||||
|
stripped = False
|
||||||
|
continue
|
||||||
|
if stripped:
|
||||||
|
line = ' ' + line.lstrip()
|
||||||
|
changes += line.rstrip()
|
||||||
|
stripped = True
|
||||||
|
|
||||||
cmakelists = 'CMakeLists.txt'
|
cmakelists = 'CMakeLists.txt'
|
||||||
for line in fileinput.input(os.path.join(fmt_repo.dir, cmakelists),
|
for line in fileinput.input(os.path.join(fmt_repo.dir, cmakelists),
|
||||||
|
Loading…
Reference in New Issue
Block a user