-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support annotating a file that contains only a shebang
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
- Loading branch information
1 parent
ca360e3
commit 1825e0c
Showing
3 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# SPDX-FileCopyrightText: 2019 Free Software Foundation Europe e.V. <https://fsfe.org> | ||
# SPDX-FileCopyrightText: 2022 Florian Snow <[email protected]> | ||
# SPDX-FileCopyrightText: 2024 Carmen Bianca BAKKER <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
|
@@ -368,8 +369,10 @@ def test_find_and_replace_separate_shebang(): | |
assert find_and_replace_header(text, info) == expected | ||
|
||
|
||
def test_find_and_replace_only_shebang(): | ||
"""When the file only contains a shebang, keep it at the top of the file.""" | ||
def test_find_and_replace_shebang_but_no_copyright(): | ||
"""When the file contains a shebang but no copyright information, keep it at | ||
the top of the file. | ||
""" | ||
info = ReuseInfo({"GPL-3.0-or-later"}) | ||
text = cleandoc( | ||
""" | ||
|
@@ -395,6 +398,24 @@ def test_find_and_replace_only_shebang(): | |
assert find_and_replace_header(text, info) == expected | ||
|
||
|
||
def test_find_and_replace_only_shebang(): | ||
"""When the file only contains a shebang, add copyright info below it.""" | ||
info = ReuseInfo({"GPL-3.0-or-later"}) | ||
text = "#!/usr/bin/env python3" | ||
expected = ( | ||
cleandoc( | ||
""" | ||
#!/usr/bin/env python3 | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
""" | ||
) | ||
+ "\n" | ||
) | ||
|
||
assert find_and_replace_header(text, info) == expected | ||
|
||
|
||
def test_find_and_replace_keep_old_comment(): | ||
"""When encountering a comment that does not contain copyright and | ||
licensing information, preserve it below the REUSE header. | ||
|