meta: don't overwrite preconfigured hooks with stubs
Metadata
Current evaluation
Hook stub generation now preserves existing primed meta/hooks scripts; merged in snapcraft#3386 via commit bb9525144, with added unit-test fixtures and coverage.
Resolution: closed resolved
Reason: PR #3386 was merged as commit bb9525144. It checks whether a hook script already exists before generating a stub and adds unit coverage for preserving preconfigured hooks.
Evaluated by: mr-cal-bot
No scores available.
Issue body
If a hook stub is being generated it would overwrite a primed
hook (in meta/hooks/). Check for existence of script before
generating the stub.
Add some unit tests to get some needed coverage here, extending
the SnapcraftYaml fixture to include support for hooks.
LP: #1905072
Signed-off-by: Chris Patterson <chris.patterson@canonical.com>
- [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [ ] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Hook stub generation now preserves existing primed meta/hooks scripts; merged in snapcraft#3386 via commit bb9525144, with added unit-test fixtures and coverage. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged #3386 in commit bb9525144: hook stub generation now preserves existing primed hooks; hook fixtures and unit tests were added. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #3386 (bb9525144) prevents hook stub generation from overwriting existing primed hook scripts and adds hook fixtures and unit coverage. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged a fix that prevents hook stub generation from overwriting existing preconfigured hooks by verifying script existence first. Includes unit tests and passed CI. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix preventing hook stub generation from overwriting preconfigured hooks in meta/hooks/ by verifying script existence first. Includes unit tests and resolves LP: #1905072. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #3296 meta: write stubs for command-chain using hooks when needed | snapcraft | merged | Merged #3296 in commit 95225991f, adding Snapcraft metadata generation of stub hooks for command-chain-based hooks. | |
| #6433 Generated hooks are not included in the Snap | snapcraft | closed | Generated part hooks now replace stubs correctly; commit 271462658 prevents premature stub creation and was targeted for Snapcraft 9.1.3. | |
| #6434 Replace generated hook stubs with built hooks when hooks are declared | snapcraft | closed | Closed unmerged; the generated-hook regression was fixed separately by commit 271462658 and released in Snapcraft 9.1.3. | |
| #3837 fix: hooks: process generated hooks | snapcraft | merged | Merged as commit c77e3a07a (CRAFT-1159): core22 now includes lifecycle-generated hooks in the snap via meta/hooks wrappers, with snap/hooks taking priority; adds spread tests for core18/20/22. | |
| #2440 meta: make hooks executable instead of complaining they're not | snapcraft | merged | PR #2440 by Saviq merged to master as commit c2f5a0dc0: snapcraft's meta no longer errors on non-executable hook scripts and instead chmods them +x. Fixes Launchpad bug #1812003. |