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

Applying modifications... [failed] #820

Closed
yoyo837 opened this issue Mar 31, 2020 · 8 comments · Fixed by #821
Closed

Applying modifications... [failed] #820

yoyo837 opened this issue Mar 31, 2020 · 8 comments · Fixed by #821
Labels

Comments

@yoyo837
Copy link

yoyo837 commented Mar 31, 2020

Description

→ error: unknown option `features/components/form/FormFileUpload.vue' 

Backquotes are to the left of the file path and single quotes are to the right, which is wrong.

Steps to reproduce

Debug Logs

expand to view
husky > pre-commit (node v12.16.1)
Preparing... [started]
Preparing... [completed]
Running tasks... [started]
Running tasks for *.{js,vue} [started]
eslint [started]
eslint [completed]
Running tasks for *.{js,vue} [completed]
Running tasks... [completed]
Applying modifications... [started]
Applying modifications... [failed]
→ error: unknown option `features/components/form/FormFileUpload.vue'  // here <--------------
usage: git add [<options>] [--] <pathspec>...

    -n, --dry-run         dry run
    -v, --verbose         be verbose

    -i, --interactive     interactive picking
    -p, --patch           select hunks interactively
    -e, --edit            edit current diff and apply
    -f, --force           allow adding otherwise ignored files
    -u, --update          update tracked files
    --renormalize         renormalize EOL of tracked files (implies -u)
    -N, --intent-to-add   record only the fact that the path will be added later
    -A, --all             add changes from all tracked and untracked files
    --ignore-removal      ignore paths removed in the working tree (same as --no-all)
    --refresh             don't add, only refresh the index
    --ignore-errors       just skip files which cannot be added because of errors
    --ignore-missing      check if - even missing - files are ignored in dry run
    --chmod (+|-)x        override the executable bit of the listed files

Cleaning up... [started]
Cleaning up... [completed]

Environment

  • OS: macOS 10.15.4
  • Node.js: v12.16.1
  • lint-staged: v10.1.0
@iiroj
Copy link
Member

iiroj commented Mar 31, 2020

Hello, thanks for the issue. Can you test on v10.0.10 if this is a regression? Can you also post your configuration?

This particular command can be seen here:
https://github.com/okonet/lint-staged/blob/master/lib/gitWorkflow.js#L241

It hasn't been directly touched in v10.1.0, but I assume it wouldn't hurt to add the -- separator before paths.

EDIT: Please also post debug logs by running lint-staged in debug mode: lint-staged --debug.

@yoyo837
Copy link
Author

yoyo837 commented Mar 31, 2020

After run:

yarn remove lint-staged
yarn add lint-staged@10.0.10 -D

It works well.

My config in package.json:

  "lint-staged": {
    "**/*.{js,tsx,ts,less}": [
      "prettier --write"
    ],
    "**/*.{js,vue}": "eslint",
    "**/*.{vue}": "stylelint --custom-syntax=postcss-html",
    "**/*.scss": "stylelint --syntax=scss"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  }

Based on the above information, if debugging information is still needed, please let me know and I will try it later.

@iiroj
Copy link
Member

iiroj commented Mar 31, 2020

Hey, please post the debug log. It contains things like the parsed file paths so it would help figuring out what the issue is.

@yoyo837
Copy link
Author

yoyo837 commented Mar 31, 2020

husky > pre-commit (node v12.16.1)
2020-03-31T07:34:32.689Z lint-staged:bin Running `lint-staged@10.1.0`
2020-03-31T07:34:32.690Z lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  debug: true,
  maxArgLength: 131072,
  stash: true,
  quiet: false,
  relative: false,
  shell: false
}
2020-03-31T07:34:32.691Z lint-staged Loading config using `cosmiconfig`
2020-03-31T07:34:32.700Z lint-staged Successfully loaded config from `/Users/tanghui/git/ydmap/ydmap-ssr-portal/pages/package.json`:
{ '*.{js,vue}': 'eslint' }
2020-03-31T07:34:32.700Z lint-staged:cfg Validating config
Running lint-staged with the following config:
{
  '*.{js,vue}': 'eslint'
}
2020-03-31T07:34:32.701Z lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`)
2020-03-31T07:34:32.702Z lint-staged:run Running all linter scripts
2020-03-31T07:34:32.702Z lint-staged:resolveGitRepo Resolving git repo from `/Users/tanghui/git/ydmap/ydmap-ssr-portal/pages`
2020-03-31T07:34:32.702Z lint-staged:resolveGitRepo Unset GIT_DIR (was `/Users/tanghui/git/ydmap/ydmap-ssr-portal/.git/modules/pages`)
2020-03-31T07:34:32.702Z lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ]
2020-03-31T07:34:32.714Z lint-staged:file Reading file `/Users/tanghui/git/ydmap/ydmap-ssr-portal/pages/.git`
2020-03-31T07:34:32.714Z lint-staged:resolveGitRepo Resolved git directory to be `/Users/tanghui/git/ydmap/ydmap-ssr-portal/pages`
2020-03-31T07:34:32.714Z lint-staged:resolveGitRepo Resolved git config directory to be `/Users/tanghui/git/ydmap/ydmap-ssr-portal/.git/modules/pages`
2020-03-31T07:34:32.714Z lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only', '-z' ]
2020-03-31T07:34:32.722Z lint-staged:run Loaded list of staged files in git:
[ '-vue-features/components/form/FormFileUpload.vue', 'package.json' ]
2020-03-31T07:34:32.722Z lint-staged:chunkFiles Resolved an argument string length of 157 characters from 2 files
2020-03-31T07:34:32.722Z lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 131072
2020-03-31T07:34:32.722Z lint-staged:gen-tasks Generating linter tasks
2020-03-31T07:34:32.726Z lint-staged:gen-tasks Generated task: 
{
  pattern: '*.{js,vue}',
  commands: 'eslint',
  fileList: [
    '/Users/tanghui/git/ydmap/ydmap-ssr-portal/pages/-vue-features/components/form/FormFileUpload.vue'
  ]
}
2020-03-31T07:34:32.727Z lint-staged:make-cmd-tasks Creating listr tasks for commands 'eslint'
2020-03-31T07:34:32.727Z lint-staged:task cmd: eslint
2020-03-31T07:34:32.727Z lint-staged:task args: []
2020-03-31T07:34:32.727Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
Preparing... [started]
2020-03-31T07:34:32.730Z lint-staged:git Backing up original state...
2020-03-31T07:34:32.730Z lint-staged:git Getting partially staged files...
2020-03-31T07:34:32.730Z lint-staged:git Running git command [ 'status', '--porcelain' ]
2020-03-31T07:34:32.744Z lint-staged:git Found partially staged files: []
2020-03-31T07:34:32.744Z lint-staged:git Getting deleted files...
2020-03-31T07:34:32.744Z lint-staged:git Running git command [ 'ls-files', '--deleted' ]
2020-03-31T07:34:32.751Z lint-staged:git Found deleted files: []
2020-03-31T07:34:32.751Z lint-staged:git Backing up merge state...
2020-03-31T07:34:32.751Z lint-staged:file Reading file `/Users/tanghui/git/ydmap/ydmap-ssr-portal/.git/modules/pages/MERGE_HEAD`
2020-03-31T07:34:32.751Z lint-staged:file Reading file `/Users/tanghui/git/ydmap/ydmap-ssr-portal/.git/modules/pages/MERGE_MODE`
2020-03-31T07:34:32.751Z lint-staged:file Reading file `/Users/tanghui/git/ydmap/ydmap-ssr-portal/.git/modules/pages/MERGE_MSG`
2020-03-31T07:34:32.751Z lint-staged:file File `/Users/tanghui/git/ydmap/ydmap-ssr-portal/.git/modules/pages/MERGE_HEAD` doesn't exist, ignoring...
2020-03-31T07:34:32.751Z lint-staged:file File `/Users/tanghui/git/ydmap/ydmap-ssr-portal/.git/modules/pages/MERGE_MODE` doesn't exist, ignoring...
2020-03-31T07:34:32.751Z lint-staged:file File `/Users/tanghui/git/ydmap/ydmap-ssr-portal/.git/modules/pages/MERGE_MSG` doesn't exist, ignoring...
2020-03-31T07:34:32.751Z lint-staged:git Done backing up merge state!
2020-03-31T07:34:32.751Z lint-staged:git Running git command [
  'stash',
  'save',
  '--include-untracked',
  'lint-staged automatic backup'
]
2020-03-31T07:34:32.819Z lint-staged:git Running git command [ 'stash', 'list' ]
2020-03-31T07:34:32.833Z lint-staged:git Running git command [ 'stash', 'apply', '--quiet', '--index', 'stash@{0}' ]
2020-03-31T07:34:32.891Z lint-staged:git Restoring merge state...
2020-03-31T07:34:32.891Z lint-staged:git Done restoring merge state!
2020-03-31T07:34:32.891Z lint-staged:git Done backing up original state!
Preparing... [completed]
Running tasks... [started]
Running tasks for *.{js,vue} [started]
eslint [started]
eslint [completed]
Running tasks for *.{js,vue} [completed]
Running tasks... [completed]
Applying modifications... [started]
2020-03-31T07:34:34.146Z lint-staged:git Adding task modifications to index...
2020-03-31T07:34:34.146Z lint-staged:git Running git command [
  'add',
  '-vue-features/components/form/FormFileUpload.vue',
  'package.json'
]
Applying modifications... [failed]
→ error: unknown option `features/components/form/FormFileUpload.vue'
usage: git add [<options>] [--] <pathspec>...

    -n, --dry-run         dry run
    -v, --verbose         be verbose

    -i, --interactive     interactive picking
    -p, --patch           select hunks interactively
    -e, --edit            edit current diff and apply
    -f, --force           allow adding otherwise ignored files
    -u, --update          update tracked files
    --renormalize         renormalize EOL of tracked files (implies -u)
    -N, --intent-to-add   record only the fact that the path will be added later
    -A, --all             add changes from all tracked and untracked files
    --ignore-removal      ignore paths removed in the working tree (same as --no-all)
    --refresh             don't add, only refresh the index
    --ignore-errors       just skip files which cannot be added because of errors
    --ignore-missing      check if - even missing - files are ignored in dry run
    --chmod (+|-)x        override the executable bit of the listed files

