Skip to content

Commit 8b8788a

Browse files
committed
refactor(hooks): add hook skipping logic for permission updates
#345 (comment)
1 parent 43c4d70 commit 8b8788a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,13 @@ def _has_shebang(file_path: Path) -> bool:
714714
except Exception:
715715
return False
716716

717+
def _should_skip_hook(hook: Path) -> bool:
718+
"""Check if hook file should be skipped for permission update."""
719+
return (hook.is_symlink() or
720+
not hook.is_file() or
721+
hook.name == "README.md" or
722+
hook.name.endswith(".sample"))
723+
717724
def ensure_executable_scripts(project_path: Path, tracker: StepTracker | None = None) -> None:
718725
"""Ensure POSIX .sh scripts under .specify/scripts and hooks under .specify/hooks have execute bits (no-op on Windows)."""
719726
if os.name == "nt":
@@ -750,8 +757,7 @@ def ensure_executable_scripts(project_path: Path, tracker: StepTracker | None =
750757
if hooks_root.is_dir():
751758
for hook in hooks_root.iterdir():
752759
try:
753-
if (hook.is_symlink() or not hook.is_file() or
754-
hook.name == "README.md" or hook.name.endswith(".sample")):
760+
if _should_skip_hook(hook):
755761
continue
756762
if not _has_shebang(hook):
757763
continue

0 commit comments

Comments
 (0)