Add git hooks package and lnk hooks CLI - #26
Merged
Merged
Conversation
This file contains hidden or 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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds git hook automation for lnk: a
post-mergehook in the lnk repo and apost-checkouthook in project repos. MakesProjectRestoreidempotent and introduces collision-safe hook restore paths so hooks can run unattended on every checkout without silently replacing user files.What's new
internal/hookspackage - installs and uninstalls lnk-managedpost-mergeandpost-checkoutscripts, using marker comments to refuse overwriting foreign hooks.lnk hooksCLI -install,uninstall, andruncommands, with--projecttargeting a project repo instead of the lnk repo.service.RunHookdispatches to collision-safe restore logic and wraps every body inrunWithTimeout, so a hung or failing restore never blocks the git operation.ProjectRestorenow skips symlinks that already resolve to the correct storage target instead of recreating them.RestoreHookandProjectRestoreHookcreate missing symlinks, replace stale symlinks, and report real-file collisions without backing them up.Usage
lnk hooks installpost-mergehook in the lnk repolnk hooks install --projectpost-checkouthook in the current project repolnk hooks uninstallpost-mergehooklnk hooks uninstall --projectpost-checkouthooklnk hooks run <hook-name> [args...]Behavior changes / guardrails
installrefuses to overwrite a hook that was not written by lnk.post-checkoutresolves the project root from the current working directory and refuses to treat the lnk repo (or any clone of it) as a project..lnk-backupis created during hook execution.Testing
RestoreHook,ProjectRestoreHook,RunHook, and project restore idempotency.post-checkouthooks for missing-symlink restore, collision reporting, and idempotent branch switches.make checkruns fmt, vet, lint, unit, and integration suites; all green.