Skip to content

Add CI detection to skip installing hooks#142

Open
Kikobeats wants to merge 1 commit into
toplenboren:masterfrom
Kikobeats:master
Open

Add CI detection to skip installing hooks#142
Kikobeats wants to merge 1 commit into
toplenboren:masterfrom
Kikobeats:master

Conversation

@Kikobeats

@Kikobeats Kikobeats commented Apr 13, 2026

Copy link
Copy Markdown

It's necessary to add is-ci to yarn lock .cc @toplenboren

Summary by CodeRabbit

  • Bug Fixes
    • Git hooks installation now automatically skips in continuous integration environments, improving performance and compatibility with automated build pipelines.

@changeset-bot

changeset-bot Bot commented Apr 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 85b5338

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The skipInstall() function in simple-git-hooks.js was enhanced to detect CI environments using the is-ci package. When CI is detected, the function now logs an informational message and returns early, preventing git hook installation in continuous integration contexts.

Changes

Cohort / File(s) Summary
CI Environment Detection
simple-git-hooks.js
Added CI detection logic to skipInstall() function using require('is-ci'). When running in CI, the function logs [INFO] CI detected, skipping installing hook. and returns early before existing default behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 In CI pipelines where bots toil and run,
No need for hooks when the tests are done,
We detect the machine, skip with a smile,
And log the truth: "No hooks here, but style!"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: adding CI detection to skip installing hooks, which matches the core functionality added in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
simple-git-hooks.js (1)

465-468: Add tests for the new CI branch in skipInstall().

Current tests cover SKIP_INSTALL_SIMPLE_GIT_HOOKS, but not CI detection. Please add at least one case asserting CI causes skipInstall() to return true (and skip hook setup in postinstall/CLI flows).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@simple-git-hooks.js` around lines 465 - 468, Add a unit test for the CI
branch in skipInstall(): mock/stub the is-ci module to return true (or set
process.env.CI) and assert that skipInstall() returns true; additionally add an
integration-style test that simulates the postinstall/CLI flow (calling the
function that triggers hook setup) and assert it does not attempt to install
hooks when is-ci is true. Target the skipInstall() function and the
postinstall/CLI entrypoint used in the existing tests, restoring the original
is-ci behavior after the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@simple-git-hooks.js`:
- Around line 465-468: Add a unit test for the CI branch in skipInstall():
mock/stub the is-ci module to return true (or set process.env.CI) and assert
that skipInstall() returns true; additionally add an integration-style test that
simulates the postinstall/CLI flow (calling the function that triggers hook
setup) and assert it does not attempt to install hooks when is-ci is true.
Target the skipInstall() function and the postinstall/CLI entrypoint used in the
existing tests, restoring the original is-ci behavior after the test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1a28b5c8-dd75-4055-b822-6237e4195e78

📥 Commits

Reviewing files that changed from the base of the PR and between 7625657 and 85b5338.

📒 Files selected for processing (1)
  • simple-git-hooks.js

Comment thread simple-git-hooks.js
console.log(`[INFO] SKIP_INSTALL_SIMPLE_GIT_HOOKS is set to "${SKIP_INSTALL_SIMPLE_GIT_HOOKS}", skipping installing hook.`)
return true;
}
if (require('is-ci')) {

@JounQin JounQin Apr 13, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a breaking change, not everyone wants this. And you can easily set SKIP_INSTALL_SIMPLE_GIT_HOOKS=1 env on CI.

https://github.com/toplenboren/simple-git-hooks?tab=readme-ov-file#i-want-to-skip-git-hooks

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

agree, then it could be shipped as v3 🙂

@Kikobeats Kikobeats requested a review from JounQin April 14, 2026 06:55
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.

2 participants