diff --git a/src/reuse/_annotate.py b/src/reuse/_annotate.py index b867d62a..4d282ce7 100644 --- a/src/reuse/_annotate.py +++ b/src/reuse/_annotate.py @@ -342,11 +342,13 @@ def verify_write_access( def verify_paths_comment_style(args: Namespace, paths: Iterable[Path]) -> None: - """Exit if --fallback-dot-license or --skip-unrecognised is not enabled and - one of the paths has an unrecognised style. + """Exit if --style, --force-dot-license, --fallback-dot-license, + or --skip-unrecognised is not enabled and one of the paths has an + unrecognised style. """ if ( - not args.fallback_dot_license + not args.style + and not args.fallback_dot_license and not args.skip_unrecognised and not args.force_dot_license ): diff --git a/tests/test_main_annotate.py b/tests/test_main_annotate.py index 781ecc8f..367c18ba 100644 --- a/tests/test_main_annotate.py +++ b/tests/test_main_annotate.py @@ -452,6 +452,31 @@ def test_annotate_specify_style(fake_repository, stringio, mock_date_today): assert simple_file.read_text() == expected +def test_annotate_specify_style_unrecognised( + fake_repository, stringio, mock_date_today +): + """Add a header to a file that is unrecognised.""" + + simple_file = fake_repository / "hello.foo" + simple_file.touch() + expected = "# SPDX-FileCopyrightText: 2018 Jane Doe" + + result = main( + [ + "annotate", + "--copyright", + "Jane Doe", + "--style", + "python", + "hello.foo", + ], + out=stringio, + ) + + assert result == 0 + assert simple_file.read_text().strip() == expected + + def test_annotate_implicit_style(fake_repository, stringio, mock_date_today): """Add a header to a file that has a recognised extension.""" simple_file = fake_repository / "foo.js"