Skip to content

Commit 8930324

Browse files
committed
refactor(hooks): add hook skipping logic for permission updates
github#345 (comment)
1 parent 327c39c commit 8930324

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/specify_cli/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,13 @@ def _has_shebang(file_path: Path) -> bool:
690690
except Exception:
691691
return False
692692

693+
def _should_skip_hook(hook: Path) -> bool:
694+
"""Check if hook file should be skipped for permission update."""
695+
return (hook.is_symlink() or
696+
not hook.is_file() or
697+
hook.name == "README.md" or
698+
hook.name.endswith(".sample"))
699+
693700
def ensure_executable_scripts(project_path: Path, tracker: StepTracker | None = None) -> None:
694701
"""Ensure POSIX .sh scripts under .specify/scripts and hooks under .specify/hooks have execute bits (no-op on Windows)."""
695702
if os.name == "nt":
@@ -726,8 +733,7 @@ def ensure_executable_scripts(project_path: Path, tracker: StepTracker | None =
726733
if hooks_root.is_dir():
727734
for hook in hooks_root.iterdir():
728735
try:
729-
if (hook.is_symlink() or not hook.is_file() or
730-
hook.name == "README.md" or hook.name.endswith(".sample")):
736+
if _should_skip_hook(hook):
731737
continue
732738
if not _has_shebang(hook):
733739
continue

0 commit comments

Comments
 (0)