Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImprove tidy's license validation logic #12781
Conversation
highfive
commented
Aug 9, 2016
|
Heads up! This PR modifies the following files:
|
| @@ -150,3 +154,7 @@ def test_file_list(self): | |||
| def do_tests(): | |||
| suite = unittest.TestLoader().loadTestsFromTestCase(CheckTidiness) | |||
| return 0 if unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() else 1 | |||
| unittest.TextTestRunner(verbosity=2).run(suite) | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
With last commit i added grabbing actual comment block, and also added checking for blank line after shebang, so that doesn't messed up license check. |
|
The travis failure is unrelated to these changes. |
| @@ -7,97 +7,14 @@ | |||
| # option. This file may not be copied, modified, or distributed | |||
| # except according to those terms. | |||
|
|
|||
| mpl = "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/" | |||
This comment has been minimized.
This comment has been minimized.
aneeshusa
Aug 10, 2016
Member
Why put these onto a single line? AFAIK the indentation never changes, just the comment character at the start of each line. IMO this form is nicer:
mpl = """\
This Source Code...
""",
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Aug 10, 2016
Member
Style Nit: Also, the name could be in uppercase, since it's a constant (even though it doesn't make any difference in python).
This comment has been minimized.
This comment has been minimized.
UK992
Aug 10, 2016
Author
Contributor
@aneeshusa i changed it to this type of form, and before matching with header remove all newlines.
|
|
||
|
|
||
| def licensed_mpl(header): | ||
| if licenseck.mpl in header: |
This comment has been minimized.
This comment has been minimized.
|
|
||
| # These licenses are valid for use in Servo | ||
| licenses = [ | ||
| apache = "Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. This file may not be copied, modified, or distributed except according to those terms." |
This comment has been minimized.
This comment has been minimized.
| copyright = [ | ||
| "See the COPYRIGHT file at the top-level directory of this distribution", | ||
| "See http://rust-lang.org/COPYRIGHT", | ||
| ] |
This comment has been minimized.
This comment has been minimized.
| yield (1, "missing blank line after shebang") | ||
|
|
||
| blank_lines = 0 | ||
| MAX_BLANK_LINES = 2 if lines[0].startswith("#!") else 1 |
This comment has been minimized.
This comment has been minimized.
| @@ -150,3 +159,6 @@ def test_file_list(self): | |||
| def do_tests(): | |||
| suite = unittest.TestLoader().loadTestsFromTestCase(CheckTidiness) | |||
| return 0 if unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() else 1 | |||
|
|
|||
| if __name__ == "__main__": | |||
| do_tests() | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -1,6 +1,17 @@ | |||
| Release History | |||
| --------------- | |||
|
|
|||
| 0.1.0 (2016-04-19) | |||
This comment has been minimized.
This comment has been minimized.
|
|
||
| def licensed_apache(header): | ||
| if licenseck.apache in header: | ||
| for copyright in licenseck.copyright: |
This comment has been minimized.
This comment has been minimized.
| @@ -305,7 +339,7 @@ def check_toml(file_name, lines): | |||
| for idx, line in enumerate(lines): | |||
| if line.find("*") != -1: | |||
| yield (idx + 1, "found asterisk instead of minimum version number") | |||
| for license in licenses_toml: | |||
| for license in licenseck.licenses_toml: | |||
This comment has been minimized.
This comment has been minimized.
|
Addressed all reviews. |
| @@ -139,3 +66,4 @@ | |||
| 'name = "webrender"', | |||
| 'name = "webrender_traits"', | |||
| ] | |||
| # noqa: Indicate to flake8 that we do not want to check indentation here | |||
This comment has been minimized.
This comment has been minimized.
aneeshusa
Aug 10, 2016
Member
We shouldn't need this anymore since we don't have unindented strings inside a list (the old licenses variable).
This comment has been minimized.
This comment has been minimized.
| @@ -17,12 +17,9 @@ | |||
| import StringIO | |||
| import subprocess | |||
| import sys | |||
| from licenseck import licenses, licenses_toml, licenses_dep_toml | |||
| import licenseck as licenses | |||
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Aug 11, 2016
Member
Nit: This should be from licenseck import MPL, ... (we don't wanna prefer * even though we import all the names)
| EMACS_HEADER = "/* -*- Mode:" | ||
| VIM_HEADER = "/* vim:" | ||
| MAX_LICENSE_LINESPAN = max(len(license.splitlines()) for license in licenses) | ||
| COMMENTS = ["// ", "# ", " *", "/* ", "*/ "] |
This comment has been minimized.
This comment has been minimized.
|
|
||
|
|
||
| def licensed_mpl(header): | ||
| return licenses.MPL.replace('\n', ' ') in header |
This comment has been minimized.
This comment has been minimized.
wafflespeanut
Aug 11, 2016
Member
Instead of doing a string replacement for every function call, we could just have a global variable like mpl = MPL.replace('\n', ' ') or something at the top.
This comment has been minimized.
This comment has been minimized.
|
|
||
|
|
||
| def licensed_apache(header): | ||
| if licenses.APACHE.replace('\n', ' ') in header: |
This comment has been minimized.
This comment has been minimized.
highfive
commented
Aug 12, 2016
|
|
Thanks again! :) @bors-servo r+ |
|
|
Improve tidy's license validation logic Rebased and fixed #10721, which is inactive for months. Fixes #10716 r? @larsbergstrom or @edunham <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12781) <!-- Reviewable:end -->
|
|
highfive
commented
Aug 14, 2016
|
|
@bors-servo retry #11574 |
Improve tidy's license validation logic Rebased and fixed #10721, which is inactive for months. Fixes #10716 r? @larsbergstrom or @edunham <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12781) <!-- Reviewable:end -->
|
|
|
@bors-servo retry #12797 |
|
|
|
|


UK992 commentedAug 9, 2016
•
edited
Rebased and fixed #10721, which is inactive for months.
Fixes #10716
r? @larsbergstrom or @edunham
This change is