Skip to content

Speed up pre-commit localization check#22076

Merged
aasimkhan30 merged 1 commit into
mainfrom
aasim/fix/preCommitPerf
May 7, 2026
Merged

Speed up pre-commit localization check#22076
aasimkhan30 merged 1 commit into
mainfrom
aasim/fix/preCommitPerf

Conversation

@aasimkhan30
Copy link
Copy Markdown
Contributor

@aasimkhan30 aasimkhan30 commented May 7, 2026

Summary

  • Scope pre-commit localization extraction to staged files by adding a --precommit mode to scripts/localization-extract.js.
  • Keep existing full localization behavior unchanged for normal npm run localization usage.

Performance

Measured on Windows/PowerShell from the repository root with no staged localization inputs.

Scenario Command / hook step Before After
Localization in pre-commit npm run localization vs node scripts/localization-extract.js --precommit 22.64s 0.68s
Full pre-commit hook .husky/pre-commit ~25.46s 3.10s
CRLF check node scripts/ensure-crlf.js 0.52s unchanged, already staged-file scoped
Lint npm run precommit / lint-staged --quiet 2.30s unchanged, already staged-file scoped

Validation

  • node scripts/localization-extract.js --precommit
  • .husky/pre-commit via Git Bash sh
  • npx prettier --check scripts/localization-extract.js
  • git diff --check

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 speeds up the repo’s pre-commit workflow by adding a --precommit mode to scripts/localization-extract.js that only extracts localization for extensions impacted by staged localization inputs, while preserving the existing full-extraction behavior for npm run localization. It also updates the Husky hook to use the new mode and adds timing notes documenting the improvement.

Changes:

  • Add staged-file detection and --precommit execution path to scripts/localization-extract.js.
  • Update .husky/pre-commit to run node scripts/localization-extract.js --precommit.
  • Add PRECOMMIT_TIMINGS.md documenting before/after timings and hook behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scripts/localization-extract.js Adds --precommit mode that scopes localization extraction to affected extensions based on staged files.
.husky/pre-commit Switches localization step to the new staged-only mode for faster pre-commit runs.
PRECOMMIT_TIMINGS.md Documents measured pre-commit timing improvements and current/updated hook behavior.

Comment on lines +23 to +33
const EXTENSION_INPUTS = {
mssql: ["extensions/mssql/src/", "extensions/mssql/package.nls.json"],
"sql-database-projects": [
"extensions/sql-database-projects/src/",
"extensions/sql-database-projects/package.nls.json",
],
"data-workspace": [
"extensions/data-workspace/src/",
"extensions/data-workspace/package.nls.json",
],
};
const LOCALIZATION_SCRIPT_INPUTS = [
"scripts/localization-extract.js",
"scripts/file-utils.js",
"scripts/terminal-logger.js",
return output
.toString("utf8")
.split("\0")
.map((file) => file.replace(/\\/g, "/").trim())
async function extractLocalizationForPrecommit() {
const affectedExtensions = getAffectedExtensionsForPrecommit();
if (!affectedExtensions.length) {
console.log("No staged localization inputs; skipping localization extraction.");
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 78064 KB 78064 KB ⚪ 0 KB ( 0% )
sql-database-projects VSIX 6309 KB 6309 KB ⚪ 0 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )
keymap VSIX 7 KB 7 KB ⚪ 0 KB ( 0% )

"scripts/terminal-logger.js",
];

function getStagedFiles() {
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.

How is the linter being limited to just staged files? something that could be shared between the two?

@aasimkhan30 aasimkhan30 merged commit 3870c2a into main May 7, 2026
10 checks passed
@aasimkhan30 aasimkhan30 deleted the aasim/fix/preCommitPerf branch May 7, 2026 22:59
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