Skip to content

fix(engine): isolate Git diff fixtures from global hooks #252

Description

@luojiyin1987

Problem

packages/host/engine/tests/integration/git-diff.test.ts creates temporary Git repositories.

The fixture commits inherit the user's global core.hooksPath.

A global commit-msg hook can reject fixture messages such as init.

This causes the integration test to fail before it reaches readGitDiff.

Reproduction

Set a global hooks path that runs commitlint.

git config --global core.hooksPath ~/.git-hooks

Run:

pnpm exec vitest run packages/host/engine/tests/integration/git-diff.test.ts

The fixture commit fails with subject-empty and type-empty.

The test already disables GPG signing with commit.gpgsign=false.

Root cause

The test does not override core.hooksPath for fixture commits.

Git therefore runs hooks from the user environment.

Fix

In packages/host/engine/tests/integration/git-diff.test.ts, add this config before commit:

'-c',
`core.hooksPath=${join(cwd, '.git', 'hooks')}`,

Use the fixture repository's own .git/hooks directory.

The default hooks there are safe and do not inherit user hooks.

Validation

A minimal temporary repository commits init successfully when this override is set.

The same commit fails without it when the global commitlint hook is active.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions