Questions tagged [git-husky]

Git husky is a Git hook. Git hooks are scripts that Git executes before or after events such as: commit, push, and receive. Use this tag for questions specifically about Git husky, not for questions about Git hooks in general.

92 questions
0
votes
0 answers

Husky pre-commit hook not triggering using lint-staged

New to husky and having problems running pre-commit hook. pre-commit file (I have husky install script): #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" npx lint-staged .eslintrc: { "root": true, "parser": "@typescript-eslint/parser", …
moze
  • 322
  • 1
  • 5
  • 14
0
votes
1 answer

How to stop a commit if test coverage is below a certain percentage?

I'm using Jest to test a NestJS application and I'm trying to create a git hook with husky that will not allow a commit if tests coverage are under 95%, I haven't tried anything yet cause I really don't know how to even describe my question…
RinnieR
  • 209
  • 5
  • 15
0
votes
0 answers

Husky, git, detect new code and file extensions (for test)

It's a very custom question, but maybe someone has the answer or has been in this scenario. Is there a way to specify (maybe with Husky) that if some new file has been added in some folder, then the PR need to have an specific file extension too? My…
pmiranda
  • 7,602
  • 14
  • 72
  • 155
0
votes
1 answer

Run ESLint during commit on Angular projects

I configured Eslint on an Angular project to check the code during commits. I made an error on purpouse to test if my configuration works: I set the rule "no-console":"error" and I left a console.log() inside the code. When committing ESLint gives…
Matt
  • 265
  • 4
  • 17
0
votes
1 answer

.NET Core solution projects and husky v6 installation

I'd like to migrate husky from v4 to v6. As it says in the installation guide: Another case you may be in is if your package.json file and .git directory are not at the same level. [...] By design, husky install must be run in the same directory as…
0
votes
1 answer

Escape hatch for husky v6?

I've recently installed husky v6 - and I love it. But sometimes I would like to avoid running it - is there some argument that provides an escape hatch?
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
0
votes
0 answers

Protect deleting/renaming file in git repository

Is it possible to have one or more files in a git repository that can be changed but not deleted or renamed? The use case is about a repository setup where multiple env files can only be tweaked by developers but prevent them to accidentally delete…
kuus
  • 453
  • 1
  • 5
  • 15
0
votes
1 answer

Husky not getting triggered on git events

I have created a react app which implements husky to capture lint errors: Environment git version 2.21.0 (Apple Git-122), node v8.16.2, npm v6.4.1 Lint implementation Created a react using npx create-react-app my-app-name Implemented eslint using…
Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219
0
votes
1 answer

GIT: How to trigger an npm script, after git push of particular file in the remote branch?

I have a requirement that once I push a csv file to remote branch, it should call an npm script to process the data from CSV file. Please advice which would be the best way to do this.
Narasimhan
  • 73
  • 1
  • 7
0
votes
1 answer

Yorkie git hooks always fail with "not found"

I am using yorkie 2.0.0, and cannot run any custom shell scripts in my git hooks. My directory structure looks like this: |-- .githooks | |-- commit-msg | |-- package.json |-- .git | |-- hooks | | |--
Daniel Smedema
  • 919
  • 8
  • 15
0
votes
1 answer

Why does `git` commands fail when run as part of a git hook in a subfolder?

We recently moved a Node project into a subfolder of a mono-repo, and after that our commit hooks (installed using Husky) started failing due to being executed in the wrong directory: { Error: Command failed: git rev-parse HEAD fatal: not a git…
oligofren
  • 20,744
  • 16
  • 93
  • 180
0
votes
1 answer

GIT (HUSKY): exit code when a file is being committed?

is there a way to check if a file is being committed and exit with an error ? I have a file in git that needs to be there but should never be modified and i was hoping to use husky as a pre-commit - so if anybody tries to modify the file and commit…
Mark Smith
  • 437
  • 1
  • 6
  • 11
0
votes
0 answers

Git push error with Husky

I'm using Windows with git bash, and yesterday i did a commit with other scripts and nothing happened. Today I can't push my files on account this error above. Anyone knows why this happening?
Daniel Pereira
  • 495
  • 1
  • 5
  • 19
0
votes
1 answer

Custom git hook in package.json with husky

I am trying to validate the commit message at commit. For that, I am using Husky and the commit-msg hook. However, as I also do commit message validation at build time, I want the validation code to be available in a separate JS file. So I am trying…
Stilltorik
  • 1,662
  • 4
  • 19
  • 31
0
votes
1 answer

Tslint on latest Ionic

I am trying to lint my ionic project and abort the commit if lint fails. Running npm run lint in the console shows the error. I have installed precommit and lately husky ("husky": "^0.15.0-rc.6") with the below code inside package.json "husky": { …
Xerri
  • 4,916
  • 6
  • 45
  • 54