public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Tobias Burnus <tobias@codesourcery.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch] gcc-changelog: Add warning for auto-added files
Date: Fri, 16 Dec 2022 14:36:26 +0100	[thread overview]
Message-ID: <d5d68d21-4603-78c8-ee46-78c73180d868@suse.cz> (raw)
In-Reply-To: <f5c3e7dc-2244-99ca-c584-f157eca131b4@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

On 12/16/22 13:33, Tobias Burnus wrote:
> Thus, the auto-add feature does not seem to be an often used feature - neither on
> purpose nor accidentally. And glancing at the results, I think it was as often used
> on purpose as it was used accidentally.

Hello.

Understood, I do support the newly added warning with a small patch tweak.

> 
> I was wondering whether the commit hook should print this warning/note or not.

I would print it.

> It can be helpful in case something too much got committed, but for the usual
> case that the file was missed, it simply comes too late. (Frankly, I don't
> know whether the hook currently runs with '-v' or not.)

Cheers,
Martin

[-- Attachment #2: tweak.patch --]
[-- Type: text/x-patch, Size: 2304 bytes --]

diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py
index b9a60312099..e82fbcacd3e 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -22,6 +22,7 @@ import difflib
 import os
 import re
 import sys
+from collections import defaultdict
 
 default_changelog_locations = {
     'c++tools',
@@ -707,7 +708,7 @@ class GitCommit:
                 msg += f' (did you mean "{candidates[0]}"?)'
                 details = '\n'.join(difflib.Differ().compare([file], [candidates[0]])).rstrip()
             self.errors.append(Error(msg, file, details))
-        auto_add_warnings = {}
+        auto_add_warnings = defaultdict(list)
         for file in sorted(changed_files - mentioned_files):
             if not self.in_ignored_location(file):
                 if file in self.new_files:
@@ -740,10 +741,7 @@ class GitCommit:
                         file = file[len(entry.folder):].lstrip('/')
                         entry.lines.append('\t* %s: New file.' % file)
                         entry.files.append(file)
-                        if entry.folder not in auto_add_warnings:
-                            auto_add_warnings[entry.folder] = [file]
-                        else:
-                            auto_add_warnings[entry.folder].append(file)
+                        auto_add_warnings[entry.folder].append(file)
                     else:
                         msg = 'new file in the top-level folder not mentioned in a ChangeLog'
                         self.errors.append(Error(msg, file))
@@ -763,11 +761,9 @@ class GitCommit:
                 self.errors.append(Error(error, pattern))
         for entry, val in auto_add_warnings.items():
             if len(val) == 1:
-                self.warnings.append('Auto-added new file \'%s/%s\''
-                                     % (entry, val[0]))
+                self.warnings.append(f"Auto-added new file '{entry}/{val[0]}'")
             else:
-                self.warnings.append('Auto-added %d new files in \'%s\''
-                                     % (len(val), entry))
+                self.warnings.append(f"Auto-added {len(val)} new files in '{entry}'")
 
     def check_for_correct_changelog(self):
         for entry in self.changelog_entries:


      reply	other threads:[~2022-12-16 13:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 12:33 Tobias Burnus
2022-12-16 13:36 ` Martin Liška [this message]

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=d5d68d21-4603-78c8-ee46-78c73180d868@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.com \
    /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: link
Be 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).