Niloct
Niloct

Reputation: 10015

Are pre-commit hooks clonable?

I was reading PEP8:

a backslash followed by a space and a newline does not count as a line continuation marker. Some editors don't preserve it and many projects (like CPython itself) have pre-commit hooks that reject it.

Resorting to the community, I thought pre-commit hooks weren't pushable/clonable.

How can CPython have pre-commit hooks if this is true ?

(A naive question perhaps)

Upvotes: 2

Views: 140

Answers (1)

Daemon Painter
Daemon Painter

Reputation: 3520

Git hooks are client-side or server-side. Please note that

It’s important to note that client-side hooks are not copied when you clone a repository. If your intent with these scripts is to enforce a policy, you’ll probably want to do that on the server side source

The distinction is based on the type of operation being performed:

Client-side hooks are triggered by operations such as committing and merging, while server-side hooks run on network operations such as receiving pushed commits.

pre-commit hooks are client-side, thus not clonable as you correctly state. I find this discussion on why that would also be a large security risk.

However, regarding PEP8 I believe this page is holding the answer. The pre-commit scripts are created locally from the repository on your machine (and, of course, can be bypassed).

Upvotes: 1

Related Questions