git commit bypasses code inspection

The first is the background when I use this command. After the local branch merges with the master branch (in order to resolve some conflicts in advance), I then submit mr and request to merge the local branch into the master branch.
The problem lies in the commit after the local branch merges with the master branch to resolve the conflict. Because a lot of content has been updated on the master branch, a lot of files have been updated during the commit.

Insert image description here
The git commit failed to submit, and a lot of errors were reported. When I saw it, they were all eslint syntax errors, and they were all files updated from the master branch. It was probably some historical issues. I definitely didn’t have time to modify them one by one at this time, so I had to go around the errors
Insert image description here
. The eslint syntax is checked in the pre-commit hook. Here is the explanation for this

First, let’s get to know the hooks of git:

Hooks are stored in the hooks subdirectory of the git directory. That is, .git/hooks in most projects. When using git init to initialize a new repository, git will place some sample scripts in this directory by default. In addition to being called themselves, these scripts also reveal the parameters passed in when they are triggered. All of the examples are shell scripts, some with Perl code mixed in, but any properly named executable script will work.

GIT_DIR/hooks/pre-commit :

This hook is called by the git commit command and can be skipped by adding the –no-verify parameter to the command. This hook requires no parameters and is called after getting the commit message and before starting the commit. If the hook return value is not 0, the git commit command will abort execution.

**Annotation:** This hook can be used to check for code errors before submission (such as running the lint program).

Guess you like

Origin blog.csdn.net/xiaoxiannv666/article/details/119775776
Recommended