Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to skip adding of files to git when there were no changes? (slow) #1325

Open
NullVoxPopuli opened this issue Sep 15, 2023 · 1 comment
Open

Comments

@NullVoxPopuli
Copy link

NullVoxPopuli commented Sep 15, 2023

Description

when I run with --debug, I'm seeing that the git add phase takes 3s.
This is a long time.

[STARTED] Applying modifications from tasks...
...
  lint-staged:GitWorkflow Adding task modifications to index... +3s

Steps to reproduce

It's a private repo, so I'm not sure. I'd just like to disable some of lint-staged behavior though.

Debug Logs

expand to view
  lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  cwd: undefined,
  debug: true,
  diff: undefined,
  diffFilter: undefined,
  maxArgLength: undefined,
  quiet: false,
  relative: false,
  shell: false,
  stash: false,
  verbose: false
} +0ms
  lint-staged:validateOptions Validating options... +0ms
  lint-staged:validateOptions Validated options! +0ms
  lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +0ms
  lint-staged:runAll Running all linter scripts... +0ms
  lint-staged:runAll Using working directory `<repo>` +0ms
  lint-staged:resolveGitRepo Resolving git repo from `<repo>` +0ms
  lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
  lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +0ms
  lint-staged:execGit Running git command [ 'rev-parse', '--show-prefix' ] +0ms
  lint-staged:file Reading file `<repo>/.git` +0ms
  lint-staged:resolveGitRepo Resolved git directory to be `<repo>` +10ms
  lint-staged:resolveGitRepo Resolved git config directory to be `../worktree-root/.git/worktrees/auditboard-frontend-4` +0ms
  lint-staged:execGit Running git command [ 'log', '-1' ] +10ms
⚠ Skipping backup because `--no-stash` was used.

  lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +4ms
  lint-staged:runAll Loaded list of staged files in git:
  lint-staged:runAll [
  lint-staged:runAll   '<repo>/.husky/pre-commit',
  lint-staged:runAll   '<repo>/pnpm-lock.yaml',
  lint-staged:runAll   '<repo>/tools/monorepo/package.json',
  lint-staged:runAll   '<repo>/tools/monorepo/src/tasks/report-time-of-process.ts',
  lint-staged:runAll   '<repo>/tools/monorepo/src/tasks/turbo.ts',
  lint-staged:runAll   '<repo>/tools/monorepo/src/utils/analytics.ts',
  lint-staged:runAll   '<repo>/tools/monorepo/src/utils/process.ts'
  lint-staged:runAll ] +21ms
  lint-staged:searchConfigs Searching for configuration files... +0ms
  lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name' ] +8ms
  lint-staged:execGit Running git command [ 'ls-files', '-z', '--full-name', '--others', '--exclude-standard' ] +3ms
✂️

  lint-staged:loadConfig Successfully loaded config from `<repo>/.lintstagedrc.js`:
  lint-staged:loadConfig {
  lint-staged:loadConfig   '*.{js,ts}': [Function (anonymous)],
  lint-staged:loadConfig   '*.{gjs,gts}': [Function (anonymous)],
  lint-staged:loadConfig   '*.hbs': [Function (anonymous)],
  lint-staged:loadConfig   '*.css': [Function (anonymous)],
  lint-staged:loadConfig   '*.json': [Function (anonymous)],
✂️
  lint-staged:loadConfig } +1ms
  lint-staged:validateConfig Validating config from `<repo>/.lintstagedrc.js`... +0ms
  lint-staged:validateConfig Validated config from `<repo>/.lintstagedrc.js`: +0ms
  lint-staged:validateConfig {
  lint-staged:validateConfig   '*.{js,ts}': [Function (anonymous)],
  lint-staged:validateConfig   '*.{gjs,gts}': [Function (anonymous)],
  lint-staged:validateConfig   '*.hbs': [Function (anonymous)],
  lint-staged:validateConfig   '*.css': [Function (anonymous)],
  lint-staged:validateConfig   '*.json': [Function (anonymous)],
✂️
  lint-staged:validateConfig } +0ms
  lint-staged:loadConfig Successfully loaded config from `<repo>/package.json`:
  lint-staged:loadConfig null +0ms
  lint-staged:searchConfigs Found 1 config files +5ms
  lint-staged:groupFilesByConfig Grouping 7 files by 1 configurations +0ms
  lint-staged:chunkFiles Resolved an argument string length of 562 characters from 7 files +0ms
  lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 65536 +0ms
  lint-staged:generateTasks Generating linter tasks +0ms
  lint-staged:generateTasks Generated task: 
  lint-staged:generateTasks {
  lint-staged:generateTasks   pattern: '*.{js,ts}',
  lint-staged:generateTasks   commands: [Function (anonymous)],
  lint-staged:generateTasks   fileList: [
  lint-staged:generateTasks     '<repo>/tools/monorepo/src/tasks/report-time-of-process.ts',
  lint-staged:generateTasks     '<repo>/tools/monorepo/src/tasks/turbo.ts',
  lint-staged:generateTasks     '<repo>/tools/monorepo/src/utils/analytics.ts',
  lint-staged:generateTasks     '<repo>/tools/monorepo/src/utils/process.ts'
  lint-staged:generateTasks   ]
  lint-staged:generateTasks } +1ms
 ✂️
} +0ms
✂️
  lint-staged:chunkFiles Resolved an argument string length of 431 characters from 5 files +3ms
  lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 65536 +0ms
