From: Matthieu Baerts <matthieu.baerts@tessares.net>
To: "Kernel.org Tools" <tools@linux.kernel.org>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
Matthieu Baerts <matthieu.baerts@tessares.net>
Subject: [PATCH b4] ez: treat cover-letter as git commit msg
Date: Thu, 12 Jan 2023 18:52:29 +0100 [thread overview]
Message-ID: <20230112-cover-letter-72-chars-v1-1-69b15b1e3fef@tessares.net> (raw)
It is common to write the cover-letter in a merge commit message. For
this reason, it is recommended to wrap it at 72 chars and have a short
title. It is like a git commit message at the end while lines starting
with '#' will be ignored.
For this reason and to "trick" the text editor, the temp file is now
called COMMIT_EDITMSG like the one generated by 'git commit'.
At the end, the file didn't contain any restructured-text format.
While at it, the default template is also wrapped to 72 chars.
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
b4/ez.py | 41 +++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/b4/ez.py b/b4/ez.py
index 82500e3..2b6c0d6 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -451,21 +451,22 @@ def start_new_series(cmdargs: argparse.Namespace) -> None:
# create a default cover letter and store it where the strategy indicates
cover = ('EDITME: cover title for %s' % seriesname,
'',
- '# Lines starting with # will be removed from the cover letter. You can use',
- '# them to add notes or reminders to yourself.',
+ '# Lines starting with # will be removed from the cover letter. You can',
+ '# use them to add notes or reminders to yourself.',
'',
- 'EDITME: describe the purpose of this series. The information you put here',
- 'will be used by the project maintainer to make a decision whether your',
- 'patches should be reviewed, and in what priority order. Please be very',
- 'detailed and link to any relevant discussions or sites that the maintainer',
- 'can review to better understand your proposed changes. If you only have a',
- 'single patch in your series, the contents of the cover letter will be',
- 'appended to the "under-the-cut" portion of the patch.',
+ 'EDITME: describe the purpose of this series. The information you put',
+ 'here will be used by the project maintainer to make a decision whether',
+ 'your patches should be reviewed, and in what priority order. Please be',
+ 'very detailed and link to any relevant discussions or sites that the',
+ 'maintainer can review to better understand your proposed changes. If you',
+ 'only have a single patch in your series, the contents of the cover',
+ 'letter will be appended to the "under-the-cut" portion of the patch.',
'',
'# You can add trailers to the cover letter. Any email addresses found in',
- '# these trailers will be added to the addresses specified/generated during',
- '# the b4 send stage. You can also run "b4 prep --auto-to-cc" to auto-populate',
- '# the To: and Cc: trailers based on the code being modified.',
+ '# these trailers will be added to the addresses specified/generated',
+ '# during the b4 send stage. You can also run "b4 prep --auto-to-cc" to',
+ '# auto-populate the To: and Cc: trailers based on the code being',
+ '# modified.',
'',
'Signed-off-by: %s <%s>' % (usercfg.get('name', ''), usercfg.get('email', '')),
'',
@@ -686,17 +687,21 @@ def edit_cover() -> None:
corecfg = b4.get_config_from_git(r'core\..*', {'editor': os.environ.get('EDITOR', 'vi')})
editor = corecfg.get('editor')
logger.debug('editor=%s', editor)
- # We give it a suffix .rst in hopes that editors autoload restructured-text rules
- with tempfile.NamedTemporaryFile(suffix='.rst') as temp_cover:
- temp_cover.write(cover.encode())
- temp_cover.seek(0)
+ # Use COMMIT_EDITMSG name in hopes that editors autoload git commit rules
+ with tempfile.TemporaryDirectory(prefix='b4-') as temp_dir:
+ temp_fpath = os.path.join(temp_dir, 'COMMIT_EDITMSG')
+ with open(temp_fpath, 'xb') as temp_cover:
+ temp_cover.write(cover.encode())
+
sp = shlex.shlex(editor, posix=True)
sp.whitespace_split = True
- cmdargs = list(sp) + [temp_cover.name]
+ cmdargs = list(sp) + [temp_fpath]
logger.debug('Running %s' % ' '.join(cmdargs))
sp = subprocess.Popen(cmdargs)
sp.wait()
- new_cover = temp_cover.read().decode(errors='replace').strip()
+
+ with open(temp_fpath, 'rb') as temp_cover:
+ new_cover = temp_cover.read().decode(errors='replace').strip()
if new_cover == cover:
logger.info('Cover letter unchanged.')
---
base-commit: 5b2056d4002a1d71dc64c56ee65585c5d8739c32
change-id: 20230112-cover-letter-72-chars-82141c15333b
Best regards,
--
Matthieu Baerts <matthieu.baerts@tessares.net>
next reply other threads:[~2023-01-12 17:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 17:52 Matthieu Baerts [this message]
2023-01-13 21:54 ` [PATCH b4] ez: treat cover-letter as git commit msg Konstantin Ryabitsev
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=20230112-cover-letter-72-chars-v1-1-69b15b1e3fef@tessares.net \
--to=matthieu.baerts@tessares.net \
--cc=konstantin@linuxfoundation.org \
--cc=tools@linux.kernel.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: 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).