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

"⚠ Some of your tasks use git add command." #775

Closed
jakearchibald opened this issue Jan 22, 2020 · 14 comments
Closed

"⚠ Some of your tasks use git add command." #775

jakearchibald opened this issue Jan 22, 2020 · 14 comments

Comments

@jakearchibald
Copy link

Description

I'm getting the message "⚠ Some of your tasks use git add command." during linting, but it isn't clear what tasks it's referring to.

Steps to reproduce

https://gist.github.com/jakearchibald/c5e18f54ddd9f8bb852e2d2abdbb3884

  1. Check out the above.
  2. Make a change to test.js.
  3. Stage the change.
  4. Run ./node_modules/.bin/lint-staged

Debug Logs

expand to view
  lint-staged:bin Running `lint-staged@10.0.1` +0ms
  lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  debug: true,
  maxArgLength: 131072,
  quiet: false,
  relative: false,
  shell: false
} +2ms
  lint-staged Loading config using `cosmiconfig` +0ms
  lint-staged Successfully loaded config from `/Users/jakearchibald/dev/buildoff/package.json`:
  lint-staged { '*.{js,css,json,md,ts,tsx}': [ 'prettier --write', 'git add' ] } +28ms
  lint-staged:cfg Validating config +0ms
Running lint-staged with the following config:
{
  '*.{js,css,json,md,ts,tsx}': [
    'prettier --write',
    'git add'
  ]
}
  lint-staged:run Running all linter scripts +0ms
  lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ] +0ms
  lint-staged:git Running git command [ 'rev-parse', '--show-superproject-working-tree' ] +23ms
  lint-staged:run Resolved git directory to be `/Users/jakearchibald/dev/buildoff` +45ms
  lint-staged:run Resolved git config directory to be `/Users/jakearchibald/dev/buildoff/.git` +0ms
  lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only' ] +21ms
  lint-staged:run Loaded list of staged files in git:
  lint-staged:run [ 'test.js' ] +14ms
  lint-staged:chunkFiles Resolved an argument string length of 41 characters from 1 files +0ms
  lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 131072 +0ms
  lint-staged:gen-tasks Generating linter tasks +0ms
  lint-staged:gen-tasks Generated task:
  lint-staged:gen-tasks {
  lint-staged:gen-tasks   pattern: '*.{js,css,json,md,ts,tsx}',
  lint-staged:gen-tasks   commands: [ 'prettier --write', 'git add' ],
  lint-staged:gen-tasks   fileList: [ '/Users/jakearchibald/dev/buildoff/test.js' ]
  lint-staged:gen-tasks } +3ms
  lint-staged:make-cmd-tasks Creating listr tasks for commands [ 'prettier --write', 'git add' ] +0ms
  lint-staged:task cmd: prettier --write /Users/jakearchibald/dev/buildoff/test.js +0ms
  lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +0ms
  lint-staged:task cmd: git add /Users/jakearchibald/dev/buildoff/test.js +0ms
  lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false } +14ms
⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.

Preparing... [started]
  lint-staged:git Backing up original state... +0ms
  lint-staged:git Backing up merge state... +0ms
  lint-staged:file Reading buffer from file `/Users/jakearchibald/dev/buildoff/.git/MERGE_HEAD` +0ms
  lint-staged:file Reading buffer from file `/Users/jakearchibald/dev/buildoff/.git/MERGE_MODE` +0ms
  lint-staged:file Reading buffer from file `/Users/jakearchibald/dev/buildoff/.git/MERGE_MSG` +0ms
  lint-staged:file File `/Users/jakearchibald/dev/buildoff/.git/MERGE_HEAD` doesn't exist, ignoring... +4ms
  lint-staged:file File `/Users/jakearchibald/dev/buildoff/.git/MERGE_MODE` doesn't exist, ignoring... +0ms
  lint-staged:file File `/Users/jakearchibald/dev/buildoff/.git/MERGE_MSG` doesn't exist, ignoring... +0ms
  lint-staged:git Done backing up merge state! +4ms
  lint-staged:git Running git command [
  'stash',
  'save',
  '--quiet',
  '--include-untracked',
  '--keep-index',
  'lint-staged automatic backup'
] +39ms
  lint-staged:git Restoring merge state... +92ms
  lint-staged:git Done restoring merge state! +0ms
  lint-staged:git Running git command [ 'ls-files', '--others', '--exclude-standard' ] +92ms
  lint-staged:git Running git command [ 'stash', 'list' ] +6ms
  lint-staged:git Running git command [
  'diff',
  '--binary',
  '--unified=0',
  '--no-color',
  '--no-ext-diff',
  '--patch',
  'stash@{0}',
  '-R'
] +16ms
  lint-staged:git Done backing up original state! +29ms