Cleaning up... [started]
2020-03-31T07:34:34.153Z lint-staged:git Dropping backup stash...
2020-03-31T07:34:34.153Z lint-staged:git Running git command [ 'stash', 'list' ]
2020-03-31T07:34:34.168Z lint-staged:git Running git command [ 'stash', 'drop', '--quiet', 'stash@{0}' ]
2020-03-31T07:34:34.189Z lint-staged:git Done dropping backup stash!
Cleaning up... [completed]
error: unknown option `features/components/form/FormFileUpload.vue'
usage: git add [<options>] [--] <pathspec>...

    -n, --dry-run         dry run
    -v, --verbose         be verbose

    -i, --interactive     interactive picking
    -p, --patch           select hunks interactively
    -e, --edit            edit current diff and apply
    -f, --force           allow adding otherwise ignored files
    -u, --update          update tracked files
    --renormalize         renormalize EOL of tracked files (implies -u)
    -N, --intent-to-add   record only the fact that the path will be added later
    -A, --all             add changes from all tracked and untracked files
    --ignore-removal      ignore paths removed in the working tree (same as --no-all)
    --refresh             don't add, only refresh the index
    --ignore-errors       just skip files which cannot be added because of errors
    --ignore-missing      check if - even missing - files are ignored in dry run
    --chmod (+|-)x        override the executable bit of the listed files

husky > pre-commit hook failed (add --no-verify to bypass)

@iiroj
Copy link
Member

iiroj commented Mar 31, 2020

Hmm, I wonder if this filename could be what's up:

2020-03-31T07:34:34.146Z lint-staged:git Running git command [
  'add',
  '-vue-features/components/form/FormFileUpload.vue',
  'package.json'
]

EDIT Can you try editing lint-staged code directly to see if this helps:

Open node_modules/lint-staged/lib/gitWorkflow.js and on line 241 edit:

--- this.stagedFileChunks.map(stagedFiles => this.execGit(['add', ...stagedFiles]))
+++ this.stagedFileChunks.map(stagedFiles => this.execGit(['add', '--', ...stagedFiles]))

So in effect add the '--' argument to the this.execGit command

@iiroj
Copy link
Member

iiroj commented Mar 31, 2020

I was able to replicate the issue in a test and made a PR #821

@okonet
Copy link
Collaborator

okonet commented Mar 31, 2020

🎉 This issue has been resolved in version 10.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@yoyo837
Copy link
Author

yoyo837 commented Apr 1, 2020

v10.1.1 is works well. Thanks quickly fix.

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

Successfully merging a pull request may close this issue.

3 participants