[STARTED] Preparing lint-staged...
  lint-staged:GitWorkflow Backing up original state... +0ms
  lint-staged:GitWorkflow Getting partially staged files... +0ms
  lint-staged:execGit Running git command [ 'status', '-z' ] +35ms
  lint-staged:GitWorkflow Found partially staged files: [] +28ms
[COMPLETED] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] .lintstagedrc.js — 7 files
[STARTED] *.{js,ts} — 4 files
[STARTED] *.{gjs,gts} — 0 files
[STARTED] *.hbs — 0 files
[STARTED] *.css — 0 files
[STARTED] *.json — 1 file
[STARTED] apps/client/app/**/*.{js,ts,gjs,gts,hbs} — 0 files
[SKIPPED] *.{gjs,gts} — no files
[SKIPPED] *.hbs — no files
[SKIPPED] *.css — no files
[SKIPPED] apps/client/app/**/*.{js,ts,gjs,gts,hbs} — no files
[STARTED] pnpm exec cross-env FILES="tools/monorepo/src/tasks/report-time-of-process.ts tools/monorepo/src/tasks/turbo.ts tools/monorepo/src/utils/analytics.ts tools/monorepo/src/utils/process.ts" pnpm lint:js:fix
[STARTED] pnpm exec cross-env FILES="tools/monorepo/package.json" pnpm lint:prettier:fix
[COMPLETED] pnpm exec cross-env FILES="tools/monorepo/package.json" pnpm lint:prettier:fix
[COMPLETED] *.json — 1 file
[COMPLETED] pnpm exec cross-env FILES="tools/monorepo/src/tasks/report-time-of-process.ts tools/monorepo/src/tasks/turbo.ts tools/monorepo/src/utils/analytics.ts tools/monorepo/src/utils/process.ts" pnpm lint:js:fix
[STARTED] pnpm exec cross-env FILES="tools/monorepo/src/tasks/report-time-of-process.ts tools/monorepo/src/tasks/turbo.ts tools/monorepo/src/utils/analytics.ts tools/monorepo/src/utils/process.ts" pnpm lint:prettier:fix
[COMPLETED] pnpm exec cross-env FILES="tools/monorepo/src/tasks/report-time-of-process.ts tools/monorepo/src/tasks/turbo.ts tools/monorepo/src/utils/analytics.ts tools/monorepo/src/utils/process.ts" pnpm lint:prettier:fix
[COMPLETED] *.{js,ts} — 4 files
[COMPLETED] .lintstagedrc.js — 7 files
[COMPLETED] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
  lint-staged:GitWorkflow Adding task modifications to index... +3s
  lint-staged:execGit Running git command [
  'add',
  '--',
  '<repo>/tools/monorepo/src/tasks/report-time-of-process.ts',
  '<repo>/tools/monorepo/src/tasks/turbo.ts',
  '<repo>/tools/monorepo/src/utils/analytics.ts',
  '<repo>/tools/monorepo/src/utils/process.ts',
  '<repo>/tools/monorepo/package.json'
] +3s
  lint-staged:GitWorkflow Done adding task modifications to index! +8ms
  lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +8ms
[COMPLETED] Applying modifications from tasks...
  lint-staged Tasks were executed successfully! +3s
 

Environment

  • OS: Ubuntu 23.04
  • Node.js: 18.17.1
  • lint-staged: 14.0.1
@iiroj
Copy link
Member

iiroj commented Sep 17, 2023

Hello,

do you mean your linters make no changes, but the git add step still takes that long? I guess it would be possible to to run git add on only those files that have unstaged modifications at this point:

https://github.com/okonet/lint-staged/blob/19a6527c8ac07dbafa2b8c1774e849d3cab635c3/lib/gitWorkflow.js#L258-L264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants