* [gentoo-portage-dev] [PATCH] repoman commit: Prefix commit message template with cat/PN
@ 2015-08-10 14:06 Michał Górny
2015-08-10 14:46 ` Michał Górny
0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2015-08-10 14:06 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Michał Górny
---
bin/repoman | 9 +++++++--
pym/repoman/utilities.py | 7 +++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/bin/repoman b/bin/repoman
index 7cb32ce..1ba7841 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -2696,16 +2696,21 @@ else:
# We've read the content so the file is no longer needed.
commitmessagefile = None
if not commitmessage or not commitmessage.strip():
+ msg_prefix = ""
+ if repolevel > 1:
+ msg_prefix = "/".join(reposplit[1:]) + ": "
+
try:
editor = os.environ.get("EDITOR")
if editor and utilities.editor_is_executable(editor):
commitmessage = utilities.get_commit_message_with_editor(
- editor, message=qa_output)
+ editor, message=qa_output, prefix=msg_prefix)
else:
commitmessage = utilities.get_commit_message_with_stdin()
except KeyboardInterrupt:
exithandler()
- if not commitmessage or not commitmessage.strip():
+ if (not commitmessage or not commitmessage.strip()
+ or commitmessage.strip() == msg_prefix):
print("* no commit message? aborting commit.")
sys.exit(1)
commitmessage = commitmessage.rstrip()
diff --git a/pym/repoman/utilities.py b/pym/repoman/utilities.py
index b9594a7..f2d5fd8 100644
--- a/pym/repoman/utilities.py
+++ b/pym/repoman/utilities.py
@@ -399,7 +399,7 @@ def editor_is_executable(editor):
return os.access(filename, os.X_OK) and os.path.isfile(filename)
-def get_commit_message_with_editor(editor, message=None):
+def get_commit_message_with_editor(editor, message=None, prefix=""):
"""
Execute editor with a temporary file as it's argument
and return the file content afterwards.
@@ -408,13 +408,16 @@ def get_commit_message_with_editor(editor, message=None):
@type: string
@param message: An iterable of lines to show in the editor.
@type: iterable
+ @param prefix: Suggested prefix for the commit message summary line.
+ @type: string
@rtype: string or None
@return: A string on success or None if an error occurs.
"""
fd, filename = mkstemp()
try:
os.write(fd, _unicode_encode(_(
- "\n# Please enter the commit message " + \
+ prefix +
+ "\n\n# Please enter the commit message " + \
"for your changes.\n# (Comment lines starting " + \
"with '#' will not be included)\n"),
encoding=_encodings['content'], errors='backslashreplace'))
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] repoman commit: Prefix commit message template with cat/PN
2015-08-10 14:06 [gentoo-portage-dev] [PATCH] repoman commit: Prefix commit message template with cat/PN Michał Górny
@ 2015-08-10 14:46 ` Michał Górny
0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2015-08-10 14:46 UTC (permalink / raw
To: gentoo-portage-dev
[-- Attachment #1: Type: text/plain, Size: 335 bytes --]
Dnia 2015-08-10, o godz. 16:06:31
Michał Górny <mgorny@gentoo.org> napisał(a):
> ---
> bin/repoman | 9 +++++++--
> pym/repoman/utilities.py | 7 +++++--
> 2 files changed, 12 insertions(+), 4 deletions(-)
Pushed now after IRC review.
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-10 14:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-10 14:06 [gentoo-portage-dev] [PATCH] repoman commit: Prefix commit message template with cat/PN Michał Górny
2015-08-10 14:46 ` Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox