Skip to content

test(host-service): pin core.hooksPath in the dirty-hook fixture - #9192

Open
serhii-kucherenko wants to merge 2 commits into
ParadevAI:mainfrom
serhii-kucherenko:serhii/hooks-path-test-fixture
Open

serhii-kucherenko wants to merge 2 commits into
ParadevAI:mainfrom
serhii-kucherenko:serhii/hooks-path-test-fixture

Conversation

@serhii-kucherenko

@serhii-kucherenko serhii-kucherenko commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What & why

The materialize integration test installs a post-checkout hook in its fixture repo's .git/hooks and expects a plain checkout to fail on it. On a machine with a global core.hooksPath, git never runs that hook: the checkout succeeds and the test fails. This sets core.hooksPath in the fixture repo's own config with git config, so the hook runs on every machine. git config quotes the value, so a temp path with # or ; still works. Only the test fixture changes.

How I tested it

  • With a global core.hooksPath set, bun test test/integration/pr-branch-materialize.integration.test.ts in packages/host-service: 3/3 pass.
  • Red first: the same run with the file as it is on main fails "materialize-first worktree creation survives hooks that dirty tracked files during checkout" (expect(oldCheckoutError).toBeInstanceOf(Error), received null).
  • With TMPDIR set to a folder whose name has #: 3/3 pass. The same run with a raw [core] hooksPath = ... line appended to .git/config fails the same test, because git reads # as a comment start.
  • Biome passes on the changed file, and tsc passes in packages/host-service.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR)

Summary by CodeRabbit

  • Tests
    • Updated integration test setup to configure the repository’s local hooks directory before installing its checkout hook. The test now awaits hook setup and uses the corresponding Git instance and repository path, supporting consistent execution of the branch materialization integration test.

The materialize test installs a post-checkout hook in its repo's
.git/hooks and expects a plain checkout to fail on it. On a machine
with a global core.hooksPath, git never runs that hook, the checkout
succeeds, and the test fails. Pinning core.hooksPath in the repo's own
config makes the hook run on every machine.
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c251f81-ee9e-43a4-ac35-81eabe8a4cf3
Commits

Reviewing files that changed from the base of the PR and between 7ebcb76 and 9e1cd85.

Files selected for processing: 1
  • packages/host-service/test/integration/pr-branch-materialize.integration.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

The integration test now awaits an asynchronous helper that configures the repository’s core.hooksPath to its .git/hooks directory before installing the checkout hook.

Changes: Integration test hook setup

Layer / File(s) Summary
Configure checkout hook
packages/host-service/test/integration/pr-branch-materialize.integration.test.ts
The helper accepts a SimpleGit instance and repository path, sets core.hooksPath to the repository’s .git/hooks directory, and returns a promise. The test awaits the helper and passes both arguments.

Estimated code review effort: 2 (Simple) | ~5 minutes

Suggested reviewers: avipeltz

Merge Risk: Minimal · up to 9e1cd

No actionable merge-blocking risk remains in this test-only change.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title follows conventional commit format (type(scope): subject) and names the primary change: pinning core.hooksPath in the dirty-hook test fixture. The raw summary confirms the change sets core.h…
Description check Passed The description follows the template's main sections. The 'What & why' section explains the problem (a global core.hooksPath stops the post-checkout hook from running) and the fix (setting core.hooksP…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title follows conventional commit format (type(scope): subject) and names the primary change: pinning core.hooksPath in the dirty-hook test fixture. The raw summary confirms the change sets core.hooksPath in the fixture repository before installing the hook, and the title matches that scope.

Full details: Description check

Explanation

The description follows the template's main sections. The 'What & why' section explains the problem (a global core.hooksPath stops the post-checkout hook from running) and the fix (setting core.hooksPath in the fixture repo's config with git config). The 'How I tested it' section lists concrete commands, results, and a red-first run. The checklist is present and marked. The template asks for a linked issue, which the description does not include, and it does not include screenshots. Neither is required for this test-only change, so these gaps are non-critical.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Low impact] The change affects only a temporary integration-test repository.

The PR appears safe to merge, with a non-blocking path-escaping issue in the test fixture.

Findings

  1. P2 Special characters skip the hook ▶
Fix with agent prompt
### Issue 1
packages/host-service/test/integration/pr-branch-materialize.integration.test.ts:79-82
`hooksDir` is written into Git config without escaping. If `TMPDIR` contains `#` or `;`, Git reads the rest of the path as a comment. The hook is then skipped, and the dirty-hook test fails even without a global `core.hooksPath`. Use `git config --local core.hooksPath` to write the value with proper escaping.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Pins core.hooksPath to the fixture's own hook directory so a global setting cannot skip the dirty-hook test.

  • The dirty-hook test uses its own Git hook directory.

Reviews (1) · Last reviewed commit: "test(host-service): pin core.hooksPath i..." · Reviewed by Greptile

Comment on lines +79 to +82
appendFileSync(
join(repoPath, ".git", "config"),
`[core]\n\thooksPath = ${hooksDir}\n`,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Special characters skip the hook

hooksDir is written into Git config without escaping. If TMPDIR contains # or ;, Git reads the rest of the path as a comment. The hook is then skipped, and the dirty-hook test fails even without a global core.hooksPath. Use git config --local core.hooksPath to write the value with proper escaping.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/host-service/test/integration/pr-branch-materialize.integration.test.ts
Line: 79-82

Comment:
**Special characters skip the hook**

`hooksDir` is written into Git config without escaping. If `TMPDIR` contains `#` or `;`, Git reads the rest of the path as a comment. The hook is then skipped, and the dirty-hook test fails even without a global `core.hooksPath`. Use `git config --local core.hooksPath` to write the value with proper escaping.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

A raw [core] append breaks when the temp path holds # or ;, because git
reads those as a comment start. git config quotes the value.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant