jenkins-bot has submitted this change and it was merged.
Change subject: handleArgs: Reformat the regex for version to not break on old git
versions
......................................................................
handleArgs: Reformat the regex for version to not break on old git versions
On at least Git 1.7.0.4 `git checkout -- pywikibot/bot.py` still results in
those two lines getting automatically changed to
m = re.search(r"\$Id$", ver)
when using `git diff` and
m = re.search(r"\$Id: blob-object-name", ver)
in the file itself.
This breaks further code because the regular expession doesn't match
pywikibot.__version__ and thus `m` is None but is used by the code later on as
if it were not None.
This seems to have been fixed in later git versions (at least 1.7.9.5 and 1.8.4
don't show this behaviour).
Change-Id: If3ddc5c86c8ef2f9214f367eed3634f708c8a440
---
M pywikibot/bot.py
1 file changed, 7 insertions(+), 2 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 508bb7f..8aaa050 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -643,8 +643,13 @@
if config.verbose_output:
import re
ver = pywikibot.__version__ # probably can be improved on
- m = re.search(r"\$Id: (\w+) "
- r"\$", ver)
+ # Please don't change the regular expression here unless you really
+ # have to - some git versions (like 1.7.0.4) seem to treat lines
+ # containing just `$Id:` as if they were ident lines (see
+ # gitattributes(5)) leading to unwanted behaviour like automatic
+ # replacement with `$Id$` or `$Id$`.
+ m = re.search(r"\$Id"
+ r": (\w+) \$", ver)
pywikibot.output(u'Pywikipediabot r%s' % m.group(1))
pywikibot.output(u'Python %s' % sys.version)
--
To view, visit
https://gerrit.wikimedia.org/r/81575
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If3ddc5c86c8ef2f9214f367eed3634f708c8a440
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mineo <themineo(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot