changeset 7159:9cef5615da7b

issues: simplify example in ini file The example setting from the default ini file is: issue_pat = (?:\s*#)(\d+) issue_server_link = https://issues.example.com/{repo}/issue/{id} issue_prefix = # in which the clause '(?:\s*#)' is overly complex: 1. '\s*' means optional whitespace, which means there can be whitespace or no whitespace, which means that you could equally write: (?:#)(\d+) (If any leading whitespace was eaten by the regexp, 32e1e0745d3c would take care to restore a part of it.) 2. '(?:xxx)' means a non-capturing set of parentheses. In this case this is equal to just mentioning 'xxx'. So the simplified pattern becomes: #(\d+) If instead of _optional_ whitespace, _mandatory_ whitespace was intended, then the pattern should be different. But this would also mean that patterns like PR#123 would not be matched anymore.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Fri, 09 Feb 2018 20:19:32 +0100
parents 62b7f3d2434a
children 2b2e37660e95
files development.ini kallithea/lib/paster_commands/template.ini.mako
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/development.ini	Tue Feb 13 08:36:26 2018 +0100
+++ b/development.ini	Fri Feb 09 20:19:32 2018 +0100
@@ -175,7 +175,7 @@
 ## default one used here is #<numbers> with a regex passive group for `#`
 ## {id} will be all groups matched from this pattern
 
-issue_pat = (?:\s*#)(\d+)
+issue_pat = #(\d+)
 
 ## server url to the issue, each {id} will be replaced with match
 ## fetched from the regex and {repo} is replaced with full repository name
--- a/kallithea/lib/paster_commands/template.ini.mako	Tue Feb 13 08:36:26 2018 +0100
+++ b/kallithea/lib/paster_commands/template.ini.mako	Fri Feb 09 20:19:32 2018 +0100
@@ -268,7 +268,7 @@
 <%text>## default one used here is #<numbers> with a regex passive group for `#`</%text>
 <%text>## {id} will be all groups matched from this pattern</%text>
 
-issue_pat = (?:\s*#)(\d+)
+issue_pat = #(\d+)
 
 <%text>## server url to the issue, each {id} will be replaced with match</%text>
 <%text>## fetched from the regex and {repo} is replaced with full repository name</%text>