Skip to content

Remove husky pre-commit and pre-push hooks; integrate copilot pre-commit checks directly in hygiene function#308698

Merged
joaomoreno merged 1 commit intomainfrom
joao/moccasin-heron
Apr 9, 2026
Merged

Remove husky pre-commit and pre-push hooks; integrate copilot pre-commit checks directly in hygiene function#308698
joaomoreno merged 1 commit intomainfrom
joao/moccasin-heron

Conversation

@joaomoreno
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 9, 2026 07:13
@joaomoreno joaomoreno enabled auto-merge (squash) April 9, 2026 07:13
@joaomoreno joaomoreno self-assigned this Apr 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the Copilot extension’s Husky-based git hooks and instead triggers Copilot’s staged-file linting/formatting via the repo’s existing build/hygiene.ts pre-commit flow when Copilot files are staged.

Changes:

  • Remove Husky setup (prepare) and the husky devDependency from extensions/copilot.
  • Delete Copilot’s Husky pre-commit (lint-staged) and pre-push (git-lfs) hook scripts.
  • Add a Copilot-specific lint-staged invocation inside build/hygiene.ts when staged paths include extensions/copilot/.
Show a summary per file
File Description
extensions/copilot/package.json Removes Husky hook installation and the Husky dependency.
extensions/copilot/package-lock.json Updates lockfile to reflect removal of Husky.
extensions/copilot/.husky/pre-push Removes git-lfs pre-push guard hook.
extensions/copilot/.husky/pre-commit Removes lint-staged pre-commit hook.
build/hygiene.ts Runs lint-staged in extensions/copilot when Copilot files are staged.

Copilot's findings

Files not reviewed (1)
  • extensions/copilot/package-lock.json: Language not supported
  • Files reviewed: 4/5 changed files
  • Comments generated: 4

Comment on lines +293 to +294
// Run copilot pre-commit checks if copilot files are staged
if (some.some(f => f.startsWith('extensions/copilot/'))) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

lint-staged (via tsfmt/eslint) can rewrite files and update the git index. Because some is computed before running these checks, any files modified/restaged by lint-staged may be missing from the subsequent createGitIndexVinyls(some) hygiene run. Consider rerunning git diff --cached --name-only after lint-staged (or moving the lint-staged invocation before computing some).

Copilot uses AI. Check for mistakes.
// Run copilot pre-commit checks if copilot files are staged
if (some.some(f => f.startsWith('extensions/copilot/'))) {
console.log('Running copilot pre-commit checks...');
const result = cp.spawnSync('npx', ['lint-staged'], {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

Spawning npx lint-staged without --no-install can cause npm to download packages when lint-staged isn't present locally, which is risky for offline/devbox scenarios and can introduce non-determinism. Consider invoking the local binary explicitly (or using npx --no-install) so this fails fast instead of attempting a network install.

Suggested change
const result = cp.spawnSync('npx', ['lint-staged'], {
const result = cp.spawnSync('npx', ['--no-install', 'lint-staged'], {

Copilot uses AI. Check for mistakes.
Comment on lines +300 to +301
if (result.status !== 0) {
console.error('Copilot pre-commit checks failed');
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

spawnSync can fail to start (e.g. missing npx on PATH), in which case result.status is null and result.error contains the reason. Right now this reports a generic failure; consider handling result.error / result.signal to surface a more actionable message for developers.

Suggested change
if (result.status !== 0) {
console.error('Copilot pre-commit checks failed');
if (result.error) {
console.error('Copilot pre-commit checks failed to start');
console.error(result.error);
process.exit(1);
}
if (result.signal) {
console.error(`Copilot pre-commit checks terminated by signal ${result.signal}`);
process.exit(1);
}
if (result.status !== 0) {
console.error(`Copilot pre-commit checks failed with exit code ${result.status}`);

Copilot uses AI. Check for mistakes.
Comment on lines 6231 to 6234
"scripts": {
"postinstall": "tsx ./script/postinstall.ts",
"prepare": "husky",
"vscode-dts:update": "node script/build/vscodeDtsUpdate.js",
"vscode-dts:check": "node script/build/vscodeDtsCheck.js",
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

Removing Husky here also removes the Copilot-specific pre-push git-lfs guard. Since extensions/copilot/.gitattributes enables LFS for *.sqlite, consider adding an alternative enforcement point (e.g. a repo-level pre-push check or a CI validation) so contributors without git-lfs don’t accidentally commit/push large sqlite blobs.

Copilot uses AI. Check for mistakes.
@joaomoreno joaomoreno merged commit 591f068 into main Apr 9, 2026
27 checks passed
@joaomoreno joaomoreno deleted the joao/moccasin-heron branch April 9, 2026 07:48
@vs-code-engineering vs-code-engineering bot added this to the 1.116.0 milestone Apr 9, 2026
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.

3 participants