File: make_message

package info (click to toggle)
squeekboard 1.43.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,284 kB
  • sloc: ansic: 2,730; xml: 1,247; python: 296; sh: 48; makefile: 10
file content (36 lines) | stat: -rwxr-xr-x 1,039 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3

"""Extracts commit message for the last release from NEWS.md file.
"""

from itertools import dropwhile
import sys

with open('NEWS.md') as f:
    contents = f.readlines()

    if contents[0].startswith('## '):
        name = contents[0][3:]
        contents = contents[1:]
    elif contents[1].startswith('---'):
        name = contents[0]
        contents = contents[2:]
    else:
        raise ValueError("Can't find release name")
    name = name.strip()

print("Release", name)
# git wants a single newline between commit title and message body
print()
# meanwhile, markdown ignores newlines after a title
contents = dropwhile(lambda x: x.strip() == '', contents)

# Need to look up forward
contents = list(contents)

for line, nextline in zip(contents, contents[1:] + ['']):
    if nextline.startswith('---') or line.startswith('## '):
        break
    elif nextline.startswith('===') or line.startswith('# '):
        raise ValueError("Encountered title instead of release section")
    print(line.strip())