Repository navigation
contributing: Define the SPDX copyright header convention #7749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
41a2044
contributing: Define "Other GRASS authors" in COPYING
wenzeslaus cd3c991
doc: Use SPDX copyright tags in style guide header templates
wenzeslaus ae74969
g.parser: Emit SPDX copyright header from --script
wenzeslaus 173ae42
g.parser: Add test for --script output header
wenzeslaus 6dcf534
utils: Remove unused copywrite.pl
wenzeslaus 3ade3fe
contributing: Use GRASS Development Team as the collective copyright …
wenzeslaus 2a8d408
contributing: Leave COPYING unchanged and describe the team line as t…
wenzeslaus ffe5237
contributing: Simplify the wording of the copyright header rules
wenzeslaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| """Tests of the header emitted by g.parser --script | ||
|
|
||
| The header is produced by G__script() in lib/gis/parser_script.c. | ||
| """ | ||
|
|
||
| import os | ||
| import re | ||
|
|
||
| import pytest | ||
|
|
||
| import grass.script as gs | ||
| from grass.tools import Tools | ||
|
|
||
| TOOL = "v.what.rast" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def session(tmp_path_factory): | ||
| """Set up a GRASS session for the tests.""" | ||
| tmp_path = tmp_path_factory.mktemp("grass_session") | ||
| project = "test_project" | ||
| gs.create_project(tmp_path, project) | ||
| with gs.setup.init(tmp_path / project, env=os.environ.copy()) as session: | ||
| yield session | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def script(session): | ||
| """Return the script generated by TOOL --script.""" | ||
| tools = Tools(session=session) | ||
| return tools.run_cmd([TOOL, "--script"]).stdout | ||
|
|
||
|
|
||
| def test_script_header_has_no_obsolete_license_text(script): | ||
| """The generated header carries no COPYRIGHT field and no GPL paragraph.""" | ||
| for obsolete in ("COPYRIGHT:", "free software", "GNU General Public License"): | ||
| assert obsolete not in script, ( | ||
| f"Generated script still contains obsolete license text: {obsolete!r}" | ||
| ) | ||
|
|
||
|
|
||
| def test_script_header_has_one_holder_per_line(script): | ||
| """Each copyright line names one holder, and the collective one comes last.""" | ||
| lines = script.splitlines() | ||
| copyright_lines = [ | ||
| i for i, line in enumerate(lines) if "SPDX-FileCopyrightText:" in line | ||
| ] | ||
| identifiers = [ | ||
| i for i, line in enumerate(lines) if "SPDX-License-Identifier:" in line | ||
| ] | ||
|
|
||
| assert len(identifiers) == 1, "Expected exactly one SPDX-License-Identifier line." | ||
| assert copyright_lines, "Expected at least one SPDX-FileCopyrightText line." | ||
| assert max(copyright_lines) < identifiers[0], ( | ||
| "All SPDX-FileCopyrightText lines must precede SPDX-License-Identifier." | ||
| ) | ||
| assert ( | ||
| lines[max(copyright_lines)] | ||
| == "# SPDX-FileCopyrightText: GRASS Development Team" | ||
| ), "The last copyright line must be the collective line." | ||
| for i in copyright_lines: | ||
| assert not re.search(r",\s+and\s|\sand\sthe\s", lines[i]), ( | ||
| f"Copyright line names more than one holder: {lines[i]!r}" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.