On 6/15/21 11:42 PM, Jason Merrill wrote:
On Tue, Jun 15, 2021 at 10:04 PM Martin Sebor via Gcc <gcc@gcc.gnu.org
<mailto:gcc@gcc.gnu.org>> wrote:
On 6/15/21 6:56 PM, Hans-Peter Nilsson wrote:
> On Fri, 11 Jun 2021, Martin Sebor via Gcc wrote:
>
>> On 6/11/21 11:32 AM, Jonathan Wakely wrote:
>>> On Fri, 11 Jun 2021 at 18:02, Martin Sebor wrote:
>>>> My objection is to making our policies and tools more restrictive
>>>> than they need to be. We shouldn't expect everyone to study whole
>>>> manuals just to figure out how to successfully commit a change (or
>>>> learn how to format it just the right way). It should be easy.
>>>
>>> I agree, to some extent. But consistency is also good. The
conventions
>>> for GNU ChangeLog formatting exist for a reason, and so do the
>>> conventions for good Git commit messages.
>>>
>>>> Setting this discussion aside for a moment and using a different
>>>> example, the commit hook rejects commit messages that don't start
>>>> ChangeLog entries with tabs. It also rejects commit messages that
>>>> don't list all the same test files as those changed by the commit
>>>> (and probably some others as well). That's in my view unnecessary
>>>> when the hook could just replace the leading spaces with tabs and
>>>> automatically mention all the tests.
>>>>
>>>> I see this proposal as heading in the same direction. Rather than
>>>> making the script fix things up if we get them wrong it would
reject
>>>> the commit, requiring the user to massage the ChangeLog by
hand into
>>>> an unnecessarily rigid format.
>>>
>>> You cannot "fix things up" in a server-side receive hook, because
>>> changing the commit message would alter the commit hash, which
would
>>> require the committer to do a rebase to proceed. That breaks the
>>> expected behaviour and workflow of a git repo.
>>>
>>> You can use the scripts on the client side to verify your commit
>>> message before pushing, so you don't have to be surprised when the
>>> server rejects it.
>>
>> That sounds like a killer argument. Do we have shared client-side
>> scripts that could fix things up for us, or are we each on our own
>> to write them?
>
> I hope I got your view wrong. If not: the "scripts fixing
> things up for us" direction is flawed (compared to the "scripts
> rejecting bad formats"), unless offered as a non-default option;
> please don't proceed.
>
> Why? For one, there'll always be bugs in the scripting.
> Mitigate those situations: while wrongly rejecting a commit is
> bad, wrongly "fixing things up" is worse, as a general rule.
> Better avoid that. (There's probably a popular "pattern name"
> for what I try to describe.)
The word that comes to mind is Technophobia. Is it wise to trust
compilers to transform programs from their source form into
executables? What if there are bugs in either? What about the OS?
The whole computer, or the Internet? Our cars? Fortunately, there's
more to gain than to lose by trusting automation. If there weren't
human progress would be stuck sometime in the 1700's.
But we're not talking about anything anywhere that sophisticated
here: a sed script to copy and paste a piece of text in
the description of a change from one place to another. It's been
done a few times before with more important data than ChangeLogs.
git gcc-commit-mklog already automates most of the process. It could
also automate adding [PRxxxxx] to the first line. Is that what you're
asking for?
Like, say:
>From a4e1c5eef3491e3d2e72a01e864af204f124a994 Mon Sep 17 00:00:00 2001
From: Jason Merrill <ja...@redhat.com>
Date: Wed, 16 Jun 2021 16:46:38 -0400
Subject: [PATCH] mklog: add subject line skeleton
To: gcc-patc...@gcc.gnu.org
contrib/ChangeLog:
* mklog.py: Add an initial component: [PRnnnnn] line when
we have a PR.
---
contrib/mklog.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/contrib/mklog.py b/contrib/mklog.py
index 5c93c707128..6113ae30a8e 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,7 @@ 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 +136,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 +169,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 +314,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 (start[0] == ''):
+ # initial commit subject line 'component: [PRnnnnn]'
+ m = prnum_regex.match(firstpr)
+ if m:
+ start.insert (0, m.group('comp') + ': [PR'
+ + m.group('num') + ']')
if start:
- # appent empty line
+ # append empty line
if start[-1] != '':
start.append('')
else:
--
2.27.0