Preparing... [completed]
Running tasks... [started]
Running tasks for *.{js,css,json,md,ts,tsx} [started]
prettier --write [started]
prettier --write [completed]
git add [started]
git add [completed]
Running tasks for *.{js,css,json,md,ts,tsx} [completed]
Running tasks... [completed]
Applying modifications... [started]
  lint-staged:git Running git command [ 'ls-files', '--modified' ] +198ms
  lint-staged:git Running git command [ 'status', '--porcelain' ] +7ms
  lint-staged:git Running git command [ 'stash', 'list' ] +9ms
  lint-staged:git Running git command [ 'show', '--format=%b', 'stash@{0}^3' ] +15ms
  lint-staged:git Running git command [ 'apply', '-v', '--whitespace=nowarn', '--recount', '--unidiff-zero' ] +9ms
Applying modifications... [completed]
Cleaning up... [started]
  lint-staged:git Dropping backup stash... +239ms
  lint-staged:git Running git command [ 'stash', 'list' ] +8ms
  lint-staged:git Running git command [ 'stash', 'drop', '--quiet', 'stash@{0}' ] +15ms
  lint-staged:git Done dropping backup stash! +38ms
Cleaning up... [completed]
  lint-staged tasks were executed successfully! +485ms

Environment

  • OS: OSX 10.14.6
  • Node.js: v12.4.0
  • lint-staged: 10.0.1
@iiroj
Copy link
Member

iiroj commented Jan 22, 2020

This is covered in the changelog. Your configuration looks like the following:

{
  '*.{js,css,json,md,ts,tsx}': [
    'prettier --write',
    'git add'
  ]
}

From v10 onwards the git add part is automatic and not necessary to include in your configuration.

@iiroj iiroj closed this as completed Jan 22, 2020
@jakearchibald
Copy link
Author

Huh, that was added by npx mrm lint-staged. I guess that has since been updated?

@iiroj
Copy link
Member

iiroj commented Jan 22, 2020

Good catch. Let me see if there’s something we’ve forgot to update.

@iiroj iiroj reopened this Jan 22, 2020
@iiroj
Copy link
Member

iiroj commented Jan 22, 2020

This seems to be an issue in another package, so I suggest you open an issue there. I don’t have any access to that repo.

https://github.com/sapegin/mrm-tasks/blob/master/packages/mrm-task-lint-staged/index.js#L81

@iiroj iiroj closed this as completed Jan 22, 2020
@jakearchibald
Copy link
Author

Your docs currently recommend npx mrm lint-staged. To be honest, I didn't realise it was a third-party project.

Is it worth updating the docs to make it clear that npx mrm lint-staged will do the wrong thing?

@iiroj
Copy link
Member

iiroj commented Jan 22, 2020

@okonet what do you think? I see there’s some earlier discussion in that github repo.

@okonet
Copy link
Collaborator

okonet commented Jan 22, 2020

I'll update the task since I wrote that.

@PLQin
Copy link

PLQin commented Aug 28, 2020

nice , solved my problem

PLQin pushed a commit to PLQin/vue-pc-template that referenced this issue Aug 28, 2020
TBolton2000 added a commit to IBM/text-to-speech-code-pattern that referenced this issue Jul 20, 2021
As seen here: lint-staged/lint-staged#775, git add is not needed here any more
TBolton2000 added a commit to IBM/text-to-speech-code-pattern that referenced this issue Jul 21, 2021
* Remove git add from lint-staged

As seen here: lint-staged/lint-staged#775, git add is not needed here any more

* changed npm installing to ci prod

This prevents husky from being installed which is was failing due to not having the .git file in the Docker work dir

* Adjust experience test to select voice manually
TBolton2000 added a commit to IBM/speech-to-text-code-pattern that referenced this issue Jul 21, 2021
TBolton2000 added a commit to IBM/speech-to-text-code-pattern that referenced this issue Jul 21, 2021
* Change initial npm install to ci to prevent husky

Husky causes containerize to fail from trying to install husky with new base nodejs image

* Remove git add from lint-staged

See lint-staged/lint-staged#775
lawvs added a commit to lawvs/poi that referenced this issue Nov 17, 2021
@aneta-s
Copy link

aneta-s commented Nov 19, 2021

Description

I'm getting the message "⚠ Some of your tasks use git add command." during linting, but it isn't clear what tasks it's referring to.

Steps to reproduce

https://gist.github.com/jakearchibald/c5e18f54ddd9f8bb852e2d2abdbb3884

  1. Check out the above.
  2. Make a change to test.js.
  3. Stage the change.
  4. Run ./node_modules/.bin/lint-staged

Debug Logs

expand to view

Environment

  • OS: OSX 10.14.6
  • Node.js: v12.4.0
  • lint-staged: 10.0.1

I found this issue, when searching for a solution for my error. After updating to Big Sur (MAC), I'm not able to commit my changes to Github pages. I wonder if this issue is also the solution for my error in my console, when committing in git:

➜  gatsby-simplefolio git:(master) ✗ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   static/resume-uxui-designer.pdf

➜  gatsby-simplefolio git:(master) ✗ git add .
➜  gatsby-simplefolio git:(master) ✗ git commit -m 'edit'
husky > pre-commit (node v14.17.5)
⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.

