pre-commit-hook

Does it make sense to add `go mod vendor` to a pre-commit hook?

拈花ヽ惹草 提交于 2021-02-07 10:59:35
问题 Setup: Our project is using golang 1.12.14 We are using go build -mod=vendor Issue: When new dependencies are added to go.mod the vendor folder isn't updated and people are committing code and forgetting to run go mod vendor to update the folder. My understanding is that since -mod=vendor specifies to use packages from the vendor folder, the go.mod file will have discrepancies from what we are actually using when building the project. Question: Should go mod vendor be added to a pre-commit

npm run deploy ignore hooks

Deadly 提交于 2020-07-18 08:11:09
问题 I was getting below error while committing the changes. Simply adding .pre-commit-config.yaml file or deleting .git\hooks folder was not resolving my problem. So I added --no-verify option while committing and it solved my problem. Now, I am trying to deploy my react app to Github Pages. When I run npm run deploy I get the same error as shown in the below picture. How I can add --no-verify option while npm run deploy ? Simply adding .pre-commit-config.yaml file or deleting .git\hooks folder

Bash confirmation won't wait for user input

筅森魡賤 提交于 2020-06-12 08:02:46
问题 I am trying to implement confirmation prompt with a bash script but for some reason, prompt won't wait for user input. I've tried many examples but no luck so far. I am on MacOS if it makes any difference. Just a few examples I tried (All copy+paste from other answers in SO): #!/bin/bash read -p "Are you sure? " -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]] then # do dangerous stuff fi #!/bin/bash read -p "Continue (y/n)?" CONT if [ "$CONT" = "y" ]; then echo "yaaa";

lint-staged not running on precommit

大城市里の小女人 提交于 2020-05-10 07:25:30
问题 prettier is not running on precommit. This worked with the same configuration in other projects, so I'm baffled why it's not working this time. This is the relevant section of my package.json file: "scripts": { "precommit": "lint-staged" }, "lint-staged": { "*.{js,json,css,scss,html,md}": [ "prettier --write", "git add" ] }, Edit. Here are the relevant devDependencies: "devDependencies": { "husky": "^0.14.3", "lint-staged": "^7.0.4", "prettier": "1.12.0" }, 回答1: The problem for me was I ran "

lint-staged not running on precommit

走远了吗. 提交于 2020-05-10 07:25:10
问题 prettier is not running on precommit. This worked with the same configuration in other projects, so I'm baffled why it's not working this time. This is the relevant section of my package.json file: "scripts": { "precommit": "lint-staged" }, "lint-staged": { "*.{js,json,css,scss,html,md}": [ "prettier --write", "git add" ] }, Edit. Here are the relevant devDependencies: "devDependencies": { "husky": "^0.14.3", "lint-staged": "^7.0.4", "prettier": "1.12.0" }, 回答1: The problem for me was I ran "

Unexpected behavior with “git commit .” when pre-commit hook modifies staged files

房东的猫 提交于 2020-04-15 03:45:31
问题 In my experience git commit -a has had equivalent behavior to git commit . However, recently I have created a pre-commit hook that automatically formats my source code and now git commit . has some unexpected side-effects: the file that is committed ends up as modified in the working directory and in the index after the commit command finishes. This doesn't happen with git commit -a . I'm trying to understand what is going on behind the scenes when running git commit . that is causing this to

Calling git in pre-commit hook

江枫思渺然 提交于 2020-01-25 10:13:37
问题 I am getting weird results of running my git pre-commit hook, for example when I do git diff --name-only in terminal it seems to give different result than when it is executed in .git/hooks/pre-commit So my questions are: Am I allowed to call git inside git hooks? If 1. is ok: when exactly is pre-commit hook called if I do git commit -am"bla"? In particular does git do staging first and then it calls the pre-commit hook or not? I ask this because I tried 2 or 3 times this: I modify a file, I

Trying to create a pre-commit hook that verify externals

痞子三分冷 提交于 2020-01-16 19:17:06
问题 I am currently trying to create a pre-commit hook that prevent user to tag a version of code with external that are not tags. I am just trying to figure out a way to get the external that are specify in a transaction but cant figure out how. The command svnlook dont seem to be able to return anything that remotely look like externals modification. And with the svn command it seem to be the transaction that I am unable to specify. I have no idea what command to use in my pre-commit hook. I am

Python pre-commit unittest faild

可紊 提交于 2020-01-14 02:39:19
问题 I wish pre-commit to run the tests before committing my code. The command python -m unittest discover is working in the command line. D:\project_dir>python -m unittest discover ... ... ... ---------------------------------------------------------------------- Ran 5 tests in 6.743s OK But when trying to commit I am getting D:\project_dir>git commit -m "fix tests with hook" run tests................................................................Failed hookid: tests usage: python.exe -m

Git pre-commit hook not working on windows

别说谁变了你拦得住时间么 提交于 2020-01-01 18:20:11
问题 I have a git pre-commit hook, but after commiting to the local repo, the script does not get called. This is how it looks, it is in python, the name of the hook file is called pre-commit without any extension: #!C:/Users/al/AppData/Local/Programs/Python/Python35-32 python import sys, os sys.exit(1) 回答1: Your pre-commit hook might suffer from one or more of the following issues: Is the shebang line correct? The shebang line should be the complete path to the executable which is used to run the