public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1601] mklog: add subject line skeleton Date: Thu, 17 Jun 2021 17:16:38 +0000 (GMT) [thread overview] Message-ID: <20210617171638.93E33393D02D@sourceware.org> (raw) https://gcc.gnu.org/g:58e3b17f4c42d050a1768b025712e6d18bcb76ae commit r12-1601-g58e3b17f4c42d050a1768b025712e6d18bcb76ae Author: Jason Merrill <jason@redhat.com> Date: Wed Jun 16 16:46:38 2021 -0400 mklog: add subject line skeleton In the recent gcc-commit-mklog thread on gcc@ it occurred to me that the command could also fill in part of the subject line. If the first PR is foo/1234, and the commit does not yet have a subject line, this will add foo: [PR1234] contrib/ChangeLog: * mklog.py: Add an initial component: [PRnnnnn] line when we have a PR. Diff: --- contrib/mklog.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/mklog.py b/contrib/mklog.py index 5c93c707128..1f59055e723 100755 --- a/contrib/mklog.py +++ b/contrib/mklog.py @@ -39,6 +39,7 @@ import requests from unidiff import PatchSet pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)') +prnum_regex = re.compile(r'PR (?P<comp>[a-z+-]+)/(?P<num>[0-9]+)') dr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<dr>DR [0-9]+)') dg_regex = re.compile(r'{\s+dg-(error|warning)') identifier_regex = re.compile(r'^([a-zA-Z0-9_#].*)') @@ -67,6 +68,8 @@ PATCH must be generated using diff(1)'s -up or -cp options script_folder = os.path.realpath(__file__) root = os.path.dirname(os.path.dirname(script_folder)) +firstpr = '' + def find_changelog(path): folder = os.path.split(path)[0] @@ -134,6 +137,7 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False): prs = [] out = '' diff = PatchSet(data) + global firstpr for file in diff: # skip files that can't be parsed @@ -166,6 +170,9 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False): # Found dg-warning/dg-error line break + if prs: + firstpr = prs[0] + if fill_pr_titles: out += get_pr_titles(prs) @@ -308,8 +315,14 @@ if __name__ == '__main__': start = list(takewhile(lambda l: not l.startswith('#'), lines)) end = lines[len(start):] with open(args.changelog, 'w') as f: + if not start or not start[0]: + # initial commit subject line 'component: [PRnnnnn]' + m = prnum_regex.match(firstpr) + if m: + title = f'{m.group("comp")}: [PR{m.group("num")}]' + start.insert(0, title) if start: - # appent empty line + # append empty line if start[-1] != '': start.append('') else:
reply other threads:[~2021-06-17 17:16 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210617171638.93E33393D02D@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).