2

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)

Niloct
  • 9,491
  • 3
  • 44
  • 57

1 Answers1

1

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).

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
  • Thanks for the info, but then, check this: https://github.com/python/cpython/search?q=pre-commit There is no git pre-commit hook in the online repository. – Niloct Nov 19 '20 at 14:04
  • makes sense: you don't clone it, you run something that creates one upon deploying the repository. This might be simple as "copy this file in the git hook folder and rename it", or "clone these files and put them in that folder". Your query shows interesting results in that sense. – Daemon Painter Nov 19 '20 at 14:15
  • 1
    I am guessing they refer to pre-commit hooks as Travis related hooks. Take a look at https://github.com/python/cpython/tree/master/Tools/scripts (patchcheck.py) – Niloct Nov 19 '20 at 14:39
  • Yes, and I do believe something is moving at least some of the scripts to the git hook folder and have them automatically executed. By I need to find a stronger evidence of this. – Daemon Painter Nov 19 '20 at 15:20