ℹ No staged files match any configured task.
error: cannot run gpg2: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
➜  gatsby-simplefolio git:(master) ✗ git push origin master
Everything up-to-date
➜  gatsby-simplefolio git:(master) ✗ 

@iiroj
Copy link
Member

iiroj commented Nov 19, 2021

@aneta-s you issue doesn't seem related to lint-staged:

error: cannot run gpg2: No such file or directory
error: gpg failed to sign the data

Try installing gpg first:
https://formulae.brew.sh/formula/gnupg#default

@aneta-s
Copy link

aneta-s commented Nov 22, 2021

@aneta-s you issue doesn't seem related to lint-staged:

error: cannot run gpg2: No such file or directory
error: gpg failed to sign the data

Try installing gpg first: https://formulae.brew.sh/formula/gnupg#default

@iiroj I have finally installed gpg, and tried to push changes to my repo, but it nothing changed. Honestly, if it is not related to lint-staged issue, then where should I look?

➜  gatsby-simplefolio git:(master) ✗ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   static/resume-uxui-designer.pdf

➜  gatsby-simplefolio git:(master) ✗ git add .
➜  gatsby-simplefolio git:(master) ✗ git coomit -m 'edit1'
WARNING: You called a Git command named 'coomit', which does not exist.
Continuing in 0.1 seconds, assuming that you meant 'commit'.
husky > pre-commit (node v14.17.5)
⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.

ℹ No staged files match any configured task.
error: cannot run gpg2: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
➜  gatsby-simplefolio git:(master) ✗ git commit -m 'edit2'
husky > pre-commit (node v14.17.5)
⚠ Some of your tasks use `git add` command. Please remove it from the config since all modifications made by tasks will be automatically added to the git commit index.

ℹ No staged files match any configured task.
error: cannot run gpg2: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
➜  gatsby-simplefolio git:(master) ✗ git push origin master
Everything up-to-date
➜  gatsby-simplefolio git:(master) ✗ 

@iiroj
Copy link
Member

iiroj commented Nov 22, 2021

@aneta-s you have configured git to sign your commits, and it's trying to use gpg2 to do so. Does that bin exist on your system, can you run it? Can you commit when disabling git hooks, for example with --no-verify? The reason I believe this is not related to lint-staged is that your logs say No staged files match any configured task, which means lint-staged didn't really do anything and just exited early.

I cannot really offer any general git support, unfortunately.

@aneta-s
Copy link

aneta-s commented Nov 22, 2021

@iiroj I appreciate your willingness a lot!
If I look in my bin folder, I can't see gpg2 folder. If I type in git command --no-verify, zsh says command not found. Sorry, I've not touch react for a while now.
Can you be more specific what you mean by "if bin exist on my system"? I mean I see bin folder, but no hooks related names in it
Below are my dependencies, does this help at least?

{
  "name": "gatsby-starter-hello-world",
  "private": true,
  "description": "A simplified bare-bones starter for Gatsby",
  "version": "0.1.0",
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "dependencies": {
    "bootstrap": "^4.4.1",
    "gatsby": "^2.19.5",
    "gatsby-image": "^2.2.39",
    "gatsby-plugin-manifest": "^2.2.38",
    "gatsby-plugin-offline": "^3.0.32",
    "gatsby-plugin-react-helmet": "^3.1.21",
    "gatsby-plugin-sass": "^2.1.27",
    "gatsby-plugin-sharp": "^2.4.0",
    "gatsby-source-filesystem": "^2.1.46",
    "gatsby-transformer-sharp": "^2.3.13",
    "node-sass": "^4.13.1",
    "prop-types": "^15.7.2",
    "react": "^16.13.1",
    "react-bootstrap": "^1.0.0-beta.16",
    "react-dom": "^16.13.1",
    "react-github-btn": "^1.1.1",
    "react-helmet": "^5.2.1",
    "react-reveal": "^1.2.2",
    "react-tilt": "^0.1.4",
    "uuid": "^3.4.0"
  },
  "devDependencies": {
    "babel-eslint": "^10.0.3",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-config-prettier": "^6.9.0",
    "eslint-plugin-import": "^2.20.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^3.1.2",
    "eslint-plugin-react": "^7.18.0",
    "eslint-plugin-react-hooks": "^2.3.0",
    "husky": "^4.2.1",
    "lint-staged": "^10.0.2",
    "prettier": "^1.19.1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/gatsbyjs/gatsby-starter-hello-world.git"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.+(js|jsx)": [
      "eslint --fix",
      "git add"
    ],
    "*.+(json|css|md)": [
      "prettier --write",
      "git add"
    ]
  },
  "homepage": "https://github.com/gatsbyjs/gatsby-starter-hello-world#readme",
  "main": ".eslintrc.js",
  "directories": {
    "example": "examples"
  },
  "keywords": [],
  "author": ""
}

@huangjihua
Copy link

  "lint-staged": {
    "src/*.ts": [
      "prettier --write",
      "eslint --cache --fix",
      "git add"  // lint-staged 在10以上版本无需增加 git add
    ]
  },

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

6 participants