* [PATCH b4] ez: treat cover-letter as git commit msg
@ 2023-01-12 17:52 Matthieu Baerts
2023-01-13 21:54 ` Konstantin Ryabitsev
0 siblings, 1 reply; 2+ messages in thread
From: Matthieu Baerts @ 2023-01-12 17:52 UTC (permalink / raw)
To: Kernel.org Tools; +Cc: Konstantin Ryabitsev, Matthieu Baerts
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>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH b4] ez: treat cover-letter as git commit msg
2023-01-12 17:52 [PATCH b4] ez: treat cover-letter as git commit msg Matthieu Baerts
@ 2023-01-13 21:54 ` Konstantin Ryabitsev
0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Ryabitsev @ 2023-01-13 21:54 UTC (permalink / raw)
To: Kernel.org Tools, Matthieu Baerts
On Thu, 12 Jan 2023 18:52:29 +0100, Matthieu Baerts wrote:
> 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'.
>
> [...]
Applied, thanks!
[1/1] ez: treat cover-letter as git commit msg
commit: d581e43b2135f37884d0fb6389f0b283e06ebd95
Best regards,
--
Konstantin Ryabitsev <konstantin@linuxfoundation.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-13 21:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12 17:52 [PATCH b4] ez: treat cover-letter as git commit msg Matthieu Baerts
2023-01-13 21:54 ` Konstantin Ryabitsev
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 NNTP newsgroup(s).