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

commitlint does not detect input #777

Closed
1 of 4 tasks
DanielRuf opened this issue Aug 15, 2019 · 9 comments
Closed
1 of 4 tasks

commitlint does not detect input #777

DanielRuf opened this issue Aug 15, 2019 · 9 comments
Labels

Comments

@DanielRuf
Copy link

DanielRuf commented Aug 15, 2019

Expected Behavior

Currently when we have a Git hook (sh script) with only commitlint as command, it fails to fall back to COMMIT_EDITMSG.

Current Behavior

It fails with [input] is required: supply via stdin, or --env or --edit or --from and --to

Using commitlint --edit works.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Check the fallback if it works.

Steps to Reproduce (for bugs)

  1. Create a hook with only commitlint as command

Context

Your Environment

Executable Version
commitlint --version VERSION
git --version VERSION
node --version VERSION
@marionebl
Copy link
Contributor

Thanks for reporting. Could you share the invocation of commitlint you use in the git hook script?

@DanielRuf
Copy link
Author

with only commitlint as command

@DanielRuf
Copy link
Author

There is nothing more.

@anikethsaha
Copy link

I am facing this same issue, I am not using husky and here is my package.json

 "gitHooks": {
        "pre-commit": "lint-staged",
        "commit-msg": "commitlint"
    },

@TrevorRice
Copy link

I am facing this same issue, I am not using husky and here is my package.json

 "gitHooks": {
        "pre-commit": "lint-staged",
        "commit-msg": "commitlint"
    },

@anikethsaha are you using Vue CLI by chance? If so, this article might be of use.

@anikethsaha
Copy link

anikethsaha commented Jul 10, 2020

no I am not using that, its just standalone project.

though I will check the article, thanks

@ghost
Copy link

ghost commented Aug 29, 2020

Having same problem using commitlint with husky & have been doing so for years.

For me this happened about a month ago. I haven't changed anything relevant in my package.json file; it just happened one day after doing a @commitlint/cli version upgrade; there were days in between doing other things so didn't notice & by time I did it was too late to pin-point.

Anyway hadn't got around to sorting it out until now. In meanwhile I've been git commiting manually with --no-verify on the command line but it's really getting a drag.

Good news is I can show something reproducible just from bash command line on Linux Mint.

Firstly my package.json:

  "devDependencies": {
    "@commitlint/cli": "9.1.2",
    "@commitlint/config-conventional": "9.1.2",
    "eslint": "7.7.0",
    "husky": "4.2.5",
    "lint-staged": "10.2.13",
    "prettier": "2.1.1",
    "tappity-tap": "latest",
    "typescript": "4.0.2"
  },
  "commitlint": {
    "extends": [
      "@commitlint/config-conventional"
    ]
  },
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -e $GIT_PARAMS",
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "**/*.ts": [
      "eslint --fix",
      "prettier --write"
    ]
  }

Now to demonstrate @commitlint/cli working ...

$ $ ./node_modules/.bin/commitlint <.git/COMMIT_EDITMSG ; echo $?
0

and now failing ...

$ ./node_modules/.bin/commitlint -e ; echo $?
@commitlint/cli@9.1.2 - Lint your commit messages

[input] reads from stdin if --edit, --env, --from and --to are omitted

Options:
  --color, -c          toggle colored output           [boolean] [default: true]
  --config, -g         path to the config file                          [string]
  --cwd, -d            directory to execute in
                                         [string] [default: (Working Directory)]
  --edit, -e           read last commit message from the specified file or
                       fallbacks to ./.git/COMMIT_EDITMSG
                                                       [string] [default: false]
  --env, -E            check message in the file at path given by environment
                       variable value                                   [string]
  --extends, -x        array of shareable configurations to extend       [array]
  --help-url, -H       help url in error message                        [string]
  --from, -f           lower end of the commit range to lint; applies if
                       edit=false                                       [string]
  --format, -o         output format of the results                     [string]
  --parser-preset, -p  configuration preset to use for
                       conventional-commits-parser                      [string]
  --quiet, -q          toggle console output          [boolean] [default: false]
  --to, -t             upper end of the commit range to lint; applies if
                       edit=false                                       [string]
  --verbose, -V        enable verbose output for reports without problems
                                                                       [boolean]
  -v, --version        display version information                     [boolean]
  -h, --help           Show help                                       [boolean]
[input] is required: supply via stdin, or --env or --edit or --from and --to
1

Notice the echo $? command reporting 0 (success) in the first instance and 1 (fail) in the second instance.

Hope this helps. Feel sure this must be affecting many many people who have just given up.

At any rate, I'd like to say thanks for providing this FOSS package & well understand that volunteers maintain it.

@escapedcat
Copy link
Member

@indiescripter your problem might be handled in: #2065
Because it looks like you are using the -e flag.

This issue seems to be slightly different.

@ghost
Copy link

ghost commented Sep 1, 2020

Many thanks @escapedcat . Reverting to @commitlint/cli & @commitlint/config-conventional v9.1.1 escaped the problem!

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

No branches or pull requests

5 participants