Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ The Geographic Resources Analysis and Support System (GRASS)
Geographic Information System (GIS) is Copyright by members
of the GRASS Development Team.

Copyright notices in individual source files use SPDX tags, for example:

SPDX-FileCopyrightText: 1999-2022 Jane Doe
Comment thread
cwhite911 marked this conversation as resolved.
SPDX-FileCopyrightText: Other GRASS authors
SPDX-License-Identifier: GPL-2.0-or-later

Other GRASS authors denotes the authors of a file who are not named
individually in it.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
Expand Down
18 changes: 12 additions & 6 deletions doc/development/style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,19 @@ Use the following header in your source code.
#
# PURPOSE: Provide short description of module here...
#
# COPYRIGHT: (C) 2024 by John Doe and the GRASS Development Team
#
# SPDX-FileCopyrightText: 2024 John Doe
# SPDX-FileCopyrightText: Other GRASS authors
# SPDX-License-Identifier: GPL-2.0-or-later
##############################################################################
```

Each copyright holder gets one `SPDX-FileCopyrightText` line carrying the years
of their own contributions. Add a line for yourself when you make a substantial
contribution, the same threshold as an `AUTHOR(S)` entry, and leave other
people's lines alone. The line `SPDX-FileCopyrightText: Other GRASS authors`
comes last and covers everyone not named individually; the `COPYING` file
defines it. The `SPDX-License-Identifier` line follows all copyright lines.

#### Use Standard Options in Interface

GRASS tools must use the GRASS parser to handle its command line parameters. To
Expand Down Expand Up @@ -960,8 +967,7 @@ Please use the following docstring template:
Classes:
- example::ExampleClass

(C) 2024 by the GRASS Development Team

SPDX-FileCopyrightText: 2024 Other GRASS authors
SPDX-License-Identifier: GPL-2.0-or-later

@author First Author <first somewhere.com>
Expand Down Expand Up @@ -1078,8 +1084,8 @@ original work remains, it must be properly cited.
* MODULE: g.foo
* AUTHOR(S): John Doe <jdoe at somewhere org>
* PURPOSE: Provide short description of module here...
* COPYRIGHT: (C) 2010 by John Doe, and the GRASS Development Team
*
* SPDX-FileCopyrightText: 2010 John Doe
* SPDX-FileCopyrightText: Other GRASS authors
* SPDX-License-Identifier: GPL-2.0-or-later
*
*****************************************************************************/
Expand Down
14 changes: 3 additions & 11 deletions general/g.parser/g.parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -565,17 +565,9 @@ <h3>Easy creation of a script</h3>
# MODULE: v.what.rast_wrapper
# AUTHOR(S): username
# PURPOSE: Wrapper for v.what.rast
# COPYRIGHT: (C) 2017 by username, and the GRASS Development Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# SPDX-FileCopyrightText: 2017 username
Comment thread
cwhite911 marked this conversation as resolved.
# SPDX-FileCopyrightText: Other GRASS authors
# SPDX-License-Identifier: GPL-2.0-or-later
#
############################################################################

Expand Down
14 changes: 3 additions & 11 deletions general/g.parser/g.parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,9 @@ v.what.rast --script
# MODULE: v.what.rast_wrapper
# AUTHOR(S): username
# PURPOSE: Wrapper for v.what.rast
# COPYRIGHT: (C) 2017 by username, and the GRASS Development Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# SPDX-FileCopyrightText: 2017 username
# SPDX-FileCopyrightText: Other GRASS authors
# SPDX-License-Identifier: GPL-2.0-or-later
#
############################################################################

Expand Down
63 changes: 63 additions & 0 deletions general/g.parser/tests/g_parser_script_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""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: Other GRASS authors"
), "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}"
)
32 changes: 6 additions & 26 deletions lib/gis/parser_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

\brief GIS Library - Argument parsing functions (script)

(C) 2001-2009, 2011 by the GRASS Development Team

This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
SPDX-FileCopyrightText: 2001-2009, 2011 Other GRASS authors
Comment thread
cwhite911 marked this conversation as resolved.
SPDX-License-Identifier: GPL-2.0-or-later

\author Original author CERL
\author Soeren Gebbert added Dec. 2009 WPS process_description document
Expand All @@ -33,28 +31,10 @@ void G__script(void)
fprintf(fp, "# MODULE: %s_wrapper\n", G_program_name());
fprintf(fp, "# AUTHOR(S): %s\n", G_whoami());
fprintf(fp, "# PURPOSE: Wrapper for %s\n", G_program_name());
fprintf(fp,
"# COPYRIGHT: (C) %s by %s, and the GRASS Development Team\n",
GRASS_VERSION_DATE, G_whoami());
fprintf(fp, "#\n");
fprintf(fp, "# This program is free software; you can redistribute it "
"and/or modify\n");
fprintf(fp, "# it under the terms of the GNU General Public License as "
"published by\n");
fprintf(fp, "# the Free Software Foundation; either version 2 of the "
"License, or\n");
fprintf(fp, "# (at your option) any later version.\n");
fprintf(fp, "#\n");
fprintf(
fp,
"# This program is distributed in the hope that it will be useful,\n");
fprintf(
fp,
"# but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
fprintf(
fp,
"# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
fprintf(fp, "# GNU General Public License for more details.\n");
fprintf(fp, "# SPDX-FileCopyrightText: %s %s\n", GRASS_VERSION_DATE,
G_whoami());
fprintf(fp, "# SPDX-FileCopyrightText: Other GRASS authors\n");
fprintf(fp, "# SPDX-License-Identifier: GPL-2.0-or-later\n");
fprintf(fp, "#\n");
fprintf(fp, "##############################################################"
"##############\n\n");
Expand Down
Loading
Loading