jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/398509 )

Change subject: diff_checker.py: Fix the logic of calculating error state
......................................................................


diff_checker.py: Fix the logic of calculating error state

Also fix an encoding issue in Python 3 where `universal_newlines` parameter
in `subprocess.check_output` forces the result to be in text mode, but it also
needs to know the `encoding` of the result to correctly decode utf-8 diffs,
but `check_output` in Python 2 does not have the `encoding` parameter.
Therefore we have to decode the file and normalize newlines ourselves in both
Python 2 and 3.

Change-Id: I7ab6d63c1d213087e23481679c7ef2a8665835d9
---
M scripts/maintenance/diff_checker.py
1 file changed, 4 insertions(+), 5 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved



diff --git a/scripts/maintenance/diff_checker.py 
b/scripts/maintenance/diff_checker.py
index 957c247..734befd 100644
--- a/scripts/maintenance/diff_checker.py
+++ b/scripts/maintenance/diff_checker.py
@@ -51,10 +51,9 @@
     """Return the PatchSet for the latest commit."""
     # regex from https://github.com/PyCQA/pylint/blob/master/pylintrc
     output = check_output(
-        ['git', 'diff', '-U0', '@~..@'], universal_newlines=True)
-    if version_info.major == 2:
-        return PatchSet.from_string(output, encoding='utf-8')
-    return PatchSet.from_string(output)
+        ['git', 'diff', '-U0', '@~..@'])
+    return PatchSet.from_string(
+        output.replace(b'\r\n', b'\n'), encoding='utf-8')
 
 
 def print_error(path, line_no, col_no, error):
@@ -119,7 +118,7 @@
                     )
                     error = True
         if added_lines:
-            error = check_tokens(path, added_lines) and error
+            error = not check_tokens(path, added_lines) or error
     return not error
 
 

-- 
To view, visit https://gerrit.wikimedia.org/r/398509
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7ab6d63c1d213087e23481679c7ef2a8665835d9
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.w...@gmail.com>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to