jenkins-bot has submitted this change and it was merged. Change subject: Allow lines >100 chars if they are URLs ......................................................................
Allow lines >100 chars if they are URLs Lines >100 chars are allowed if they look like http/https URLs optionally wrapped in <>. The validation isn't precise and will allow unbalanced braces, but seriously is that horrible? Bug: T142800 Change-Id: I8f400441de6d53b073f9c637a3ac73f1d37e7538 --- M commit_message_validator/__init__.py M commit_message_validator/tests/data/check_message_ok.msg A commit_message_validator/tests/data/really_long_url_ok.msg A commit_message_validator/tests/data/really_long_url_ok.out M commit_message_validator/tests/test_commit-message-validator.py 5 files changed, 17 insertions(+), 6 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/commit_message_validator/__init__.py b/commit_message_validator/__init__.py old mode 100755 new mode 100644 index 1969448..ee64e30 --- a/commit_message_validator/__init__.py +++ b/commit_message_validator/__init__.py @@ -34,7 +34,7 @@ Checks: - First line <=80 characters - Second line blank - - No line >100 characters + - No line >100 characters (unless it is only a URL) - "Bug:" is capitalized - "Bug:" is followed by a space - Exactly one task id on each Bug: line @@ -56,9 +56,11 @@ if line: yield "Second line should be empty" - # No line >100 + # No line >100 unless it is all a URL elif len(line) > 100: - yield "Line should be <=100 characters" + m = re.match(r'^<?https?://\S+>?$', line, re.IGNORECASE) + if not m: + yield "Line should be <=100 characters" m = re.match(r'^(bug|closes|fixes|task):(\W)*(.*)', line, re.IGNORECASE) if m: diff --git a/commit_message_validator/tests/data/check_message_ok.msg b/commit_message_validator/tests/data/check_message_ok.msg index a7fb18a..d90f841 100644 --- a/commit_message_validator/tests/data/check_message_ok.msg +++ b/commit_message_validator/tests/data/check_message_ok.msg @@ -9,7 +9,7 @@ Other checks: - First line <=80 characters - Second line blank -- No line >100 characters +- No line >100 characters unless it is a URL - "Bug:" is capitalized - "Bug:" is followed by a space - Exactly one task id on each Bug: line diff --git a/commit_message_validator/tests/data/really_long_url_ok.msg b/commit_message_validator/tests/data/really_long_url_ok.msg new file mode 100644 index 0000000..8f705c0 --- /dev/null +++ b/commit_message_validator/tests/data/really_long_url_ok.msg @@ -0,0 +1,7 @@ +A commit with a really long URL is valid + +This commit message includes a URL that is >100 characters but that's ok as +long as it is on a line by itself. +http://www.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com/is_actually_a_valid_and_live_domain.html + +Change-Id: I395fd614bfa8bcfc46a35f955fb77ec6f03f7a0b diff --git a/commit_message_validator/tests/data/really_long_url_ok.out b/commit_message_validator/tests/data/really_long_url_ok.out new file mode 100644 index 0000000..76dfe33 --- /dev/null +++ b/commit_message_validator/tests/data/really_long_url_ok.out @@ -0,0 +1,2 @@ +commit-message-validator v%version% +Commit message is formatted properly! Keep up the good work! diff --git a/commit_message_validator/tests/test_commit-message-validator.py b/commit_message_validator/tests/test_commit-message-validator.py index ae8101d..866b3fe 100644 --- a/commit_message_validator/tests/test_commit-message-validator.py +++ b/commit_message_validator/tests/test_commit-message-validator.py @@ -22,6 +22,8 @@ file pairs where there is a `.msg` and `.out` file. If both exist it'll create a test for this pair where the `.msg` is the commit message and the `.out` is the expected output. + + Filenames for tests that will pass validation must end with 'ok'. """ def __new__(cls, name, bases, dct): @@ -54,9 +56,7 @@ class TestCommitMessageValidator(with_metaclass(MetaValidator, unittest.TestCase)): - """Validate the commit messages using test files.""" - pass -- To view, visit https://gerrit.wikimedia.org/r/304430 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8f400441de6d53b073f9c637a3ac73f1d37e7538 Gerrit-PatchSet: 2 Gerrit-Project: integration/commit-message-validator Gerrit-Branch: master Gerrit-Owner: BryanDavis <bda...@wikimedia.org> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Paladox <thomasmulhall...@yahoo.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits