Skip to content

Commit

Permalink
Fix annotating symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
matrss committed Jun 22, 2023
1 parent 0552ef1 commit 03f5b43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/reuse/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# SPDX-FileCopyrightText: 2022 Pietro Albini <[email protected]>
# SPDX-FileCopyrightText: 2023 DB Systel GmbH
# SPDX-FileCopyrightText: 2023 Johannes Zarl-Zierl <[email protected]>
# SPDX-FileCopyrightText: 2023 Matthias Riße
#
# SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -476,6 +477,10 @@ def _check_read(self, path: Path) -> None:
_("'{}' is not a directory").format(path)
)
return
if not path.exists() and path.is_symlink():
# If the path is a broken symlink we can continue, allowing usage of
# --force-dot-license even if the link target is not readable.
return
raise ArgumentTypeError(_("can't open '{}'").format(path))

def _check_write(self, path: Path) -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/reuse/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# SPDX-FileCopyrightText: 2022 Florian Snow <[email protected]>
# SPDX-FileCopyrightText: 2022 Yaman Qalieh
# SPDX-FileCopyrightText: 2022 Carmen Bianca Bakker <[email protected]>
# SPDX-FileCopyrightText: 2023 Matthias Riße
#
# SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -392,7 +393,7 @@ def _is_uncommentable(path: Path) -> bool:
registered as an UncommentableCommentStyle.
"""
is_uncommentable = _get_comment_style(path) == UncommentableCommentStyle
return is_uncommentable or is_binary(str(path))
return is_uncommentable or path.is_symlink() or is_binary(str(path))


def _verify_paths_line_handling(
Expand Down

0 comments on commit 03f5b43

Please sign in to comment.