jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/668344 )
Change subject: [IMPR] Add replacement description to -summary message ......................................................................
[IMPR] Add replacement description to -summary message
To add the replacements to -summary option a %(description)s placeholder must be used. For example: -summary:"Bot operated replacement:%(description)s done." includes all replacements within the summary string like "Bot operated replacement: (-a +b) done."
Change-Id: I21bb8ce1f53f0155f608e12a4f6b3f3f2dfafada --- M scripts/replace.py 1 file changed, 14 insertions(+), 10 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py index a9187e8..7f4399c 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -57,7 +57,10 @@
-summary:XYZ Set the summary message text for the edit to XYZ, bypassing the predefined message texts with original and replacements - inserted. Can't be used with -automaticsummary. + inserted. To add the replacements to your summary use the + %(description)s placeholder, for example: + -summary:"Bot operated replacement: %(description)s" + Can't be used with -automaticsummary.
-automaticsummary Uses an automatic summary for all replacements which don't have a summary defined. Can't be used with -summary. @@ -640,19 +643,20 @@ summary_messages.add(replacement.edit_summary) elif replacement.default_summary: default_summaries.add((replacement.old, replacement.new)) + summary_messages = sorted(summary_messages) if default_summaries: if self.opt.summary: - summary_messages.insert(0, self.opt.summary) + msg = self.opt.summary else: - comma = self.site.mediawiki_message('comma-separator') - default_summary = comma.join( - '-{0} +{1}'.format(*default_summary) - for default_summary in default_summaries) - summary_messages.insert(0, i18n.twtranslate( - self.site, 'replace-replacing', - {'description': ' ({0})'.format(default_summary)} - )) + msg = i18n.twtranslate(self.site, 'replace-replacing') + comma = self.site.mediawiki_message('comma-separator') + default_summary = comma.join( + '-{} +{}'.format(*default_summary) + for default_summary in default_summaries) + desc = {'description': ' ({})'.format(default_summary)} + summary_messages.insert(0, msg % desc) + semicolon = self.site.mediawiki_message('semicolon-separator') return semicolon.join(summary_messages)