From 6814f28def9771dd45fe6d6b58fa48fecce0e49d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 31 Dec 2014 13:13:40 -0800 Subject: [PATCH 001/854] s/bootstrap-sass/sass-bootstrap/g --- base.mako | 4 ++-- bower.json | 2 +- scss/main.scss | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/base.mako b/base.mako index ebfd5755..62b8dc29 100644 --- a/base.mako +++ b/base.mako @@ -47,7 +47,7 @@

A framework for managing and maintaining multi-language pre-commit hooks.

Build Status Coverage Status

-

@@ -62,7 +62,7 @@ - +

+

diff --git a/index.mako b/index.mako index af9051ba..970d2ddc 100644 --- a/index.mako +++ b/index.mako @@ -243,7 +243,7 @@ host. For configuring Docker hooks, your entry should correspond to an executable inside the Docker container, and will be used to override the default container - entrypoint. Your Docker CMD will not run when + entrypoint. Your Docker CMD will not run when pre-commit passes a file list as arguments to the run container command. Docker allows you to use any language that's not supported by pre-commit as a builtin. @@ -354,7 +354,7 @@

script

Script hooks provide a way to write simple scripts which - valdiate files. The entry should be a path + valdiate files. The entry should be a path relative to the root of the hook repository.

From 1b462efba48c19b8b14ead4f8d9cf2298b3fdd0c Mon Sep 17 00:00:00 2001 From: Frieder Bluemle Date: Mon, 15 May 2017 22:36:07 +0800 Subject: [PATCH 092/854] Fix GitHub spelling --- base.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base.mako b/base.mako index 7be16e93..0eaa9ecf 100644 --- a/base.mako +++ b/base.mako @@ -30,7 +30,7 @@

  • Demo
  • From 6a694f88a499129987ed4a061c040838c0c1afef Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Tue, 13 Jun 2017 18:07:12 -0700 Subject: [PATCH 093/854] Fix typo --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 0c74f415..89287710 100644 --- a/index.mako +++ b/index.mako @@ -352,7 +352,7 @@

    script

    Script hooks provide a way to write simple scripts which - valdiate files. The entry should be a path + validate files. The entry should be a path relative to the root of the hook repository.

    From edc0d6f7fc4fd82490ce5bc8282d8742af1c9219 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 3 Jul 2017 12:40:58 -0700 Subject: [PATCH 094/854] Switch from bower to npm --- .gitignore | 3 +-- Makefile | 18 +++++++++--------- base.mako | 4 ++-- bower.json | 8 -------- package.json | 5 +++++ requirements-dev.txt | 1 - scss/main.scss | 2 +- 7 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 bower.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 7b46b5f5..93aaa514 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ .project .pydevproject /all-hooks.json -/bower_components +/node_modules /build -/nenv /venv diff --git a/Makefile b/Makefile index 5cfd9d0c..b66caee3 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ all: install-hooks build/main.css all-hooks.json index.html hooks.html install-hooks: venv venv/bin/pre-commit install -build/main.css: nenv build scss/main.scss scss/_variables.scss +build/main.css: venv node_modules build scss/main.scss scss/_variables.scss venv/bin/sassc -s compressed scss/main.scss build/main.css all-hooks.json: venv make_all_hooks.py all-repos.yaml @@ -20,23 +20,23 @@ venv: requirements-dev.txt Makefile virtualenv venv -ppython3.6 venv/bin/pip install -r requirements-dev.txt -nenv: venv - rm -rf nenv - venv/bin/nodeenv nenv --prebuilt && \ - . nenv/bin/activate && \ - npm install -g bower && \ - bower install +node_modules: package.json + ( \ + npm install && \ + npm prune && \ + touch $@ \ + ) || touch $@ --reference $^ --date '1 day ago' push: venv venv/bin/markdown-to-presentation push \ --master-branch real_master \ --pages-branch master \ .travis.yml README.md CNAME \ - build bower_components *.html *.png favicon.ico \ + build node_modules *.html *.png favicon.ico \ all-hooks.json install-local.py clean: - rm -rf venv nenv build bower_components *.html all-hooks.json + rm -rf venv build node_modules *.html all-hooks.json build: mkdir -p build diff --git a/base.mako b/base.mako index 0eaa9ecf..69202421 100644 --- a/base.mako +++ b/base.mako @@ -62,8 +62,8 @@ Brought to you by Yelp. Check out some of our other open source projects on GitHub. - - + + From 529592e3444f2276c322a1c3863323b4b614cda7 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 23 Aug 2017 09:00:57 -0700 Subject: [PATCH 109/854] Document long regular expressions --- index.mako | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/index.mako b/index.mako index 7782634a..df05cc35 100644 --- a/index.mako +++ b/index.mako @@ -640,6 +640,39 @@ $ identify-cli --filename-only some-random-file; echo $? here is a guide to ensuring compatibility.

    +

    Regular expressions

    + +

    + The patterns for files and exclude + are python + regular expressions. +

    + +

    + As such, you can use any of the features that python regexes + support. +

    + +

    + If you find that your regular expression is becoming unwieldy + due to a long list of excluded / included things, you may find + a + verbose + regular expression useful. One can enable this with yaml's + multiline literals and the (?x) regex flag. + +

    +# ...
    +    -   id: my-hook
    +        exclude: >
    +            (?x)^(
    +                path/to/file1.py|
    +                path/to/file2.py|
    +                path/to/file3.py
    +            )$
    +
    +

    +

    Overriding Language Version

    Sometimes you only want to run the hooks on a specific version of the language. For each language, they default to using the system installed language (So for example if I’m running python2.6 and a hook specifies python, pre-commit will run the hook using python2.6). Sometimes you don’t want the default system installed version so you can override this on a per-hook basis by setting the language_version.

    
    From 7ce18926b5a4f2e4d3e07183e540d1538dfabd18 Mon Sep 17 00:00:00 2001
    From: Anthony Sottile 
    Date: Sat, 2 Sep 2017 18:57:46 -0700
    Subject: [PATCH 110/854] local hooks can use `types` too.
    
    ---
     index.mako | 7 ++++++-
     1 file changed, 6 insertions(+), 1 deletion(-)
    
    diff --git a/index.mako b/index.mako
    index df05cc35..a452dd8a 100644
    --- a/index.mako
    +++ b/index.mako
    @@ -523,7 +523,12 @@
                     This enables you to install things which previously would
                     require a trivial mirror repository.
                 

    -

    A local hook must define id, name, language, entry, and files as specified under Creating new hooks

    +

    + A local hook must define id, + name, language, entry, + and files / types as specified under + Creating new hooks +

    Here's an example configuration with a few local hooks:

     -   repo: local
    
    From edbe523d7e36d171de46453a414879222711caa1 Mon Sep 17 00:00:00 2001
    From: Anthony Sottile 
    Date: Sat, 2 Sep 2017 21:03:49 -0700
    Subject: [PATCH 111/854] Document the docker_image language
    
    ---
     index.mako | 40 +++++++++++++++++++++++++++++++++++++++-
     1 file changed, 39 insertions(+), 1 deletion(-)
    
    diff --git a/index.mako b/index.mako
    index a452dd8a..388100db 100644
    --- a/index.mako
    +++ b/index.mako
    @@ -245,6 +245,7 @@
                 

    Supported languages

    • docker
    • +
    • docker_image
    • golang
    • node
    • python
    • @@ -283,6 +284,42 @@ for an example Docker-based hook.

      +

      docker_image

      +

      new in 0.18.0

      +

      + A more lightweight approach to docker hooks. The + docker_image "language" uses existing docker + images to provide hook executables. +

      +

      + docker_image hooks can be conviently configured as + local hooks. +

      +

      + The entry specifies the docker tag to use. If + an image has a ENTRYPOINT defined, nothing + special is needed to hook up the executable. If the container + does not specify an ENTRYPOINT or you want to + change the entrypoint you can specify it as well in your + entry. +

      +

      For example:

      +
      +-   id: dockerfile-provides-entrypoint
      +    name: ...
      +    language: docker_image
      +    entry: my.registry.example.com/docker-image-1:latest
      +-   id: dockerfile-no-entrypoint-1
      +    name: ...
      +    language: docker_image
      +    entry: --entrypoint my-exe my.registry.example.com/docker-image-2:latest
      +# Alternative equivalent solution
      +-   id: dockerfile-no-entrypoint-2
      +    name: ///
      +    language: docker_image
      +    entry: my.registry.example.com/docker-image-3:latest my-exe
      +
      +

      golang

      new in 0.12.0

      @@ -519,7 +556,8 @@

      new in 0.13.0 repository hooks can use any language which supports additional_dependencies or - pcre / script / system. + pcre / script / system / + docker_image. This enables you to install things which previously would require a trivial mirror repository.

      From 3f871a76dd864df69487da3e42a6df5c709423bc Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 2 Sep 2017 21:13:23 -0700 Subject: [PATCH 112/854] Fix some typos --- index.mako | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.mako b/index.mako index 388100db..c2daf564 100644 --- a/index.mako +++ b/index.mako @@ -297,7 +297,7 @@

      The entry specifies the docker tag to use. If - an image has a ENTRYPOINT defined, nothing + an image has an ENTRYPOINT defined, nothing special is needed to hook up the executable. If the container does not specify an ENTRYPOINT or you want to change the entrypoint you can specify it as well in your @@ -315,7 +315,7 @@ entry: --entrypoint my-exe my.registry.example.com/docker-image-2:latest # Alternative equivalent solution - id: dockerfile-no-entrypoint-2 - name: /// + name: ... language: docker_image entry: my.registry.example.com/docker-image-3:latest my-exe

    From ccc643a187ceb75fd2e2373bcfa4bb00c0f2f675 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 6 Sep 2017 11:22:14 -0700 Subject: [PATCH 113/854] Add header id --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index c2daf564..e16c72fd 100644 --- a/index.mako +++ b/index.mako @@ -527,7 +527,7 @@

    This will pass --max-line-length=131 to flake8.

    -

    Arguments Pattern in hooks

    +

    Arguments Pattern in hooks

    If you are writing your own custom hook as a script-type or even a system hook, your hook should expect to receive the args value and then a list of staged files.

    For example, assuming a .pre-commit-config.yaml:

    From 7bfdbdf88ab035f0705797b86c39a9a018327a00 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 13 Sep 2017 16:34:22 -0700 Subject: [PATCH 114/854] Document the command line interface --- index.mako | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/index.mako b/index.mako index e16c72fd..5acfe829 100644 --- a/index.mako +++ b/index.mako @@ -8,6 +8,7 @@
  • Adding plugins
  • Usage
  • Creating new hooks
  • +
  • Command line interface
  • Advanced features
  • Contributing
  • @@ -462,6 +463,186 @@

    +
    + + +

    All pre-commit commands take the following options:

    +
      +
    • + --color {auto,always,never}: whether to use + color in output. Defaults to `auto`. +
    • +
    • + -c CONFIG, --config CONFIG: + path to alternate config file +
    • +
    • + -h, --help: show help and + available options. +
    • +
    + +

    pre-commit autoupdate [options]

    +

    Auto-update pre-commit config to the latest repos' versions.

    +

    Options:

    +

    +

      +
    • + --bleeding-edge: update to the bleeding + edge of `master` instead of the latest tagged version + (the default behaviour). +
    • +
    +

    + +

    pre-commit clean [options]

    +

    Clean out cached pre-commit files.

    +

    Options: (no additional options)

    + +

    pre-commit install [options]

    +

    Install the pre-commit script.

    +

    Options:

    +

    +

      +
    • + -f, --overwrite: overwrite + existing hooks / remove migration mode. +
    • +
    • + --install-hooks: also install hook + environments for all available hooks. +
    • +
    • + -t {pre-commit,pre-push,commit-msg}, + --hook-type {pre-commit,pre-push,commit-msg}: + which hook type to install. +
    • +
    • + --allow-missing-config: whether to allow + the installed hook scripts to permit a missing + configuration file. +
    • +
    +

    +

    Some example useful invocations:

    +

    +

      +
    • + pre-commit install: default install + invocation will run existing hook scripts alongside + pre-commit. +
    • +
    • + pre-commit install -f --install-hooks: + idempotently replace git hook scripts with pre-commit + and also install hooks. +
    • +
    +

    + +

    pre-commit install-hooks [options]

    +

    + Install hook environments for all environments in the config + file. You may find + pre-commit install --install-hooks more useful. +

    +

    Options: (no additional options)

    + +

    pre-commit migrate-config [options]

    +

    + new in 1.0.0 Migrate list configuration to the new + map configuration format. +

    +

    Options: (no additional options)

    + +

    pre-commit run [hook-id] [options]

    +

    Run hooks.

    +

    Options:

    +

    +

      +
    • + [hook-id]: specify a single hook-id to run + only that hook. +
    • +
    • + -a, --all-files: run on all + the files in the repo. +
    • +
    • + --files [FILES [FILES ...]]: specific + filenames to run hooks on. +
    • +
    • + --source SOURCE + + --origin ORIGIN: run against the files + changed between SOURCE...ORIGIN in git. +
    • +
    • + --show-diff-on-failure: + new in 0.13.4 when hooks fail, run + git diff directly afterward. +
    • +
    • + -v, --verbose: produce hook + output independent of success. Include hook ids in + output. +
    • +
    +

    + +

    Some example useful invocations:

    +

    +

      +
    • + pre-commit run: this is what pre-commit + runs by default when committing. This will run all + hooks against currently staged files. +
    • +
    • + pre-commit run --all-files: run all the + hooks against all the files. This is a useful + invocation if you are using pre-commit in CI. +
    • +
    • + pre-commit run flake8: run the `flake8` + hook against all staged files. +
    • +
    • + + git ls-files -- '*.py' | + xargs pre-commit run --files + : run all hooks against all '*.py' files in the + repository. +
    • +
    • + + pre-commit run --source HEAD^^^ + --origin HEAD + : run against the files that have changed + between HEAD^^^ and HEAD. This form is useful when + leveraged in a pre-receive hook. +
    • +
    +

    + +

    pre-commit sample-config [options]

    +

    Produce a sample .pre-commit-config.yaml.

    +

    Options: (no additional options)

    + +

    pre-commit uninstall

    +

    Uninstall the pre-commit script.

    +

    Options:

    +

    +

      +
    • + -t {pre-commit,pre-push,commit-msg}, + --hook-type {pre-commit,pre-push,commit-msg}: + which hook type to uninstall. +
    • +
    +

    +
    +
    @@ -606,6 +630,32 @@ Produce a sample `.pre-commit-config.yaml`. Options: (no additional options) +## pre-commit try-repo REPO [options] [](#pre-commit-try-repo) + +_new in 1.3.0_ Try the hooks in a repository, useful for developing new hooks. +`try-repo` can also be used for testing out a repository before adding it to +your configuration. `try-repo` prints a configuration it generates based on +the remote hook repository before running the hooks. + +Options: + +- `REPO`: required clonable hooks repository. Can be a local path on + disk. +- `--ref REF`: Manually select a ref to run against, otherwise the `HEAD` + revision will be used. +- `pre-commit try-repo` also supports all available options for + [`pre-commit run`](#pre-commit-run). + +Some example useful invocations: +- `pre-commit try-repo git://github.com/pre-commit/pre-commit-hooks`: runs all + the hooks in the latest revision of `pre-commit/pre-commit-hooks`. +- `pre-commit try-repo ../path/to/repo`: run all the hooks in a repository on + disk. +- `pre-commit try-repo ../pre-commit-hooks flake8`: run only the `flake8` hook + configured in a local `../pre-commit-hooks` repository. +- See [`pre-commit run`](#pre-commit-run) for more useful `run` invocations + which are also supported by `pre-commit try-repo`. + ## pre-commit uninstall [options] [](#pre-commit-uninstall) Uninstall the pre-commit script. From 27b521618289777d04e1ec158573f4348712bc2d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 10 Oct 2017 15:08:36 -0700 Subject: [PATCH 127/854] Document repeatability and lack of 'sha: latest' support --- index.mako | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/index.mako b/index.mako index 48ee4c03..7b179031 100644 --- a/index.mako +++ b/index.mako @@ -943,6 +943,23 @@ instance, adding `pre-commit run --all-files` as a CI step will ensure everything stays in tip-top shape. To check only files which have changed, which may be faster, use something like `git diff-tree --no-commit-id --name-only -r $REVISION | xargs pre-commit run --files`. + +## Using the latest sha for a repository + +`pre-commit` configuration aims to give a repeatable and fast experience and +therefore intentionally doesn't provide facilities for "unpinned latest +version" for hook repositories. + +Instead, `pre-commit` provides tools to make it easy to upgrade to the +latest versions with [`pre-commit autoupdate`](#pre-commit-autoupdate). If +you need the absolute latest version of a hook (instead of the latest tagged +version), pass the `--bleeding-edge` parameter to `autoupdate`. + +`pre-commit` assumes that the value of `sha` is an immutable ref (such as a +tag or SHA) and will cache based on that. Using a branch name (or `HEAD`) for +the value of `sha` is not supported and will only represent the state of +that mutable ref at the time of hook installation (and will *NOT* update +automatically). ''')}
    From 3ae3d8af4f7dbfe4b5a44b3215c22353b8b2c3a1 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 27 Oct 2017 08:13:02 -0700 Subject: [PATCH 128/854] Add doctoc to hooks list: thlorenz/doctoc#134 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 44a5fa51..bda7d582 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -61,3 +61,4 @@ - git://github.com/awebdeveloper/pre-commit-prettier - git://github.com/prettier/prettier - git://github.com/adrienverge/yamllint +- git://github.com/thlorenz/doctoc From 9799440aba3ba4a0cd326ceb5a07b50827657dc9 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 27 Oct 2017 09:58:03 -0700 Subject: [PATCH 129/854] Document necessary passenv with tox --- index.mako | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/index.mako b/index.mako index 7b179031..2a82cf66 100644 --- a/index.mako +++ b/index.mako @@ -944,6 +944,57 @@ everything stays in tip-top shape. To check only files which have changed, which may be faster, use something like `git diff-tree --no-commit-id --name-only -r $REVISION | xargs pre-commit run --files`. +## Usage with tox + +[tox](http://tox.readthedocs.io/) is useful for configuring test / CI tools +such as pre-commit. One feature of `tox>=2` is it will clear environment +variables such that tests are more reproducible. Under some conditions, +pre-commit requires a few environment variables and so they must be +whitelisted. + +When cloning repos over ssh (`repo: git@github.com:...`), `git` requires the +`SSH_AUTH_SOCK` variable and will otherwise fail: + +``` +[INFO] Initializing environment for git@github.com:pre-commit/pre-commit-hooks. +An unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/git', 'clone', '--no-checkout', 'git@github.com:pre-commit/pre-commit-hooks', '/home/asottile/.cache/pre-commit/repofdkwkq_v') +Return code: 128 +Expected return code: 0 +Output: (none) +Errors: + Cloning into '/home/asottile/.cache/pre-commit/repofdkwkq_v'... + Permission denied (publickey). + fatal: Could not read from remote repository. + + Please make sure you have the correct access rights + and the repository exists. + + +Check the log at /home/asottile/.cache/pre-commit/pre-commit.log +``` + +Add the following to your tox testenv: + +```ini +[testenv] +passenv = SSH_AUTH_SOCK +``` + +pre-commit uses `os.path.expanduser` to create the cache directory, on windows +this requires the `HOMEPATH` environment variable: + +```ini +[testenv] +passenv = HOMEPATH +``` + +Or with both: + +```ini +[testenv] +passenv = HOMEPATH SSH_AUTH_SOCK +``` + ## Using the latest sha for a repository `pre-commit` configuration aims to give a repeatable and fast experience and From 73775e9f7605968e0c84fea02395ae2b668c7d9e Mon Sep 17 00:00:00 2001 From: Jesse Lang Date: Wed, 1 Nov 2017 18:09:40 -0500 Subject: [PATCH 130/854] Add beautysh to the list of repos A Bash beautifier for the masses. https://pypi.python.org/pypi/beautysh --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index bda7d582..02c26245 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -44,6 +44,7 @@ # - git://github.com/jordant/rubocop-pre-commit-hook - git://github.com/jstewmon/check-swagger - git://github.com/detailyang/pre-commit-shell +- git://github.com/bemeurer/beautysh # https://github.com/sanmai-NL/pre-commit-hooks_R/issues/1 # - git://github.com/sanmai-NL/pre-commit-hooks_R # https://github.com/magicmark/pre-commit-es6-imports-reorder/issues/1 From 91bdd48f0521f393941ffe71250b239d87f01a26 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 8 Nov 2017 12:11:51 -0800 Subject: [PATCH 131/854] Document `pre-commit autoupdate --repo ...` --- index.mako | 1 + 1 file changed, 1 insertion(+) diff --git a/index.mako b/index.mako index 2a82cf66..7236b736 100644 --- a/index.mako +++ b/index.mako @@ -556,6 +556,7 @@ Options: - `--bleeding-edge`: update to the bleeding edge of `master` instead of the latest tagged version (the default behaviour). +- `--repo REPO`: _new in 1.4.0_ Only update this repository. ## pre-commit clean [options] [](#pre-commit-clean) From 87aefa859ce3e0e98f5dd5309f3ae336706aa40d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 9 Nov 2017 08:38:34 -0800 Subject: [PATCH 132/854] Update introduced version (1.4.0 was broken) --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 7236b736..43c94ae2 100644 --- a/index.mako +++ b/index.mako @@ -556,7 +556,7 @@ Options: - `--bleeding-edge`: update to the bleeding edge of `master` instead of the latest tagged version (the default behaviour). -- `--repo REPO`: _new in 1.4.0_ Only update this repository. +- `--repo REPO`: _new in 1.4.1_ Only update this repository. ## pre-commit clean [options] [](#pre-commit-clean) From 0c3252bc701991c1942cab8d0f838560351dbdae Mon Sep 17 00:00:00 2001 From: Fadi Hadzh Date: Thu, 16 Nov 2017 02:19:02 +0300 Subject: [PATCH 133/854] Add pre-commit-isort --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 02c26245..0512ca53 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -54,6 +54,7 @@ - git://github.com/doublify/pre-commit-clang-format - git://github.com/doublify/pre-commit-go - git://github.com/doublify/pre-commit-hindent +- git://github.com/doublify/pre-commit-isort - git://github.com/doublify/pre-commit-rust - git://github.com/chewse/pre-commit-mirrors-pydocstyle - git://github.com/kintoandar/pre-commit From c1a92413d9daaf1d29f6dd3b5e057dd21026f3e7 Mon Sep 17 00:00:00 2001 From: Thierry Deo Date: Fri, 15 Dec 2017 15:21:36 +0100 Subject: [PATCH 134/854] Remove pricematch mirrors and hooks --- all-repos.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/all-repos.yaml b/all-repos.yaml index 0512ca53..a1b763ff 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -21,9 +21,6 @@ - git://github.com/asottile/reorder_python_imports - git://github.com/asottile/cheetah_lint - git://github.com/digitalpulp/pre-commit-php -- git://github.com/pricematch/mirrors-rubocop -- git://github.com/pricematch/mirrors-closure-linter -- git://github.com/pricematch/pricematch-pre-commit-hooks - git://github.com/elidupuis/mirrors-jscs - git://github.com/elidupuis/mirrors-sass-lint # https://github.com/elidupuis/mirrors-standard/issues/2 From 094f4be368f6857c750a512711b4c33c1aabf0cd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 21 Dec 2017 10:31:56 -0800 Subject: [PATCH 135/854] Add yesqa to the list of pre-commit hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index a1b763ff..6b6f4b26 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -19,6 +19,7 @@ - git://github.com/asottile/add-trailing-comma - git://github.com/asottile/pyupgrade - git://github.com/asottile/reorder_python_imports +- git://github.com/asottile/yesqa - git://github.com/asottile/cheetah_lint - git://github.com/digitalpulp/pre-commit-php - git://github.com/elidupuis/mirrors-jscs From 3d5303712fabc63b599bfc4f92af7e9d3d614152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Mon, 1 Jan 2018 22:58:48 +0100 Subject: [PATCH 136/854] fixed minor typo in documentation --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 43c94ae2..f86fa138 100644 --- a/index.mako +++ b/index.mako @@ -718,7 +718,7 @@ implicit conflicts (such as with removed python imports). _new in 0.3.5_ pre-commit can be used to manage `pre-push` hooks. Simply `pre-commit install --hook-type pre-push`. -## pre-commit for commit messsages +## pre-commit for commit messages _new in 0.15.4_ pre-commit can be used to manage `commit-msg` hooks. Simply `pre-commit install --hook-type commit-msg`. From e00644ba88202759f0de106b80085a57b2c59ea0 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 13 Jan 2018 18:11:04 -0800 Subject: [PATCH 137/854] https --- README.md | 2 +- base.mako | 6 +++--- index.mako | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 27365bc1..7b20e514 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ pre-commit.github.io [![Build Status](https://travis-ci.org/pre-commit/pre-commit.github.io.svg?branch=real_master)](https://travis-ci.org/pre-commit/pre-commit.github.io) -This powers http://pre-commit.com +This powers https://pre-commit.com diff --git a/base.mako b/base.mako index 7531351d..d2586941 100644 --- a/base.mako +++ b/base.mako @@ -39,7 +39,7 @@

    - + pre-commit

    @@ -47,9 +47,9 @@

    Build Status Coverage Status

    -

    - +

    diff --git a/index.mako b/index.mako index f86fa138..ab179cee 100644 --- a/index.mako +++ b/index.mako @@ -83,7 +83,7 @@ requirements-dev.txt): pre-commit ``` -Using [homebrew](http://brew.sh): +Using [homebrew](https://brew.sh): ``` brew install pre-commit @@ -947,7 +947,7 @@ which may be faster, use something like ## Usage with tox -[tox](http://tox.readthedocs.io/) is useful for configuring test / CI tools +[tox](https://tox.readthedocs.io/) is useful for configuring test / CI tools such as pre-commit. One feature of `tox>=2` is it will clear environment variables such that tests are more reproducible. Under some conditions, pre-commit requires a few environment variables and so they must be From de0d6315796303fecabe0903a4dbdcc7d16afb3f Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 13 Jan 2018 20:08:30 -0800 Subject: [PATCH 138/854] Mention node support on windows --- index.mako | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.mako b/index.mako index ab179cee..e1ab9e98 100644 --- a/index.mako +++ b/index.mako @@ -417,6 +417,9 @@ match the `entry` – usually through `bin` in package.json. __Support:__ node hooks work without any system-level dependencies. It has been tested on linux and macOS and _may_ work under cygwin. +_new in 1.5.0_ windows is now supported for node hooks. Currently python3 +only due to [a bug in cpython](https://bugs.python.org/issue32539). + ### python The hook repository must have a `setup.py`. It will be installed via From 5a71f997a70388718da59eb609f808d8b2b466c6 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 15 Jan 2018 10:24:44 -0800 Subject: [PATCH 139/854] Add mirrors-isort --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 6b6f4b26..a6b78ee5 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -5,6 +5,7 @@ - git://github.com/pre-commit/mirrors-csslint - git://github.com/pre-commit/mirrors-eslint - git://github.com/pre-commit/mirrors-fixmyjs +- git://github.com/pre-commit/mirrors-isort - git://github.com/pre-commit/mirrors-jshint - git://github.com/pre-commit/mirrors-puppet-lint - git://github.com/pre-commit/mirrors-pylint From e33754985f31057d0afa54e2b439c48e090cf885 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 15 Jan 2018 18:47:56 -0800 Subject: [PATCH 140/854] Switch back to pre-commit.com now that it's https --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index e1ab9e98..6d72d6e9 100644 --- a/index.mako +++ b/index.mako @@ -67,7 +67,7 @@ Non Administrative Installation: ``` -curl https://raw.githubusercontent.com/pre-commit/pre-commit.github.io/real_master/install-local.py | python +curl https://pre-commit.com/install-local.py | python - ``` System Level Install: From b691f057b3a6f07f7b72621c5bd3ee32a0fd829c Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 1 Feb 2018 08:35:14 -0800 Subject: [PATCH 141/854] Document `py` launcher translation for windows --- .pre-commit-config.yaml | 1 - index.mako | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c3f6803..e5fb15d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,6 @@ entry: scss-lint types: [scss] language: ruby - language_version: 2.1.5 additional_dependencies: ['scss_lint:0.52.0'] - id: no-github-dot-git name: No need for .git for github urls diff --git a/index.mako b/index.mako index 6d72d6e9..be3d8af5 100644 --- a/index.mako +++ b/index.mako @@ -937,6 +937,11 @@ This tells pre-commit to use ruby `2.1.5` to run the `scss-lint` hook. Valid values for specific languages are listed below: - python: Whatever system installed python interpreters you have. The value of this argument is passed as the `-p` to `virtualenv`. + - _new in 1.4.3_: on windows the + [pep394](https://www.python.org/dev/peps/pep-0394/) name will be + translated into a py launcher call for portability. So continue to use + names like `python3` (`py -3`) or `python3.6` (`py -3.6`) even on + windows. - node: See [nodeenv](https://github.com/ekalinin/nodeenv#advanced). - ruby: See [ruby-build](https://github.com/sstephenson/ruby-build/tree/master/share/ruby-build). From c0eb556ef9f1aae21d3af0306b272b4de21b71f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Thu, 1 Feb 2018 18:27:45 +0100 Subject: [PATCH 142/854] Updated doc for hook's verbose attribute + fix typo in stages' doc --- index.mako | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 43c94ae2..a1866cfd 100644 --- a/index.mako +++ b/index.mako @@ -193,7 +193,7 @@ repository's configuration. =c= (optional) list of additional parameters to pass to the hook. =r= =c= `stages` - =c= (optional) configes the hook to the `commit`, `push`, or `commit-msg` + =c= (optional) confines the hook to the `commit`, `push`, or `commit-msg` stage. See [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). =r= @@ -205,6 +205,10 @@ repository's configuration. =c= `always_run` =c= (optional) if `true`, this hook will run even if there are no matching files. _new in 0.7.2_. +=r= + =c= `verbose` + =c= (optional) if `true`, forces the output of the hook to be printed even when + the hook passes. _new in 1.5.3_. ``` One example of a complete configuration: @@ -295,6 +299,10 @@ file that tells pre-commit: =c= `always_run` =c= (optional: default `false`) if `true` this hook will run even if there are no matching files. _new in 0.7.2_. +=r= + =c= `verbose` + =c= (optional) if `true`, forces the output of the hook to be printed even when + the hook passes. _new in 1.5.3_. =r= =c= `pass_filenames` =c= (optional: default `true`) if `true` this hook must take filenames as From 6dfb15ecff22471b3aa08fecac200c0ba55a595a Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 1 Feb 2018 09:31:50 -0800 Subject: [PATCH 143/854] Update release version for `verbose` option Note: this version is not yet released, but will be soon! --- index.mako | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.mako b/index.mako index 80ad8584..ccb4dcb9 100644 --- a/index.mako +++ b/index.mako @@ -208,7 +208,7 @@ repository's configuration. =r= =c= `verbose` =c= (optional) if `true`, forces the output of the hook to be printed even when - the hook passes. _new in 1.5.3_. + the hook passes. _new in 1.6.0_. ``` One example of a complete configuration: @@ -302,7 +302,7 @@ file that tells pre-commit: =r= =c= `verbose` =c= (optional) if `true`, forces the output of the hook to be printed even when - the hook passes. _new in 1.5.3_. + the hook passes. _new in 1.6.0_. =r= =c= `pass_filenames` =c= (optional: default `true`) if `true` this hook must take filenames as From 0874e5d4bc781a9eac065ff37901c606d0e96507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Thu, 1 Feb 2018 22:12:52 +0100 Subject: [PATCH 144/854] Document the fact that the hook's name can be overriden --- index.mako | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.mako b/index.mako index a1866cfd..95d79f88 100644 --- a/index.mako +++ b/index.mako @@ -170,6 +170,9 @@ repository's configuration. =r= =c= `id` =c= which hook from the repository to use. +=r= + =c= `name` + =c= (optional) override the name of the hook - shown during hook execution. =r= =c= `language_version` =c= (optional) override the language version for the From 8d1ce50ed29fc61be88a55ad02e4bbbc80f48d1b Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 12 Feb 2018 10:38:39 -0800 Subject: [PATCH 145/854] Add xcodeproj-sort-pre-commit-hook CC @noahsark769 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index a6b78ee5..a2ff8ee6 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -63,3 +63,4 @@ - git://github.com/prettier/prettier - git://github.com/adrienverge/yamllint - git://github.com/thlorenz/doctoc +- git://github.com/noahsark769/xcodeproj-sort-pre-commit-hook From c962d5a0ea6faa87e57f36468e2572612380c2ae Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 7 Mar 2018 12:59:46 -0800 Subject: [PATCH 146/854] Documentation updates for 1.7.0 --- index.mako | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/index.mako b/index.mako index 6e7df209..d6bac6ca 100644 --- a/index.mako +++ b/index.mako @@ -143,8 +143,8 @@ from. =c= `repo` =c= the repository url to `git clone` from =r= - =c= `sha` - =c= the revision or tag to clone at + =c= `rev` + =c= the revision or tag to clone at. _new in 1.7.0_ previously `sha` =r= =c= `hooks` =c= A list of [hook mappings](#pre-commit-configyaml---hooks). @@ -155,7 +155,7 @@ A sample repository with all defaults present: ```yaml repos: - repo: https://github.com/pre-commit/pre-commit-hooks - sha: v0.9.4 + rev: v1.2.3 hooks: - ... ``` @@ -219,7 +219,7 @@ One example of a complete configuration: ```yaml repos: - repo: git://github.com/pre-commit/pre-commit-hooks - sha: v0.9.1 + rev: v1.2.3 hooks: - id: trailing-whitespace ``` @@ -230,7 +230,7 @@ trailing-whitespace hook. ## Updating hooks automatically You can update your hooks to the latest version automatically by running -`pre-commit autoupdate`. This will bring the hooks to the latest sha on the +`pre-commit autoupdate`. This will bring the hooks to the latest tag on the master branch. ''')} @@ -537,7 +537,7 @@ Using config: =============================================================================== repos: - repo: ../hook-repo - sha: 84f01ac09fcd8610824f9626a590b83cfae9bcbd + rev: 84f01ac09fcd8610824f9626a590b83cfae9bcbd hooks: - id: foo =============================================================================== @@ -570,7 +570,8 @@ Options: - `--bleeding-edge`: update to the bleeding edge of `master` instead of the latest tagged version (the default behaviour). -- `--repo REPO`: _new in 1.4.1_ Only update this repository. +- `--repo REPO`: _new in 1.4.1_ Only update this repository. _new in 1.7.0_ + This option may be specified multiple times. ## pre-commit clean [options] [](#pre-commit-clean) @@ -758,7 +759,7 @@ as follows: ```yaml - repo: git://github.com/pre-commit/pre-commit-hooks - sha: v0.9.1 + rev: v1.2.3 hooks: - id: flake8 args: [--max-line-length=131] @@ -775,7 +776,7 @@ For example, assuming a `.pre-commit-config.yaml`: ```yaml - repo: git://github.com/path/to/your/hook/repo - sha: badf00ddeadbeef + rev: badf00ddeadbeef hooks: - id: my-hook-script-id args: [--myarg1=1, --myarg1=2] @@ -937,7 +938,7 @@ per-hook basis by setting the `language_version`. ```yaml - repo: git://github.com/pre-commit/mirrors-scss-lint - sha: v0.54.0 + rev: v0.54.0 hooks: - id: scss-lint language_version: 2.1.5 @@ -1015,7 +1016,7 @@ Or with both: passenv = HOMEPATH SSH_AUTH_SOCK ``` -## Using the latest sha for a repository +## Using the latest version for a repository `pre-commit` configuration aims to give a repeatable and fast experience and therefore intentionally doesn't provide facilities for "unpinned latest @@ -1026,9 +1027,9 @@ latest versions with [`pre-commit autoupdate`](#pre-commit-autoupdate). If you need the absolute latest version of a hook (instead of the latest tagged version), pass the `--bleeding-edge` parameter to `autoupdate`. -`pre-commit` assumes that the value of `sha` is an immutable ref (such as a +`pre-commit` assumes that the value of `rev` is an immutable ref (such as a tag or SHA) and will cache based on that. Using a branch name (or `HEAD`) for -the value of `sha` is not supported and will only represent the state of +the value of `rev` is not supported and will only represent the state of that mutable ref at the time of hook installation (and will *NOT* update automatically). ''')} From 55ee36eb9e61869cb891003e3f78893e38991e63 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 10 Mar 2018 16:21:03 -0800 Subject: [PATCH 147/854] git:// -> https:// --- .pre-commit-config.yaml | 2 +- all-repos.yaml | 118 ++++++++++++++++++++-------------------- hooks.mako | 4 +- index.mako | 12 ++-- 4 files changed, 68 insertions(+), 68 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5fb15d7..598b51a0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ entry: scss-lint types: [scss] language: ruby - additional_dependencies: ['scss_lint:0.52.0'] + additional_dependencies: ['scss_lint:0.57.0'] - id: no-github-dot-git name: No need for .git for github urls entry: 'github.*\.git' diff --git a/all-repos.yaml b/all-repos.yaml index a2ff8ee6..b2536d52 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -1,66 +1,66 @@ # This file is used to generate all-hooks.json -- git://github.com/pre-commit/pre-commit-hooks -- git://github.com/pre-commit/mirrors-autopep8 -- git://github.com/pre-commit/mirrors-coffeelint -- git://github.com/pre-commit/mirrors-csslint -- git://github.com/pre-commit/mirrors-eslint -- git://github.com/pre-commit/mirrors-fixmyjs -- git://github.com/pre-commit/mirrors-isort -- git://github.com/pre-commit/mirrors-jshint -- git://github.com/pre-commit/mirrors-puppet-lint -- git://github.com/pre-commit/mirrors-pylint -- git://github.com/pre-commit/mirrors-ruby-lint -- git://github.com/pre-commit/mirrors-scss-lint -- git://github.com/pre-commit/mirrors-yapf -- git://github.com/FalconSocial/pre-commit-mirrors-pep257 -- git://github.com/FalconSocial/pre-commit-python-sorter +- https://github.com/pre-commit/pre-commit-hooks +- https://github.com/pre-commit/mirrors-autopep8 +- https://github.com/pre-commit/mirrors-coffeelint +- https://github.com/pre-commit/mirrors-csslint +- https://github.com/pre-commit/mirrors-eslint +- https://github.com/pre-commit/mirrors-fixmyjs +- https://github.com/pre-commit/mirrors-isort +- https://github.com/pre-commit/mirrors-jshint +- https://github.com/pre-commit/mirrors-puppet-lint +- https://github.com/pre-commit/mirrors-pylint +- https://github.com/pre-commit/mirrors-ruby-lint +- https://github.com/pre-commit/mirrors-scss-lint +- https://github.com/pre-commit/mirrors-yapf +- https://github.com/FalconSocial/pre-commit-mirrors-pep257 +- https://github.com/FalconSocial/pre-commit-python-sorter # https://github.com/guykisel/pre-commit-robotframework-tidy/issues/1 -# - git://github.com/guykisel/pre-commit-robotframework-tidy -- git://github.com/guykisel/prospector-mirror -- git://github.com/asottile/add-trailing-comma -- git://github.com/asottile/pyupgrade -- git://github.com/asottile/reorder_python_imports -- git://github.com/asottile/yesqa -- git://github.com/asottile/cheetah_lint -- git://github.com/digitalpulp/pre-commit-php -- git://github.com/elidupuis/mirrors-jscs -- git://github.com/elidupuis/mirrors-sass-lint +# - https://github.com/guykisel/pre-commit-robotframework-tidy +- https://github.com/guykisel/prospector-mirror +- https://github.com/asottile/add-trailing-comma +- https://github.com/asottile/pyupgrade +- https://github.com/asottile/reorder_python_imports +- https://github.com/asottile/yesqa +- https://github.com/asottile/cheetah_lint +- https://github.com/digitalpulp/pre-commit-php +- https://github.com/elidupuis/mirrors-jscs +- https://github.com/elidupuis/mirrors-sass-lint # https://github.com/elidupuis/mirrors-standard/issues/2 -# - git://github.com/elidupuis/mirrors-standard -- git://github.com/Lucas-C/pre-commit-hooks -- git://github.com/Lucas-C/pre-commit-hooks-bandit -- git://github.com/Lucas-C/pre-commit-hooks-go -- git://github.com/Lucas-C/pre-commit-hooks-java -- git://github.com/Lucas-C/pre-commit-hooks-lxml -- git://github.com/Lucas-C/pre-commit-hooks-markup -- git://github.com/Lucas-C/pre-commit-hooks-nodejs -- git://github.com/Lucas-C/pre-commit-hooks-safety +# - https://github.com/elidupuis/mirrors-standard +- https://github.com/Lucas-C/pre-commit-hooks +- https://github.com/Lucas-C/pre-commit-hooks-bandit +- https://github.com/Lucas-C/pre-commit-hooks-go +- https://github.com/Lucas-C/pre-commit-hooks-java +- https://github.com/Lucas-C/pre-commit-hooks-lxml +- https://github.com/Lucas-C/pre-commit-hooks-markup +- https://github.com/Lucas-C/pre-commit-hooks-nodejs +- https://github.com/Lucas-C/pre-commit-hooks-safety - https://bitbucket.org/SamWhited/go-pre-commit.git -- git://github.com/chriskuehl/puppet-pre-commit-hooks -- git://github.com/dnephin/pre-commit-golang -- git://github.com/troian/pre-commit-golang +- https://github.com/chriskuehl/puppet-pre-commit-hooks +- https://github.com/dnephin/pre-commit-golang +- https://github.com/troian/pre-commit-golang # https://github.com/jordant/rubocop-pre-commit-hook/issues/4 -# - git://github.com/jordant/rubocop-pre-commit-hook -- git://github.com/jstewmon/check-swagger -- git://github.com/detailyang/pre-commit-shell -- git://github.com/bemeurer/beautysh +# - https://github.com/jordant/rubocop-pre-commit-hook +- https://github.com/jstewmon/check-swagger +- https://github.com/detailyang/pre-commit-shell +- https://github.com/bemeurer/beautysh # https://github.com/sanmai-NL/pre-commit-hooks_R/issues/1 -# - git://github.com/sanmai-NL/pre-commit-hooks_R +# - https://github.com/sanmai-NL/pre-commit-hooks_R # https://github.com/magicmark/pre-commit-es6-imports-reorder/issues/1 -# - git://github.com/magicmark/pre-commit-es6-imports-reorder -- git://github.com/antonbabenko/pre-commit-terraform -- git://github.com/willthames/ansible-lint -- git://github.com/doublify/pre-commit-clang-format -- git://github.com/doublify/pre-commit-go -- git://github.com/doublify/pre-commit-hindent -- git://github.com/doublify/pre-commit-isort -- git://github.com/doublify/pre-commit-rust -- git://github.com/chewse/pre-commit-mirrors-pydocstyle -- git://github.com/kintoandar/pre-commit -- git://github.com/awebdeveloper/pre-commit-stylelint -- git://github.com/awebdeveloper/pre-commit-tslint -- git://github.com/awebdeveloper/pre-commit-prettier -- git://github.com/prettier/prettier -- git://github.com/adrienverge/yamllint -- git://github.com/thlorenz/doctoc -- git://github.com/noahsark769/xcodeproj-sort-pre-commit-hook +# - https://github.com/magicmark/pre-commit-es6-imports-reorder +- https://github.com/antonbabenko/pre-commit-terraform +- https://github.com/willthames/ansible-lint +- https://github.com/doublify/pre-commit-clang-format +- https://github.com/doublify/pre-commit-go +- https://github.com/doublify/pre-commit-hindent +- https://github.com/doublify/pre-commit-isort +- https://github.com/doublify/pre-commit-rust +- https://github.com/chewse/pre-commit-mirrors-pydocstyle +- https://github.com/kintoandar/pre-commit +- https://github.com/awebdeveloper/pre-commit-stylelint +- https://github.com/awebdeveloper/pre-commit-tslint +- https://github.com/awebdeveloper/pre-commit-prettier +- https://github.com/prettier/prettier +- https://github.com/adrienverge/yamllint +- https://github.com/thlorenz/doctoc +- https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook diff --git a/hooks.mako b/hooks.mako index 5385647b..5c2f725d 100644 --- a/hooks.mako +++ b/hooks.mako @@ -13,8 +13,8 @@ Also available in json. % for repository, hooks in all_hooks.items():

    - - ${repository.replace('git://', '')} + + ${repository.replace('https://', '')}

      diff --git a/index.mako b/index.mako index d6bac6ca..88a08675 100644 --- a/index.mako +++ b/index.mako @@ -218,7 +218,7 @@ One example of a complete configuration: ```yaml repos: -- repo: git://github.com/pre-commit/pre-commit-hooks +- repo: https://github.com/pre-commit/pre-commit-hooks rev: v1.2.3 hooks: - id: trailing-whitespace @@ -663,8 +663,8 @@ Options: [`pre-commit run`](#pre-commit-run). Some example useful invocations: -- `pre-commit try-repo git://github.com/pre-commit/pre-commit-hooks`: runs all - the hooks in the latest revision of `pre-commit/pre-commit-hooks`. +- `pre-commit try-repo https://github.com/pre-commit/pre-commit-hooks`: runs + all the hooks in the latest revision of `pre-commit/pre-commit-hooks`. - `pre-commit try-repo ../path/to/repo`: run all the hooks in a repository on disk. - `pre-commit try-repo ../pre-commit-hooks flake8`: run only the `flake8` hook @@ -758,7 +758,7 @@ arguments by specifying the `args` property in your `.pre-commit-config.yaml` as follows: ```yaml -- repo: git://github.com/pre-commit/pre-commit-hooks +- repo: https://github.com/pre-commit/pre-commit-hooks rev: v1.2.3 hooks: - id: flake8 @@ -775,7 +775,7 @@ the `args` value and then a list of staged files. For example, assuming a `.pre-commit-config.yaml`: ```yaml -- repo: git://github.com/path/to/your/hook/repo +- repo: https://github.com/path/to/your/hook/repo rev: badf00ddeadbeef hooks: - id: my-hook-script-id @@ -937,7 +937,7 @@ don’t want the default system installed version so you can override this on a per-hook basis by setting the `language_version`. ```yaml -- repo: git://github.com/pre-commit/mirrors-scss-lint +- repo: https://github.com/pre-commit/mirrors-scss-lint rev: v0.54.0 hooks: - id: scss-lint From ec9ac1f9ccae2ea5a1104845c7b7ff215deaff54 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 11 Mar 2018 20:31:24 -0700 Subject: [PATCH 148/854] 1.8.0 documentation updates: - `--multiline` option for `pygrep` - `stages: [manual]` --- index.mako | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.mako b/index.mako index 88a08675..256a059c 100644 --- a/index.mako +++ b/index.mako @@ -196,8 +196,8 @@ repository's configuration. =c= (optional) list of additional parameters to pass to the hook. =r= =c= `stages` - =c= (optional) confines the hook to the `commit`, `push`, or `commit-msg` - stage. See + =c= (optional) confines the hook to the `commit`, `push`, `commit-msg`, or + `manual` stage. See [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). =r= =c= `additional_dependencies` @@ -487,6 +487,8 @@ the regex as the `entry`. The `entry` may be any python [regular expression](#regular-expressions). For case insensitive regexes you can apply the `(?i)` flag as the start of your entry, or use `args: [-i]`. +_new in 1.8.0_ For multiline matches, use `args: [--multiline]`. + __Support:__ pygrep hooks are supported on all platforms which pre-commit runs on. @@ -751,6 +753,12 @@ setting the `stages` property in your `.pre-commit-config.yaml`. The `stages` property is an array and can contain any of `commit`, `push`, and `commit-msg`. +_new in 1.8.0_ An additional `manual` stage is available for one off execution +that won't run in any hook context. This special stage is useful for taking +advantage of `pre-commit`'s cross-platform / cross-language package management +without running it on every commit. Hooks confied to `stages: [manual]` can +be executed by running `pre-commit run --hook-stage manual `. + ## Passing arguments to hooks Sometimes hooks require arguments to run correctly. You can pass static From b1c2fc79600377140b45777d08d369b9536eac25 Mon Sep 17 00:00:00 2001 From: Paul Morgan Date: Sat, 24 Mar 2018 16:06:03 +0000 Subject: [PATCH 149/854] add jumanjihouse pre-commit-hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index b2536d52..1c926632 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -27,6 +27,7 @@ - https://github.com/elidupuis/mirrors-sass-lint # https://github.com/elidupuis/mirrors-standard/issues/2 # - https://github.com/elidupuis/mirrors-standard +- https://github.com/jumanjihouse/pre-commit-hooks - https://github.com/Lucas-C/pre-commit-hooks - https://github.com/Lucas-C/pre-commit-hooks-bandit - https://github.com/Lucas-C/pre-commit-hooks-go From ca98f4db5337d427143c2fbca29a1647105d8778 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 29 Mar 2018 10:13:29 -0700 Subject: [PATCH 150/854] Add jorisroovers/gitlint to list of hooks PR here: https://github.com/jorisroovers/gitlint/pull/62 CC @jorisroovers --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 1c926632..ad4ca7af 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -65,3 +65,4 @@ - https://github.com/adrienverge/yamllint - https://github.com/thlorenz/doctoc - https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook +- https://github.com/jorisroovers/gitlint From 9f247aa5ddfaffe02d8598cc2b957860f077e36a Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 4 Apr 2018 14:06:19 -0700 Subject: [PATCH 151/854] Add ambv/black Thanks again @ambv and @dcramer! --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index ad4ca7af..408abafb 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -66,3 +66,4 @@ - https://github.com/thlorenz/doctoc - https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook - https://github.com/jorisroovers/gitlint +- https://github.com/ambv/black From a3eb482d0e835835d3a92a2f82ca328402152bdb Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 26 Apr 2018 13:29:45 -0700 Subject: [PATCH 152/854] Document log_file hook option --- index.mako | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.mako b/index.mako index 256a059c..7f906107 100644 --- a/index.mako +++ b/index.mako @@ -212,6 +212,10 @@ repository's configuration. =c= `verbose` =c= (optional) if `true`, forces the output of the hook to be printed even when the hook passes. _new in 1.6.0_. +=r= + =c= `log_file` + =c= (optional) if present, the hook output will additionally be written + to a file. _new in 0.14.0_ ``` One example of a complete configuration: From 8ce84b4727c242e2f99e9f529f64270dee3db3b0 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 12 May 2018 21:31:37 -0700 Subject: [PATCH 153/854] Add asottile/seed-isort-config --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 408abafb..479649ea 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -21,6 +21,7 @@ - https://github.com/asottile/pyupgrade - https://github.com/asottile/reorder_python_imports - https://github.com/asottile/yesqa +- https://github.com/asottile/seed-isort-config - https://github.com/asottile/cheetah_lint - https://github.com/digitalpulp/pre-commit-php - https://github.com/elidupuis/mirrors-jscs From f1d5397980ab5cdd019dfd9a0c937aa27733b3f0 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Mon, 21 May 2018 12:13:51 -0700 Subject: [PATCH 154/854] Add new hooks for Ansible and Docker checks --- all-repos.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/all-repos.yaml b/all-repos.yaml index 479649ea..fa5fc1d6 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -68,3 +68,5 @@ - https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook - https://github.com/jorisroovers/gitlint - https://github.com/ambv/black +- https://github.com/IamTheFij/ansible-pre-commit +- https://github.com/IamTheFij/docker-pre-commit From d4560719665f7147f1a8531272b941e490170672 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 21 May 2018 20:57:02 -0700 Subject: [PATCH 155/854] Document the python_venv language --- index.mako | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/index.mako b/index.mako index 7f906107..fb969c63 100644 --- a/index.mako +++ b/index.mako @@ -350,6 +350,7 @@ to provide both files or suggest users use `pre-commit>=0.12.0`. - [golang](#golang) - [node](#node) - [python](#python) +- [python_venv](#python_venv) - [ruby](#ruby) - [swift](#swift) - [pcre](#pcre) @@ -444,6 +445,22 @@ match the `entry` – usually through `console_scripts` or `scripts` in setup.py __Support:__ python hooks work without any system-level depedendencies. It has been tested on linux, macOS, windows, and cygwin. + +### python_venv + +_new in 1.9.0_ + +An alternate implementation of the [python](#python) language which uses the +python 3 [`venv`](https://docs.python.org/3/library/venv.html) module. +On many systems you need to additionally install the `python3-venv` system +package to use this language. This is otherwise a drop-in replacement for the +python` language for situations where [`virtualenv` may not +work](https://github.com/pre-commit/pre-commit/issues/631). + +__Support:__ python hooks work without any system-level depedendencies. It +has been tested on linux, macOS, windows, and cygwin. Only python3 +environments can be created with this language. + ### ruby The hook repository must have a `*.gemspec`. It will be installed via From 691298e0a6d72d5a2dfb9257d0d2f88ff22e5475 Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Fri, 25 May 2018 11:17:40 -0700 Subject: [PATCH 156/854] Document Rust support --- index.mako | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/index.mako b/index.mako index fb969c63..b341fd27 100644 --- a/index.mako +++ b/index.mako @@ -352,6 +352,7 @@ to provide both files or suggest users use `pre-commit>=0.12.0`. - [python](#python) - [python_venv](#python_venv) - [ruby](#ruby) +- [rust](#rust) - [swift](#swift) - [pcre](#pcre) - [pygrep](#pygrep) @@ -471,6 +472,28 @@ produce an executable that will match the `entry` – usually through __Support:__ ruby hooks work without any system-level dependencies. It has been tested on linux and macOS and _may_ work under cygwin. +### rust + +_new in 1.10.0_ + +Rust hooks are installed using the system installation of +[Cargo](https://github.com/rust-lang/cargo), Rust's official package manager. + +Hook repositories must have a `Cargo.toml` file which produces at least one +binary ([example](https://github.com/chriskuehl/example-rust-pre-commit-hook)), +whose name should match the `entry` definition for your hook. The repo will be +installed via `cargo install --bins` (with the binaries stored in your +pre-commit cache, not polluting your user-level Cargo installations). + +When specifying `additional_dependencies` for Rust, you can use the syntax +`{package_name}:{package_version}` to specify a new library dependency (used to +build _your_ hook repo), or the special syntax +`cli:{package_name}:{package_version}` for a CLI dependency (built separately, +with binaries made available for use by hooks). + +__Support:__ Rust hooks currently require a pre-existing Rust installation. It +has been tested on linux, Windows, and macOS. + ### swift _new in 0.11.0_ From c865ae7d558393cc4ad4a9910d5a33d52c9497d2 Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Sat, 26 May 2018 20:01:29 -0700 Subject: [PATCH 157/854] Fix typo under python_venv --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index b341fd27..15be5c2b 100644 --- a/index.mako +++ b/index.mako @@ -455,7 +455,7 @@ An alternate implementation of the [python](#python) language which uses the python 3 [`venv`](https://docs.python.org/3/library/venv.html) module. On many systems you need to additionally install the `python3-venv` system package to use this language. This is otherwise a drop-in replacement for the -python` language for situations where [`virtualenv` may not +`python` language for situations where [`virtualenv` may not work](https://github.com/pre-commit/pre-commit/issues/631). __Support:__ python hooks work without any system-level depedendencies. It From 9e0c79fb9c37c6567911bff49e8aeb572167f9bd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 2 Jun 2018 20:55:11 -0700 Subject: [PATCH 158/854] Add asottile/blacken-docs --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index fa5fc1d6..db5df066 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -22,6 +22,7 @@ - https://github.com/asottile/reorder_python_imports - https://github.com/asottile/yesqa - https://github.com/asottile/seed-isort-config +- https://github.com/asottile/blacken-docs - https://github.com/asottile/cheetah_lint - https://github.com/digitalpulp/pre-commit-php - https://github.com/elidupuis/mirrors-jscs From 8da8c2c3c9e7b941fccf3a770d8cd0defe8677ce Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 10 Jun 2018 21:27:03 +0300 Subject: [PATCH 159/854] Add hyphen, remove caps --- index.mako | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.mako b/index.mako index 15be5c2b..db43e4fe 100644 --- a/index.mako +++ b/index.mako @@ -60,7 +60,7 @@ Using pip: pip install pre-commit ``` -Non Administrative Installation: +Non-administrative installation: - _to upgrade: run again, to uninstall: pass `uninstall` to python_ - _does not work on platforms without symlink support (windows)_ @@ -70,7 +70,7 @@ Non Administrative Installation: curl https://pre-commit.com/install-local.py | python - ``` -System Level Install: +System-level install: ``` curl https://bootstrap.pypa.io/get-pip.py | sudo python - pre-commit From 584df4b4a3940886ad97059c7649cc566d4abdbd Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 10 Jun 2018 21:50:29 +0300 Subject: [PATCH 160/854] discovery -> discover --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index db43e4fe..db06a618 100644 --- a/index.mako +++ b/index.mako @@ -920,7 +920,7 @@ Some of the common tags you'll find from identify: - [tags by extension / naming convention](https://github.com/chriskuehl/identify/blob/master/identify/extensions.py) - [tags by shebang (`#!`)](https://github.com/chriskuehl/identify/blob/master/identify/interpreters.py) -To discovery the type of any file on disk, you can use `identify`'s cli: +To discover the type of any file on disk, you can use `identify`'s cli: ```console $ identify-cli setup.py From 91eab95d2820d7fdce87b5b79a4eedfab887e5d7 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 10 Jun 2018 21:56:35 +0300 Subject: [PATCH 161/854] Sentence case --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index db06a618..9bd6e0f7 100644 --- a/index.mako +++ b/index.mako @@ -1096,7 +1096,7 @@ support more languages/versions. We’d also like to get the .pre-commit-hooks.yaml files added to popular linters without maintaining forks / mirrors. -Feel free to submit Bug Reports, Pull Requests, and Feature Requests. +Feel free to submit bug reports, pull requests, and feature requests. ## Contributors From 7792a658cbc6443355b7638832dd98cfcb26d186 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 17 Jun 2018 11:31:15 -0700 Subject: [PATCH 162/854] Add types --- .gitignore | 3 ++- .pre-commit-config.yaml | 10 ++++++++-- make_all_hooks.py | 8 ++++++-- make_templates.py | 7 +++++-- mypy.ini | 2 ++ template_lib.py | 12 ++++++------ 6 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 mypy.ini diff --git a/.gitignore b/.gitignore index dd0ba8eb..2deee430 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ *.html *.pyc *.swp +/.mypy_cache /all-hooks.json -/node_modules /build +/node_modules /venv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 598b51a0..a9ecd84e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,6 @@ +repos: - repo: git@github.com:pre-commit/pre-commit-hooks - sha: v0.9.1 + rev: v1.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -8,9 +9,14 @@ - id: debug-statements - id: flake8 - repo: https://github.com/asottile/reorder_python_imports.git - sha: v0.3.5 + rev: v1.0.1 hooks: - id: reorder-python-imports +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.610-1 + hooks: + - id: mypy + exclude: ^install-local.py$ - repo: local hooks: - id: scss-lint diff --git a/make_all_hooks.py b/make_all_hooks.py index b26a7726..184f0217 100644 --- a/make_all_hooks.py +++ b/make_all_hooks.py @@ -4,12 +4,15 @@ import os.path import subprocess import tempfile +from typing import Any +from typing import Dict +from typing import Tuple import aspy.yaml from pre_commit.clientlib import load_manifest -def get_manifest(repo_path): +def get_manifest(repo_path: str) -> Tuple[str, Dict[str, Any]]: print(f'*** {repo_path}') with tempfile.TemporaryDirectory() as directory: repo_dir = os.path.join(directory, 'repo') @@ -20,13 +23,14 @@ def get_manifest(repo_path): return (repo_path, aspy.yaml.ordered_load(open(manifest_path))) -def main(): +def main() -> int: repos = aspy.yaml.ordered_load(open('all-repos.yaml')) pool = multiprocessing.Pool(4) hooks_json = collections.OrderedDict(pool.map(get_manifest, repos)) with open('all-hooks.json', 'w') as hooks_json_file: json.dump(hooks_json, hooks_json_file, indent=4) + return 0 if __name__ == '__main__': diff --git a/make_templates.py b/make_templates.py index 0f6fb6ec..690ae987 100644 --- a/make_templates.py +++ b/make_templates.py @@ -1,6 +1,8 @@ import collections import json import os.path +from typing import Any +from typing import Dict import mako.lookup @@ -18,7 +20,7 @@ ] -def get_env(): +def get_env() -> Dict[str, Any]: all_hooks = json.loads( open('all-hooks.json').read(), object_pairs_hook=collections.OrderedDict, @@ -26,7 +28,7 @@ def get_env(): return {'all_hooks': all_hooks} -def main(): +def main() -> int: env = get_env() for template in ALL_TEMPLATES: template_name, _ = os.path.splitext(template) @@ -34,6 +36,7 @@ def main(): with open('{}.html'.format(template_name), 'w') as html_file: template_obj = template_lookup.get_template(template) html_file.write(template_obj.render(**env)) + return 0 if __name__ == '__main__': diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 00000000..82aa7eb9 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,2 @@ +[mypy] +disallow_untyped_defs = True diff --git a/template_lib.py b/template_lib.py index 9752b6b7..c5cf0e72 100644 --- a/template_lib.py +++ b/template_lib.py @@ -13,7 +13,7 @@ INDENT = ' ' * 8 -def _render_table(code): +def _render_table(code: str) -> str: """Renders our custom "table" type ```table @@ -38,13 +38,13 @@ def _render_table(code): in_row = False col_buffer = None - def _maybe_end_col(): + def _maybe_end_col() -> None: nonlocal col_buffer if col_buffer is not None: output.append(f'{md(col_buffer)}') col_buffer = None - def _maybe_end_row(): + def _maybe_end_row() -> None: nonlocal in_row if in_row: output.append('') @@ -75,7 +75,7 @@ def _maybe_end_row(): class Renderer(markdown_code_blocks.CodeRenderer): - def header(self, text, level, raw=None): + def header(self, text: str, level: int, raw: str) -> str: match = ID_RE.search(raw) if match: h_id = match.group(1) @@ -87,14 +87,14 @@ def header(self, text, level, raw=None): f' ' ) - def block_code(self, code, lang): + def block_code(self, code: str, lang: str) -> str: if lang == 'table': return _render_table(code) else: return super().block_code(code, lang) -def md(s): +def md(s: str) -> str: html = markdown_code_blocks.highlight(s, Renderer=Renderer) # manually bless the highlighted output. return markupsafe.Markup(html) From 15ee957e454fc50d5211ff94ee70869fb1187210 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 17 Jun 2018 12:34:41 -0700 Subject: [PATCH 163/854] pyupgrade --- .pre-commit-config.yaml | 6 ++++++ make_templates.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9ecd84e..f26503df 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,12 @@ repos: rev: v1.0.1 hooks: - id: reorder-python-imports +- repo: https://github.com/asottile/pyupgrade + rev: v1.3.1 + hooks: + - id: pyupgrade + args: [--py36-plus] + exclude: ^install-local.py$ - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.610-1 hooks: diff --git a/make_templates.py b/make_templates.py index 690ae987..8935944a 100644 --- a/make_templates.py +++ b/make_templates.py @@ -33,7 +33,7 @@ def main() -> int: for template in ALL_TEMPLATES: template_name, _ = os.path.splitext(template) env['template_name'] = template_name - with open('{}.html'.format(template_name), 'w') as html_file: + with open(f'{template_name}.html', 'w') as html_file: template_obj = template_lookup.get_template(template) html_file.write(template_obj.render(**env)) return 0 From 7482da9f071c4c7fe3edcc53a85bd0a63e3993fa Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 18 Jun 2018 09:13:59 -0700 Subject: [PATCH 164/854] Clarify that `re.search` is used --- index.mako | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 9bd6e0f7..2b374d94 100644 --- a/index.mako +++ b/index.mako @@ -958,7 +958,8 @@ If you'd like to use `types` with compatibility for older versions ## Regular expressions The patterns for `files` and `exclude` are python -[regular expressions](https://docs.python.org/3/library/re.html#regular-expression-syntax). +[regular expressions](https://docs.python.org/3/library/re.html#regular-expression-syntax) +and are matched with [`re.search`](https://docs.python.org/3/library/re.html#re.search). As such, you can use any of the features that python regexes support. From fd8ef079ed16283dd4de45c458b57d642bcc0256 Mon Sep 17 00:00:00 2001 From: Matt Kulka Date: Tue, 19 Jun 2018 10:06:20 -0700 Subject: [PATCH 165/854] add mattlqx repos --- all-repos.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/all-repos.yaml b/all-repos.yaml index db5df066..2b9d3534 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -71,3 +71,5 @@ - https://github.com/ambv/black - https://github.com/IamTheFij/ansible-pre-commit - https://github.com/IamTheFij/docker-pre-commit +- https://github.com/mattlqx/pre-commit-ruby +- https://github.com/mattlqx/pre-commit-sign From a4a54cd8b2b91d62eb0a7b040c8d03a91fcb7a47 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 25 Jun 2018 18:22:01 -0700 Subject: [PATCH 166/854] It's amazing anything works --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 2b374d94..0de02e91 100644 --- a/index.mako +++ b/index.mako @@ -47,7 +47,7 @@ require root access. If one of your developers doesn’t have node installed but modifies a JavaScript file, pre-commit automatically handles downloading and building node to run eslint without root. ''')} - +
      ${md(''' From 243c48666982fde72f7a9e507545ed98c72e4499 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 27 Jun 2018 15:11:12 -0700 Subject: [PATCH 167/854] Add mirrors-mypy --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 2b9d3534..807d0956 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -7,6 +7,7 @@ - https://github.com/pre-commit/mirrors-fixmyjs - https://github.com/pre-commit/mirrors-isort - https://github.com/pre-commit/mirrors-jshint +- https://github.com/pre-commit/mirrors-mypy - https://github.com/pre-commit/mirrors-puppet-lint - https://github.com/pre-commit/mirrors-pylint - https://github.com/pre-commit/mirrors-ruby-lint From ebef97ca8233680a6d8e28c82a3910541ae1a24f Mon Sep 17 00:00:00 2001 From: Scott Gorsuch Date: Thu, 28 Jun 2018 09:15:50 -0400 Subject: [PATCH 168/854] Fix typo --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 0de02e91..b011b19c 100644 --- a/index.mako +++ b/index.mako @@ -387,7 +387,7 @@ _new in 0.18.0_ A more lightweight approach to `docker` hooks. The `docker_image` "language" uses existing docker images to provide hook executables. -`docker_image` hooks can be conviently configured as [local](#repository-local) +`docker_image` hooks can be conveniently configured as [local](#repository-local) hooks. The `entry` specifies the docker tag to use. If an image has an From 9c6645f813ff49dc3601982c04d8a1e0443a1e14 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 1 Jul 2018 12:07:02 -0700 Subject: [PATCH 169/854] Faster clone with --depth=1 --- make_all_hooks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make_all_hooks.py b/make_all_hooks.py index 184f0217..0bdcc43c 100644 --- a/make_all_hooks.py +++ b/make_all_hooks.py @@ -16,7 +16,8 @@ def get_manifest(repo_path: str) -> Tuple[str, Dict[str, Any]]: print(f'*** {repo_path}') with tempfile.TemporaryDirectory() as directory: repo_dir = os.path.join(directory, 'repo') - subprocess.call(('git', 'clone', '-q', repo_path, repo_dir)) + cmd = ('git', 'clone', '--depth', '1', '-q', repo_path, repo_dir) + subprocess.check_call(cmd) manifest_path = os.path.join(repo_dir, '.pre-commit-hooks.yaml') # Validate the manifest just to make sure it's ok. load_manifest(manifest_path) From 2cd3fc3224e660bec198bd914ffe43a3b55df55d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 4 Jul 2018 12:58:12 -0700 Subject: [PATCH 170/854] Move the "Developing hooks interactively" section higher --- index.mako | 76 +++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/index.mako b/index.mako index b011b19c..e7df2dc0 100644 --- a/index.mako +++ b/index.mako @@ -343,6 +343,44 @@ _new in 0.12.0_ Prior to 0.12.0 the file was `hooks.yaml` (now `.pre-commit-hooks.yaml`). For backwards compatibility it is suggested to provide both files or suggest users use `pre-commit>=0.12.0`. +## Developing hooks interactively + +Since the `repo` property of `.pre-commit-config.yaml` can refer to anything +that `git clone ...` understands, it's often useful to point it at a local +directory while developing hooks. + +[`pre-commit try-repo`](#pre-commit-try-repo) streamlines this process by +enabling a quick way to try out a repository. Here's how one might work +interactively: + +```console +~/work/hook-repo $ git checkout origin/master -b feature + +# ... make some changes + +~/work/hook-repo $ # A commit is needed so `pre-commit` can clone +~/work/hook-repo $ git commit -m "Add new hook: foo" + +# In another terminal or tab + +~/work/other-repo $ pre-commit try-repo ../hook-repo foo --verbose --all-files +=============================================================================== +Using config: +=============================================================================== +repos: +- repo: ../hook-repo + rev: 84f01ac09fcd8610824f9626a590b83cfae9bcbd + hooks: + - id: foo +=============================================================================== +[INFO] Initializing environment for ../hook-repo. +[foo] Foo................................................................Passed +hookid: foo + +Hello from foo hook! + +``` + ## Supported languages - [docker](#docker) @@ -556,44 +594,6 @@ This hook type will not be given a virtual environment to work with – if it needs additional dependencies the consumer must install them manually. __Support:__ the support of system hooks depend on the executables. - -## Developing hooks interactively - -Since the `repo` property of `.pre-commit-config.yaml` can refer to anything -that `git clone ...` understands, it's often useful to point it at a local -directory while developing hooks. - -[`pre-commit try-repo`](#pre-commit-try-repo) streamlines this process by -enabling a quick way to try out a repository. Here's how one might work -interactively: - -```console -~/work/hook-repo $ git checkout origin/master -b feature - -# ... make some changes - -~/work/hook-repo $ # A commit is needed so `pre-commit` can clone -~/work/hook-repo $ git commit -m "Add new hook: foo" - -# In another terminal or tab - -~/work/other-repo $ pre-commit try-repo ../hook-repo foo --verbose --all-files -=============================================================================== -Using config: -=============================================================================== -repos: -- repo: ../hook-repo - rev: 84f01ac09fcd8610824f9626a590b83cfae9bcbd - hooks: - - id: foo -=============================================================================== -[INFO] Initializing environment for ../hook-repo. -[foo] Foo................................................................Passed -hookid: foo - -Hello from foo hook! - -``` ''')}
      From cfadbcd9b33f187154d5c2a37ede80b2e9107cd9 Mon Sep 17 00:00:00 2001 From: Matt Kulka Date: Wed, 18 Jul 2018 10:33:44 -0700 Subject: [PATCH 171/854] add search-and-replace plugin --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 807d0956..324f0470 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -74,3 +74,4 @@ - https://github.com/IamTheFij/docker-pre-commit - https://github.com/mattlqx/pre-commit-ruby - https://github.com/mattlqx/pre-commit-sign +- https://github.com/mattlqx/pre-commit-search-and-replace From dce1bb704f3b5aebdae1296b9350ff95cb4914dd Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 19 Jul 2018 16:57:06 +0100 Subject: [PATCH 172/854] Added bashate hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 324f0470..5e4c3a86 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -75,3 +75,4 @@ - https://github.com/mattlqx/pre-commit-ruby - https://github.com/mattlqx/pre-commit-sign - https://github.com/mattlqx/pre-commit-search-and-replace +- https://github.com/openstack-dev/bashate From ec4eefd6bc739432cc8194c4e592362320962166 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 28 Jul 2018 18:17:23 -0700 Subject: [PATCH 173/854] Add pre-commit/pygrep-hooks repo --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 5e4c3a86..b00f0111 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -13,6 +13,7 @@ - https://github.com/pre-commit/mirrors-ruby-lint - https://github.com/pre-commit/mirrors-scss-lint - https://github.com/pre-commit/mirrors-yapf +- https://github.com/pre-commit/pygrep-hooks - https://github.com/FalconSocial/pre-commit-mirrors-pep257 - https://github.com/FalconSocial/pre-commit-python-sorter # https://github.com/guykisel/pre-commit-robotframework-tidy/issues/1 From 25d992e2b8fa93d17f8b55d5eb6909d84b944932 Mon Sep 17 00:00:00 2001 From: Alessandro Cuppari Date: Sun, 29 Jul 2018 21:15:19 -0400 Subject: [PATCH 174/854] Added commitlint to supported hooks list --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index b00f0111..6e7370b4 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -77,3 +77,4 @@ - https://github.com/mattlqx/pre-commit-sign - https://github.com/mattlqx/pre-commit-search-and-replace - https://github.com/openstack-dev/bashate +- https://github.com/alessandrojcm/commitlint-pre-commit-hook \ No newline at end of file From 2b070e31280fce97a5ec873848c6e413e50c7155 Mon Sep 17 00:00:00 2001 From: Alessandro Cuppari Date: Mon, 30 Jul 2018 00:22:08 -0400 Subject: [PATCH 175/854] Fixed end-of-file on all-repos.yaml --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 6e7370b4..4e355abc 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -77,4 +77,4 @@ - https://github.com/mattlqx/pre-commit-sign - https://github.com/mattlqx/pre-commit-search-and-replace - https://github.com/openstack-dev/bashate -- https://github.com/alessandrojcm/commitlint-pre-commit-hook \ No newline at end of file +- https://github.com/alessandrojcm/commitlint-pre-commit-hook From 0c3e898231be5a76b9c933982e1c82d867f599b3 Mon Sep 17 00:00:00 2001 From: Henry Tang Date: Tue, 31 Jul 2018 23:57:31 +0800 Subject: [PATCH 176/854] Added henrrykt/pre-commit-perl --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index b00f0111..8688f996 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -77,3 +77,4 @@ - https://github.com/mattlqx/pre-commit-sign - https://github.com/mattlqx/pre-commit-search-and-replace - https://github.com/openstack-dev/bashate +- https://github.com/henryykt/pre-commit-perl From c29be99936ddaef6a14d5bd9dcbc10c19b9c91f1 Mon Sep 17 00:00:00 2001 From: Jake Kaufman Date: Tue, 31 Jul 2018 17:28:23 -0400 Subject: [PATCH 177/854] Fix `local` anchor link Fixes a link that was pointed at an anchor that didn't exist. --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index e7df2dc0..8532dae6 100644 --- a/index.mako +++ b/index.mako @@ -425,7 +425,7 @@ _new in 0.18.0_ A more lightweight approach to `docker` hooks. The `docker_image` "language" uses existing docker images to provide hook executables. -`docker_image` hooks can be conveniently configured as [local](#repository-local) +`docker_image` hooks can be conveniently configured as [local](#repository-local-hooks) hooks. The `entry` specifies the docker tag to use. If an image has an From d0901bea46de6d5da165b304ee9d2b5f7afbbda2 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 2 Sep 2018 20:08:32 -0700 Subject: [PATCH 178/854] Document `language: fail` --- index.mako | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/index.mako b/index.mako index 8532dae6..c610d849 100644 --- a/index.mako +++ b/index.mako @@ -385,6 +385,7 @@ Hello from foo hook! - [docker](#docker) - [docker_image](#docker_image) +- [fail](#fail) - [golang](#golang) - [node](#node) - [python](#python) @@ -451,6 +452,29 @@ For example: entry: my.registry.example.com/docker-image-3:latest my-exe ``` +### fail + +_new in 1.11.0_ + +A lightweight `language` to forbid files by filename. The `fail` language is +especially useful for [local](#repository-local-hooks) hooks. + +The `entry` will be printed when the hook fails. It is suggested to provide +a brief description for `name` and more verbose fix instructions in `entry`. + +Here's an example which prevents any file except those ending with `.rst` from +being added to the `changelog` directory: + +```yaml +- repo: local + hooks: + - id: changelogs-rst + name: changelogs must be rst + entry: changelog filenames must end in .rst + language: fail + files: 'changelog/.*(? Date: Sun, 16 Sep 2018 19:54:13 -0300 Subject: [PATCH 179/854] Add Nim Hooks, written by @asottile --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 809bdaa5..4d896d45 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -79,3 +79,4 @@ - https://github.com/openstack-dev/bashate - https://github.com/alessandrojcm/commitlint-pre-commit-hook - https://github.com/henryykt/pre-commit-perl +- https://github.com/juancarlospaco/pre-commit-nim From bb9ea8e8f8c17cd0bf66abb75008e8bce3501e2b Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 20 Sep 2018 10:13:57 -0700 Subject: [PATCH 180/854] re-enable https://github.com/guykisel/pre-commit-robotframework-tidy https://github.com/guykisel/pre-commit-robotframework-tidy/issues/1#issuecomment-423261889 --- all-repos.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/all-repos.yaml b/all-repos.yaml index 4d896d45..07fc7be4 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -16,8 +16,7 @@ - https://github.com/pre-commit/pygrep-hooks - https://github.com/FalconSocial/pre-commit-mirrors-pep257 - https://github.com/FalconSocial/pre-commit-python-sorter -# https://github.com/guykisel/pre-commit-robotframework-tidy/issues/1 -# - https://github.com/guykisel/pre-commit-robotframework-tidy +- https://github.com/guykisel/pre-commit-robotframework-tidy - https://github.com/guykisel/prospector-mirror - https://github.com/asottile/add-trailing-comma - https://github.com/asottile/pyupgrade From f237b8b5c6538e0151475868a8a47744bd017905 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 20 Sep 2018 10:21:29 -0700 Subject: [PATCH 181/854] sassc -> pysassc --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ca0dca21..d257225b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ install-hooks: venv venv/bin/pre-commit install build/main.css: venv node_modules build scss/main.scss scss/_variables.scss - venv/bin/sassc -s compressed scss/main.scss build/main.css + venv/bin/pysassc -s compressed scss/main.scss build/main.css all-hooks.json: venv make_all_hooks.py all-repos.yaml venv/bin/python make_all_hooks.py From 4c10f64fc943c86a336ca38072edb47571917c66 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 6 Oct 2018 21:34:48 -0700 Subject: [PATCH 182/854] Remove broken links --- all-repos.yaml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/all-repos.yaml b/all-repos.yaml index 07fc7be4..5639c9ca 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -28,8 +28,6 @@ - https://github.com/digitalpulp/pre-commit-php - https://github.com/elidupuis/mirrors-jscs - https://github.com/elidupuis/mirrors-sass-lint -# https://github.com/elidupuis/mirrors-standard/issues/2 -# - https://github.com/elidupuis/mirrors-standard - https://github.com/jumanjihouse/pre-commit-hooks - https://github.com/Lucas-C/pre-commit-hooks - https://github.com/Lucas-C/pre-commit-hooks-bandit @@ -39,19 +37,12 @@ - https://github.com/Lucas-C/pre-commit-hooks-markup - https://github.com/Lucas-C/pre-commit-hooks-nodejs - https://github.com/Lucas-C/pre-commit-hooks-safety -- https://bitbucket.org/SamWhited/go-pre-commit.git - https://github.com/chriskuehl/puppet-pre-commit-hooks - https://github.com/dnephin/pre-commit-golang - https://github.com/troian/pre-commit-golang -# https://github.com/jordant/rubocop-pre-commit-hook/issues/4 -# - https://github.com/jordant/rubocop-pre-commit-hook - https://github.com/jstewmon/check-swagger - https://github.com/detailyang/pre-commit-shell - https://github.com/bemeurer/beautysh -# https://github.com/sanmai-NL/pre-commit-hooks_R/issues/1 -# - https://github.com/sanmai-NL/pre-commit-hooks_R -# https://github.com/magicmark/pre-commit-es6-imports-reorder/issues/1 -# - https://github.com/magicmark/pre-commit-es6-imports-reorder - https://github.com/antonbabenko/pre-commit-terraform - https://github.com/willthames/ansible-lint - https://github.com/doublify/pre-commit-clang-format From 82fa8eb8eee90962338e8726d2da296d9f0103ab Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 9 Oct 2018 09:11:39 -0700 Subject: [PATCH 183/854] Add cfn-python-lint --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 5639c9ca..64fb11b3 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -70,3 +70,4 @@ - https://github.com/alessandrojcm/commitlint-pre-commit-hook - https://github.com/henryykt/pre-commit-perl - https://github.com/juancarlospaco/pre-commit-nim +- https://github.com/awslabs/cfn-python-lint From d74edadf34f6edb3f36fe34564179fa4bef911c7 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Oct 2018 07:33:01 -0700 Subject: [PATCH 184/854] Add thoughtworks/talisman https://github.com/thoughtworks/talisman/pull/46 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 64fb11b3..6164bce6 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -71,3 +71,4 @@ - https://github.com/henryykt/pre-commit-perl - https://github.com/juancarlospaco/pre-commit-nim - https://github.com/awslabs/cfn-python-lint +- https://github.com/thoughtworks/talisman From 334d5e77264685551a63cf89daab13a02bbaf9b3 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 29 Oct 2018 08:29:22 -0700 Subject: [PATCH 185/854] Add bandit to list of hook repos - https://github.com/PyCQA/bandit/pull/411 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 6164bce6..1e790da2 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -72,3 +72,4 @@ - https://github.com/juancarlospaco/pre-commit-nim - https://github.com/awslabs/cfn-python-lint - https://github.com/thoughtworks/talisman +- https://github.com/PyCQA/bandit From 781aa0c2ae9ee6b23b1435c44e828a7f2c42e19f Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 8 Nov 2018 18:20:50 -0800 Subject: [PATCH 186/854] Add miki725/importanize CC @miki725 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 1e790da2..35414cce 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -73,3 +73,4 @@ - https://github.com/awslabs/cfn-python-lint - https://github.com/thoughtworks/talisman - https://github.com/PyCQA/bandit +- https://github.com/miki725/importanize From aa4cd8fcf6a963dc4a3b36adebdf8586ee3292e4 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 22 Nov 2018 08:41:26 -0800 Subject: [PATCH 187/854] Add PyCQA/flake8 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 35414cce..71d937f6 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -72,5 +72,6 @@ - https://github.com/juancarlospaco/pre-commit-nim - https://github.com/awslabs/cfn-python-lint - https://github.com/thoughtworks/talisman +- https://gitlab.com/PyCQA/flake8 - https://github.com/PyCQA/bandit - https://github.com/miki725/importanize From 0048bb8d253776bd639539bbdf70cf8c77be513a Mon Sep 17 00:00:00 2001 From: Daniel Pryor Date: Sat, 6 Oct 2018 22:20:08 -0600 Subject: [PATCH 188/854] Add dockerfilelint hook for others. Add dockerfilelint hook for others. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 71d937f6..a6987abb 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -67,6 +67,7 @@ - https://github.com/mattlqx/pre-commit-sign - https://github.com/mattlqx/pre-commit-search-and-replace - https://github.com/openstack-dev/bashate +- https://github.com/pryorda/dockerfilelint-precommit-hooks - https://github.com/alessandrojcm/commitlint-pre-commit-hook - https://github.com/henryykt/pre-commit-perl - https://github.com/juancarlospaco/pre-commit-nim From ed2ff4a19083db6ca6921780cdeebfb20a16c7b6 Mon Sep 17 00:00:00 2001 From: Jonathan Otsuka Date: Mon, 17 Dec 2018 21:57:01 -0600 Subject: [PATCH 189/854] Switch willthames/ansible-lint ansible/ansible-lint --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index a6987abb..b5c523ba 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -44,7 +44,7 @@ - https://github.com/detailyang/pre-commit-shell - https://github.com/bemeurer/beautysh - https://github.com/antonbabenko/pre-commit-terraform -- https://github.com/willthames/ansible-lint +- https://github.com/ansible/ansible-lint - https://github.com/doublify/pre-commit-clang-format - https://github.com/doublify/pre-commit-go - https://github.com/doublify/pre-commit-hindent From 94d68de781c575e19163adf96c730dc805c3adaa Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Fri, 21 Dec 2018 10:37:36 +0530 Subject: [PATCH 190/854] Update index.mako --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index c610d849..1c921e92 100644 --- a/index.mako +++ b/index.mako @@ -73,7 +73,7 @@ curl https://pre-commit.com/install-local.py | python - System-level install: ``` -curl https://bootstrap.pypa.io/get-pip.py | sudo python - pre-commit +curl https://bootstrap.pypa.io/get-pip.py | python - pre-commit ``` In a python project, add the following to your requirements.txt (or From af989ba8d7c1ead6974ced32f322c418c58d0085 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Mon, 24 Dec 2018 10:39:24 +0530 Subject: [PATCH 191/854] Update index.mako --- index.mako | 6 ------ 1 file changed, 6 deletions(-) diff --git a/index.mako b/index.mako index 1c921e92..8600785a 100644 --- a/index.mako +++ b/index.mako @@ -70,12 +70,6 @@ Non-administrative installation: curl https://pre-commit.com/install-local.py | python - ``` -System-level install: - -``` -curl https://bootstrap.pypa.io/get-pip.py | python - pre-commit -``` - In a python project, add the following to your requirements.txt (or requirements-dev.txt): From cf01d58acb055e1f685a03406288b506aee75cfa Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 26 Dec 2018 13:46:40 -0800 Subject: [PATCH 192/854] Add jinjalint --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index b5c523ba..c69ce7d0 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -76,3 +76,4 @@ - https://gitlab.com/PyCQA/flake8 - https://github.com/PyCQA/bandit - https://github.com/miki725/importanize +- https://github.com/motet-a/jinjalint From 5ee115bd09b36076ec4145ab34977e24bf41083a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 27 Dec 2018 20:37:14 +0000 Subject: [PATCH 193/854] Update docs to include the alias parameter. --- index.mako | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.mako b/index.mako index 8600785a..2cedeee9 100644 --- a/index.mako +++ b/index.mako @@ -164,6 +164,14 @@ repository's configuration. =r= =c= `id` =c= which hook from the repository to use. +=r= + =c= `alias` + =c= (optional) Provide an alias to the hook. The `alias` allows + differentiation for when one wants to include the same hook more + than once, with, for example, different parameters. This allows + `pre-commit run ` to target a specific entry of the hook to + run. + _new in 1.14.0_ =r= =c= `name` =c= (optional) override the name of the hook - shown during hook execution. From fc6be3a27753bc1fcf2bc72a13bb2d30572ba6b6 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 27 Dec 2018 20:41:10 +0000 Subject: [PATCH 194/854] Address review comments --- index.mako | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/index.mako b/index.mako index 2cedeee9..aede1dbc 100644 --- a/index.mako +++ b/index.mako @@ -166,11 +166,8 @@ repository's configuration. =c= which hook from the repository to use. =r= =c= `alias` - =c= (optional) Provide an alias to the hook. The `alias` allows - differentiation for when one wants to include the same hook more - than once, with, for example, different parameters. This allows - `pre-commit run ` to target a specific entry of the hook to - run. + =c= (optional) allows the hook to be referenced using an additional id when + using `pre-commit run ` _new in 1.14.0_ =r= =c= `name` From 1c465725ad38ff739e97c863c5b7d39242a2b192 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 29 Dec 2018 21:14:32 -0800 Subject: [PATCH 195/854] Use pygments-pre-commit to highlight docs --- index.mako | 24 +++++++++++- requirements-dev.txt | 1 + scss/main.scss | 88 ++++++++++++++++++++++++++------------------ 3 files changed, 75 insertions(+), 38 deletions(-) diff --git a/index.mako b/index.mako index aede1dbc..407266c5 100644 --- a/index.mako +++ b/index.mako @@ -253,6 +253,26 @@ The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow. For example: If the machine does not have node installed, pre-commit will download and build a copy of node. + +```pre-commit +$ pre-commit install +pre-commit installed at /home/asottile/workspace/pytest/.git/hooks/pre-commit +$ git commit -m "Add super awesome feature" +black....................................................................Passed +blacken-docs.........................................(no files to check)Skipped +Trim Trailing Whitespace.................................................Passed +Fix End of Files.........................................................Passed +Check Yaml...........................................(no files to check)Skipped +Debug Statements (Python)................................................Passed +Flake8...................................................................Passed +Reorder python imports...................................................Passed +pyupgrade................................................................Passed +rst ``code`` is two backticks........................(no files to check)Skipped +rst..................................................(no files to check)Skipped +changelog filenames..................................(no files to check)Skipped +[master 146c6c2c] Add super awesome feature + 1 file changed, 1 insertion(+) +``` ''')} @@ -352,7 +372,7 @@ directory while developing hooks. enabling a quick way to try out a repository. Here's how one might work interactively: -```console +```pre-commit ~/work/hook-repo $ git checkout origin/master -b feature # ... make some changes @@ -1052,7 +1072,7 @@ whitelisted. When cloning repos over ssh (`repo: git@github.com:...`), `git` requires the `SSH_AUTH_SOCK` variable and will otherwise fail: -``` +```pre-commit [INFO] Initializing environment for git@github.com:pre-commit/pre-commit-hooks. An unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/git', 'clone', '--no-checkout', 'git@github.com:pre-commit/pre-commit-hooks', '/home/asottile/.cache/pre-commit/repofdkwkq_v') Return code: 128 diff --git a/requirements-dev.txt b/requirements-dev.txt index a1ffcea9..da0903c2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,3 +4,4 @@ libsass markdown-code-blocks markdown-to-presentation>=0.0.12 pre-commit>=0.13.6 +pygments-pre-commit diff --git a/scss/main.scss b/scss/main.scss index 58bda062..e4f9a8ac 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -145,39 +145,55 @@ h1, } // vs.css: https://github.com/richleland/pygments-css -.highlight .hll { background-color: #ffc; } -.highlight .c { color: #008000; } /* Comment */ -.highlight .err { border: 1px solid #ff0; } /* Error */ -.highlight .k { color: #00f; } /* Keyword */ -.highlight .cm { color: #008000; } /* Comment.Multiline */ -.highlight .cp { color: #00f; } /* Comment.Preproc */ -.highlight .c1 { color: #008000; } /* Comment.Single */ -.highlight .cs { color: #008000; } /* Comment.Special */ -.highlight .ge { font-style: italic; } /* Generic.Emph */ -.highlight .gh { font-weight: bold; } /* Generic.Heading */ -.highlight .gp { font-weight: bold; } /* Generic.Prompt */ -.highlight .gs { font-weight: bold; } /* Generic.Strong */ -.highlight .gu { font-weight: bold; } /* Generic.Subheading */ -.highlight .kc { color: #00f; } /* Keyword.Constant */ -.highlight .kd { color: #00f; } /* Keyword.Declaration */ -.highlight .kn { color: #00f; } /* Keyword.Namespace */ -.highlight .kp { color: #00f; } /* Keyword.Pseudo */ -.highlight .kr { color: #00f; } /* Keyword.Reserved */ -.highlight .kt { color: #2b91af; } /* Keyword.Type */ -.highlight .s { color: #a31515; } /* Literal.String */ -.highlight .nc { color: #2b91af; } /* Name.Class */ -.highlight .ow { color: #00f; } /* Operator.Word */ -.highlight .sb { color: #a31515; } /* Literal.String.Backtick */ -.highlight .sc { color: #a31515; } /* Literal.String.Char */ -.highlight .sd { color: #a31515; } /* Literal.String.Doc */ -.highlight .s2 { color: #a31515; } /* Literal.String.Double */ -.highlight .se { color: #a31515; } /* Literal.String.Escape */ -.highlight .sh { color: #a31515; } /* Literal.String.Heredoc */ -.highlight .si { color: #a31515; } /* Literal.String.Interpol */ -.highlight .sx { color: #a31515; } /* Literal.String.Other */ -.highlight .sr { color: #a31515; } /* Literal.String.Regex */ -.highlight .s1 { color: #a31515; } /* Literal.String.Single */ -.highlight .ss { color: #a31515; } /* Literal.String.Symbol */ -// git diff highlights -.highlight .gi { color: #070; } -.highlight .gd { color: #911; } +.highlight.yaml, +.highlight.ini, +.highlight.bash { + .hll { background-color: #ffc; } + .c { color: #008000; } /* Comment */ + .err { border: 1px solid #ff0; } /* Error */ + .k { color: #00f; } /* Keyword */ + .cm { color: #008000; } /* Comment.Multiline */ + .cp { color: #00f; } /* Comment.Preproc */ + .c1 { color: #008000; } /* Comment.Single */ + .cs { color: #008000; } /* Comment.Special */ + .ge { font-style: italic; } /* Generic.Emph */ + .gh { font-weight: bold; } /* Generic.Heading */ + .gp { font-weight: bold; } /* Generic.Prompt */ + .gs { font-weight: bold; } /* Generic.Strong */ + .gu { font-weight: bold; } /* Generic.Subheading */ + .kc { color: #00f; } /* Keyword.Constant */ + .kd { color: #00f; } /* Keyword.Declaration */ + .kn { color: #00f; } /* Keyword.Namespace */ + .kp { color: #00f; } /* Keyword.Pseudo */ + .kr { color: #00f; } /* Keyword.Reserved */ + .kt { color: #2b91af; } /* Keyword.Type */ + .s { color: #a31515; } /* Literal.String */ + .nc { color: #2b91af; } /* Name.Class */ + .ow { color: #00f; } /* Operator.Word */ + .sb { color: #a31515; } /* Literal.String.Backtick */ + .sc { color: #a31515; } /* Literal.String.Char */ + .sd { color: #a31515; } /* Literal.String.Doc */ + .s2 { color: #a31515; } /* Literal.String.Double */ + .se { color: #a31515; } /* Literal.String.Escape */ + .sh { color: #a31515; } /* Literal.String.Heredoc */ + .si { color: #a31515; } /* Literal.String.Interpol */ + .sx { color: #a31515; } /* Literal.String.Other */ + .sr { color: #a31515; } /* Literal.String.Regex */ + .s1 { color: #a31515; } /* Literal.String.Single */ + .ss { color: #a31515; } /* Literal.String.Symbol */ + // git diff highlights + .gi { color: #070; } + .gd { color: #911; } +} + +// pygments-pre-commit +.highlight.pre-commit, +.highlight.console { + pre { border: 0; background-color: #2d0922; color: #fff; } + + // scss-lint:disable SelectorFormat + .-Color-BGRed { background-color: #c00; } + .-Color-BGGreen { background-color: #4e9a06; } + .-Color-BlackBGYellow { background-color: #c4a000; color: #2e3436; } + .-Color-BlackBGCyan { background-color: #06989a; color: #2e3436; } +} From 78dbfcb6dc411730d38898f997560a0f67850262 Mon Sep 17 00:00:00 2001 From: "Shakya, Milind" Date: Wed, 2 Jan 2019 18:00:30 -0500 Subject: [PATCH 196/854] Add milin/giticket --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index c69ce7d0..a7c608f5 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -77,3 +77,4 @@ - https://github.com/PyCQA/bandit - https://github.com/miki725/importanize - https://github.com/motet-a/jinjalint +- https://github.com/milin/giticket From b5b07c3c7a84b157848e49d45b2876d39c311d28 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 6 Jan 2019 09:04:23 -0800 Subject: [PATCH 197/854] Add PyCQA/pydocstyle --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index a7c608f5..bafcdc4a 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -75,6 +75,7 @@ - https://github.com/thoughtworks/talisman - https://gitlab.com/PyCQA/flake8 - https://github.com/PyCQA/bandit +- https://github.com/PyCQA/pydocstyle - https://github.com/miki725/importanize - https://github.com/motet-a/jinjalint - https://github.com/milin/giticket From fe53516e7250bcc27ae5c3e555aee09078c6d7b8 Mon Sep 17 00:00:00 2001 From: Jan Gazda <1oglop1@gmail.com> Date: Mon, 7 Jan 2019 12:33:21 +0100 Subject: [PATCH 198/854] Swap mirrors for official PyCQA repos --- all-repos.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/all-repos.yaml b/all-repos.yaml index bafcdc4a..8f8e869d 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -30,7 +30,6 @@ - https://github.com/elidupuis/mirrors-sass-lint - https://github.com/jumanjihouse/pre-commit-hooks - https://github.com/Lucas-C/pre-commit-hooks -- https://github.com/Lucas-C/pre-commit-hooks-bandit - https://github.com/Lucas-C/pre-commit-hooks-go - https://github.com/Lucas-C/pre-commit-hooks-java - https://github.com/Lucas-C/pre-commit-hooks-lxml @@ -50,7 +49,6 @@ - https://github.com/doublify/pre-commit-hindent - https://github.com/doublify/pre-commit-isort - https://github.com/doublify/pre-commit-rust -- https://github.com/chewse/pre-commit-mirrors-pydocstyle - https://github.com/kintoandar/pre-commit - https://github.com/awebdeveloper/pre-commit-stylelint - https://github.com/awebdeveloper/pre-commit-tslint From 30b7cb11f7069fa473f6c401326601603bac3399 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 7 Jan 2019 08:07:32 -0800 Subject: [PATCH 199/854] Add https://github.com/sqlalchemyorg/zimports --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 8f8e869d..1f47458b 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -77,3 +77,4 @@ - https://github.com/miki725/importanize - https://github.com/motet-a/jinjalint - https://github.com/milin/giticket +- https://github.com/sqlalchemyorg/zimports From bfae47d52f6af7cce34043f080c63e264bd6c3df Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 8 Jan 2019 14:42:29 -0800 Subject: [PATCH 200/854] Updates for pre-commit 1.14 --- index.mako | 138 +++++++++++++++++++++++++++++++++++-------- requirements-dev.txt | 2 + 2 files changed, 117 insertions(+), 23 deletions(-) diff --git a/index.mako b/index.mako index 407266c5..f23fc158 100644 --- a/index.mako +++ b/index.mako @@ -98,7 +98,7 @@ pre-commit config file describes what repositories and hooks are installed. ## .pre-commit-config.yaml - top level -_new in 1.0.0_ The default configuration file top-level was changed from a +_new in 1.0.0_: The default configuration file top-level was changed from a list to a map. If you're using an old version of pre-commit, the top-level list is the same as the value of [`repos`](#pre-commit-configyaml---repos). If you'd like to migrate to the new configuration format, run @@ -106,6 +106,38 @@ If you'd like to migrate to the new configuration format, run migrate your configuration. ```table +=r= + =c= `repos` + =c= A list of [repository mappings](#pre-commit-configyaml---repos). +=r= + =c= `default_language_version` + =c= (optional: default `{}`) a mapping from language to the default + `language_version` that should be used for that language. This will + only override individual hooks that do not set `language_version`. + + For example: + + ```yaml + # by default use `python3.7` for `language: python` hooks + default_language_version: + python: python3.7 + ``` + + _new in 1.14.0_ +=r= + =c= `default_stages` + =c= (optional: default (all stages)) a configuration-wide default for + the `stages` property of hooks. This will only override individual + hooks that do not set `stages`. + + For example: + + ```yaml + # default all the hooks to only run on `commit` / `push` + default_stages: [commit, push] + ``` + + _new in 1.14.0_ =r= =c= `exclude` =c= (optional: default `^$`) global file exclude pattern. _new in 1.1.0_. @@ -113,12 +145,9 @@ migrate your configuration. =c= `fail_fast` =c= (optional: default `false`) set to `true` to have pre-commit stop running hooks after the first failure. _new in 1.1.0_. -=r= - =c= `repos` - =c= A list of [repository mappings](#pre-commit-configyaml---repos). ``` -A sample top-level with all defaults present: +A sample top-level: ```yaml exclude: '^$' @@ -138,7 +167,7 @@ from. =c= the repository url to `git clone` from =r= =c= `rev` - =c= the revision or tag to clone at. _new in 1.7.0_ previously `sha` + =c= the revision or tag to clone at. _new in 1.7.0_: previously `sha` =r= =c= `hooks` =c= A list of [hook mappings](#pre-commit-configyaml---hooks). @@ -167,8 +196,8 @@ repository's configuration. =r= =c= `alias` =c= (optional) allows the hook to be referenced using an additional id when - using `pre-commit run ` - _new in 1.14.0_ + using `pre-commit run `. + _new in 1.14.0_. =r= =c= `name` =c= (optional) override the name of the hook - shown during hook execution. @@ -214,7 +243,7 @@ repository's configuration. =r= =c= `log_file` =c= (optional) if present, the hook output will additionally be written - to a file. _new in 0.14.0_ + to a file. _new in 0.14.0_. ``` One example of a complete configuration: @@ -358,7 +387,7 @@ For example: types: [text] ``` -_new in 0.12.0_ Prior to 0.12.0 the file was `hooks.yaml` +_new in 0.12.0_: Prior to 0.12.0 the file was `hooks.yaml` (now `.pre-commit-hooks.yaml`). For backwards compatibility it is suggested to provide both files or suggest users use `pre-commit>=0.12.0`. @@ -372,13 +401,15 @@ directory while developing hooks. enabling a quick way to try out a repository. Here's how one might work interactively: +_new in 1.14.0_: a commit is no longer necessary to `try-repo` on a local +directory. `pre-commit` will clone any uncommitted changes. + ```pre-commit ~/work/hook-repo $ git checkout origin/master -b feature # ... make some changes -~/work/hook-repo $ # A commit is needed so `pre-commit` can clone -~/work/hook-repo $ git commit -m "Add new hook: foo" +# new in 1.14.0: a commit is no longer necessary for `try-repo` # In another terminal or tab @@ -515,7 +546,7 @@ match the `entry` – usually through `bin` in package.json. __Support:__ node hooks work without any system-level dependencies. It has been tested on linux and macOS and _may_ work under cygwin. -_new in 1.5.0_ windows is now supported for node hooks. Currently python3 +_new in 1.5.0_: windows is now supported for node hooks. Currently python3 only due to [a bug in cpython](https://bugs.python.org/issue32539). ### python @@ -612,7 +643,7 @@ the regex as the `entry`. The `entry` may be any python [regular expression](#regular-expressions). For case insensitive regexes you can apply the `(?i)` flag as the start of your entry, or use `args: [-i]`. -_new in 1.8.0_ For multiline matches, use `args: [--multiline]`. +_new in 1.8.0_: For multiline matches, use `args: [--multiline]`. __Support:__ pygrep hooks are supported on all platforms which pre-commit runs on. @@ -659,9 +690,21 @@ Options: - `--bleeding-edge`: update to the bleeding edge of `master` instead of the latest tagged version (the default behaviour). -- `--repo REPO`: _new in 1.4.1_ Only update this repository. _new in 1.7.0_ +- `--repo REPO`: _new in 1.4.1_: Only update this repository. _new in 1.7.0_: This option may be specified multiple times. +## pre-commit gc [options] [](#pre-commit-gc) + +_new in 1.14.0_ + +Clean unused cached repos. + +`pre-commit` keeps a cache of installed hook repositories which grows over +time. This command can be run periodically to clean out unused repos from +the cache directory. + +Options: (no additional options) + ## pre-commit clean [options] [](#pre-commit-clean) Clean out cached pre-commit files. @@ -697,7 +740,9 @@ Options: (no additional options) ## pre-commit migrate-config [options] [](#pre-commit-migrate-config) -_new in 1.0.0_ Migrate list configuration to the new map configuration format. +_new in 1.0.0_ + +Migrate list configuration to the new map configuration format. Options: (no additional options) @@ -712,7 +757,7 @@ Options: - `--files [FILES [FILES ...]]`: specific filenames to run hooks on. - `--source SOURCE` + `--origin ORIGIN`: run against the files changed between `SOURCE...ORIGIN` in git. -- `--show-diff-on-failure`: _new in 0.13.4_ when hooks fail, run `git diff` +- `--show-diff-on-failure`: _new in 0.13.4_: when hooks fail, run `git diff` directly afterward. - `-v`, `--verbose`: produce hook output independent of success. Include hook ids in output. @@ -737,7 +782,9 @@ Options: (no additional options) ## pre-commit try-repo REPO [options] [](#pre-commit-try-repo) -_new in 1.3.0_ Try the hooks in a repository, useful for developing new hooks. +_new in 1.3.0_ + +Try the hooks in a repository, useful for developing new hooks. `try-repo` can also be used for testing out a repository before adding it to your configuration. `try-repo` prints a configuration it generates based on the remote hook repository before running the hooks. @@ -819,12 +866,12 @@ implicit conflicts (such as with removed python imports). ## pre-commit during push -_new in 0.3.5_ pre-commit can be used to manage `pre-push` hooks. Simply +_new in 0.3.5_: pre-commit can be used to manage `pre-push` hooks. Simply `pre-commit install --hook-type pre-push`. ## pre-commit for commit messages -_new in 0.15.4_ pre-commit can be used to manage `commit-msg` hooks. Simply +_new in 0.15.4_: pre-commit can be used to manage `commit-msg` hooks. Simply `pre-commit install --hook-type commit-msg`. `commit-msg` hooks can be configured by setting `stages: [commit-msg]`. @@ -840,7 +887,7 @@ setting the `stages` property in your `.pre-commit-config.yaml`. The `stages` property is an array and can contain any of `commit`, `push`, and `commit-msg`. -_new in 1.8.0_ An additional `manual` stage is available for one off execution +_new in 1.8.0_: An additional `manual` stage is available for one off execution that won't run in any hook context. This special stage is useful for taking advantage of `pre-commit`'s cross-platform / cross-language package management without running it on every commit. Hooks confied to `stages: [manual]` can @@ -902,7 +949,7 @@ Repository-local hooks are useful when: You can configure repository-local hooks by specifying the `repo` as the sentinel `local`. -_new in 0.13.0_ local hooks can use any language which supports +_new in 0.13.0_: local hooks can use any language which supports `additional_dependencies` or `docker_image` / `fail` / `pcre` / `pygrep` / `script` / `system`. This enables you to install things which previously would require a trivial @@ -935,11 +982,44 @@ Here's an example configuration with a few `local` hooks: additional_dependencies: ['scss_lint:0.52.0'] ``` +## meta hooks + +_new in 1.4.0_ + +`pre-commit` provides several hooks which are useful for checking the +pre-commit configuration itself. These can be enabled using `repo: meta`. + +```yaml +- repo: meta + hooks: + - id: ... +``` + +The currently available `meta` hooks: + +```table +=r= + =c= `check-hooks-apply` + =c= ensures that the configured hooks apply to at least one file in the + repository. + _new in 1.4.0_. +=r= + =c= `check-useless-excludes` + =c= ensures that `exclude` directives apply to _any_ file in the + repository. + _new in 1.4.0_. +=r= + =c= `identity` + =c= a simple hook which prints all arguments passed to it, uesful for + debugging. + _new in 1.14.0_. +``` + + ## Filtering files with types _new in 0.15.0_ - Filtering with `types` provides several advantages over traditional filtering with `files`. @@ -1053,6 +1133,18 @@ Valid values for specific languages are listed below: - node: See [nodeenv](https://github.com/ekalinin/nodeenv#advanced). - ruby: See [ruby-build](https://github.com/sstephenson/ruby-build/tree/master/share/ruby-build). +_new in 1.14.0_: you can now set `default_language_version` at the +[top level](#pre-commit-configyaml---top-level) in your configuration to +control the default versions across all hooks of a language. + +```yaml +default_language_version: + # force all unspecified python hooks to run python3 + python: python3 + # force all unspecified ruby hooks to run ruby 2.1.5 + ruby: 2.1.5 +``` + ## Usage in continuous integration pre-commit can also be used as a tool for continuous integration. For diff --git a/requirements-dev.txt b/requirements-dev.txt index da0903c2..53107177 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,5 +3,7 @@ mako libsass markdown-code-blocks markdown-to-presentation>=0.0.12 +# remove once merged and release +git+https://github.com/asottile/mistune@nested_code_blocks pre-commit>=0.13.6 pygments-pre-commit From aa896d238049d04a4c1a5d9fe41ed77b45146b50 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 8 Jan 2019 16:30:14 -0800 Subject: [PATCH 201/854] Responsive tables --- index.mako | 4 +--- scss/main.scss | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/index.mako b/index.mako index f23fc158..5866257b 100644 --- a/index.mako +++ b/index.mako @@ -115,10 +115,9 @@ migrate your configuration. `language_version` that should be used for that language. This will only override individual hooks that do not set `language_version`. - For example: + For example to use `python3.7` for `language: python` hooks: ```yaml - # by default use `python3.7` for `language: python` hooks default_language_version: python: python3.7 ``` @@ -133,7 +132,6 @@ migrate your configuration. For example: ```yaml - # default all the hooks to only run on `commit` / `push` default_stages: [commit, push] ``` diff --git a/scss/main.scss b/scss/main.scss index e4f9a8ac..2b7bb6a4 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -197,3 +197,17 @@ h1, .-Color-BlackBGYellow { background-color: #c4a000; color: #2e3436; } .-Color-BlackBGCyan { background-color: #06989a; color: #2e3436; } } + +@media (max-width: $screen-md-max) { + .table-bordered td:first-child { + background: #f5f5f5; + } + + .table-bordered td { + display: block; + } + + .table-bordered tr { + border: 0; + } +} From 5faa41b12a040a7700fadd859838fa81d18b59d0 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 8 Jan 2019 17:48:51 -0800 Subject: [PATCH 202/854] This did nothing, oops --- scss/main.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scss/main.scss b/scss/main.scss index 2b7bb6a4..a44d65a6 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -206,8 +206,4 @@ h1, .table-bordered td { display: block; } - - .table-bordered tr { - border: 0; - } } From 14779c9acc73c804a5a3de641222adc30c8737bd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 8 Jan 2019 17:51:04 -0800 Subject: [PATCH 203/854] pre-commit autoupdate --- .pre-commit-config.yaml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f26503df..d77908ad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,25 +1,28 @@ repos: -- repo: git@github.com:pre-commit/pre-commit-hooks - rev: v1.3.0 +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.1.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - - id: autopep8-wrapper - id: check-yaml - id: debug-statements - id: flake8 -- repo: https://github.com/asottile/reorder_python_imports.git - rev: v1.0.1 +- repo: https://github.com/pre-commit/mirrors-autopep8 + rev: v1.4.3 + hooks: + - id: autopep8 +- repo: https://github.com/asottile/reorder_python_imports + rev: v1.3.4 hooks: - id: reorder-python-imports - repo: https://github.com/asottile/pyupgrade - rev: v1.3.1 + rev: v1.11.0 hooks: - id: pyupgrade args: [--py36-plus] exclude: ^install-local.py$ - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.610-1 + rev: v0.650 hooks: - id: mypy exclude: ^install-local.py$ From b2bf446cded65fc0562fcabfa99fdb1523470640 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 9 Jan 2019 15:13:42 -0800 Subject: [PATCH 204/854] Use merged version --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 53107177..cdcb61e9 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,6 +4,6 @@ libsass markdown-code-blocks markdown-to-presentation>=0.0.12 # remove once merged and release -git+https://github.com/asottile/mistune@nested_code_blocks +git+https://github.com/lepture/mistune@449c2b5 pre-commit>=0.13.6 pygments-pre-commit From 19b6425b37a36aa4e9602adcddcb01dc819bc2fc Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 10 Jan 2019 11:22:20 -0800 Subject: [PATCH 205/854] Document installation from conda-forge --- index.mako | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/index.mako b/index.mako index 5866257b..89d50ad5 100644 --- a/index.mako +++ b/index.mako @@ -56,7 +56,7 @@ installed. Using pip: -``` +```bash pip install pre-commit ``` @@ -66,7 +66,7 @@ Non-administrative installation: - _does not work on platforms without symlink support (windows)_ -``` +```bash curl https://pre-commit.com/install-local.py | python - ``` @@ -79,9 +79,17 @@ pre-commit Using [homebrew](https://brew.sh): -``` +```bash brew install pre-commit ``` + +Using [conda](https://conda.io) (via [conda-forge](https://conda-forge.org)): + +```bash +conda config --add channels conda-forge +conda install pre_commit +``` + ''')} From c92d12d3c49ea03a9a497ffa5180896b33bf0f6a Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 10 Jan 2019 12:35:59 -0800 Subject: [PATCH 206/854] Use the less-global conda installation approach --- index.mako | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.mako b/index.mako index 89d50ad5..6045fdf0 100644 --- a/index.mako +++ b/index.mako @@ -86,8 +86,7 @@ brew install pre-commit Using [conda](https://conda.io) (via [conda-forge](https://conda-forge.org)): ```bash -conda config --add channels conda-forge -conda install pre_commit +conda install -c conda-forge pre_commit ``` ''')} From 45ffc518fd6c30a09dcad6590f65df36db558a5d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 11 Jan 2019 07:47:41 -0800 Subject: [PATCH 207/854] Document `require_serial` --- index.mako | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.mako b/index.mako index 6045fdf0..526c27c3 100644 --- a/index.mako +++ b/index.mako @@ -367,6 +367,10 @@ file that tells pre-commit: =c= `pass_filenames` =c= (optional: default `true`) if `true` this hook must take filenames as positional arguments. _new in 0.14.0_. +=r= + =c= `require_serial` + =c= (optional: default `false`) if `true` this hook will execute using a + a single process instead of in parallel. _new in 1.13.0_. =r= =c= `description` =c= (optional: default `''`) description of the hook. used for metadata From 5ad55a58c7772ecc58f85f9694db12dad28d7b00 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 30 Jan 2019 00:39:27 -0800 Subject: [PATCH 208/854] Migrate to official pycqa/flake8 hooks repo Committed via https://github.com/asottile/all-repos --- .pre-commit-config.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d77908ad..cee49dd9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,23 +6,26 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: debug-statements +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.7.1 + hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-autopep8 rev: v1.4.3 hooks: - id: autopep8 - repo: https://github.com/asottile/reorder_python_imports - rev: v1.3.4 + rev: v1.3.5 hooks: - id: reorder-python-imports - repo: https://github.com/asottile/pyupgrade - rev: v1.11.0 + rev: v1.11.1 hooks: - id: pyupgrade args: [--py36-plus] exclude: ^install-local.py$ - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.650 + rev: v0.660 hooks: - id: mypy exclude: ^install-local.py$ From fae7961aa10811114f0625b3a1fe5dcbe751bf72 Mon Sep 17 00:00:00 2001 From: Nikolaus Schlemm Date: Thu, 31 Jan 2019 13:33:58 +0100 Subject: [PATCH 209/854] Added pip-compile-multi Caters for verifying that pip-compile-multi has been run after changing (multiple) requirements.in files --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 1f47458b..7e2b96e8 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -78,3 +78,4 @@ - https://github.com/motet-a/jinjalint - https://github.com/milin/giticket - https://github.com/sqlalchemyorg/zimports +- https://github.com/peterdemin/pip-compile-multi From a57574e8b31ac32d82383b171ad753e4e1f4b3ab Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Thu, 31 Jan 2019 12:31:44 -0800 Subject: [PATCH 210/854] Add "args" parameter to Creating new hooks section --- index.mako | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.mako b/index.mako index 526c27c3..806c7199 100644 --- a/index.mako +++ b/index.mako @@ -383,6 +383,9 @@ file that tells pre-commit: =c= `minimum_pre_commit_version` =c= (optional: default `0.0.0`) allows one to indicate a minimum compatible pre-commit version. _new in 0.6.7_. +=r= + =c= `args` + =c= (optional) See [Passing arguments to hooks](#passing-arguments-to-hooks). ``` For example: From 7971d795300d8c6ba64c6c717a444ba9f901370a Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Thu, 31 Jan 2019 13:37:32 -0800 Subject: [PATCH 211/854] Update index.mako --- index.mako | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 806c7199..60620b6f 100644 --- a/index.mako +++ b/index.mako @@ -385,7 +385,8 @@ file that tells pre-commit: compatible pre-commit version. _new in 0.6.7_. =r= =c= `args` - =c= (optional) See [Passing arguments to hooks](#passing-arguments-to-hooks). + =c= (optional: default `[]`) list of additional parameters to pass to the hook. + ``` For example: From 79d9f86dd5d96004d4a165d761c133445e509020 Mon Sep 17 00:00:00 2001 From: Max R Date: Fri, 1 Feb 2019 12:31:37 -0500 Subject: [PATCH 212/854] Fix typo --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 60620b6f..c1fed0a7 100644 --- a/index.mako +++ b/index.mako @@ -1023,7 +1023,7 @@ The currently available `meta` hooks: _new in 1.4.0_. =r= =c= `identity` - =c= a simple hook which prints all arguments passed to it, uesful for + =c= a simple hook which prints all arguments passed to it, useful for debugging. _new in 1.14.0_. ``` From 38faf5a77e942493515dd888337e0022defb6952 Mon Sep 17 00:00:00 2001 From: Eliot Alter Date: Thu, 14 Feb 2019 07:38:20 -0800 Subject: [PATCH 213/854] Fix a typo --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index c1fed0a7..598bb9a1 100644 --- a/index.mako +++ b/index.mako @@ -370,7 +370,7 @@ file that tells pre-commit: =r= =c= `require_serial` =c= (optional: default `false`) if `true` this hook will execute using a - a single process instead of in parallel. _new in 1.13.0_. + single process instead of in parallel. _new in 1.13.0_. =r= =c= `description` =c= (optional: default `''`) description of the hook. used for metadata From 3ef57506ccbff061ce1a0b19e68b901ad6f1a1a1 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 23 Feb 2019 15:42:30 -0800 Subject: [PATCH 214/854] sec: upgrade bootstrap-sass --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 35c34be5..d8073dcb 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,6 @@ "repository": "github.com/pre-commit/pre-commit.github.io", "license": "MIT", "dependencies": { - "bootstrap-sass": "3.3.7" + "bootstrap-sass": "3.4.1" } } From 4bff9927a54939d40f6ee037b108a6c7e3fc326c Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 27 Feb 2019 22:51:16 -0800 Subject: [PATCH 215/854] Add some new toys I made --- all-repos.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/all-repos.yaml b/all-repos.yaml index 7e2b96e8..61f7ca66 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -24,6 +24,8 @@ - https://github.com/asottile/yesqa - https://github.com/asottile/seed-isort-config - https://github.com/asottile/blacken-docs +- https://github.com/asottile/dead +- https://github.com/asottile/setup-cfg-fmt - https://github.com/asottile/cheetah_lint - https://github.com/digitalpulp/pre-commit-php - https://github.com/elidupuis/mirrors-jscs From 43c9a8592940baa6d528c619a47eaac10b2c1ee7 Mon Sep 17 00:00:00 2001 From: Elliot Jordan Date: Thu, 28 Feb 2019 14:05:07 -0800 Subject: [PATCH 216/854] Add pre-commit-macadmin --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 61f7ca66..ee4a7d81 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -81,3 +81,4 @@ - https://github.com/milin/giticket - https://github.com/sqlalchemyorg/zimports - https://github.com/peterdemin/pip-compile-multi +- https://github.com/homebysix/pre-commit-macadmin From c284b84c8f7bb02c6e681356ac0a81aa011921ca Mon Sep 17 00:00:00 2001 From: Brett Randall Date: Sun, 17 Mar 2019 19:57:53 +1100 Subject: [PATCH 217/854] Mention the potential need to passenv proxy vars for tox http(s) clone. --- index.mako | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.mako b/index.mako index 598bb9a1..0f146ee5 100644 --- a/index.mako +++ b/index.mako @@ -1202,6 +1202,21 @@ Add the following to your tox testenv: passenv = SSH_AUTH_SOCK ``` +Likewise, when cloning repos over http/https (`repo: https://github.com:...`), you might +be working behind a corporate http(s) proxy server, in which case `git` requires the +`http_proxy`, `https_proxy` and `no_proxy` variables to be set, or the clone may fail + +If you need to retain proxy-variables, add the following to your tox testenv: + +Add the following to your tox testenv: + +```ini +[testenv] +passenv = http_proxy + https_proxy + no_proxy +``` + pre-commit uses `os.path.expanduser` to create the cache directory, on windows this requires the `HOMEPATH` environment variable: From ecd802f41698719c869e55fd99428df7843503be Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 17 Mar 2019 02:04:01 -0700 Subject: [PATCH 218/854] Formatting fixup --- index.mako | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/index.mako b/index.mako index 0f146ee5..8a42a2b2 100644 --- a/index.mako +++ b/index.mako @@ -1202,19 +1202,14 @@ Add the following to your tox testenv: passenv = SSH_AUTH_SOCK ``` -Likewise, when cloning repos over http/https (`repo: https://github.com:...`), you might -be working behind a corporate http(s) proxy server, in which case `git` requires the -`http_proxy`, `https_proxy` and `no_proxy` variables to be set, or the clone may fail - -If you need to retain proxy-variables, add the following to your tox testenv: - -Add the following to your tox testenv: +Likewise, when cloning repos over http / https +(`repo: https://github.com:...`), you might be working behind a corporate +http(s) proxy server, in which case `git` requires the `http_proxy`, +`https_proxy` and `no_proxy` variables to be set, or the clone may fail: ```ini [testenv] -passenv = http_proxy - https_proxy - no_proxy +passenv = http_proxy https_proxy no_proxy ``` pre-commit uses `os.path.expanduser` to create the cache directory, on windows From d35e67428db88c728beb003b3f3b14adba56c071 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 18 Mar 2019 07:51:11 -0700 Subject: [PATCH 219/854] Use USERPROFILE instead of HOMEPATH (more reliable) --- index.mako | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/index.mako b/index.mako index 8a42a2b2..d076fb9e 100644 --- a/index.mako +++ b/index.mako @@ -1213,18 +1213,11 @@ passenv = http_proxy https_proxy no_proxy ``` pre-commit uses `os.path.expanduser` to create the cache directory, on windows -this requires the `HOMEPATH` environment variable: +this requires the `USERPROFILE` environment variable: ```ini [testenv] -passenv = HOMEPATH -``` - -Or with both: - -```ini -[testenv] -passenv = HOMEPATH SSH_AUTH_SOCK +passenv = USERPROFILE ``` ## Using the latest version for a repository From 3ace0ad3641bdc090c0f87fb2651771e439b6cf2 Mon Sep 17 00:00:00 2001 From: Ryan Fortman Date: Mon, 18 Mar 2019 13:21:54 -0600 Subject: [PATCH 220/854] Adding in prometheus validation repo --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index ee4a7d81..eabbd608 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -82,3 +82,4 @@ - https://github.com/sqlalchemyorg/zimports - https://github.com/peterdemin/pip-compile-multi - https://github.com/homebysix/pre-commit-macadmin +- https://github.com/fortman/pre-commit-prometheus From 8a05d59f6d50a18d999a81f283709ecb3596c95c Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 21 Mar 2019 18:41:38 -0700 Subject: [PATCH 221/854] Document top level minimum_pre_commit_version --- index.mako | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.mako b/index.mako index d076fb9e..37c45686 100644 --- a/index.mako +++ b/index.mako @@ -150,6 +150,10 @@ migrate your configuration. =c= `fail_fast` =c= (optional: default `false`) set to `true` to have pre-commit stop running hooks after the first failure. _new in 1.1.0_. +=r= + =c= `minimum_pre_commit_version` + =c= (optional: default `'0'`) require a minimum version of pre-commit. + _new in 1.15.0_. ``` A sample top-level: @@ -381,7 +385,7 @@ file that tells pre-commit: [Overriding language version](#overriding-language-version). =r= =c= `minimum_pre_commit_version` - =c= (optional: default `0.0.0`) allows one to indicate a minimum + =c= (optional: default `'0'`) allows one to indicate a minimum compatible pre-commit version. _new in 0.6.7_. =r= =c= `args` From 00ed6133baedccca33a51674ad24af65b544d812 Mon Sep 17 00:00:00 2001 From: Chase Pierce Date: Wed, 27 Mar 2019 04:19:15 -0600 Subject: [PATCH 222/854] add syntaqx/git-hooks to all-repos --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index eabbd608..295ef35c 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -83,3 +83,4 @@ - https://github.com/peterdemin/pip-compile-multi - https://github.com/homebysix/pre-commit-macadmin - https://github.com/fortman/pre-commit-prometheus +- https://github.com/syntaqx/git-hooks From ad2a5645b4272c441bb934d5319c24f6112941ee Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 28 Mar 2019 12:10:04 +0100 Subject: [PATCH 223/854] Add pre-commit-luacheck hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 295ef35c..b07405ac 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -84,3 +84,4 @@ - https://github.com/homebysix/pre-commit-macadmin - https://github.com/fortman/pre-commit-prometheus - https://github.com/syntaqx/git-hooks +- https://github.com/Calinou/pre-commit-luacheck From 0ef636681b992aef4d4ee3a1fcf7746822bb80e9 Mon Sep 17 00:00:00 2001 From: Belmin Fernandez Date: Sat, 30 Mar 2019 07:17:53 -0400 Subject: [PATCH 224/854] Add belminf/pre-commit-chef --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index b07405ac..16376a9c 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -85,3 +85,4 @@ - https://github.com/fortman/pre-commit-prometheus - https://github.com/syntaqx/git-hooks - https://github.com/Calinou/pre-commit-luacheck +- https://github.com/belminf/pre-commit-chef From af278c59a6fcb83537e18445b7100fe2d9f66a0a Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Apr 2019 19:02:57 -0700 Subject: [PATCH 225/854] Add isort as a supported repository --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 16376a9c..df8d039b 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -86,3 +86,4 @@ - https://github.com/syntaqx/git-hooks - https://github.com/Calinou/pre-commit-luacheck - https://github.com/belminf/pre-commit-chef +- https://github.com/timothycrosley/isort From 92a08fe84839a7fd7321107558e1273a7a5a59f1 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 20 Apr 2019 16:43:42 -0700 Subject: [PATCH 226/854] python3.6 is the default in travis now Committed via https://github.com/asottile/all-repos --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3f978f37..a50fae81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: python -python: 3.6 install: pip install virtualenv --upgrade script: make after_success: make push From e6988cdd86f5e7dee67db5932b65d3696d34b1e0 Mon Sep 17 00:00:00 2001 From: Marc Jay Date: Sun, 21 Apr 2019 22:32:42 +0100 Subject: [PATCH 227/854] Document prepare-commit-msg hooks Update documentation to cover additional stage: prepare-commit-msg --- index.mako | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/index.mako b/index.mako index 37c45686..7c27bdc1 100644 --- a/index.mako +++ b/index.mako @@ -233,8 +233,8 @@ repository's configuration. =c= (optional) list of additional parameters to pass to the hook. =r= =c= `stages` - =c= (optional) confines the hook to the `commit`, `push`, `commit-msg`, or - `manual` stage. See + =c= (optional) confines the hook to the `commit`, `push`, `prepare-commit-msg`, + `commit-msg`, or `manual` stage. See [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). =r= =c= `additional_dependencies` @@ -736,8 +736,9 @@ Options: - `-f`, `--overwrite`: overwrite existing hooks / remove migration mode. - `--install-hooks`: also install hook environments for all available hooks. -- `-t {pre-commit,pre-push,commit-msg}`, - `--hook-type {pre-commit,pre-push,commit-msg}`: which hook type to install. +- `-t {pre-commit,pre-push,prepare-commit-msg,commit-msg}`, + `--hook-type {pre-commit,pre-push,prepare-commit-msg,commit-msg}`: + which hook type to install. - `--allow-missing-config`: whether to allow the installed hook scripts to permit a missing configuration file. @@ -831,8 +832,9 @@ Uninstall the pre-commit script. Options: -- `-t {pre-commit,pre-push,commit-msg}`, - `--hook-type {pre-commit,pre-push,commit-msg}`: which hook type to uninstall. +- `-t {pre-commit,pre-push,prepare-commit-msg,commit-msg}`, + `--hook-type {pre-commit,pre-push,prepare-commit-msg,commit-msg}`: which hook + type to uninstall. ''')} @@ -896,13 +898,25 @@ _new in 0.15.4_: pre-commit can be used to manage `commit-msg` hooks. Simply current contents of the commit message which can be validated. If a hook exits nonzero, the commit will be aborted. +_new in X_: pre-commit can be used to manage `prepare-commit-msg` hooks. +Simply `pre-commit install --hook-type prepare-commit-msg`. + +`prepare-commit-msg` hooks can be used to create dynamic templates for commit +messages. `prepare-commit-msg` hooks can be configured by setting +`stages: [prepare-commit-msg]`. `prepare-commit-msg` hooks will be passed a +single filename -- this file contains any initial commit message (e.g. from +`git commit -m "..."` or a template) and can be modified by the hook before +the editor is shown. A hook may want to check for `GIT_EDITOR=:` as this +indicates that no editor will be launched. If a hook exits nonzero, +the commit will be aborted. + ## Confining hooks to run at certain stages If pre-commit during push has been installed, then all hooks (by default) will be run during the `push` stage. Hooks can however be confined to a stage by setting the `stages` property in your `.pre-commit-config.yaml`. The -`stages` property is an array and can contain any of `commit`, `push`, and -`commit-msg`. +`stages` property is an array and can contain any of `commit`, `push`, +`prepare-commit-msg` and `commit-msg`. _new in 1.8.0_: An additional `manual` stage is available for one off execution that won't run in any hook context. This special stage is useful for taking From 5505ea5c0d594a1b0208c49bac6cfcbf2dd1f302 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 21 Apr 2019 15:35:43 -0700 Subject: [PATCH 228/854] Remove mention of USERPROFILE (unnecessary in tox>=2.8) --- index.mako | 8 -------- 1 file changed, 8 deletions(-) diff --git a/index.mako b/index.mako index 37c45686..9bdd7c70 100644 --- a/index.mako +++ b/index.mako @@ -1216,14 +1216,6 @@ http(s) proxy server, in which case `git` requires the `http_proxy`, passenv = http_proxy https_proxy no_proxy ``` -pre-commit uses `os.path.expanduser` to create the cache directory, on windows -this requires the `USERPROFILE` environment variable: - -```ini -[testenv] -passenv = USERPROFILE -``` - ## Using the latest version for a repository `pre-commit` configuration aims to give a repeatable and fast experience and From c0c453aed297792ef781763d1e982dfbf3430e59 Mon Sep 17 00:00:00 2001 From: Marc Jay Date: Sun, 21 Apr 2019 23:41:27 +0100 Subject: [PATCH 229/854] Update with version number for future release (0.16.0) --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 7c27bdc1..6b0d3119 100644 --- a/index.mako +++ b/index.mako @@ -898,7 +898,7 @@ _new in 0.15.4_: pre-commit can be used to manage `commit-msg` hooks. Simply current contents of the commit message which can be validated. If a hook exits nonzero, the commit will be aborted. -_new in X_: pre-commit can be used to manage `prepare-commit-msg` hooks. +_new in 0.16.0_: pre-commit can be used to manage `prepare-commit-msg` hooks. Simply `pre-commit install --hook-type prepare-commit-msg`. `prepare-commit-msg` hooks can be used to create dynamic templates for commit From 6ed0a0e1f2d39465dd8b37f58e9c51ba9ea44b79 Mon Sep 17 00:00:00 2001 From: Marc Jay Date: Sun, 21 Apr 2019 23:43:11 +0100 Subject: [PATCH 230/854] Update with the correct version number: 1.16.0 --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 6b0d3119..fad57fbc 100644 --- a/index.mako +++ b/index.mako @@ -898,7 +898,7 @@ _new in 0.15.4_: pre-commit can be used to manage `commit-msg` hooks. Simply current contents of the commit message which can be validated. If a hook exits nonzero, the commit will be aborted. -_new in 0.16.0_: pre-commit can be used to manage `prepare-commit-msg` hooks. +_new in 1.16.0_: pre-commit can be used to manage `prepare-commit-msg` hooks. Simply `pre-commit install --hook-type prepare-commit-msg`. `prepare-commit-msg` hooks can be used to create dynamic templates for commit From 2842d5b9014cbdaaa01713d9f9642656407d09df Mon Sep 17 00:00:00 2001 From: Ross Jacobs Date: Thu, 25 Apr 2019 02:17:37 +0100 Subject: [PATCH 231/854] Added c linter repo to list https://github.com/pocc/pre-commit-hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index df8d039b..f81f5c25 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -87,3 +87,4 @@ - https://github.com/Calinou/pre-commit-luacheck - https://github.com/belminf/pre-commit-chef - https://github.com/timothycrosley/isort +- https://github.com/pocc/pre-commit-hooks From 0dccb44371a7cdd645898402fdba243792df9b4e Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 28 Apr 2019 22:06:52 -0700 Subject: [PATCH 232/854] Update badges --- base.mako | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/base.mako b/base.mako index d2586941..79a2e064 100644 --- a/base.mako +++ b/base.mako @@ -44,9 +44,8 @@

      A framework for managing and maintaining multi-language pre-commit hooks.

      -

      Build Status -Coverage Status -

      +

      Build Status +Azure DevOps Coverage

      From 552ace043ed399e543e3b79aa9f3fb491ad97b2a Mon Sep 17 00:00:00 2001 From: Max R Date: Mon, 29 Apr 2019 01:39:38 -0400 Subject: [PATCH 233/854] Whitespace nits --- index.mako | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.mako b/index.mako index c0d96e20..794cb358 100644 --- a/index.mako +++ b/index.mako @@ -476,7 +476,7 @@ Running Docker hooks requires a running Docker engine on your host. For configuring Docker hooks, your `entry` should correspond to an executable inside the Docker container, and will be used to override the default container entrypoint. Your Docker `CMD` will not run when pre-commit passes a file list -as arguments to the run container command. Docker allows you to use any +as arguments to the run container command. Docker allows you to use any language that's not supported by pre-commit as a builtin. __Support:__ docker hooks are known to work on any system which has a working @@ -871,8 +871,8 @@ time and stashing the unstaged changes while running hooks. ## pre-commit during merges -The biggest gripe we’ve had in the past with pre-commit hooks was during -merge conflict resolution. When working on very large projects a merge often +The biggest gripe we’ve had in the past with pre-commit hooks was during merge +conflict resolution. When working on very large projects a merge often results in hundreds of committed files. I shouldn’t need to run hooks on all of these files that I didn’t even touch! This often led to running commit with `--no-verify` and allowed introduction of real bugs that hooks could have @@ -1120,7 +1120,7 @@ As such, you can use any of the features that python regexes support. If you find that your regular expression is becoming unwieldy due to a long list of excluded / included things, you may find a [verbose](https://docs.python.org/3/library/re.html#re.VERBOSE) regular -expression useful. One can enable this with yaml's multiline literals and +expression useful. One can enable this with yaml's multiline literals and the `(?x)` regex flag. ```yaml From bd156b2108094c4fc5f76615ed63dbf5c4818256 Mon Sep 17 00:00:00 2001 From: Dwight Gunning Date: Wed, 1 May 2019 22:48:09 +0200 Subject: [PATCH 234/854] Added Angular-cli ng lint hook to the list --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index f81f5c25..cc30480d 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -88,3 +88,4 @@ - https://github.com/belminf/pre-commit-chef - https://github.com/timothycrosley/isort - https://github.com/pocc/pre-commit-hooks +- https://github.com/dwightgunning/pre-commit-nglint From 813bc230eb4ec397d42d99bdc4420a849bf3b553 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 2 May 2019 09:55:51 -0700 Subject: [PATCH 235/854] ambv/black => python/black --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index cc30480d..19203af7 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -60,7 +60,7 @@ - https://github.com/thlorenz/doctoc - https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook - https://github.com/jorisroovers/gitlint -- https://github.com/ambv/black +- https://github.com/python/black - https://github.com/IamTheFij/ansible-pre-commit - https://github.com/IamTheFij/docker-pre-commit - https://github.com/mattlqx/pre-commit-ruby From fde58a3f2e2e1ec8e5d9a0b6ad401807a06b584a Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 8 May 2019 14:31:11 -0700 Subject: [PATCH 236/854] Combine mypy.ini and setup.cfg Committed via https://github.com/asottile/all-repos --- mypy.ini => setup.cfg | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename mypy.ini => setup.cfg (100%) diff --git a/mypy.ini b/setup.cfg similarity index 100% rename from mypy.ini rename to setup.cfg From 2af88199659ab90f7686c0e33ad901285f183cde Mon Sep 17 00:00:00 2001 From: Chase Pierce Date: Sat, 25 May 2019 00:27:15 -0600 Subject: [PATCH 237/854] add the official golangci-lint resource above the unofficial ones --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 19203af7..2bbc427d 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -39,6 +39,7 @@ - https://github.com/Lucas-C/pre-commit-hooks-nodejs - https://github.com/Lucas-C/pre-commit-hooks-safety - https://github.com/chriskuehl/puppet-pre-commit-hooks +- https://github.com/golangci/golangci-lint - https://github.com/dnephin/pre-commit-golang - https://github.com/troian/pre-commit-golang - https://github.com/jstewmon/check-swagger From 123bd51277c296504aa599a7014da40e625fab49 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 18 Jun 2019 08:26:01 -0700 Subject: [PATCH 238/854] Add codespell to list of hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 2bbc427d..24d048a0 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -90,3 +90,4 @@ - https://github.com/timothycrosley/isort - https://github.com/pocc/pre-commit-hooks - https://github.com/dwightgunning/pre-commit-nglint +- https://github.com/codespell-project/codespell From 29b005ffee39e29aac8839b16f71938ef470ee85 Mon Sep 17 00:00:00 2001 From: Emmanuel Sciara Date: Wed, 19 Jun 2019 00:27:31 +0200 Subject: [PATCH 239/854] Clarify Confining hooks to run at certain stages --- index.mako | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/index.mako b/index.mako index 794cb358..c4997cc3 100644 --- a/index.mako +++ b/index.mako @@ -912,11 +912,21 @@ the commit will be aborted. ## Confining hooks to run at certain stages -If pre-commit during push has been installed, then all hooks (by default) will -be run during the `push` stage. Hooks can however be confined to a stage by -setting the `stages` property in your `.pre-commit-config.yaml`. The -`stages` property is an array and can contain any of `commit`, `push`, -`prepare-commit-msg` and `commit-msg`. +Since the `default_stage` top level configuration property of the +`.pre-commit-config.yaml` file is set to all stages by default, when installing +hooks using the `-t`/`--hook-type` option (see [pre-commit +install [options]](#pre-commit-install)), all hooks will be installed by default +to run at the stage defined through that option. for instance, +`pre-commit install --hook-type pre-push` will install by default all hooks +to run at the `push` stage. + +Hooks can however be confined to a stage by setting the `stages` property in +your `.pre-commit-config.yaml`. The `stages` property is an array and can +contain any of `commit`, `push`, `prepare-commit-msg` and `commit-msg`. + +If you do not want to have hooks installed by default on the stage passed +during a `pre-commit install --hook-type ...`, please set the `default_stage` +top level configuration property to the desired stages, also as an array. _new in 1.8.0_: An additional `manual` stage is available for one off execution that won't run in any hook context. This special stage is useful for taking From 14d9f409e17c9d3815cd6cbb06b6b4dfab3a6bb7 Mon Sep 17 00:00:00 2001 From: Emmanuel Sciara Date: Wed, 19 Jun 2019 01:04:58 +0200 Subject: [PATCH 240/854] Clarify Confining hooks - fixed typos + `manual` --- index.mako | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.mako b/index.mako index c4997cc3..56391061 100644 --- a/index.mako +++ b/index.mako @@ -912,7 +912,7 @@ the commit will be aborted. ## Confining hooks to run at certain stages -Since the `default_stage` top level configuration property of the +Since the `default_stages` top level configuration property of the `.pre-commit-config.yaml` file is set to all stages by default, when installing hooks using the `-t`/`--hook-type` option (see [pre-commit install [options]](#pre-commit-install)), all hooks will be installed by default @@ -922,10 +922,11 @@ to run at the `push` stage. Hooks can however be confined to a stage by setting the `stages` property in your `.pre-commit-config.yaml`. The `stages` property is an array and can -contain any of `commit`, `push`, `prepare-commit-msg` and `commit-msg`. +contain any of `commit`, `push`, `prepare-commit-msg`, `commit-msg` and +`manual`. If you do not want to have hooks installed by default on the stage passed -during a `pre-commit install --hook-type ...`, please set the `default_stage` +during a `pre-commit install --hook-type ...`, please set the `default_stages` top level configuration property to the desired stages, also as an array. _new in 1.8.0_: An additional `manual` stage is available for one off execution From 2e703873a689ea210e99b285b0278823ddc374a1 Mon Sep 17 00:00:00 2001 From: Adrian Bridgett Date: Wed, 19 Jun 2019 08:25:17 +0100 Subject: [PATCH 241/854] add poetry and gitlab-ci hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 24d048a0..67dbfe83 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -91,3 +91,4 @@ - https://github.com/pocc/pre-commit-hooks - https://github.com/dwightgunning/pre-commit-nglint - https://github.com/codespell-project/codespell +- https://gitlab.com/smop/pre-commit-hooks.git From ee2499e4ed9357509e0928e9735807d893947493 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 19 Jun 2019 08:23:53 -0700 Subject: [PATCH 242/854] Enforce hooks --- .pre-commit-config.yaml | 4 ++-- Makefile | 6 +++++- index.mako | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cee49dd9..5374a310 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: language: ruby additional_dependencies: ['scss_lint:0.57.0'] - id: no-github-dot-git - name: No need for .git for github urls - entry: 'github.*\.git' + name: No need for .git for github/gitlab urls + entry: '(github|gitlab).*\.git' files: all-repos.yaml language: pygrep diff --git a/Makefile b/Makefile index d257225b..945ebee1 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ # To build scss continuously I use `watch -n 0.1 make build/main.css` -all: install-hooks build/main.css all-hooks.json index.html hooks.html +all: install-hooks check build/main.css all-hooks.json index.html hooks.html .PHONY: install-hooks install-hooks: venv venv/bin/pre-commit install +.PHONY: check +check: venv + venv/bin/pre-commit run --all-files --show-diff-on-failure + build/main.css: venv node_modules build scss/main.scss scss/_variables.scss venv/bin/pysassc -s compressed scss/main.scss build/main.css diff --git a/index.mako b/index.mako index 56391061..bbd27d7a 100644 --- a/index.mako +++ b/index.mako @@ -871,7 +871,7 @@ time and stashing the unstaged changes while running hooks. ## pre-commit during merges -The biggest gripe we’ve had in the past with pre-commit hooks was during merge +The biggest gripe we’ve had in the past with pre-commit hooks was during merge conflict resolution. When working on very large projects a merge often results in hundreds of committed files. I shouldn’t need to run hooks on all of these files that I didn’t even touch! This often led to running commit From fad9aec1e226d5b425465fba6033a147d2db3640 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 19 Jun 2019 08:24:59 -0700 Subject: [PATCH 243/854] Remove unnecessary .git --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 67dbfe83..068b8aa8 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -91,4 +91,4 @@ - https://github.com/pocc/pre-commit-hooks - https://github.com/dwightgunning/pre-commit-nglint - https://github.com/codespell-project/codespell -- https://gitlab.com/smop/pre-commit-hooks.git +- https://gitlab.com/smop/pre-commit-hooks From 771c02040e72c168a415bc3765017420cf4d058f Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 19 Jun 2019 08:31:08 -0700 Subject: [PATCH 244/854] cache pre-commit --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a50fae81..8bb04f89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,3 +12,4 @@ env: cache: directories: - $HOME/.cache/pip + - $HOME/.cache/pre-commit From 8e260e48a9aa3f013a105465c05e2a34fca845d7 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 19 Jun 2019 08:34:47 -0700 Subject: [PATCH 245/854] Add import-linter --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 068b8aa8..5cc33360 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -92,3 +92,4 @@ - https://github.com/dwightgunning/pre-commit-nglint - https://github.com/codespell-project/codespell - https://gitlab.com/smop/pre-commit-hooks +- https://github.com/seddonym/import-linter From aab78755709ef50f4b5271f34ee8577572e62e2c Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 26 Jun 2019 00:51:57 +0200 Subject: [PATCH 246/854] Add .taskcluster.yml validator to list of repos --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 5cc33360..b09ce34b 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -93,3 +93,4 @@ - https://github.com/codespell-project/codespell - https://gitlab.com/smop/pre-commit-hooks - https://github.com/seddonym/import-linter +- https://github.com/marco-c/taskcluster_yml_validator From f8242691ba70bef3234e721dbf6d70d4fd395eef Mon Sep 17 00:00:00 2001 From: Elliot Jordan Date: Sat, 29 Jun 2019 14:49:47 -0700 Subject: [PATCH 247/854] Minor spelling corrections --- index.mako | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.mako b/index.mako index bbd27d7a..63cf00ce 100644 --- a/index.mako +++ b/index.mako @@ -572,7 +572,7 @@ The hook repository must have a `setup.py`. It will be installed via `pip install .`. The installed package will provide an executable that will match the `entry` – usually through `console_scripts` or `scripts` in setup.py. -__Support:__ python hooks work without any system-level depedendencies. It +__Support:__ python hooks work without any system-level dependencies. It has been tested on linux, macOS, windows, and cygwin. @@ -587,7 +587,7 @@ package to use this language. This is otherwise a drop-in replacement for the `python` language for situations where [`virtualenv` may not work](https://github.com/pre-commit/pre-commit/issues/631). -__Support:__ python hooks work without any system-level depedendencies. It +__Support:__ python hooks work without any system-level dependencies. It has been tested on linux, macOS, windows, and cygwin. Only python3 environments can be created with this language. @@ -596,7 +596,7 @@ environments can be created with this language. The hook repository must have a `*.gemspec`. It will be installed via `gem build *.gemspec && gem install *.gem`. The installed package will produce an executable that will match the `entry` – usually through -`exectuables` in your gemspec. +`executables` in your gemspec. __Support:__ ruby hooks work without any system-level dependencies. It has been tested on linux and macOS and _may_ work under cygwin. From b339a79d8d36a960505ceaea03c061ffc78b7aed Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 7 Jul 2019 12:32:23 -0700 Subject: [PATCH 248/854] Add myint/docformatter to hooks list Thanks @akbiggs / @myint! https://github.com/myint/docformatter/pull/25 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index b09ce34b..199e9db4 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -94,3 +94,4 @@ - https://gitlab.com/smop/pre-commit-hooks - https://github.com/seddonym/import-linter - https://github.com/marco-c/taskcluster_yml_validator +- https://github.com/myint/docformatter From c7dacf5d87c885da68b4c7e52b3ad4bcbdbf1524 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 17 Jul 2019 23:32:34 +0200 Subject: [PATCH 249/854] add R hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 199e9db4..65f61894 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -95,3 +95,4 @@ - https://github.com/seddonym/import-linter - https://github.com/marco-c/taskcluster_yml_validator - https://github.com/myint/docformatter +- https://github.com/lorenzwalthert/pre-commit-hooks From ce07e0837e5390c10ab79bbc53e5a4be28a24c78 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 22 Jul 2019 15:18:13 -0700 Subject: [PATCH 250/854] Update black github url... again <3 @ambv --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 65f61894..53473f28 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -61,7 +61,7 @@ - https://github.com/thlorenz/doctoc - https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook - https://github.com/jorisroovers/gitlint -- https://github.com/python/black +- https://github.com/psf/black - https://github.com/IamTheFij/ansible-pre-commit - https://github.com/IamTheFij/docker-pre-commit - https://github.com/mattlqx/pre-commit-ruby From 1dc6542425cc66d17a3494ac75c0ec72c512ef06 Mon Sep 17 00:00:00 2001 From: FelixSeptem Date: Thu, 25 Jul 2019 19:51:52 +0800 Subject: [PATCH 251/854] add FelixSeptem hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 53473f28..3df94f4a 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -96,3 +96,4 @@ - https://github.com/marco-c/taskcluster_yml_validator - https://github.com/myint/docformatter - https://github.com/lorenzwalthert/pre-commit-hooks +- https://github.com/FelixSeptem/pre-commit-golang From 6454d6d8626c73ba2faf445cad4528e3d3d5a353 Mon Sep 17 00:00:00 2001 From: daVerona Date: Tue, 30 Jul 2019 00:08:55 +0900 Subject: [PATCH 252/854] Added pre-commit-cpp to all-repos.yaml --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 3df94f4a..4beb3308 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -97,3 +97,4 @@ - https://github.com/myint/docformatter - https://github.com/lorenzwalthert/pre-commit-hooks - https://github.com/FelixSeptem/pre-commit-golang +- https://gitlab.com/daverona-env/pre-commit-cpp From c34b0e5bcbf0fe9a8bcea00e0d83f9fe05b9766b Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 3 Aug 2019 15:45:46 -0700 Subject: [PATCH 253/854] Add documentation for new things in 1.18 --- index.mako | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/index.mako b/index.mako index 63cf00ce..561f289c 100644 --- a/index.mako +++ b/index.mako @@ -695,7 +695,8 @@ ${md(''' All pre-commit commands take the following options: - `--color {auto,always,never}`: whether to use color in output. - Defaults to `auto`. + Defaults to `auto`. _new in 1.18.0_: can be overridden by using + `PRE_COMMIT_COLOR={auto,always,never}` or disabled using `TERM=dumb`. - `-c CONFIG`, `--config CONFIG`: path to alternate config file - `-h`, `--help`: show help and available options. @@ -710,6 +711,12 @@ Options: - `--repo REPO`: _new in 1.4.1_: Only update this repository. _new in 1.7.0_: This option may be specified multiple times. +## pre-commit clean [options] [](#pre-commit-clean) + +Clean out cached pre-commit files. + +Options: (no additional options) + ## pre-commit gc [options] [](#pre-commit-gc) _new in 1.14.0_ @@ -722,11 +729,28 @@ the cache directory. Options: (no additional options) -## pre-commit clean [options] [](#pre-commit-clean) +## pre-commit init-templatedir DIRECTORY [options] [](#pre-commit-init-templatedir) -Clean out cached pre-commit files. +_new in 1.18.0_ -Options: (no additional options) +Install hook script in a directory intended for use with +`git config init.templateDir`. + +Options: + +- `-t {pre-commit,pre-push,prepare-commit-msg,commit-msg}`, + `--hook-type {pre-commit,pre-push,prepare-commit-msg,commit-msg}`: + which hook type to install. + +Some example useful invocations: + +```bash +git config --global init.templateDir ~/.git-template +pre-commit init-templatedir ~/.git-template +``` + +Now whenever a repository is cloned or created, it will have the hooks set up +already! ## pre-commit install [options] [](#pre-commit-install) @@ -1057,6 +1081,48 @@ The currently available `meta` hooks: _new in 1.14.0_. ``` +## automatically enabling pre-commit on repositories + +_new in 1.18.0_ + +`pre-commit init-templatedir` can be used to set up a skeleton for `git`'s +`init.templateDir` option. This means that any newly cloned repository will +automatically have the hooks set up without the need to run +`pre-commit install`. + +To configure, first set `git`'s `init.templateDir` -- in this example I'm +using `~/.git-template` as my template directory. + +```console +$ git config --global init.templateDir ~/.git-template +$ pre-commit init-templatedir ~/.git-template +pre-commit installed at /home/asottile/.git-template/hooks/pre-commit +``` + +Now whenever you clone a pre-commit enabled repo, the hooks will already be +set up! + +```pre-commit +$ git clone -q git@github.com:asottile/pyupgrade +$ cd pyupgrade +$ git commit --allow-empty -m 'Hello world!' +Check docstring is first.............................(no files to check)Skipped +Check Yaml...........................................(no files to check)Skipped +Debug Statements (Python)............................(no files to check)Skipped +... +``` + +`init-templatedir` uses the `--allow-missing-config` option from +`pre-commit install` so repos without a config will be skipped: + +```console +$ git init sample +Initialized empty Git repository in /tmp/sample/.git/ +$ cd sample +$ git commit --allow-empty -m 'Initial commit' +`.pre-commit-config.yaml` config file not found. Skipping `pre-commit`. +[master (root-commit) d1b39c1] Initial commit +``` ## Filtering files with types From 338ce2f1af9061a9312881d4307109f942098f20 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 9 Aug 2019 08:25:51 -0700 Subject: [PATCH 254/854] Add relint --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 4beb3308..2db8b1ab 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -98,3 +98,4 @@ - https://github.com/lorenzwalthert/pre-commit-hooks - https://github.com/FelixSeptem/pre-commit-golang - https://gitlab.com/daverona-env/pre-commit-cpp +- https://github.com/codingjoe/relint From 0f01a937f167a1100f69b8f0b151fa72a1766c34 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 12 Aug 2019 14:46:14 +0000 Subject: [PATCH 255/854] Update all-repos.yaml add nixpkgs-fmt --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 2db8b1ab..ef2339e1 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -99,3 +99,4 @@ - https://github.com/FelixSeptem/pre-commit-golang - https://gitlab.com/daverona-env/pre-commit-cpp - https://github.com/codingjoe/relint +- https://github.com/nix-community/nixpkgs-fmt From 2f451cbae1c5f3910cab7a194ea329c30103b545 Mon Sep 17 00:00:00 2001 From: Ryan Delaney Date: Mon, 12 Aug 2019 16:40:49 -0700 Subject: [PATCH 256/854] Expand cli documentation Fixes #239 and #225 --- index.mako | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/index.mako b/index.mako index 561f289c..220bd926 100644 --- a/index.mako +++ b/index.mako @@ -758,25 +758,38 @@ Install the pre-commit script. Options: -- `-f`, `--overwrite`: overwrite existing hooks / remove migration mode. -- `--install-hooks`: also install hook environments for all available hooks. +- `-f`, `--overwrite`: Replace any existing git hooks with the pre-commit + script. +- `--install-hooks`: Also install environments for all available hooks now + (rather than when they are first executed). See [`pre-commit + install-hooks`](#pre-commit-install-hooks). - `-t {pre-commit,pre-push,prepare-commit-msg,commit-msg}`, `--hook-type {pre-commit,pre-push,prepare-commit-msg,commit-msg}`: - which hook type to install. -- `--allow-missing-config`: whether to allow the installed hook scripts to - permit a missing configuration file. + Specify which hook type to install. +- `--allow-missing-config`: Hook scripts will permit a missing configuration + file. Some example useful invocations: -- `pre-commit install`: default install invocation will run existing hook - scripts alongside pre-commit. -- `pre-commit install -f --install-hooks`: idempotently replace git hook - scripts with pre-commit and also install hooks. +- `pre-commit install`: Default invocation. Installs the pre-commit script + alongside any existing git hooks. +- `pre-commit install --install-hooks --overwrite`: Idempotently replaces + existing git hook scripts with pre-commit, and also installs hook + environments. ## pre-commit install-hooks [options] [](#pre-commit-install-hooks) -Install hook environments for all environments in the config file. You may -find `pre-commit install --install-hooks` more useful. +Install all missing environments for the available hooks. Unless this command or +`install --install-hooks` is executed, each hook's environment is created the +first time the hook is called. + +Each hook is initialized in a separate environment appropriate to the language +the hook is written in. For example: python +[virtualenv](https://virtualenv.pypa.io/en/stable/), ruby +[rbenv](https://github.com/rbenv/rbenv), etc. + +This command does not install the pre-commit script. To install the script along with +the hook environments in one command, use `pre-commit install --install hooks`. Options: (no additional options) From 1adb975024ef1b4f1516913b32f0a2d49d46c44e Mon Sep 17 00:00:00 2001 From: Ryan Delaney Date: Mon, 12 Aug 2019 17:01:56 -0700 Subject: [PATCH 257/854] Replace link back to own docs --- index.mako | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.mako b/index.mako index 220bd926..8d1b32e5 100644 --- a/index.mako +++ b/index.mako @@ -784,9 +784,7 @@ Install all missing environments for the available hooks. Unless this command or first time the hook is called. Each hook is initialized in a separate environment appropriate to the language -the hook is written in. For example: python -[virtualenv](https://virtualenv.pypa.io/en/stable/), ruby -[rbenv](https://github.com/rbenv/rbenv), etc. +the hook is written in. See [supported languages](#Supported-languages). This command does not install the pre-commit script. To install the script along with the hook environments in one command, use `pre-commit install --install hooks`. From 6f8f8738197f888611f1acacfc388b51af897fd6 Mon Sep 17 00:00:00 2001 From: Ryan Delaney Date: Mon, 12 Aug 2019 20:50:12 -0700 Subject: [PATCH 258/854] Use lower case in supported-language anchor --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 8d1b32e5..81ab54a4 100644 --- a/index.mako +++ b/index.mako @@ -784,7 +784,7 @@ Install all missing environments for the available hooks. Unless this command or first time the hook is called. Each hook is initialized in a separate environment appropriate to the language -the hook is written in. See [supported languages](#Supported-languages). +the hook is written in. See [supported languages](#supported-languages). This command does not install the pre-commit script. To install the script along with the hook environments in one command, use `pre-commit install --install hooks`. From f263cdbcf46f97e1bd6229f2ab6d27bf8290ca88 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 13 Aug 2019 15:22:11 -0700 Subject: [PATCH 259/854] Add svg logo --- Makefile | 2 +- logo.svg | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 logo.svg diff --git a/Makefile b/Makefile index 945ebee1..97969d1e 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ push: venv --master-branch real_master \ --pages-branch master \ .nojekyll .travis.yml README.md CNAME \ - build node_modules *.html *.png favicon.ico \ + build node_modules *.html *.png *.svg favicon.ico \ all-hooks.json install-local.py clean: diff --git a/logo.svg b/logo.svg new file mode 100644 index 00000000..acd985b2 --- /dev/null +++ b/logo.svg @@ -0,0 +1 @@ + From be7ba71adf795ff7beaf62138cd5a8e553a59ad2 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 13 Aug 2019 16:13:28 -0700 Subject: [PATCH 260/854] Add a quick start to the top --- index.mako | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/index.mako b/index.mako index 81ab54a4..8bbfbb93 100644 --- a/index.mako +++ b/index.mako @@ -89,6 +89,84 @@ Using [conda](https://conda.io) (via [conda-forge](https://conda-forge.org)): conda install -c conda-forge pre_commit ``` +## Quick start + +### 1. Install pre-commit + +- follow the [install](#install) instructions above +- `pre-commit --version` should show you what version you're using + +```console +$ pre-commit --version +pre-commit 1.18.1 +``` + +### 2. Add a pre-commit configuration + +- create a file named `.pre-commit-config.yaml` +- you can generate a very basic configuration using + [`pre-commit sample-config`](#pre-commit-sample-config) +- the full set of options for the configuration are listed [below](#plugins) +- this example uses a formatter for python code, however `pre-commit` works for + any programming language +- other [supported hooks](hooks.html) are available + +```yaml +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/psf/black + rev: 19.3b0 + hooks: + - id: black +``` + +### 3. Install the git hook scripts + +- run `pre-commit install` to set up the git hook scripts + +```console +$ pre-commit install +pre-commit installed at .git/hooks/pre-commit +``` + +- now `pre-commit` will run automatically on `git commit`! + +### 4. (optional) Run against all the files + +- it's usually a good idea to run the hooks against all of the files when adding + new hooks (usually `pre-commit` will only run on the changed files during + git hooks) + +```pre-commit +$ pre-commit run --all-files +[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks. +[INFO] Initializing environment for https://github.com/psf/black. +[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks. +[INFO] Once installed this environment will be reused. +[INFO] This may take a few minutes... +[INFO] Installing environment for https://github.com/psf/black. +[INFO] Once installed this environment will be reused. +[INFO] This may take a few minutes... +Check Yaml...............................................................Passed +Fix End of Files.........................................................Passed +Trim Trailing Whitespace.................................................Failed +hookid: trailing-whitespace + +Files were modified by this hook. Additional output: + +Fixing sample.py + +black....................................................................Passed +``` + +- oops! looks like I had some trailing whitespace +- consider running that in [CI](#usage-in-continuous-integration) too + ''')} From 9ddba4ebd03e647db025d5d036ecba78fdfcfca1 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 15 Aug 2019 14:11:48 -0300 Subject: [PATCH 261/854] Update conda install command The package has been renamed on conda-forge: https://github.com/conda-forge/pre_commit-feedstock/issues/35 https://github.com/conda-forge/pre-commit-feedstock --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 8bbfbb93..e441550d 100644 --- a/index.mako +++ b/index.mako @@ -86,7 +86,7 @@ brew install pre-commit Using [conda](https://conda.io) (via [conda-forge](https://conda-forge.org)): ```bash -conda install -c conda-forge pre_commit +conda install -c conda-forge pre-commit ``` ## Quick start From b0afe9458da8d2026fbc3c2520d0703e31d4a5a1 Mon Sep 17 00:00:00 2001 From: Danielle Date: Thu, 29 Aug 2019 21:28:01 -0700 Subject: [PATCH 262/854] Add beancount-check to validate beancount files. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index ef2339e1..8bcd7df5 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -100,3 +100,4 @@ - https://gitlab.com/daverona-env/pre-commit-cpp - https://github.com/codingjoe/relint - https://github.com/nix-community/nixpkgs-fmt +- https://github.com/d6e/beancount-check From ed1a88c0fed028003eb2f03d497746bfdf622b73 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 2 Sep 2019 17:13:56 -0700 Subject: [PATCH 263/854] Update for latest pygments-pre-commit --- scss/main.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scss/main.scss b/scss/main.scss index a44d65a6..1945fa56 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -194,8 +194,8 @@ h1, // scss-lint:disable SelectorFormat .-Color-BGRed { background-color: #c00; } .-Color-BGGreen { background-color: #4e9a06; } - .-Color-BlackBGYellow { background-color: #c4a000; color: #2e3436; } - .-Color-BlackBGCyan { background-color: #06989a; color: #2e3436; } + .-Color-Black-BGYellow { background-color: #c4a000; color: #2e3436; } + .-Color-Black-BGCyan { background-color: #06989a; color: #2e3436; } } @media (max-width: $screen-md-max) { From d7bec221679e79857f8467ed11d5c9d8de258e49 Mon Sep 17 00:00:00 2001 From: Iconmaster Date: Fri, 27 Sep 2019 09:53:53 -0400 Subject: [PATCH 264/854] Update all-repos.yaml --- all-repos.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/all-repos.yaml b/all-repos.yaml index 8bcd7df5..7e932918 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -101,3 +101,5 @@ - https://github.com/codingjoe/relint - https://github.com/nix-community/nixpkgs-fmt - https://github.com/d6e/beancount-check +- https://github.com/iconmaster5326/cmake-format-pre-commit-hook + From c960fccdd9f6cba196472c618ae8b0fa686d05d8 Mon Sep 17 00:00:00 2001 From: Iconmaster Date: Fri, 27 Sep 2019 10:00:16 -0400 Subject: [PATCH 265/854] Fix extra line at end --- all-repos.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 7e932918..fc221f51 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -102,4 +102,3 @@ - https://github.com/nix-community/nixpkgs-fmt - https://github.com/d6e/beancount-check - https://github.com/iconmaster5326/cmake-format-pre-commit-hook - From f2414975d0de7514249b6e891c3298b410091276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Ta=C5=9Fkaya?= <47358913+isidentical@users.noreply.github.com> Date: Sun, 6 Oct 2019 11:46:51 +0300 Subject: [PATCH 266/854] Add inspectortiger --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index fc221f51..8524138e 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -102,3 +102,4 @@ - https://github.com/nix-community/nixpkgs-fmt - https://github.com/d6e/beancount-check - https://github.com/iconmaster5326/cmake-format-pre-commit-hook +- https://github.com/thg-consulting/inspectortiger From 4638359ab9c4d44d354eed6221a5ecc1d5e5fb36 Mon Sep 17 00:00:00 2001 From: Piotr Janiszewski Date: Mon, 7 Oct 2019 21:57:43 +0200 Subject: [PATCH 267/854] Add nbhooks to all-repos.yaml --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 8524138e..cf98461d 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -103,3 +103,4 @@ - https://github.com/d6e/beancount-check - https://github.com/iconmaster5326/cmake-format-pre-commit-hook - https://github.com/thg-consulting/inspectortiger +- https://gitlab.com/iamlikeme/nbhooks From d374e2288c10e7269a0cd15dcff39678bb478690 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 24 Oct 2019 14:32:58 -0700 Subject: [PATCH 268/854] Add vint for vim script linting --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index cf98461d..0bf7d841 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -104,3 +104,4 @@ - https://github.com/iconmaster5326/cmake-format-pre-commit-hook - https://github.com/thg-consulting/inspectortiger - https://gitlab.com/iamlikeme/nbhooks +- https://github.com/Kuniwak/vint From df23da8b6b36cc31ec582426fac8391f577ad43b Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Fri, 1 Nov 2019 19:35:25 -0400 Subject: [PATCH 269/854] Adding nbstripout to available hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 0bf7d841..634eef8d 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -105,3 +105,4 @@ - https://github.com/thg-consulting/inspectortiger - https://gitlab.com/iamlikeme/nbhooks - https://github.com/Kuniwak/vint +- https://github.com/kynan/nbstripout From 1000d9f5cbcba146d3e08af13de8c4cff0ec3b4d Mon Sep 17 00:00:00 2001 From: Iconmaster Date: Mon, 4 Nov 2019 12:58:16 -0500 Subject: [PATCH 270/854] Update all-repos.yaml --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 0bf7d841..a8818244 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -105,3 +105,4 @@ - https://github.com/thg-consulting/inspectortiger - https://gitlab.com/iamlikeme/nbhooks - https://github.com/Kuniwak/vint +- https://github.com/eschulte/lisp-format From 434d4cc1ebe8134eca51f09ebd1e7035018f8783 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 5 Nov 2019 14:46:25 -0800 Subject: [PATCH 271/854] Add shellcheck-py --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index a8818244..e1338897 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -106,3 +106,4 @@ - https://gitlab.com/iamlikeme/nbhooks - https://github.com/Kuniwak/vint - https://github.com/eschulte/lisp-format +- https://github.com/ryanrhee/shellcheck-py From a6da2dd1ebc3081b04bebdcb17e3d0b2b8fa7ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 8 Nov 2019 17:26:45 +0200 Subject: [PATCH 272/854] Add swagger-cli --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index e1338897..e8656c0d 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -107,3 +107,4 @@ - https://github.com/Kuniwak/vint - https://github.com/eschulte/lisp-format - https://github.com/ryanrhee/shellcheck-py +- https://github.com/APIDevTools/swagger-cli From fd668a818dc1524b5b5668d454cf594968542c0f Mon Sep 17 00:00:00 2001 From: Aleksey Burov Date: Sun, 17 Nov 2019 15:38:52 +0700 Subject: [PATCH 273/854] Add gitlab-ci-linter --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index b8396027..7cfbd77d 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -109,3 +109,4 @@ - https://github.com/ryanrhee/shellcheck-py - https://github.com/APIDevTools/swagger-cli - https://github.com/kynan/nbstripout +- https://gitlab.com/devopshq/gitlab-ci-linter From 0faca054789980cf1b9b644e5fe58755306b1761 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 25 Nov 2019 09:34:26 -0800 Subject: [PATCH 274/854] Document PRE_COMMIT_HOME + CI setups --- index.mako | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/index.mako b/index.mako index e441550d..b87acafb 100644 --- a/index.mako +++ b/index.mako @@ -1350,6 +1350,78 @@ everything stays in tip-top shape. To check only files which have changed, which may be faster, use something like `git diff-tree --no-commit-id --name-only -r $REVISION | xargs pre-commit run --files`. +## Managing CI Caches + +`pre-commit` by default places its repository store in `~/.cache/pre-commit` +-- this can be configured in two ways: + +- `PRE_COMMIT_HOME`: if set, pre-commit will use that location instead. +- `XDG_CACHE_HOME`: if set, pre-commit will use `$XDG_CACHE_HOME/pre-commit` + following the [XDG Base Directory Specification]. + +[XDG Base Directory Specification]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html + +### travis-ci example + +```yaml +cache: + directories: + - $HOME/.cache/pre-commit +``` + +### appveyor example + +```yaml +cache: +- '%USERPROFILE%\.cache\pre-commit' +``` + +### azure pipelines example + +note: azure pipelines uses immutable caches so the python version and +`.pre-commit-config.yaml` hash must be included in the cache key. for a +repository template, see [asottile@job--pre-commit.yml]. + +[job--pre-commit.yml]: https://github.com/asottile/azure-pipeline-templates/blob/master/job--pre-commit.yml + +```yaml +jobs: +- job: precommit + + # ... + + variables: + PRE_COMMIT_HOME: $(Pipeline.Workspace)/pre-commit-cache + + steps: + + # ... + + - script: echo "##vso[task.setvariable variable=PY]$(python -VV)" + - task: CacheBeta@0 + inputs: + key: pre-commit | .pre-commit-config.yaml | "$(PY)" + path: $(PRE_COMMIT_HOME) +``` + +### github actions example + +**see the [official pre-commit github action]** + +[official pre-commit github action]: https://github.com/pre-commit/action + +like [azure pipelines](#azure-pipelines-example), github actions also uses +immutable caches: + +```yaml + - name: set PY + run: echo "::set-env name=PY::$(python -VV | sha256sum | cut -d' ' -f1)" + - uses: actions/cache@v1 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} +``` + ## Usage with tox [tox](https://tox.readthedocs.io/) is useful for configuring test / CI tools From 18df5e43bf1988d8e3e2054f9dcd998358f59c29 Mon Sep 17 00:00:00 2001 From: dkolepp Date: Wed, 4 Dec 2019 22:42:46 +0000 Subject: [PATCH 275/854] feat: update h1 tags to match lower heading tags --- index.mako | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/index.mako b/index.mako index b87acafb..32cb6276 100644 --- a/index.mako +++ b/index.mako @@ -18,7 +18,7 @@ from template_lib import md

      - + ${md(''' Git hook scripts are useful for identifying simple issues before submission to code review. We run our hooks on every commit to automatically point out @@ -49,7 +49,7 @@ and building node to run eslint without root. ''')}
      - + ${md(''' Before you can run hooks, you need to have the pre-commit package manager installed. @@ -171,9 +171,7 @@ black....................................................................Passed
      - + ${md(''' Once you have pre-commit installed, adding pre-commit plugins to your project is done with the `.pre-commit-config.yaml` configuration file. @@ -355,7 +353,7 @@ master branch.
      - + ${md(''' Run `pre-commit install` to install pre-commit into your git hooks. pre-commit will now run on every commit. Every time you clone a project using pre-commit @@ -393,7 +391,7 @@ changelog filenames..................................(no files to check)Skipped
      - + ${md(''' pre-commit currently supports hooks written in [many languages](#supported-languages). As long as your git repo is an @@ -767,7 +765,7 @@ __Support:__ the support of system hooks depend on the executables.
      - + ${md(''' All pre-commit commands take the following options: @@ -952,7 +950,7 @@ Options:
      - + ${md(''' ## Running in migration mode @@ -1488,7 +1486,7 @@ automatically).
      - + ${md(''' We’re looking to grow the project and get more contributors especially to From 270246d79031872fc0b0bd9e0f3fca7fd4122537 Mon Sep 17 00:00:00 2001 From: bmorcos Date: Thu, 5 Dec 2019 15:11:31 -0500 Subject: [PATCH 276/854] Add pre-commit-hooks-cpp There are other hooks for this, but they didn't have args setup so I made my own. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 7cfbd77d..4d07cc7a 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -110,3 +110,4 @@ - https://github.com/APIDevTools/swagger-cli - https://github.com/kynan/nbstripout - https://gitlab.com/devopshq/gitlab-ci-linter +- https://github.com/bmorcos/pre-commit-hooks-cpp From a1a6eeb027ad77e6f848b163e216a0e442f5f37e Mon Sep 17 00:00:00 2001 From: Bahjat Date: Fri, 6 Dec 2019 16:39:53 +0100 Subject: [PATCH 277/854] adds https://github.com/Bahjat/pre-commit-golang --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 4d07cc7a..d93fdde5 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -40,6 +40,7 @@ - https://github.com/Lucas-C/pre-commit-hooks-safety - https://github.com/chriskuehl/puppet-pre-commit-hooks - https://github.com/golangci/golangci-lint +- https://github.com/Bahjat/pre-commit-golang - https://github.com/dnephin/pre-commit-golang - https://github.com/troian/pre-commit-golang - https://github.com/jstewmon/check-swagger From f5eaa27c4bcad3cf014299ffc737bea4838c0b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 13 Dec 2019 09:06:18 +0200 Subject: [PATCH 278/854] Add markdownlint-cli --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index d93fdde5..33026f69 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -112,3 +112,4 @@ - https://github.com/kynan/nbstripout - https://gitlab.com/devopshq/gitlab-ci-linter - https://github.com/bmorcos/pre-commit-hooks-cpp +- https://github.com/igorshubovych/markdownlint-cli From ae77a1b53beff1f7282b42528716878a6fec51cc Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 19 Dec 2019 10:48:58 -0800 Subject: [PATCH 279/854] Add note about overriding `types` --- index.mako | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.mako b/index.mako index 32cb6276..95e4db27 100644 --- a/index.mako +++ b/index.mako @@ -1264,6 +1264,17 @@ For example: will match a file `foo/1.py` but will not match `setup.py`. +If you want to match a file path that isn't included in a `type` when using an +existing hook you'll need to revert back to `files` only matching by overriding +the `types` setting. Here's an example of using `check-json` against non-json +files: + +```yaml + - id: check-json + types: [file] # override `types: [json]` + files: \.(json|myext)$ +``` + Files can also be matched by shebang. With `types: python`, an `exe` starting with `#!/usr/bin/env python3` will also be matched. From dcec1612735dff8c71993776f203b30ee710b947 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 19 Dec 2019 17:48:25 -0800 Subject: [PATCH 280/854] Clarify python requirements (pyproject.toml works) --- index.mako | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.mako b/index.mako index 95e4db27..ab6a03c3 100644 --- a/index.mako +++ b/index.mako @@ -644,9 +644,10 @@ only due to [a bug in cpython](https://bugs.python.org/issue32539). ### python -The hook repository must have a `setup.py`. It will be installed via -`pip install .`. The installed package will provide an executable that will -match the `entry` – usually through `console_scripts` or `scripts` in setup.py. +The hook repository must be installable via `pip install .` (usually by either +`setup.py` or `pyproject.toml`). The installed package will provide an +executable that will match the `entry` – usually through `console_scripts` or +`scripts` in setup.py. __Support:__ python hooks work without any system-level dependencies. It has been tested on linux, macOS, windows, and cygwin. From 573b208cab080734631c2fdb68876580c5d343a4 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 20 Dec 2019 22:45:01 -0800 Subject: [PATCH 281/854] This can just be pylint no need to support python2.6 any more! --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index ab6a03c3..d03999b3 100644 --- a/index.mako +++ b/index.mako @@ -1119,7 +1119,7 @@ Here's an example configuration with a few `local` hooks: hooks: - id: pylint name: pylint - entry: python -m pylint.__main__ + entry: pylint language: system types: [python] - id: check-x From 2fbf128e4310f9f1594c71cafc539ea961f58ee2 Mon Sep 17 00:00:00 2001 From: Ryan Delaney Date: Tue, 31 Dec 2019 12:47:13 -0800 Subject: [PATCH 282/854] Autoupdate pre-commit hooks --- .pre-commit-config.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5374a310..7e5d7b7c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,31 +1,31 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.1.0 + rev: v2.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: debug-statements - repo: https://gitlab.com/pycqa/flake8 - rev: 3.7.1 + rev: 3.7.9 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v1.4.3 + rev: v1.4.4 hooks: - id: autopep8 - repo: https://github.com/asottile/reorder_python_imports - rev: v1.3.5 + rev: v1.8.0 hooks: - id: reorder-python-imports - repo: https://github.com/asottile/pyupgrade - rev: v1.11.1 + rev: v1.25.2 hooks: - id: pyupgrade args: [--py36-plus] exclude: ^install-local.py$ - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.660 + rev: v0.761 hooks: - id: mypy exclude: ^install-local.py$ From dc6a868a326c2353ccaefd356d663556dae919e9 Mon Sep 17 00:00:00 2001 From: Ryan Delaney Date: Tue, 31 Dec 2019 12:50:56 -0800 Subject: [PATCH 283/854] Reword pass_filenames docs The existing docs are not (perfectly) clear about whether `false` will ensure that filenames are _not_ passed in. --- index.mako | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.mako b/index.mako index d03999b3..315e0ac3 100644 --- a/index.mako +++ b/index.mako @@ -445,8 +445,8 @@ file that tells pre-commit: the hook passes. _new in 1.6.0_. =r= =c= `pass_filenames` - =c= (optional: default `true`) if `true` this hook must take filenames as - positional arguments. _new in 0.14.0_. + =c= (optional: default `true`) if `false` no arguments will be passed to + the hook. _new in 0.14.0_. =r= =c= `require_serial` =c= (optional: default `false`) if `true` this hook will execute using a From 56d50cf2c4e01373463f175c201177394a87af98 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 2 Jan 2020 12:11:45 -0800 Subject: [PATCH 284/854] render the pre-commit version directly in output --- index.mako | 5 ++--- scss/main.scss | 1 + template_lib.py | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/index.mako b/index.mako index 315e0ac3..7fde1ff0 100644 --- a/index.mako +++ b/index.mako @@ -96,9 +96,8 @@ conda install -c conda-forge pre-commit - follow the [install](#install) instructions above - `pre-commit --version` should show you what version you're using -```console -$ pre-commit --version -pre-commit 1.18.1 +```cmd +pre-commit --version ``` ### 2. Add a pre-commit configuration diff --git a/scss/main.scss b/scss/main.scss index 1945fa56..2b190140 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -196,6 +196,7 @@ h1, .-Color-BGGreen { background-color: #4e9a06; } .-Color-Black-BGYellow { background-color: #c4a000; color: #2e3436; } .-Color-Black-BGCyan { background-color: #06989a; color: #2e3436; } + .-Color-Faint { color: #ccc; } } @media (max-width: $screen-md-max) { diff --git a/template_lib.py b/template_lib.py index c5cf0e72..dec8830f 100644 --- a/template_lib.py +++ b/template_lib.py @@ -1,4 +1,8 @@ +import os import re +import shlex +import subprocess +import sys import markdown_code_blocks import markupsafe @@ -74,6 +78,14 @@ def _maybe_end_row() -> None: return ''.join(output) +def _render_cmd(code: str) -> str: + cmdstr = code.strip() + path = f'{os.path.dirname(sys.executable)}{os.pathsep}{os.environ["PATH"]}' + env = {**os.environ, 'PATH': path} + output = subprocess.check_output(shlex.split(cmdstr), env=env).decode() + return str(md(f'```pre-commit\n$ {cmdstr}\n{output}```')) + + class Renderer(markdown_code_blocks.CodeRenderer): def header(self, text: str, level: int, raw: str) -> str: match = ID_RE.search(raw) @@ -90,6 +102,8 @@ def header(self, text: str, level: int, raw: str) -> str: def block_code(self, code: str, lang: str) -> str: if lang == 'table': return _render_table(code) + elif lang == 'cmd': + return _render_cmd(code) else: return super().block_code(code, lang) From a1966393fe831817e4bfa23b0726cb8720a0faae Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 2 Jan 2020 13:55:42 -0800 Subject: [PATCH 285/854] Documentation updates for 1.21.0 --- index.mako | 155 ++++++++++++++++++++++++++++++++++++------- requirements-dev.txt | 4 +- 2 files changed, 133 insertions(+), 26 deletions(-) diff --git a/index.mako b/index.mako index 7fde1ff0..87752696 100644 --- a/index.mako +++ b/index.mako @@ -154,7 +154,8 @@ $ pre-commit run --all-files Check Yaml...............................................................Passed Fix End of Files.........................................................Passed Trim Trailing Whitespace.................................................Failed -hookid: trailing-whitespace +- hook id: trailing-whitespace +- exit code: 1 Files were modified by this hook. Additional output: @@ -218,6 +219,9 @@ migrate your configuration. ``` _new in 1.14.0_ +=r= + =c= `files` + =c= (optional: default `''`) global file include pattern. _new in 1.21.0_. =r= =c= `exclude` =c= (optional: default `^$`) global file exclude pattern. _new in 1.1.0_. @@ -308,8 +312,8 @@ repository's configuration. =c= (optional) list of additional parameters to pass to the hook. =r= =c= `stages` - =c= (optional) confines the hook to the `commit`, `push`, `prepare-commit-msg`, - `commit-msg`, or `manual` stage. See + =c= (optional) confines the hook to the `commit`, `merge-commit`, `push`, + `prepare-commit-msg`, `commit-msg`, or `manual` stage. See [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). =r= =c= `additional_dependencies` @@ -346,8 +350,8 @@ trailing-whitespace hook. ## Updating hooks automatically You can update your hooks to the latest version automatically by running -`pre-commit autoupdate`. This will bring the hooks to the latest tag on the -master branch. +[`pre-commit autoupdate`](#pre-commit-autoupdate). By default, this will +bring the hooks to the latest tag on the master branch. ''')}
      @@ -516,8 +520,9 @@ repos: - id: foo =============================================================================== [INFO] Initializing environment for ../hook-repo. -[foo] Foo................................................................Passed -hookid: foo +Foo......................................................................Passed +- hook id: foo +- duration: 0.02s Hello from foo hook! @@ -525,6 +530,7 @@ Hello from foo hook! ## Supported languages +- [conda](#conda) - [docker](#docker) - [docker_image](#docker_image) - [fail](#fail) @@ -540,6 +546,21 @@ Hello from foo hook! - [script](#script) - [system](#system) +### conda + +_new in 1.21.0_ + +The hook repository must contain an `environment.yml` file which will be used +via `conda env create --file environment.yml ...` to create the environment. + +The `conda` language also supports `additional_dependencies` and will pass any +of the values directly into `conda install`. This language can therefore be +used with [local](#repository-local-hooks) hooks. + +__Support:__ `conda` hooks work as long as there is a system-installed `conda` +binary (such as [`miniconda`](https://docs.conda.io/en/latest/miniconda.html)). +It has been tested on linux, macOS, and windows. + ### docker _new in 0.10.0_ @@ -651,7 +672,6 @@ executable that will match the `entry` – usually through `console_scripts` or __Support:__ python hooks work without any system-level dependencies. It has been tested on linux, macOS, windows, and cygwin. - ### python_venv _new in 1.9.0_ @@ -784,9 +804,55 @@ Options: - `--bleeding-edge`: update to the bleeding edge of `master` instead of the latest tagged version (the default behaviour). +- `--freeze`: _new in 1.21.0): Store "frozen" hashes in `rev` instead of tag + names. - `--repo REPO`: _new in 1.4.1_: Only update this repository. _new in 1.7.0_: This option may be specified multiple times. +Here are some sample invocations using this `.pre-commit-config.yaml`: + +```yaml +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.1.0 + hooks: + - id: trailing-whitespace +- repo: https://github.com/asottile/pyupgrade + rev: v1.25.0 + hooks: + - id: pyupgrade + args: [--py36-plus] +``` + +```console +$ : default: update to latest tag on default branch +$ pre-commit autoupdate # by default: pick tags +Updating https://github.com/pre-commit/pre-commit-hooks ... updating v2.1.0 -> v2.4.0. +Updating https://github.com/asottile/pyupgrade ... updating v1.25.0 -> v1.25.2. +$ grep rev: .pre-commit-config.yaml + rev: v2.4.0 + rev: v1.25.2 +``` + +```console +$ : update a specific repository to the latest revision of the default branch +$ pre-commit autoupdate --bleeding-edge --repo https://github.com/pre-commit/pre-commit-hooks +Updating https://github.com/pre-commit/pre-commit-hooks ... updating v2.1.0 -> 5df1a4bf6f04a1ed3a643167b38d502575e29aef. +$ grep rev: .pre-commit-config.yaml + rev: 5df1a4bf6f04a1ed3a643167b38d502575e29aef + rev: v1.25.0 +``` + +```console +$ : update to frozen versions +$ pre-commit autoupdate --freeze +Updating https://github.com/pre-commit/pre-commit-hooks ... updating v2.1.0 -> v2.4.0 (frozen). +Updating https://github.com/asottile/pyupgrade ... updating v1.25.0 -> v1.25.2 (frozen). +$ grep rev: .pre-commit-config.yaml + rev: 0161422b4e09b47536ea13f49e786eb3616fe0d7 # frozen: v2.4.0 + rev: 34a269fd7650d264e4de7603157c10d0a9bb8211 # frozen: v1.25.2 +``` + ## pre-commit clean [options] [](#pre-commit-clean) Clean out cached pre-commit files. @@ -814,8 +880,8 @@ Install hook script in a directory intended for use with Options: -- `-t {pre-commit,pre-push,prepare-commit-msg,commit-msg}`, - `--hook-type {pre-commit,pre-push,prepare-commit-msg,commit-msg}`: +- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`, + `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`: which hook type to install. Some example useful invocations: @@ -839,8 +905,8 @@ Options: - `--install-hooks`: Also install environments for all available hooks now (rather than when they are first executed). See [`pre-commit install-hooks`](#pre-commit-install-hooks). -- `-t {pre-commit,pre-push,prepare-commit-msg,commit-msg}`, - `--hook-type {pre-commit,pre-push,prepare-commit-msg,commit-msg}`: +- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`, + `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`: Specify which hook type to install. - `--allow-missing-config`: Hook scripts will permit a missing configuration file. @@ -943,8 +1009,8 @@ Uninstall the pre-commit script. Options: -- `-t {pre-commit,pre-push,prepare-commit-msg,commit-msg}`, - `--hook-type {pre-commit,pre-push,prepare-commit-msg,commit-msg}`: which hook +- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`, + `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`: which hook type to uninstall. ''')}
      @@ -957,8 +1023,8 @@ ${md(''' By default, if you have existing hooks `pre-commit install` will install in a migration mode which runs both your existing hooks and hooks for pre-commit. -To disable this behavior, simply pass `-f` / `--overwrite` to the `install` -command. If you decide not to use pre-commit, `pre-commit uninstall` will +To disable this behavior, pass `-f` / `--overwrite` to the `install` command. +If you decide not to use pre-commit, `pre-commit uninstall` will restore your hooks to the state prior to installation. ## Temporarily disabling hooks @@ -994,23 +1060,61 @@ manually edited during conflict resolution. This also includes files which were automatically merged by git. Git isn't perfect and this can often catch implicit conflicts (such as with removed python imports). +## pre-commit during clean merges + +_new in 1.21.0_ pre-commit can be used to manage [pre-merge-commit] hooks. + +To use `pre-merge-commit` hooks with pre-commit, run: + +```console +$ pre-commit install --hook-type pre-merge-commit +pre-commit installed at .git/hooks/pre-merge-commit +``` + +The hook fires after a merge succeeds but before the merge commit is created. + +Note that you need to be using at least git 2.24 which added support for the +pre-merge-commit hook. + +[pre-merge-commit]: https://git-scm.com/docs/githooks#_pre_merge_commit + ## pre-commit during push -_new in 0.3.5_: pre-commit can be used to manage `pre-push` hooks. Simply -`pre-commit install --hook-type pre-push`. +_new in 0.3.5_: pre-commit can be used to manage [pre-push] hooks. + +To use `pre-push` hooks with pre-commit, run: + +```console +$ pre-commit install --hook-type pre-push +pre-commit installed at .git/hooks/pre-push +``` + +[pre-push]: https://git-scm.com/docs/githooks#_pre_push ## pre-commit for commit messages -_new in 0.15.4_: pre-commit can be used to manage `commit-msg` hooks. Simply -`pre-commit install --hook-type commit-msg`. +_new in 0.15.4_: pre-commit can be used to manage [commit-msg] hooks. + +To use `commit-msg` hooks with pre-commit, run: + +```console +$ pre-commit install --hook-type commit-msg +pre-commit installed at .git/hooks/commit-msg +``` `commit-msg` hooks can be configured by setting `stages: [commit-msg]`. `commit-msg` hooks will be passed a single filename -- this file contains the current contents of the commit message which can be validated. If a hook exits nonzero, the commit will be aborted. -_new in 1.16.0_: pre-commit can be used to manage `prepare-commit-msg` hooks. -Simply `pre-commit install --hook-type prepare-commit-msg`. +_new in 1.16.0_: pre-commit can be used to manage [prepare-commit-msg] hooks. + +To use `prepare-commit-msg` hooks with pre-commit run: + +```console +$ pre-commit install --hook-type prepare-commit-msg` +pre-commit installed at .git/hooks/prepare-commit-msg +``` `prepare-commit-msg` hooks can be used to create dynamic templates for commit messages. `prepare-commit-msg` hooks can be configured by setting @@ -1021,6 +1125,9 @@ the editor is shown. A hook may want to check for `GIT_EDITOR=:` as this indicates that no editor will be launched. If a hook exits nonzero, the commit will be aborted. +[commit-msg]: https://git-scm.com/docs/githooks#_commit_msg +[prepare-commit-msg]: https://git-scm.com/docs/githooks#_prepare_commit_msg + ## Confining hooks to run at certain stages Since the `default_stages` top level configuration property of the @@ -1033,8 +1140,8 @@ to run at the `push` stage. Hooks can however be confined to a stage by setting the `stages` property in your `.pre-commit-config.yaml`. The `stages` property is an array and can -contain any of `commit`, `push`, `prepare-commit-msg`, `commit-msg` and -`manual`. +contain any of `commit`, `merge-commit`, `push`, `prepare-commit-msg`, +`commit-msg` and `manual`. If you do not want to have hooks installed by default on the stage passed during a `pre-commit install --hook-type ...`, please set the `default_stages` diff --git a/requirements-dev.txt b/requirements-dev.txt index cdcb61e9..d74d1341 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,5 +5,5 @@ markdown-code-blocks markdown-to-presentation>=0.0.12 # remove once merged and release git+https://github.com/lepture/mistune@449c2b5 -pre-commit>=0.13.6 -pygments-pre-commit +pre-commit>=1.21.0 +pygments-pre-commit>=1.4.0 From 30bc07717b47527b772d20c9828ffabd651ac942 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 2 Jan 2020 14:06:20 -0800 Subject: [PATCH 286/854] Fix a 'new in' comment --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 87752696..2437850e 100644 --- a/index.mako +++ b/index.mako @@ -804,7 +804,7 @@ Options: - `--bleeding-edge`: update to the bleeding edge of `master` instead of the latest tagged version (the default behaviour). -- `--freeze`: _new in 1.21.0): Store "frozen" hashes in `rev` instead of tag +- `--freeze`: _new in 1.21.0_): Store "frozen" hashes in `rev` instead of tag names. - `--repo REPO`: _new in 1.4.1_: Only update this repository. _new in 1.7.0_: This option may be specified multiple times. From a52332009cb8e62635bb07cc81edd3ff71f073b1 Mon Sep 17 00:00:00 2001 From: "TekWize.ly" Date: Sun, 5 Jan 2020 20:27:22 -0800 Subject: [PATCH 287/854] Adds TekWizely/pre-commit-golang to all-repos.yaml --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 33026f69..34e1a1ce 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -113,3 +113,4 @@ - https://gitlab.com/devopshq/gitlab-ci-linter - https://github.com/bmorcos/pre-commit-hooks-cpp - https://github.com/igorshubovych/markdownlint-cli +- https://github.com/TekWizely/pre-commit-golang From 42f2bf21454e6e533c2ba6d29fbb35911c83d185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 12 Jan 2020 13:42:13 +0200 Subject: [PATCH 288/854] Link to upstream pylint repo instead of the pre-commit mirror Refs https://github.com/PyCQA/pylint/pull/3007 --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 34e1a1ce..106277b4 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -9,7 +9,6 @@ - https://github.com/pre-commit/mirrors-jshint - https://github.com/pre-commit/mirrors-mypy - https://github.com/pre-commit/mirrors-puppet-lint -- https://github.com/pre-commit/mirrors-pylint - https://github.com/pre-commit/mirrors-ruby-lint - https://github.com/pre-commit/mirrors-scss-lint - https://github.com/pre-commit/mirrors-yapf @@ -78,6 +77,7 @@ - https://gitlab.com/PyCQA/flake8 - https://github.com/PyCQA/bandit - https://github.com/PyCQA/pydocstyle +- https://github.com/PyCQA/pylint - https://github.com/miki725/importanize - https://github.com/motet-a/jinjalint - https://github.com/milin/giticket From 3dd359525544876851829bf5ba3504e154091690 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 15 Jan 2020 13:04:09 -0800 Subject: [PATCH 289/854] Document the default docker args --- index.mako | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.mako b/index.mako index 2437850e..f25f9b18 100644 --- a/index.mako +++ b/index.mako @@ -575,6 +575,9 @@ entrypoint. Your Docker `CMD` will not run when pre-commit passes a file list as arguments to the run container command. Docker allows you to use any language that's not supported by pre-commit as a builtin. +pre-commit will automatically mount the repository source as a volume using +`-v $PWD:/src:rw,Z' and set the working directory using `--workdir /src`. + __Support:__ docker hooks are known to work on any system which has a working `docker` executable. It has been tested on linux and macOS. Hooks that are run via `boot2docker` are known to be unable to make modifications to files. From 81e4cc51c85496ced4605622bcdb1ab3cd057242 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 17 Jan 2020 09:39:29 -0800 Subject: [PATCH 290/854] Provide a simpler "run against the changed files" command --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index f25f9b18..91d95202 100644 --- a/index.mako +++ b/index.mako @@ -1467,7 +1467,7 @@ pre-commit can also be used as a tool for continuous integration. For instance, adding `pre-commit run --all-files` as a CI step will ensure everything stays in tip-top shape. To check only files which have changed, which may be faster, use something like -`git diff-tree --no-commit-id --name-only -r $REVISION | xargs pre-commit run --files`. +`pre-commit run --origin HEAD --source origin/HEAD`. ## Managing CI Caches From 0c782bd1147cd95fbe2915e4c37dcacf368c982f Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 27 Jan 2020 11:49:43 -0800 Subject: [PATCH 291/854] Add markdownlint/markdownlint --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 106277b4..7b52a3fe 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -114,3 +114,4 @@ - https://github.com/bmorcos/pre-commit-hooks-cpp - https://github.com/igorshubovych/markdownlint-cli - https://github.com/TekWizely/pre-commit-golang +- https://github.com/markdownlint/markdownlint From c949decc831185921c76d115a144f1ca2a5a9a17 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 28 Jan 2020 18:57:18 -0800 Subject: [PATCH 292/854] Update documentation for 2.0.0 --- index.mako | 90 +++++++++++++++++------------------------------------- 1 file changed, 28 insertions(+), 62 deletions(-) diff --git a/index.mako b/index.mako index 91d95202..b2cf279f 100644 --- a/index.mako +++ b/index.mako @@ -303,10 +303,9 @@ repository's configuration. =c= `types` =c= (optional) override the default file types to run on. See [Filtering files with types](#filtering-files-with-types). - _new in 0.15.0_. =r= =c= `exclude_types` - =c= (optional) file types to exclude. _new in 0.15.0_. + =c= (optional) file types to exclude. =r= =c= `args` =c= (optional) list of additional parameters to pass to the hook. @@ -319,11 +318,11 @@ repository's configuration. =c= `additional_dependencies` =c= (optional) a list of dependencies that will be installed in the environment where this hook gets run. One useful application is to - install plugins for hooks such as `eslint`. _new in 0.6.6_. + install plugins for hooks such as `eslint`. =r= =c= `always_run` =c= (optional) if `true`, this hook will run even if there are no matching - files. _new in 0.7.2_. + files. =r= =c= `verbose` =c= (optional) if `true`, forces the output of the hook to be printed even when @@ -331,7 +330,7 @@ repository's configuration. =r= =c= `log_file` =c= (optional) if present, the hook output will additionally be written - to a file. _new in 0.14.0_. + to a file. ``` One example of a complete configuration: @@ -402,8 +401,7 @@ installable package (gem, npm, pypi, etc.) or exposes an executable, it can be used with pre-commit. Each git repo can support as many languages/hooks as you want. -The hook must exit nonzero on failure or modify files in the working directory -_(since 0.6.3)_. +The hook must exit nonzero on failure or modify files in the working directory. A git repo containing pre-commit plugins must contain a .pre-commit-hooks.yaml file that tells pre-commit: @@ -425,7 +423,6 @@ file that tells pre-commit: =r= =c= `files` =c= (optional: default `''`) the pattern of files to run on. - _new in 0.15.0_: now optional. =r= =c= `exclude` =c= (optional: default `^$`) exclude files that were matched by `files`. @@ -433,15 +430,13 @@ file that tells pre-commit: =c= `types` =c= (optional: default `[file]`) list of file types to run on. See [Filtering files with types](#filtering-files-with-types). - _new in 0.15.0_. =r= =c= `exclude_types` =c= (optional: default `[]`) exclude files that were matched by `types`. - _new in 0.15.0_. =r= =c= `always_run` =c= (optional: default `false`) if `true` this hook will run even if there - are no matching files. _new in 0.7.2_. + are no matching files. =r= =c= `verbose` =c= (optional) if `true`, forces the output of the hook to be printed even when @@ -449,7 +444,7 @@ file that tells pre-commit: =r= =c= `pass_filenames` =c= (optional: default `true`) if `false` no arguments will be passed to - the hook. _new in 0.14.0_. + the hook. =r= =c= `require_serial` =c= (optional: default `false`) if `true` this hook will execute using a @@ -465,7 +460,7 @@ file that tells pre-commit: =r= =c= `minimum_pre_commit_version` =c= (optional: default `'0'`) allows one to indicate a minimum - compatible pre-commit version. _new in 0.6.7_. + compatible pre-commit version. =r= =c= `args` =c= (optional: default `[]`) list of additional parameters to pass to the hook. @@ -483,10 +478,6 @@ For example: types: [text] ``` -_new in 0.12.0_: Prior to 0.12.0 the file was `hooks.yaml` -(now `.pre-commit-hooks.yaml`). For backwards compatibility it is suggested -to provide both files or suggest users use `pre-commit>=0.12.0`. - ## Developing hooks interactively Since the `repo` property of `.pre-commit-config.yaml` can refer to anything @@ -541,7 +532,6 @@ Hello from foo hook! - [ruby](#ruby) - [rust](#rust) - [swift](#swift) -- [pcre](#pcre) - [pygrep](#pygrep) - [script](#script) - [system](#system) @@ -563,8 +553,6 @@ It has been tested on linux, macOS, and windows. ### docker -_new in 0.10.0_ - The hook repository must have a `Dockerfile`. It will be installed via `docker build .`. @@ -587,8 +575,6 @@ for an example Docker-based hook. ### docker_image -_new in 0.18.0_ - A more lightweight approach to `docker` hooks. The `docker_image` "language" uses existing docker images to provide hook executables. @@ -643,8 +629,6 @@ being added to the `changelog` directory: ### golang -_new in 0.12.0_ - The hook repository must contain go source code. It will be installed via `go get ./...`. pre-commit will create an isolated `GOPATH` for each hook and the `entry` should match an executable which will get installed into the @@ -724,8 +708,6 @@ has been tested on linux, Windows, and macOS. ### swift -_new in 0.11.0_ - The hook repository must have a `Package.swift`. It will be installed via `swift build -c release`. The `entry` should match an executable created by building the repository. @@ -733,22 +715,6 @@ building the repository. __Support:__ swift hooks are known to work on any system which has swift installed. It has been tested on linux and macOS. -### pcre - -_**deprecated**_: the pcre language will be removed in a later version. Use -[pygrep](#pygrep) hooks instead (usually a drop-in replacement). - -"Perl Compatible Regular Expressions" – pcre hooks are a quick way to write a -simple hook which prevents commits by file matching. Specify the regex as the -`entry`. - -macos does not ship with a functioning `grep -P` so you'll need -`brew install grep` for pcre hooks to function. - -__Support:__ pcre hooks work on any system which has a functioning -`grep -P` (or in the case of macOS: `ggrep -P`). It has been tested on linux, -macOS, windows, and cygwin. - ### pygrep _new in 1.2.0_ @@ -955,8 +921,7 @@ Options: - `--files [FILES [FILES ...]]`: specific filenames to run hooks on. - `--source SOURCE` + `--origin ORIGIN`: run against the files changed between `SOURCE...ORIGIN` in git. -- `--show-diff-on-failure`: _new in 0.13.4_: when hooks fail, run `git diff` - directly afterward. +- `--show-diff-on-failure`: when hooks fail, run `git diff` directly afterward. - `-v`, `--verbose`: produce hook output independent of success. Include hook ids in output. @@ -1083,8 +1048,6 @@ pre-merge-commit hook. ## pre-commit during push -_new in 0.3.5_: pre-commit can be used to manage [pre-push] hooks. - To use `pre-push` hooks with pre-commit, run: ```console @@ -1092,11 +1055,19 @@ $ pre-commit install --hook-type pre-push pre-commit installed at .git/hooks/pre-push ``` +During a push, pre-commit will export the following environment variables: +- `PRE_COMMIT_SOURCE`: the remote revision that is being pushed to. +- `PRE_COMMIT_ORIGIN`: the local revision that is being pushed to the remote. +- `PRE_COMMIT_REMOTE_NAME`: _new in 2.0.0_ which remote is being pushed to + (for example `origin`) +- `PRE_COMMIT_REMOTE_URL`: _new in 2.0.0_ the url of the remote that is being + pushed to (for example `git@github.com:pre-commit/pre-commit`. + [pre-push]: https://git-scm.com/docs/githooks#_pre_push ## pre-commit for commit messages -_new in 0.15.4_: pre-commit can be used to manage [commit-msg] hooks. +pre-commit can be used to manage [commit-msg] hooks. To use `commit-msg` hooks with pre-commit, run: @@ -1212,9 +1183,8 @@ Repository-local hooks are useful when: You can configure repository-local hooks by specifying the `repo` as the sentinel `local`. -_new in 0.13.0_: local hooks can use any language which supports -`additional_dependencies` or `docker_image` / `fail` / `pcre` / `pygrep` / -`script` / `system`. +local hooks can use any language which supports `additional_dependencies` or +`docker_image` / `fail` / `pygrep` / `script` / `system`. This enables you to install things which previously would require a trivial mirror repository. @@ -1323,8 +1293,6 @@ $ git commit --allow-empty -m 'Initial commit' ## Filtering files with types -_new in 0.15.0_ - Filtering with `types` provides several advantages over traditional filtering with `files`. @@ -1423,8 +1391,8 @@ the `(?x)` regex flag. Sometimes you only want to run the hooks on a specific version of the language. For each language, they default to using the system installed -language (So for example if I’m running `python2.7` and a hook specifies -`python`, pre-commit will run the hook using `python2.7`). Sometimes you +language (So for example if I’m running `python3.7` and a hook specifies +`python`, pre-commit will run the hook using `python3.7`). Sometimes you don’t want the default system installed version so you can override this on a per-hook basis by setting the `language_version`. @@ -1554,19 +1522,17 @@ When cloning repos over ssh (`repo: git@github.com:...`), `git` requires the ```pre-commit [INFO] Initializing environment for git@github.com:pre-commit/pre-commit-hooks. -An unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/git', 'clone', '--no-checkout', 'git@github.com:pre-commit/pre-commit-hooks', '/home/asottile/.cache/pre-commit/repofdkwkq_v') -Return code: 128 -Expected return code: 0 -Output: (none) -Errors: - Cloning into '/home/asottile/.cache/pre-commit/repofdkwkq_v'... - Permission denied (publickey). +An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'fetch', 'origin', '--tags') +return code: 128 +expected return code: 0 +stdout: (none) +stderr: + git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. - Check the log at /home/asottile/.cache/pre-commit/pre-commit.log ``` From 5c091c394919cdba5b2afa37b137e2db55e92171 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 30 Jan 2020 12:49:26 -0800 Subject: [PATCH 293/854] Switch to Azure Pipelines + Github Actions --- .github/workflows/deploy.yml | 18 ++++++++++++++++++ .travis.yml | 15 --------------- Makefile | 8 ++------ README.md | 3 ++- azure-pipelines.yml | 16 ++++++++++++++++ 5 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .travis.yml create mode 100644 azure-pipelines.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..3b9a8c30 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,18 @@ +name: deploy +on: + pull_request: + push: + branches: [real_master] + +jobs: + build: + name: pr + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + - run: pip install virtualenv + - run: make + - run: make push + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8bb04f89..00000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: python -install: pip install virtualenv --upgrade -script: make -after_success: make push -branches: - except: - - master -env: - global: - # GH_TOKEN - - secure: "YXgJlui6OJjTEDNBVW82I+/NF5ry5WC4QLAu2D2iNOtAq0tbZe2gSd/n6JCqfYgXsTlIgnVrN1qdH8582IXHFmZH2bUhRJ+skOgn9Y0vTmhz1Kl29BAzN6v0U0ikz5htAyzISr7s+MM78ShHMzzA/mnmkgVFhYXqUTwsB3/iE9Q=" -cache: - directories: - - $HOME/.cache/pip - - $HOME/.cache/pre-commit diff --git a/Makefile b/Makefile index 97969d1e..d83da495 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,11 @@ # To build scss continuously I use `watch -n 0.1 make build/main.css` -all: install-hooks check build/main.css all-hooks.json index.html hooks.html +all: install-hooks build/main.css all-hooks.json index.html hooks.html .PHONY: install-hooks install-hooks: venv venv/bin/pre-commit install -.PHONY: check -check: venv - venv/bin/pre-commit run --all-files --show-diff-on-failure - build/main.css: venv node_modules build scss/main.scss scss/_variables.scss venv/bin/pysassc -s compressed scss/main.scss build/main.css @@ -35,7 +31,7 @@ push: venv venv/bin/markdown-to-presentation push \ --master-branch real_master \ --pages-branch master \ - .nojekyll .travis.yml README.md CNAME \ + .nojekyll README.md CNAME \ build node_modules *.html *.png *.svg favicon.ico \ all-hooks.json install-local.py diff --git a/README.md b/README.md index 7b20e514..28592ad6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ pre-commit.github.io ==================== -[![Build Status](https://travis-ci.org/pre-commit/pre-commit.github.io.svg?branch=real_master)](https://travis-ci.org/pre-commit/pre-commit.github.io) +[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.github.io?branchName=master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=58&branchName=master) +[![Build Status](https://github.com/pre-commit/pre-commit.github.io/workflows/deploy/badge.svg)](https://github.com/pre-commit/pre-commit.github.io/actions) This powers https://pre-commit.com diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..ed46fb18 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,16 @@ +trigger: + branches: + include: [real_master, test-me-*] + tags: + include: ['*'] + +resources: + repositories: + - repository: asottile + type: github + endpoint: github + name: asottile/azure-pipeline-templates + ref: refs/tags/v1.0.0 + +jobs: +- template: job--pre-commit.yml@asottile From 55402181c13792de6a692200053c710c7c66b3ee Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 30 Jan 2020 13:48:45 -0800 Subject: [PATCH 294/854] Add daily cron --- .github/workflows/deploy.yml | 2 ++ Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3b9a8c30..5aecfc6f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,6 +3,8 @@ on: pull_request: push: branches: [real_master] + schedule: + - cron: '30 8 * * *' jobs: build: diff --git a/Makefile b/Makefile index d83da495..a5ef5804 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ index.html hooks.html: venv all-hooks.json base.mako index.mako hooks.mako make_ venv: requirements-dev.txt Makefile rm -rf venv - virtualenv venv -ppython3.6 + virtualenv venv -ppython3 venv/bin/pip install -r requirements-dev.txt node_modules: package.json From e1f46b1603f01902ba540c32ac383b28eea323fc Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 30 Jan 2020 22:01:24 -0800 Subject: [PATCH 295/854] Fix branch name in badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28592ad6..9999ed5d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ pre-commit.github.io ==================== -[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.github.io?branchName=master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=58&branchName=master) +[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.github.io?branchName=real_master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=58&branchName=real_master) [![Build Status](https://github.com/pre-commit/pre-commit.github.io/workflows/deploy/badge.svg)](https://github.com/pre-commit/pre-commit.github.io/actions) This powers https://pre-commit.com From 3bc1c31ce770c25b8d211b6dd20fc27b8b267b56 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 31 Jan 2020 20:48:15 -0800 Subject: [PATCH 296/854] Remove unnecessary aspy.yaml --- make_all_hooks.py | 16 +++++++++++----- requirements-dev.txt | 1 - 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/make_all_hooks.py b/make_all_hooks.py index 0bdcc43c..75350c48 100644 --- a/make_all_hooks.py +++ b/make_all_hooks.py @@ -1,4 +1,4 @@ -import collections +import functools import json import multiprocessing import os.path @@ -8,9 +8,12 @@ from typing import Dict from typing import Tuple -import aspy.yaml +import yaml from pre_commit.clientlib import load_manifest +Loader = getattr(yaml, 'CSafeLoader', yaml.SafeLoader) +fast_load = functools.partial(yaml.load, Loader=Loader) + def get_manifest(repo_path: str) -> Tuple[str, Dict[str, Any]]: print(f'*** {repo_path}') @@ -21,13 +24,16 @@ def get_manifest(repo_path: str) -> Tuple[str, Dict[str, Any]]: manifest_path = os.path.join(repo_dir, '.pre-commit-hooks.yaml') # Validate the manifest just to make sure it's ok. load_manifest(manifest_path) - return (repo_path, aspy.yaml.ordered_load(open(manifest_path))) + with open(manifest_path) as f: + return repo_path, fast_load(f) def main() -> int: - repos = aspy.yaml.ordered_load(open('all-repos.yaml')) + with open('all-repos.yaml') as f: + repos = fast_load(f) + pool = multiprocessing.Pool(4) - hooks_json = collections.OrderedDict(pool.map(get_manifest, repos)) + hooks_json = dict(pool.map(get_manifest, repos)) with open('all-hooks.json', 'w') as hooks_json_file: json.dump(hooks_json, hooks_json_file, indent=4) diff --git a/requirements-dev.txt b/requirements-dev.txt index d74d1341..2f9cb64c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,3 @@ -aspy.yaml mako libsass markdown-code-blocks From fe3b1848dc59c71acc03d269086bf8e0c87f7111 Mon Sep 17 00:00:00 2001 From: daverona Date: Wed, 5 Feb 2020 08:28:23 +0900 Subject: [PATCH 297/854] Updated link from daverona-env/pre-commit-cpp to toscana/pre-commit-cpp --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 7b52a3fe..87f01cc3 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -98,7 +98,7 @@ - https://github.com/myint/docformatter - https://github.com/lorenzwalthert/pre-commit-hooks - https://github.com/FelixSeptem/pre-commit-golang -- https://gitlab.com/daverona-env/pre-commit-cpp +- https://gitlab.com/toscana/pre-commit-cpp - https://github.com/codingjoe/relint - https://github.com/nix-community/nixpkgs-fmt - https://github.com/d6e/beancount-check From b52882ff4d169bf75ef4a20f68a331f67e578c76 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 11 Feb 2020 13:17:59 -0800 Subject: [PATCH 298/854] Fix typo --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index b2cf279f..2a845d6d 100644 --- a/index.mako +++ b/index.mako @@ -564,7 +564,7 @@ as arguments to the run container command. Docker allows you to use any language that's not supported by pre-commit as a builtin. pre-commit will automatically mount the repository source as a volume using -`-v $PWD:/src:rw,Z' and set the working directory using `--workdir /src`. +`-v $PWD:/src:rw,Z` and set the working directory using `--workdir /src`. __Support:__ docker hooks are known to work on any system which has a working `docker` executable. It has been tested on linux and macOS. Hooks that are From 11fd4bada7ddd526a55f78bf1a768cdb7d221127 Mon Sep 17 00:00:00 2001 From: Jack Guttman Date: Wed, 12 Feb 2020 18:30:59 -0600 Subject: [PATCH 299/854] Add custom gradle hooks repository --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 87f01cc3..501d0007 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -115,3 +115,4 @@ - https://github.com/igorshubovych/markdownlint-cli - https://github.com/TekWizely/pre-commit-golang - https://github.com/markdownlint/markdownlint +- https://github.com/jguttman94/pre-commit-gradle From fd1ac845cb71ebcd812833a29283e1e8a5fb4083 Mon Sep 17 00:00:00 2001 From: Eagu Kim Date: Thu, 13 Feb 2020 10:57:32 +0900 Subject: [PATCH 300/854] Updated link from toscana/pre-commit-cpp to daverona/pre-commit-cpp --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 501d0007..fe12684e 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -98,7 +98,7 @@ - https://github.com/myint/docformatter - https://github.com/lorenzwalthert/pre-commit-hooks - https://github.com/FelixSeptem/pre-commit-golang -- https://gitlab.com/toscana/pre-commit-cpp +- https://gitlab.com/daverona/pre-commit-cpp - https://github.com/codingjoe/relint - https://github.com/nix-community/nixpkgs-fmt - https://github.com/d6e/beancount-check From a3ce0fc17aea49bf5b509669f9588e839f5af1d5 Mon Sep 17 00:00:00 2001 From: david <14880945+ddelange@users.noreply.github.com> Date: Fri, 14 Feb 2020 19:52:29 +0100 Subject: [PATCH 301/854] Add pre-commit badge --- base.mako | 1 + 1 file changed, 1 insertion(+) diff --git a/base.mako b/base.mako index 79a2e064..a9c64e57 100644 --- a/base.mako +++ b/base.mako @@ -46,6 +46,7 @@

      A framework for managing and maintaining multi-language pre-commit hooks.

      Build Status Azure DevOps Coverage

      +pre-commit

      From bd78a8590fb0eb2a0171a5b3f26aa2cbe8657de5 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 14 Feb 2020 10:57:31 -0800 Subject: [PATCH 302/854] Fix icon layout in header --- base.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base.mako b/base.mako index a9c64e57..a6a38bba 100644 --- a/base.mako +++ b/base.mako @@ -45,7 +45,7 @@

      A framework for managing and maintaining multi-language pre-commit hooks.

      Build Status -Azure DevOps Coverage

      +Azure DevOps Coverage pre-commit

      From 8fbbb0139abaea81cd3e3c734fb7ac9bf1dc817b Mon Sep 17 00:00:00 2001 From: david <14880945+ddelange@users.noreply.github.com> Date: Fri, 14 Feb 2020 20:28:47 +0100 Subject: [PATCH 303/854] Add pre-commit badge --- index.mako | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/index.mako b/index.mako index 2a845d6d..e8c8115a 100644 --- a/index.mako +++ b/index.mako @@ -1429,6 +1429,30 @@ default_language_version: ruby: 2.1.5 ``` +## Adding the pre-commit badge + +If you like you can add the pre-commit badge to your documentation: + +- Markdown: + ```md + [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) + ``` +- HTML: + ```html + pre-commit + ``` +- reStructuredText: + ```rst + .. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white + :target: https://github.com/pre-commit/pre-commit + :alt: pre-commit + ``` +- AsciiDoc: + ``` + image:https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white[pre-commit, link=https://github.com/pre-commit/pre-commit] + ``` + + ## Usage in continuous integration pre-commit can also be used as a tool for continuous integration. For From 9ba7f0a3cf74529df6c559a02ddd0c48da27d646 Mon Sep 17 00:00:00 2001 From: david <14880945+ddelange@users.noreply.github.com> Date: Fri, 14 Feb 2020 20:38:59 +0100 Subject: [PATCH 304/854] Add Yelp/detect-secrets Quite a useful one we use org-wide --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index fe12684e..4b6ec22b 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -116,3 +116,4 @@ - https://github.com/TekWizely/pre-commit-golang - https://github.com/markdownlint/markdownlint - https://github.com/jguttman94/pre-commit-gradle +- https://github.com/Yelp/detect-secrets From dba8e51abe3a94a16f67a05a5565358c0fc420f4 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 14 Feb 2020 13:08:54 -0800 Subject: [PATCH 305/854] slight updates to coloring and markdown --- index.mako | 41 +++++++++++++++++++++++++---------------- scss/main.scss | 9 ++++++--- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/index.mako b/index.mako index e8c8115a..e57cecec 100644 --- a/index.mako +++ b/index.mako @@ -1429,29 +1429,38 @@ default_language_version: ruby: 2.1.5 ``` -## Adding the pre-commit badge +## badging your repository -If you like you can add the pre-commit badge to your documentation: +you can add a badge to your repository to show your contributors / users that +you use pre-commit! + +[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) - Markdown: - ```md - [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) - ``` + + ```md + [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) + ``` + - HTML: - ```html - pre-commit - ``` + + ```html + pre-commit + ``` + - reStructuredText: - ```rst - .. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white - :target: https://github.com/pre-commit/pre-commit - :alt: pre-commit - ``` + + ```rst + .. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white + :target: https://github.com/pre-commit/pre-commit + :alt: pre-commit + ``` + - AsciiDoc: - ``` - image:https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white[pre-commit, link=https://github.com/pre-commit/pre-commit] - ``` + ``` + image:https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white[pre-commit, link=https://github.com/pre-commit/pre-commit] + ``` ## Usage in continuous integration diff --git a/scss/main.scss b/scss/main.scss index 2b190140..ccc70813 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -145,9 +145,7 @@ h1, } // vs.css: https://github.com/richleland/pygments-css -.highlight.yaml, -.highlight.ini, -.highlight.bash { +.highlight { .hll { background-color: #ffc; } .c { color: #008000; } /* Comment */ .err { border: 1px solid #ff0; } /* Error */ @@ -197,6 +195,11 @@ h1, .-Color-Black-BGYellow { background-color: #c4a000; color: #2e3436; } .-Color-Black-BGCyan { background-color: #06989a; color: #2e3436; } .-Color-Faint { color: #ccc; } + + .c1 { color: #06989a; } + .s { color: #8ae234; } + .s1 { color: #8ae234; } + .s2 { color: #8ae234; } } @media (max-width: $screen-md-max) { From dd0d62c6b3a941eda2bb0b2254f2ceaa6fca4487 Mon Sep 17 00:00:00 2001 From: dmitri-lerko Date: Mon, 17 Feb 2020 09:29:19 +0000 Subject: [PATCH 306/854] kustomize pre-commit hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 4b6ec22b..bcb2e301 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -117,3 +117,4 @@ - https://github.com/markdownlint/markdownlint - https://github.com/jguttman94/pre-commit-gradle - https://github.com/Yelp/detect-secrets +- https://github.com/dmitri-lerko/pre-commit-docker-kustomize From 40cf2adad6553f85fb27aa5336d2952e6408c5f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 4 Feb 2020 09:04:31 +0200 Subject: [PATCH 307/854] Add Perl hook docs --- index.mako | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/index.mako b/index.mako index e57cecec..56f5b7bc 100644 --- a/index.mako +++ b/index.mako @@ -527,6 +527,7 @@ Hello from foo hook! - [fail](#fail) - [golang](#golang) - [node](#node) +- [perl](#perl) - [python](#python) - [python_venv](#python_venv) - [ruby](#ruby) @@ -649,6 +650,27 @@ been tested on linux and macOS and _may_ work under cygwin. _new in 1.5.0_: windows is now supported for node hooks. Currently python3 only due to [a bug in cpython](https://bugs.python.org/issue32539). +### perl + +_new in 2.1.0_ + +Perl hooks are installed using the system installation of +[cpan](https://perldoc.perl.org/5.30.0/cpan.html), the CPAN package installer +that comes with Perl. + +Hook repositories must have something that `cpan` supports, typically +`Makefile.PL` or `Build.PL`, which it uses to install an executable to +use in the `entry` definition for your hook. The repository will be installed +via `cpan -T .` (with the installed files stored in your pre-commit cache, +not polluting other Perl installations). + +When specifying `additional_dependencies` for Perl, you can use any of the +[install argument formats understood by `cpan`](https://perldoc.perl.org/5.30.0/CPAN.html#get%2c-make%2c-test%2c-install%2c-clean-modules-or-distributions). + +__Support:__ Perl hooks currently require a pre-existing Perl installation, +including the `cpan` tool in `PATH`. It has been tested on linux, macOS, and +Windows. + ### python The hook repository must be installable via `pip install .` (usually by either From f2a1db3a40ed786a80284c979ca6abd8c4426f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 19 Feb 2020 21:43:01 +0200 Subject: [PATCH 308/854] Add perltidy/perltidy Refs https://github.com/perltidy/perltidy/pull/20 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index bcb2e301..d249cd68 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -118,3 +118,4 @@ - https://github.com/jguttman94/pre-commit-gradle - https://github.com/Yelp/detect-secrets - https://github.com/dmitri-lerko/pre-commit-docker-kustomize +- https://github.com/perltidy/perltidy From e406a3d214c66e988d1e1d9d6bfdd4c133d17f16 Mon Sep 17 00:00:00 2001 From: Joey Espinosa Date: Thu, 20 Feb 2020 11:43:19 -0500 Subject: [PATCH 309/854] docs: add Conform policy enforcement hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index d249cd68..2e889630 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -119,3 +119,4 @@ - https://github.com/Yelp/detect-secrets - https://github.com/dmitri-lerko/pre-commit-docker-kustomize - https://github.com/perltidy/perltidy +- https://github.com/talos-systems/conform From fbe526c025b4e1c4c75d611134aeec5c7bd3127a Mon Sep 17 00:00:00 2001 From: Joey Espinosa Date: Sat, 22 Feb 2020 23:05:11 -0500 Subject: [PATCH 310/854] docs: add note about required arg for {prepare-}commit-msg Since `--commit-msg-filename` is required when using prepare-commit-msg and commit-msg for things like `try-repo`, just making a note of that in the docs. --- index.mako | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.mako b/index.mako index 56f5b7bc..8f325acf 100644 --- a/index.mako +++ b/index.mako @@ -488,6 +488,9 @@ directory while developing hooks. enabling a quick way to try out a repository. Here's how one might work interactively: +_note_: you may need to provide `--commit-msg-filename` when using this +command with hook types `prepare-commit-msg` and `commit-msg`. + _new in 1.14.0_: a commit is no longer necessary to `try-repo` on a local directory. `pre-commit` will clone any uncommitted changes. From cb2dee5e24fe75877a0acfc47b7a208ba6fc4ae6 Mon Sep 17 00:00:00 2001 From: twu Date: Sun, 1 Mar 2020 17:06:13 +0100 Subject: [PATCH 311/854] Add twu/skjold to hooks list. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 2e889630..64e092fe 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -120,3 +120,4 @@ - https://github.com/dmitri-lerko/pre-commit-docker-kustomize - https://github.com/perltidy/perltidy - https://github.com/talos-systems/conform +- https://github.com/twu/skjold From f176b5eb5ea8648d533694a8ccd74b12c0124846 Mon Sep 17 00:00:00 2001 From: Luca Trevisani Date: Mon, 9 Mar 2020 22:46:20 +0100 Subject: [PATCH 312/854] Add `commitizen` to the list of supported hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 64e092fe..4f3eaf69 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -121,3 +121,4 @@ - https://github.com/perltidy/perltidy - https://github.com/talos-systems/conform - https://github.com/twu/skjold +- https://github.com/woile/commitizen From f516ac95bf3cab7ee731f0a6f71b4ae3a7720f32 Mon Sep 17 00:00:00 2001 From: Andrew Hare Date: Thu, 20 Feb 2020 13:31:02 -0700 Subject: [PATCH 313/854] Add documentation for post-checkout --- index.mako | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/index.mako b/index.mako index 8f325acf..b6aa5f32 100644 --- a/index.mako +++ b/index.mako @@ -312,7 +312,7 @@ repository's configuration. =r= =c= `stages` =c= (optional) confines the hook to the `commit`, `merge-commit`, `push`, - `prepare-commit-msg`, `commit-msg`, or `manual` stage. See + `prepare-commit-msg`, `commit-msg`, 'post-checkout', or `manual` stage. See [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). =r= =c= `additional_dependencies` @@ -874,8 +874,8 @@ Install hook script in a directory intended for use with Options: -- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`, - `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`: +- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout}`, + `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout}`: which hook type to install. Some example useful invocations: @@ -899,8 +899,8 @@ Options: - `--install-hooks`: Also install environments for all available hooks now (rather than when they are first executed). See [`pre-commit install-hooks`](#pre-commit-install-hooks). -- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`, - `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg}`: +- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout}`, + `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout}`: Specify which hook type to install. - `--allow-missing-config`: Hook scripts will permit a missing configuration file. @@ -1127,6 +1127,40 @@ the commit will be aborted. [commit-msg]: https://git-scm.com/docs/githooks#_commit_msg [prepare-commit-msg]: https://git-scm.com/docs/githooks#_prepare_commit_msg + +## pre-commit for switching branches +_new in 2.2.0_: pre-commit can be used to manage [post-checkout] hooks. + +To use `post-checkout` hooks with pre-commit run: + +```console +$ pre-commit install --hook-type post-checkout +pre-commit installed at .git/hooks/post-checkout +``` + +`post-checkout` hooks can be used to perform repository validity checks, +auto-display differences from the previous HEAD if different, +or set working dir metadata properties. Since `post-checkout` doesn't operate +on files, any hooks must set `always_run`: + +```yaml +- repo: local + hooks: + - id: post-checkout-local + name: Post checkout + always_run: true + stages: [post-checkout] + # ... +``` + +`post-checkout` hooks have three environment variables they can check to +do their work: `$PRE_COMMIT_FROM_REF`, `$PRE_COMMIT_TO_REF`, +and `$PRE_COMMIT_CHECKOUT_TYPE`. These correspond to the first, second, +and third arguments (respectively) that are normally passed to a regular +post-checkout hook from Git. + +[post-checkout]: https://git-scm.com/docs/githooks#_post_checkout + ## Confining hooks to run at certain stages Since the `default_stages` top level configuration property of the From 4d888bc1f8da8c8063a08082deca199382c41d69 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 12 Mar 2020 12:55:37 -0700 Subject: [PATCH 314/854] Documentation updates for 2.2.0 --- index.mako | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/index.mako b/index.mako index b6aa5f32..d6d16aed 100644 --- a/index.mako +++ b/index.mako @@ -944,8 +944,10 @@ Options: - `[hook-id]`: specify a single hook-id to run only that hook. - `-a`, `--all-files`: run on all the files in the repo. - `--files [FILES [FILES ...]]`: specific filenames to run hooks on. -- `--source SOURCE` + `--origin ORIGIN`: run against the files changed between - `SOURCE...ORIGIN` in git. +- `--from-ref FROM_REF` + `--to-ref TO_REF`: run against the files changed + between `FROM_REF...TO_REF` in git. + - _new in 2.2.0_: prior to 2.2.0 the arguments were `--source` and + `--origin`. - `--show-diff-on-failure`: when hooks fail, run `git diff` directly afterward. - `-v`, `--verbose`: produce hook output independent of success. Include hook ids in output. @@ -958,7 +960,7 @@ Some example useful invocations: - `pre-commit run flake8`: run the `flake8` hook against all staged files. - `git ls-files -- '*.py' | xargs pre-commit run --files`: run all hooks against all `*.py` files in the repository. -- `pre-commit run --source HEAD^^^ --origin HEAD`: run against the files that +- `pre-commit run --from-ref HEAD^^^ --to-ref HEAD`: run against the files that have changed between `HEAD^^^` and `HEAD`. This form is useful when leveraged in a pre-receive hook. @@ -1081,8 +1083,10 @@ pre-commit installed at .git/hooks/pre-push ``` During a push, pre-commit will export the following environment variables: -- `PRE_COMMIT_SOURCE`: the remote revision that is being pushed to. -- `PRE_COMMIT_ORIGIN`: the local revision that is being pushed to the remote. +- `PRE_COMMIT_FROM_REF`: the remote revision that is being pushed to. + - _new in 2.2.0_ prior to 2.2.0 the variable was `PRE_COMMIT_SOURCE`. +- `PRE_COMMIT_TO_REF`: the local revision that is being pushed to the remote. + - _new in 2.2.0_ prior to 2.2.0 the variable was `PRE_COMMIT_ORIGIN`. - `PRE_COMMIT_REMOTE_NAME`: _new in 2.0.0_ which remote is being pushed to (for example `origin`) - `PRE_COMMIT_REMOTE_URL`: _new in 2.0.0_ the url of the remote that is being @@ -1527,7 +1531,7 @@ pre-commit can also be used as a tool for continuous integration. For instance, adding `pre-commit run --all-files` as a CI step will ensure everything stays in tip-top shape. To check only files which have changed, which may be faster, use something like -`pre-commit run --origin HEAD --source origin/HEAD`. +`pre-commit run --from-ref origin.HEAD --to-ref HEAD` ## Managing CI Caches From cc618b142c9bd24aa948db357981fbfaf75fa6aa Mon Sep 17 00:00:00 2001 From: Gherynos Date: Fri, 13 Mar 2020 14:10:38 +0000 Subject: [PATCH 315/854] Added Java hooks repository --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 4f3eaf69..6c700dac 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -122,3 +122,4 @@ - https://github.com/talos-systems/conform - https://github.com/twu/skjold - https://github.com/woile/commitizen +- https://github.com/gherynos/pre-commit-java From fc85cd382febf1857dab899ce239032722a8bcd5 Mon Sep 17 00:00:00 2001 From: James Woolfenden Date: Fri, 13 Mar 2020 16:12:57 +0000 Subject: [PATCH 316/854] Links to 3 new commit hooks A lot of existing hooks weren't cross platform, these ones all are. Python>bash. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 6c700dac..da8b2dea 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -123,3 +123,4 @@ - https://github.com/twu/skjold - https://github.com/woile/commitizen - https://github.com/gherynos/pre-commit-java +- https://github.com/JamesWoolfenden/pre-commit From e4d44a633e1d685fdad763008f05756a27befbf8 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Mon, 16 Mar 2020 18:46:53 +0200 Subject: [PATCH 317/854] index: use backtics for post-checkout Typo from https://github.com/pre-commit/pre-commit.github.io/pull/307 --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index d6d16aed..faaee429 100644 --- a/index.mako +++ b/index.mako @@ -312,7 +312,7 @@ repository's configuration. =r= =c= `stages` =c= (optional) confines the hook to the `commit`, `merge-commit`, `push`, - `prepare-commit-msg`, `commit-msg`, 'post-checkout', or `manual` stage. See + `prepare-commit-msg`, `commit-msg`, `post-checkout`, or `manual` stage. See [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). =r= =c= `additional_dependencies` From 60988e676f68f138864ebd14b59f29c333b4a4e4 Mon Sep 17 00:00:00 2001 From: Janne Enberg Date: Wed, 18 Mar 2020 19:09:43 +0200 Subject: [PATCH 318/854] Added github.com/lietu/go-pre-commit --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index da8b2dea..80b79c6c 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -124,3 +124,4 @@ - https://github.com/woile/commitizen - https://github.com/gherynos/pre-commit-java - https://github.com/JamesWoolfenden/pre-commit +- https://github.com/lietu/go-pre-commit From e3c8c7365190b960d3ef445f55945bb7ca21ad1d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Tue, 24 Mar 2020 11:16:55 +0100 Subject: [PATCH 319/854] renamed reop --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 80b79c6c..b354f843 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -96,7 +96,7 @@ - https://github.com/seddonym/import-linter - https://github.com/marco-c/taskcluster_yml_validator - https://github.com/myint/docformatter -- https://github.com/lorenzwalthert/pre-commit-hooks +- https://github.com/lorenzwalthert/precommit - https://github.com/FelixSeptem/pre-commit-golang - https://gitlab.com/daverona/pre-commit-cpp - https://github.com/codingjoe/relint From a8b895e255f5636be5b9bf3efc92cee758c0ceec Mon Sep 17 00:00:00 2001 From: Paul Morgan Date: Wed, 25 Mar 2020 23:36:46 +0000 Subject: [PATCH 320/854] add jumanjihouse yamlfmt hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index b354f843..32e80feb 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -30,6 +30,7 @@ - https://github.com/elidupuis/mirrors-jscs - https://github.com/elidupuis/mirrors-sass-lint - https://github.com/jumanjihouse/pre-commit-hooks +- https://github.com/jumanjihouse/pre-commit-hook-yamlfmt - https://github.com/Lucas-C/pre-commit-hooks - https://github.com/Lucas-C/pre-commit-hooks-go - https://github.com/Lucas-C/pre-commit-hooks-java From 8abdccac9e24a819759c29a800b3c804729aa69d Mon Sep 17 00:00:00 2001 From: Paul Morgan Date: Wed, 25 Mar 2020 23:40:22 +0000 Subject: [PATCH 321/854] add language formatter hooks from macisamuele --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 32e80feb..0feb97a7 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -126,3 +126,4 @@ - https://github.com/gherynos/pre-commit-java - https://github.com/JamesWoolfenden/pre-commit - https://github.com/lietu/go-pre-commit +- https://github.com/macisamuele/language-formatters-pre-commit-hooks From f35a28fd51576304ff5829788b8c3e323f267d4b Mon Sep 17 00:00:00 2001 From: Felippe Raposo Date: Thu, 26 Mar 2020 22:08:47 -0700 Subject: [PATCH 322/854] Fix typo on 'pre-commit install-hooks' section --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index faaee429..365b23f2 100644 --- a/index.mako +++ b/index.mako @@ -923,7 +923,7 @@ Each hook is initialized in a separate environment appropriate to the language the hook is written in. See [supported languages](#supported-languages). This command does not install the pre-commit script. To install the script along with -the hook environments in one command, use `pre-commit install --install hooks`. +the hook environments in one command, use `pre-commit install --install-hooks`. Options: (no additional options) From 81fa5ad355aff71a5426ca5ffc06598b1549f0bc Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 1 Apr 2020 08:54:04 -0700 Subject: [PATCH 323/854] Fix broken build --- all-repos.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 0feb97a7..9785a326 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -117,7 +117,6 @@ - https://github.com/TekWizely/pre-commit-golang - https://github.com/markdownlint/markdownlint - https://github.com/jguttman94/pre-commit-gradle -- https://github.com/Yelp/detect-secrets - https://github.com/dmitri-lerko/pre-commit-docker-kustomize - https://github.com/perltidy/perltidy - https://github.com/talos-systems/conform From 091e9433d310f2d272105740fac4549fb7022e2a Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Wed, 1 Apr 2020 11:03:38 -0700 Subject: [PATCH 324/854] Revert "Fix broken build" This reverts commit 81fa5ad355aff71a5426ca5ffc06598b1549f0bc. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 9785a326..0feb97a7 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -117,6 +117,7 @@ - https://github.com/TekWizely/pre-commit-golang - https://github.com/markdownlint/markdownlint - https://github.com/jguttman94/pre-commit-gradle +- https://github.com/Yelp/detect-secrets - https://github.com/dmitri-lerko/pre-commit-docker-kustomize - https://github.com/perltidy/perltidy - https://github.com/talos-systems/conform From 1d89d8eeec3fcea65c46c967be2b85b3262ddc06 Mon Sep 17 00:00:00 2001 From: Ryan Rhee Date: Wed, 8 Apr 2020 17:12:24 -0400 Subject: [PATCH 325/854] [shellcheck-py] Update URL Now has an organization URL --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 0feb97a7..55bda37f 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -108,7 +108,7 @@ - https://gitlab.com/iamlikeme/nbhooks - https://github.com/Kuniwak/vint - https://github.com/eschulte/lisp-format -- https://github.com/ryanrhee/shellcheck-py +- https://github.com/shellcheck-py/shellcheck-py - https://github.com/APIDevTools/swagger-cli - https://github.com/kynan/nbstripout - https://gitlab.com/devopshq/gitlab-ci-linter From 9324084e078b125400b1d369f3a7b9c8940f5615 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Tue, 14 Apr 2020 01:11:19 -0700 Subject: [PATCH 326/854] Add jlebar/pre-commit-hooks to list of pre-commit hook repos. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 55bda37f..0ede70a1 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -127,3 +127,4 @@ - https://github.com/JamesWoolfenden/pre-commit - https://github.com/lietu/go-pre-commit - https://github.com/macisamuele/language-formatters-pre-commit-hooks +- https://github.com/jlebar/pre-commit-hooks From 75508400ebdfe039a3a8e467a8f291a3d4f73866 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Thu, 16 Apr 2020 14:54:18 +0700 Subject: [PATCH 327/854] Add pip-tools to the list of pre-commit hook repos --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 0ede70a1..a612d315 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -128,3 +128,4 @@ - https://github.com/lietu/go-pre-commit - https://github.com/macisamuele/language-formatters-pre-commit-hooks - https://github.com/jlebar/pre-commit-hooks +- https://github.com/jazzband/pip-tools From 84708609c6b069366705213368f5615936d20c72 Mon Sep 17 00:00:00 2001 From: Ammar Najjar Date: Mon, 13 Apr 2020 04:32:43 +0200 Subject: [PATCH 328/854] feat: add copy-icon top-left all code-blocks Issue: #330 --- .pre-commit-config.yaml | 5 +++++ assets/copy-icon.svg | 1 + assets/copyable.js | 27 +++++++++++++++++++++++++++ base.mako | 1 + index.mako | 8 ++++---- package.json | 23 +++++++++++++++++++++++ scss/main.scss | 2 ++ template_lib.py | 18 ++++++++++++++---- 8 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 assets/copy-icon.svg create mode 100644 assets/copyable.js diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e5d7b7c..db44772d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,6 +29,11 @@ repos: hooks: - id: mypy exclude: ^install-local.py$ +- repo: https://github.com/pre-commit/mirrors-eslint + rev: v7.0.0-alpha.3 + hooks: + - id: eslint + args: [--fix] - repo: local hooks: - id: scss-lint diff --git a/assets/copy-icon.svg b/assets/copy-icon.svg new file mode 100644 index 00000000..16819e06 --- /dev/null +++ b/assets/copy-icon.svg @@ -0,0 +1 @@ + diff --git a/assets/copyable.js b/assets/copyable.js new file mode 100644 index 00000000..8aba102f --- /dev/null +++ b/assets/copyable.js @@ -0,0 +1,27 @@ +(function () { + function copyTextToClipboard(text) { + var textArea = document.createElement('textarea'); + textArea.value = text; + textArea.style.position = 'fixed'; + textArea.style.left = '-1'; + textArea.style.top = '-1'; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + document.execCommand('copy'); + document.body.removeChild(textArea); + } + var codeBlockElements = document.getElementsByClassName('copyable'); + for (var i = 0; i < codeBlockElements.length; i++) { + var block = codeBlockElements[i]; + var copyIcon = new Image(16, 16); + copyIcon.setAttribute('src', './assets/copy-icon.svg'); + copyIcon.setAttribute('alt', 'copy'); + copyIcon.setAttribute('title', 'copy to clipboard'); + block.insertBefore(copyIcon, block.children[0]); + copyIcon.addEventListener('click', function(block) { + var text = block.getElementsByTagName('pre')[0].innerText; + copyTextToClipboard(text); + }.bind(null, block)); + } +})(); diff --git a/base.mako b/base.mako index a6a38bba..640d2add 100644 --- a/base.mako +++ b/base.mako @@ -68,5 +68,6 @@ ga('create', 'UA-104682927-1', 'auto'); ga('send', 'pageview'); + diff --git a/index.mako b/index.mako index 365b23f2..986de677 100644 --- a/index.mako +++ b/index.mako @@ -1501,19 +1501,19 @@ you use pre-commit! - Markdown: - ```md + ```md#copyable [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) ``` - HTML: - ```html + ```html#copyable pre-commit ``` - reStructuredText: - ```rst + ```rst#copyable .. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white :target: https://github.com/pre-commit/pre-commit :alt: pre-commit @@ -1521,7 +1521,7 @@ you use pre-commit! - AsciiDoc: - ``` + ```#copyable image:https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white[pre-commit, link=https://github.com/pre-commit/pre-commit] ``` diff --git a/package.json b/package.json index d8073dcb..99a627c7 100644 --- a/package.json +++ b/package.json @@ -3,5 +3,28 @@ "license": "MIT", "dependencies": { "bootstrap-sass": "3.4.1" + }, + "eslintConfig": { + "extends": "eslint:recommended", + "rules": { + "indent": [ + "error", + 4 + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ] + }, + "parserOptions": { + "ecmaVersion": 6 + }, + "env": { + "browser": true + } } } diff --git a/scss/main.scss b/scss/main.scss index ccc70813..514a67f1 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -202,6 +202,8 @@ h1, .s2 { color: #8ae234; } } +.copyable img { cursor: pointer; } + @media (max-width: $screen-md-max) { .table-bordered td:first-child { background: #f5f5f5; diff --git a/template_lib.py b/template_lib.py index dec8830f..5466484b 100644 --- a/template_lib.py +++ b/template_lib.py @@ -3,6 +3,7 @@ import shlex import subprocess import sys +from typing import Optional import markdown_code_blocks import markupsafe @@ -99,13 +100,22 @@ def header(self, text: str, level: int, raw: str) -> str: f' ' ) - def block_code(self, code: str, lang: str) -> str: + def block_code(self, code: str, lang: Optional[str]) -> str: + copyable = False + if lang is not None: + copyable_s = '#copyable' + copyable = lang.endswith(copyable_s) + lang, _, _ = lang.partition(copyable_s) if lang == 'table': - return _render_table(code) + ret = _render_table(code) elif lang == 'cmd': - return _render_cmd(code) + ret = _render_cmd(code) else: - return super().block_code(code, lang) + ret = super().block_code(code, lang) + if copyable: + return f'

      {ret}
      ' + else: + return ret def md(s: str) -> str: From d0abd9741fb0a9a3c04a5306520846cd353f500d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 16 Apr 2020 13:42:48 -0700 Subject: [PATCH 329/854] deploy the assets too --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a5ef5804..31b669d1 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ push: venv --master-branch real_master \ --pages-branch master \ .nojekyll README.md CNAME \ - build node_modules *.html *.png *.svg favicon.ico \ + build assets node_modules *.html *.png *.svg favicon.ico \ all-hooks.json install-local.py clean: From 3868df8d91df183ddf4a2a5a01439110eba3e2e3 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Mon, 20 Apr 2020 04:25:05 +0700 Subject: [PATCH 330/854] Add pappasam/toml-sort to the list of pre-commit hook repos --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index a612d315..010bab9e 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -129,3 +129,4 @@ - https://github.com/macisamuele/language-formatters-pre-commit-hooks - https://github.com/jlebar/pre-commit-hooks - https://github.com/jazzband/pip-tools +- https://github.com/pappasam/toml-sort From a945807896c3eda8dd8629619f4873bbbe601dcc Mon Sep 17 00:00:00 2001 From: Brendan Long Date: Thu, 23 Apr 2020 15:24:24 -0600 Subject: [PATCH 331/854] Add ocamlformat hook repo This repo has a fairly basic `system` hook for ocamlformat --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 010bab9e..f0348c81 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -130,3 +130,4 @@ - https://github.com/jlebar/pre-commit-hooks - https://github.com/jazzband/pip-tools - https://github.com/pappasam/toml-sort +- https://github.com/arenadotio/pre-commit-ocamlformat From a213a68384ab68da85a2244d0d49a60cd015a2b3 Mon Sep 17 00:00:00 2001 From: Mathieu Lemay Date: Thu, 30 Apr 2020 21:31:26 -0400 Subject: [PATCH 332/854] Add mathieu-lemay/pre-commit-rust --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index f0348c81..738c5970 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -131,3 +131,4 @@ - https://github.com/jazzband/pip-tools - https://github.com/pappasam/toml-sort - https://github.com/arenadotio/pre-commit-ocamlformat +- https://github.com/mathieu-lemay/pre-commit-rust From cef5903749ae3dca2d0965efbc19565fc68e1e6d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 11 May 2020 12:48:13 -0700 Subject: [PATCH 333/854] update docs for changes in 2.4.0 --- index.mako | 57 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/index.mako b/index.mako index 986de677..be2772eb 100644 --- a/index.mako +++ b/index.mako @@ -312,7 +312,8 @@ repository's configuration. =r= =c= `stages` =c= (optional) confines the hook to the `commit`, `merge-commit`, `push`, - `prepare-commit-msg`, `commit-msg`, `post-checkout`, or `manual` stage. See + `prepare-commit-msg`, `commit-msg`, `post-checkout`, `post-commit`, or + `manual` stage. See [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). =r= =c= `additional_dependencies` @@ -688,16 +689,17 @@ has been tested on linux, macOS, windows, and cygwin. _new in 1.9.0_ -An alternate implementation of the [python](#python) language which uses the -python 3 [`venv`](https://docs.python.org/3/library/venv.html) module. -On many systems you need to additionally install the `python3-venv` system -package to use this language. This is otherwise a drop-in replacement for the -`python` language for situations where [`virtualenv` may not -work](https://github.com/pre-commit/pre-commit/issues/631). +_new in 2.4.0_: The `python_venv` language is now an alias to `python` since +`virtualenv>=20` creates equivalently structured environments. Previously, +this `language` created environments using the [venv] module. + +This `language` will be removed eventually so it is suggested to use `python` +instead. + +[venv]: https://docs.python.org/3/library/venv.html __Support:__ python hooks work without any system-level dependencies. It -has been tested on linux, macOS, windows, and cygwin. Only python3 -environments can be created with this language. +has been tested on linux, macOS, windows, and cygwin. ### ruby @@ -874,8 +876,8 @@ Install hook script in a directory intended for use with Options: -- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout}`, - `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout}`: +- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout,post-commit}`, + `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout,post-commit}`: which hook type to install. Some example useful invocations: @@ -899,8 +901,8 @@ Options: - `--install-hooks`: Also install environments for all available hooks now (rather than when they are first executed). See [`pre-commit install-hooks`](#pre-commit-install-hooks). -- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout}`, - `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout}`: +- `-t {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout,post-commit}`, + `--hook-type {pre-commit,pre-merge-commit,pre-push,prepare-commit-msg,commit-msg,post-checkout,post-commit}`: Specify which hook type to install. - `--allow-missing-config`: Hook scripts will permit a missing configuration file. @@ -1041,6 +1043,31 @@ false-negatives during committing. pre-commit only runs on the staged contents of files by temporarily saving the contents of your files at commit time and stashing the unstaged changes while running hooks. +_new in 2.4.0_: pre-commit can be used to manage [post-commit] hooks. + +To use `post-commit` hooks with pre-commit, run: + +```console +$ pre-commit install --hook-type post-commit +pre-commit installed at .git/hooks/post-commit +``` + +`post-commit` hooks fire after the commit succeeds and cannot be used to +prevent the commit from happening (use `pre-commit` instead). Since +`post-commit` does not operate on files, any hooks must set `always_run`: + +```yaml +- repo: local + hooks: + - id: post-commit-local + name: post commit + always_run: true + stages: [post-commit] + # ... +``` + +[post-commit]: https://git-scm.com/docs/githooks#_post_commit + ## pre-commit during merges The biggest gripe we’ve had in the past with pre-commit hooks was during merge @@ -1112,7 +1139,7 @@ exits nonzero, the commit will be aborted. _new in 1.16.0_: pre-commit can be used to manage [prepare-commit-msg] hooks. -To use `prepare-commit-msg` hooks with pre-commit run: +To use `prepare-commit-msg` hooks with pre-commit, run: ```console $ pre-commit install --hook-type prepare-commit-msg` @@ -1135,7 +1162,7 @@ the commit will be aborted. ## pre-commit for switching branches _new in 2.2.0_: pre-commit can be used to manage [post-checkout] hooks. -To use `post-checkout` hooks with pre-commit run: +To use `post-checkout` hooks with pre-commit, run: ```console $ pre-commit install --hook-type post-checkout From e60105756dbb8b309c63da20a8c8b02f1b062edd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 11 May 2020 14:16:38 -0700 Subject: [PATCH 334/854] Run pre-commit autoupdate Committed via https://github.com/asottile/all-repos --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index db44772d..b2afaf6f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,36 +1,36 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v2.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: debug-statements - repo: https://gitlab.com/pycqa/flake8 - rev: 3.7.9 + rev: 3.8.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v1.4.4 + rev: v1.5.2 hooks: - id: autopep8 - repo: https://github.com/asottile/reorder_python_imports - rev: v1.8.0 + rev: v2.3.0 hooks: - id: reorder-python-imports - repo: https://github.com/asottile/pyupgrade - rev: v1.25.2 + rev: v2.4.1 hooks: - id: pyupgrade args: [--py36-plus] exclude: ^install-local.py$ - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.761 + rev: v0.770 hooks: - id: mypy exclude: ^install-local.py$ - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.0.0-alpha.3 + rev: v7.0.0 hooks: - id: eslint args: [--fix] From fb20368dda8c894b04cd2841698834b2f2e73979 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Tue, 12 May 2020 20:39:20 +0700 Subject: [PATCH 335/854] Revert "Add mathieu-lemay/pre-commit-rust" --- all-repos.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 738c5970..f0348c81 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -131,4 +131,3 @@ - https://github.com/jazzband/pip-tools - https://github.com/pappasam/toml-sort - https://github.com/arenadotio/pre-commit-ocamlformat -- https://github.com/mathieu-lemay/pre-commit-rust From 0bf3131d333f700c301ac4698eb52bb5d434d482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 12 May 2020 22:35:47 +0300 Subject: [PATCH 336/854] Spelling fix --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index be2772eb..362d674d 100644 --- a/index.mako +++ b/index.mako @@ -1214,7 +1214,7 @@ top level configuration property to the desired stages, also as an array. _new in 1.8.0_: An additional `manual` stage is available for one off execution that won't run in any hook context. This special stage is useful for taking advantage of `pre-commit`'s cross-platform / cross-language package management -without running it on every commit. Hooks confied to `stages: [manual]` can +without running it on every commit. Hooks confined to `stages: [manual]` can be executed by running `pre-commit run --hook-stage manual `. ## Passing arguments to hooks From 7425340c1b5f0bb8a0d3c4bf7c74d8c7ccf0937d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 17 May 2020 07:33:16 -0700 Subject: [PATCH 337/854] Add rstcheck https://github.com/myint/rstcheck/pull/63 --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index f0348c81..85ee7be3 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -131,3 +131,4 @@ - https://github.com/jazzband/pip-tools - https://github.com/pappasam/toml-sort - https://github.com/arenadotio/pre-commit-ocamlformat +- https://github.com/myint/rstcheck From c3243fa6eab005928ebfe164759f0f9371ca053e Mon Sep 17 00:00:00 2001 From: Max Rozentsveyg Date: Mon, 18 May 2020 01:07:21 -0400 Subject: [PATCH 338/854] Add yaspeller --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 85ee7be3..9b47ce9c 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -132,3 +132,4 @@ - https://github.com/pappasam/toml-sort - https://github.com/arenadotio/pre-commit-ocamlformat - https://github.com/myint/rstcheck +- https://github.com/hcodes/yaspeller From 84fddca4250a60001848a351016acf5d511e18f6 Mon Sep 17 00:00:00 2001 From: Max Rozentsveyg Date: Mon, 18 May 2020 01:08:57 -0400 Subject: [PATCH 339/854] Add google-style-precommit-hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 9b47ce9c..7de9d450 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -133,3 +133,4 @@ - https://github.com/arenadotio/pre-commit-ocamlformat - https://github.com/myint/rstcheck - https://github.com/hcodes/yaspeller +- https://github.com/maltzj/google-style-precommit-hook From 3841403d924cef02e96a7e16abbc7f06baf1c1c9 Mon Sep 17 00:00:00 2001 From: Max Rozentsveyg Date: Wed, 20 May 2020 21:54:45 -0400 Subject: [PATCH 340/854] Verify virtualenv tgz checksum --- install-local.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/install-local.py b/install-local.py index 3be09157..652fee3c 100644 --- a/install-local.py +++ b/install-local.py @@ -4,6 +4,7 @@ import contextlib import distutils.spawn +import hashlib import io import os.path import shutil @@ -23,6 +24,7 @@ '9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/' 'virtualenv-15.1.0.tar.gz' ) +CHECKSUM = '02f8102c2436bb03b3ee6dede1919d1dac8a427541652e5ec95171ec8adbc93a' PKG_PATH = '/tmp/.virtualenv-pkg' @@ -44,8 +46,18 @@ def virtualenv(path): clean(path) print('Downloading ' + TGZ) - tar_contents = io.BytesIO(urlopen(TGZ).read()) - with contextlib.closing(tarfile.open(fileobj=tar_contents)) as tarfile_obj: + tar_bytes = urlopen(TGZ).read() + checksum = hashlib.sha256(tar_bytes).hexdigest() + if checksum != CHECKSUM: + print( + 'Checksums did not match. ' + 'Got {}, expected {}.'.format(checksum, CHECKSUM), + file=sys.stderr, + ) + return False + + tar_stream = io.BytesIO(tar_bytes) + with contextlib.closing(tarfile.open(fileobj=tar_stream)) as tarfile_obj: # Chop off the first path segment to avoid having the version in # the path for member in tarfile_obj.getmembers(): @@ -58,6 +70,7 @@ def virtualenv(path): return subprocess.call(( sys.executable, os.path.join(PKG_PATH, 'virtualenv.py'), path, )) + return True def main(): @@ -74,7 +87,8 @@ def main(): print('Cleaned ~/.pre-commit-venv ~/bin/pre-commit') return 0 - virtualenv(venv_path) + if not virtualenv(venv_path): + return 1 subprocess.check_call(( os.path.join(venv_path, 'bin', 'pip'), 'install', 'pre-commit', From 70503925f8e8f54d7ec232c487897fb00581e396 Mon Sep 17 00:00:00 2001 From: Max Rozentsveyg Date: Wed, 20 May 2020 22:02:54 -0400 Subject: [PATCH 341/854] Run more pre-commit hooks --- .pre-commit-config.yaml | 10 ++++++++++ install-local.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b2afaf6f..3d080491 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,12 +18,22 @@ repos: rev: v2.3.0 hooks: - id: reorder-python-imports + args: [--py36-plus] + exclude: ^install-local.py$ + - id: reorder-python-imports + files: install-local.py - repo: https://github.com/asottile/pyupgrade rev: v2.4.1 hooks: - id: pyupgrade args: [--py36-plus] exclude: ^install-local.py$ + - id: pyupgrade + files: install-local.py +- repo: https://github.com/asottile/add-trailing-comma + rev: v2.0.1 + hooks: + - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.770 hooks: diff --git a/install-local.py b/install-local.py index 3be09157..52249aae 100644 --- a/install-local.py +++ b/install-local.py @@ -81,7 +81,7 @@ def main(): )) print('*' * 79) - print('Installing pre-commit to {0}'.format(script_dest)) + print('Installing pre-commit to {}'.format(script_dest)) print('*' * 79) if not os.path.exists(bin_dir): @@ -94,7 +94,7 @@ def main(): os.symlink(script_src, script_dest) if not distutils.spawn.find_executable('pre-commit'): - print('It looks like {0} is not on your path'.format(bin_dir)) + print('It looks like {} is not on your path'.format(bin_dir)) print('You may want to add it.') print('Often this does the trick: source ~/.profile') From 7ca0c32ba86eb06a3bdfc65a838fa69f15a64da4 Mon Sep 17 00:00:00 2001 From: Max Rozentsveyg Date: Wed, 20 May 2020 21:44:10 -0400 Subject: [PATCH 342/854] Run mypy on install-local.py --- .pre-commit-config.yaml | 1 - install-local.py | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b2afaf6f..36e87a75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,6 @@ repos: rev: v0.770 hooks: - id: mypy - exclude: ^install-local.py$ - repo: https://github.com/pre-commit/mirrors-eslint rev: v7.0.0 hooks: diff --git a/install-local.py b/install-local.py index 3be09157..06050d34 100644 --- a/install-local.py +++ b/install-local.py @@ -13,10 +13,13 @@ if str is bytes: - from urllib import urlopen + from urllib import urlopen # type: ignore else: from urllib.request import urlopen +if False: + from typing import Generator + TGZ = ( 'https://pypi.python.org/packages/d4/0c/' @@ -27,12 +30,14 @@ def clean(dirname): + # type: (str) -> None if os.path.exists(dirname): shutil.rmtree(dirname) @contextlib.contextmanager def clean_path(): + # type: (...) -> Generator[None, None, None] try: yield finally: @@ -40,6 +45,7 @@ def clean_path(): def virtualenv(path): + # type: (str) -> int clean(PKG_PATH) clean(path) @@ -61,6 +67,7 @@ def virtualenv(path): def main(): + # type: (...) -> int venv_path = os.path.join(os.environ['HOME'], '.pre-commit-venv') bin_dir = os.path.join(os.environ['HOME'], 'bin') script_src = os.path.join(venv_path, 'bin', 'pre-commit') @@ -98,6 +105,8 @@ def main(): print('You may want to add it.') print('Often this does the trick: source ~/.profile') + return 0 + if __name__ == '__main__': exit(main()) From 180005c08e704677f4396e96b14f80bb7f8a6abf Mon Sep 17 00:00:00 2001 From: Max Rozentsveyg Date: Wed, 20 May 2020 22:07:56 -0400 Subject: [PATCH 343/854] Update virtualenv version in install-local.py --- install-local.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install-local.py b/install-local.py index 652fee3c..6899ff58 100644 --- a/install-local.py +++ b/install-local.py @@ -20,11 +20,11 @@ TGZ = ( - 'https://pypi.python.org/packages/d4/0c/' - '9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/' - 'virtualenv-15.1.0.tar.gz' + 'https://files.pythonhosted.org/packages/a4/e3/' + '1f067de470e3a86875ed915438dc3bd781fb0346254f541190a09472b677/' + 'virtualenv-16.7.10.tar.gz' ) -CHECKSUM = '02f8102c2436bb03b3ee6dede1919d1dac8a427541652e5ec95171ec8adbc93a' +CHECKSUM = 'e88fdcb08b0ecb11da97868f463dd06275923f50d87f4b9c8b2fc0994eec40f4' PKG_PATH = '/tmp/.virtualenv-pkg' From a44b46fc6951fff9ec389b552657c1fdcb5af07e Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 20 May 2020 21:29:01 -0700 Subject: [PATCH 344/854] Add print_function import this fixes a SyntaxError in python 2.x (#350) --- install-local.py | 1 + 1 file changed, 1 insertion(+) diff --git a/install-local.py b/install-local.py index b1e759b0..f9f99d34 100644 --- a/install-local.py +++ b/install-local.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import absolute_import +from __future__ import print_function from __future__ import unicode_literals import contextlib From 827ededba290062fec65bf4e736587b68dafe1c7 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 21 May 2020 00:04:41 -0700 Subject: [PATCH 345/854] fixup install-local return value --- install-local.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install-local.py b/install-local.py index f9f99d34..925cf4bf 100644 --- a/install-local.py +++ b/install-local.py @@ -61,7 +61,7 @@ def virtualenv(path): 'Got {}, expected {}.'.format(checksum, CHECKSUM), file=sys.stderr, ) - return False + return 1 tar_stream = io.BytesIO(tar_bytes) with contextlib.closing(tarfile.open(fileobj=tar_stream)) as tarfile_obj: @@ -77,7 +77,6 @@ def virtualenv(path): return subprocess.call(( sys.executable, os.path.join(PKG_PATH, 'virtualenv.py'), path, )) - return True def main(): @@ -95,7 +94,7 @@ def main(): print('Cleaned ~/.pre-commit-venv ~/bin/pre-commit') return 0 - if not virtualenv(venv_path): + if virtualenv(venv_path): return 1 subprocess.check_call(( From 0e1fc4623617e3d18060b9fea8ecf6bff3ffe954 Mon Sep 17 00:00:00 2001 From: Jeff Stein Date: Mon, 1 Jun 2020 16:37:23 -0700 Subject: [PATCH 346/854] Add dotnet-format precommit hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 7de9d450..5f2dd439 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -134,3 +134,4 @@ - https://github.com/myint/rstcheck - https://github.com/hcodes/yaspeller - https://github.com/maltzj/google-style-precommit-hook +- https://github.com/jvstein/pre-commit-dotnet-format From 67bceb715b8b41e1a5ddfedebf9d6f39e08d2512 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 6 Jun 2020 15:09:23 -0700 Subject: [PATCH 347/854] Remove confusing "in the working directory" Resolves pre-commit/pre-commit#1489 --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 362d674d..828ec597 100644 --- a/index.mako +++ b/index.mako @@ -402,7 +402,7 @@ installable package (gem, npm, pypi, etc.) or exposes an executable, it can be used with pre-commit. Each git repo can support as many languages/hooks as you want. -The hook must exit nonzero on failure or modify files in the working directory. +The hook must exit nonzero on failure or modify files. A git repo containing pre-commit plugins must contain a .pre-commit-hooks.yaml file that tells pre-commit: From b40762fd1ebc51a996e22c566090044eb7903e29 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 9 Jun 2020 13:35:28 -0700 Subject: [PATCH 348/854] rename repository to pre-commit.com --- Makefile | 2 -- README.md | 8 ++++---- hooks.mako | 2 +- package.json | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 31b669d1..40529a73 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,6 @@ node_modules: package.json push: venv venv/bin/markdown-to-presentation push \ - --master-branch real_master \ - --pages-branch master \ .nojekyll README.md CNAME \ build assets node_modules *.html *.png *.svg favicon.ico \ all-hooks.json install-local.py diff --git a/README.md b/README.md index 9999ed5d..4eea2993 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -pre-commit.github.io -==================== +pre-commit.com +============== -[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.github.io?branchName=real_master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=58&branchName=real_master) -[![Build Status](https://github.com/pre-commit/pre-commit.github.io/workflows/deploy/badge.svg)](https://github.com/pre-commit/pre-commit.github.io/actions) +[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.com?branchName=real_master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=58&branchName=real_master) +[![Build Status](https://github.com/pre-commit/pre-commit.com/workflows/deploy/badge.svg)](https://github.com/pre-commit/pre-commit.com/actions) This powers https://pre-commit.com diff --git a/hooks.mako b/hooks.mako index 5c2f725d..5e180596 100644 --- a/hooks.mako +++ b/hooks.mako @@ -4,7 +4,7 @@

      -To add to this list, fork this repository. +To add to this list, fork this repository.

      diff --git a/package.json b/package.json index 99a627c7..7e12f3eb 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "repository": "github.com/pre-commit/pre-commit.github.io", + "repository": "github.com/pre-commit/pre-commit.com", "license": "MIT", "dependencies": { "bootstrap-sass": "3.4.1" From a07e460fee1cdecf98c46e4da73a453fc08a2b44 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 9 Jun 2020 13:41:45 -0700 Subject: [PATCH 349/854] update azure pipelines after rename --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4eea2993..2975b26f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ pre-commit.com ============== -[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.com?branchName=real_master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=58&branchName=real_master) +[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.com?branchName=real_master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=64&branchName=real_master) [![Build Status](https://github.com/pre-commit/pre-commit.com/workflows/deploy/badge.svg)](https://github.com/pre-commit/pre-commit.com/actions) This powers https://pre-commit.com From 7119e350c7f393b26473d55b5dc4aa80b57b70b2 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 9 Jun 2020 13:44:01 -0700 Subject: [PATCH 350/854] remove references to real_master --- .github/workflows/deploy.yml | 2 +- README.md | 2 +- azure-pipelines.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5aecfc6f..91ed3615 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: deploy on: pull_request: push: - branches: [real_master] + branches: [master] schedule: - cron: '30 8 * * *' diff --git a/README.md b/README.md index 2975b26f..99c0da9a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ pre-commit.com ============== -[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.com?branchName=real_master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=64&branchName=real_master) +[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.com?branchName=master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=64&branchName=master) [![Build Status](https://github.com/pre-commit/pre-commit.com/workflows/deploy/badge.svg)](https://github.com/pre-commit/pre-commit.com/actions) This powers https://pre-commit.com diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ed46fb18..416cca42 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,6 +1,6 @@ trigger: branches: - include: [real_master, test-me-*] + include: [master, test-me-*] tags: include: ['*'] From 36a2eae7d10fe27b8be5b0501ed548e5c93d5e5f Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Jun 2020 10:01:38 -0700 Subject: [PATCH 351/854] forbid `verbose: true` (debugging flag) in hooks list --- make_all_hooks.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/make_all_hooks.py b/make_all_hooks.py index 75350c48..63106c20 100644 --- a/make_all_hooks.py +++ b/make_all_hooks.py @@ -6,6 +6,7 @@ import tempfile from typing import Any from typing import Dict +from typing import List from typing import Tuple import yaml @@ -15,7 +16,7 @@ fast_load = functools.partial(yaml.load, Loader=Loader) -def get_manifest(repo_path: str) -> Tuple[str, Dict[str, Any]]: +def get_manifest(repo_path: str) -> Tuple[bool, str, List[Dict[str, Any]]]: print(f'*** {repo_path}') with tempfile.TemporaryDirectory() as directory: repo_dir = os.path.join(directory, 'repo') @@ -23,17 +24,27 @@ def get_manifest(repo_path: str) -> Tuple[str, Dict[str, Any]]: subprocess.check_call(cmd) manifest_path = os.path.join(repo_dir, '.pre-commit-hooks.yaml') # Validate the manifest just to make sure it's ok. - load_manifest(manifest_path) + manifest = load_manifest(manifest_path) + # hooks should not set debugging `verbose: true` flag + for hook in manifest: + if hook['verbose']: + print(f'{repo_path} ({hook["id"]}) sets `verbose: true`') + return False, repo_path, [] + with open(manifest_path) as f: - return repo_path, fast_load(f) + return True, repo_path, fast_load(f) def main() -> int: with open('all-repos.yaml') as f: repos = fast_load(f) - pool = multiprocessing.Pool(4) - hooks_json = dict(pool.map(get_manifest, repos)) + hooks_json = {} + with multiprocessing.Pool(4) as pool: + for ok, path, manifest in pool.map(get_manifest, repos): + if not ok: + return 1 + hooks_json[path] = manifest with open('all-hooks.json', 'w') as hooks_json_file: json.dump(hooks_json, hooks_json_file, indent=4) From 52140a51dd6175af280f2906a10f0b65b16f5c46 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Jun 2020 10:02:02 -0700 Subject: [PATCH 352/854] temporarily disable https://github.com/mattlqx/pre-commit-ruby --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 5f2dd439..894fed44 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -65,7 +65,7 @@ - https://github.com/psf/black - https://github.com/IamTheFij/ansible-pre-commit - https://github.com/IamTheFij/docker-pre-commit -- https://github.com/mattlqx/pre-commit-ruby +# - https://github.com/mattlqx/pre-commit-ruby - https://github.com/mattlqx/pre-commit-sign - https://github.com/mattlqx/pre-commit-search-and-replace - https://github.com/openstack-dev/bashate From db95323e9be54159ce8e0d602728aa8510d248fd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Jun 2020 10:02:20 -0700 Subject: [PATCH 353/854] temporarily disable https://github.com/openstack-dev/bashate --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 894fed44..896aeba2 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -68,7 +68,7 @@ # - https://github.com/mattlqx/pre-commit-ruby - https://github.com/mattlqx/pre-commit-sign - https://github.com/mattlqx/pre-commit-search-and-replace -- https://github.com/openstack-dev/bashate +# - https://github.com/openstack-dev/bashate - https://github.com/pryorda/dockerfilelint-precommit-hooks - https://github.com/alessandrojcm/commitlint-pre-commit-hook - https://github.com/henryykt/pre-commit-perl From 72d4b395347447d4ef87f4937841237a024e1b39 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Jun 2020 10:02:35 -0700 Subject: [PATCH 354/854] temporarily disable https://github.com/alessandrojcm/commitlint-pre-commit-hook --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 896aeba2..1f7924c8 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -70,7 +70,7 @@ - https://github.com/mattlqx/pre-commit-search-and-replace # - https://github.com/openstack-dev/bashate - https://github.com/pryorda/dockerfilelint-precommit-hooks -- https://github.com/alessandrojcm/commitlint-pre-commit-hook +# - https://github.com/alessandrojcm/commitlint-pre-commit-hook - https://github.com/henryykt/pre-commit-perl - https://github.com/juancarlospaco/pre-commit-nim - https://github.com/awslabs/cfn-python-lint From 1bcb29c6a3fc5cff707c79d06fbbc87c5dc900f2 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Jun 2020 10:02:51 -0700 Subject: [PATCH 355/854] temporarily disable https://github.com/thg-consulting/inspectortiger --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 1f7924c8..7cc6a083 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -104,7 +104,7 @@ - https://github.com/nix-community/nixpkgs-fmt - https://github.com/d6e/beancount-check - https://github.com/iconmaster5326/cmake-format-pre-commit-hook -- https://github.com/thg-consulting/inspectortiger +# - https://github.com/thg-consulting/inspectortiger - https://gitlab.com/iamlikeme/nbhooks - https://github.com/Kuniwak/vint - https://github.com/eschulte/lisp-format From 7a887a568b8644bcd230b4b09e54a9f91e914bf8 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Jun 2020 10:03:04 -0700 Subject: [PATCH 356/854] temporarily disable https://github.com/JamesWoolfenden/pre-commit --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 7cc6a083..783dadb1 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -124,7 +124,7 @@ - https://github.com/twu/skjold - https://github.com/woile/commitizen - https://github.com/gherynos/pre-commit-java -- https://github.com/JamesWoolfenden/pre-commit +# - https://github.com/JamesWoolfenden/pre-commit - https://github.com/lietu/go-pre-commit - https://github.com/macisamuele/language-formatters-pre-commit-hooks - https://github.com/jlebar/pre-commit-hooks From dbc91122c1d9ee15aa1903d36f7cb1555238fcc9 Mon Sep 17 00:00:00 2001 From: Matt Kulka Date: Wed, 10 Jun 2020 10:22:19 -0700 Subject: [PATCH 357/854] Revert "temporarily disable https://github.com/mattlqx/pre-commit-ruby" This reverts commit 52140a51dd6175af280f2906a10f0b65b16f5c46. --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 783dadb1..faa851ef 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -65,7 +65,7 @@ - https://github.com/psf/black - https://github.com/IamTheFij/ansible-pre-commit - https://github.com/IamTheFij/docker-pre-commit -# - https://github.com/mattlqx/pre-commit-ruby +- https://github.com/mattlqx/pre-commit-ruby - https://github.com/mattlqx/pre-commit-sign - https://github.com/mattlqx/pre-commit-search-and-replace # - https://github.com/openstack-dev/bashate From 60cb9ddd6ac07d2b75f8bafbb8ff883e5d2ed0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20=C3=87elik?= Date: Wed, 10 Jun 2020 18:20:27 +0300 Subject: [PATCH 358/854] Add unimport --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index faa851ef..e05de98b 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -135,3 +135,4 @@ - https://github.com/hcodes/yaspeller - https://github.com/maltzj/google-style-precommit-hook - https://github.com/jvstein/pre-commit-dotnet-format +- https://github.com/hakancelik96/unimport From ca27074cd879f8a8a22f6f86d4e4edb4bb358eb2 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 10 Jun 2020 10:02:35 -0700 Subject: [PATCH 359/854] Revert "temporarily disable https://github.com/alessandrojcm/commitlint-pre-commit-hook" This reverts commit 72d4b395347447d4ef87f4937841237a024e1b39. --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index e05de98b..35c2308d 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -70,7 +70,7 @@ - https://github.com/mattlqx/pre-commit-search-and-replace # - https://github.com/openstack-dev/bashate - https://github.com/pryorda/dockerfilelint-precommit-hooks -# - https://github.com/alessandrojcm/commitlint-pre-commit-hook +- https://github.com/alessandrojcm/commitlint-pre-commit-hook - https://github.com/henryykt/pre-commit-perl - https://github.com/juancarlospaco/pre-commit-nim - https://github.com/awslabs/cfn-python-lint From ebf632ff3355e071fd3fae44e7bf31e348ee4b9b Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 17 Jun 2020 08:28:36 -0700 Subject: [PATCH 360/854] improve language --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 828ec597..a461fffa 100644 --- a/index.mako +++ b/index.mako @@ -1638,7 +1638,7 @@ immutable caches: such as pre-commit. One feature of `tox>=2` is it will clear environment variables such that tests are more reproducible. Under some conditions, pre-commit requires a few environment variables and so they must be -whitelisted. +allowed to be passed through. When cloning repos over ssh (`repo: git@github.com:...`), `git` requires the `SSH_AUTH_SOCK` variable and will otherwise fail: From 30ed9a3732eea04d18cf1572ec6b1e673f295f75 Mon Sep 17 00:00:00 2001 From: Marc Jay Date: Fri, 19 Jun 2020 02:23:01 +0100 Subject: [PATCH 361/854] Add support for named anchors for all configuration keys for direct linking Add special handling for anchors that match the format: `[foo](_#bar)` that adds a named anchor before a self-link Replace documentation references to configuration keys with links to key documentation where possible --- index.mako | 181 ++++++++++++++++++++++++------------------------ template_lib.py | 10 +++ 2 files changed, 101 insertions(+), 90 deletions(-) diff --git a/index.mako b/index.mako index a461fffa..5c68121f 100644 --- a/index.mako +++ b/index.mako @@ -190,13 +190,13 @@ migrate your configuration. ```table =r= - =c= `repos` + =c= [`repos`](_#top_level-repos) =c= A list of [repository mappings](#pre-commit-configyaml---repos). =r= - =c= `default_language_version` + =c= [`default_language_version`](_#top_level-default_language_version) =c= (optional: default `{}`) a mapping from language to the default - `language_version` that should be used for that language. This will - only override individual hooks that do not set `language_version`. + [`language_version`](#config-language_version) that should be used for that language. This will + only override individual hooks that do not set [`language_version`](#config-language_version). For example to use `python3.7` for `language: python` hooks: @@ -207,10 +207,10 @@ migrate your configuration. _new in 1.14.0_ =r= - =c= `default_stages` + =c= [`default_stages`](_#top_level-default_stages) =c= (optional: default (all stages)) a configuration-wide default for - the `stages` property of hooks. This will only override individual - hooks that do not set `stages`. + the [`stages`](#config-stages) property of hooks. This will only override individual + hooks that do not set [`stages`](#config-stages). For example: @@ -220,17 +220,17 @@ migrate your configuration. _new in 1.14.0_ =r= - =c= `files` + =c= [`files`](_#top_level-files) =c= (optional: default `''`) global file include pattern. _new in 1.21.0_. =r= - =c= `exclude` + =c= [`exclude`](_#top_level-exclude) =c= (optional: default `^$`) global file exclude pattern. _new in 1.1.0_. =r= - =c= `fail_fast` + =c= [`fail_fast`](_#top_level-fail_fast) =c= (optional: default `false`) set to `true` to have pre-commit stop running hooks after the first failure. _new in 1.1.0_. =r= - =c= `minimum_pre_commit_version` + =c= [`minimum_pre_commit_version`](_#top_level-minimum_pre_commit_version) =c= (optional: default `'0'`) require a minimum version of pre-commit. _new in 1.15.0_. ``` @@ -251,13 +251,13 @@ from. ```table =r= - =c= `repo` + =c= [`repo`](_#repos-repo) =c= the repository url to `git clone` from =r= - =c= `rev` + =c= [`rev`](_#repos-rev) =c= the revision or tag to clone at. _new in 1.7.0_: previously `sha` =r= - =c= `hooks` + =c= [`hooks`](_#repos-hooks) =c= A list of [hook mappings](#pre-commit-configyaml---hooks). ``` @@ -279,57 +279,57 @@ repository's configuration. ```table =r= - =c= `id` + =c= [`id`](_#config-id) =c= which hook from the repository to use. =r= - =c= `alias` + =c= [`alias`](_#config-alias) =c= (optional) allows the hook to be referenced using an additional id when using `pre-commit run `. _new in 1.14.0_. =r= - =c= `name` + =c= [`name`](_#config-name) =c= (optional) override the name of the hook - shown during hook execution. =r= - =c= `language_version` + =c= [`language_version`](_#config-language_version) =c= (optional) override the language version for the hook. See [Overriding Language Version](#overriding-language-version). =r= - =c= `files` + =c= [`files`](_#config-files) =c= (optional) override the default pattern for files to run on. =r= - =c= `exclude` + =c= [`exclude`](_#config-exclude) =c= (optional) file exclude pattern. =r= - =c= `types` + =c= [`types`](_#config-types) =c= (optional) override the default file types to run on. See [Filtering files with types](#filtering-files-with-types). =r= - =c= `exclude_types` + =c= [`exclude_types`](_#config-exclude_types) =c= (optional) file types to exclude. =r= - =c= `args` + =c= [`args`](_#config-args) =c= (optional) list of additional parameters to pass to the hook. =r= - =c= `stages` + =c= [`stages`](_#config-stages) =c= (optional) confines the hook to the `commit`, `merge-commit`, `push`, `prepare-commit-msg`, `commit-msg`, `post-checkout`, `post-commit`, or `manual` stage. See [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). =r= - =c= `additional_dependencies` + =c= [`additional_dependencies`](_#config-additional_dependencies) =c= (optional) a list of dependencies that will be installed in the environment where this hook gets run. One useful application is to install plugins for hooks such as `eslint`. =r= - =c= `always_run` + =c= [`always_run`](_#config-always_run) =c= (optional) if `true`, this hook will run even if there are no matching files. =r= - =c= `verbose` + =c= [`verbose`](_#config-verbose) =c= (optional) if `true`, forces the output of the hook to be printed even when the hook passes. _new in 1.6.0_. =r= - =c= `log_file` + =c= [`log_file`](_#config-log_file) =c= (optional) if present, the hook output will additionally be written to a file. ``` @@ -409,61 +409,61 @@ file that tells pre-commit: ```table =r= - =c= `id` + =c= [`id`](_#hooks-id) =c= the id of the hook - used in pre-commit-config.yaml. =r= - =c= `name` + =c= [`name`](_#hooks-name) =c= the name of the hook - shown during hook execution. =r= - =c= `entry` + =c= [`entry`](_#hooks-entry) =c= the entry point - the executable to run. `entry` can also contain arguments that will not be overridden such as `entry: autopep8 -i`. =r= - =c= `language` + =c= [`language`](_#hooks-language) =c= the language of the hook - tells pre-commit how to install the hook. =r= - =c= `files` + =c= [`files`](_#hooks-files) =c= (optional: default `''`) the pattern of files to run on. =r= - =c= `exclude` - =c= (optional: default `^$`) exclude files that were matched by `files`. + =c= [`exclude`](_#hooks-exclude) + =c= (optional: default `^$`) exclude files that were matched by [`files`](#hooks-files). =r= - =c= `types` + =c= [`types`](_#hooks-types) =c= (optional: default `[file]`) list of file types to run on. See [Filtering files with types](#filtering-files-with-types). =r= - =c= `exclude_types` - =c= (optional: default `[]`) exclude files that were matched by `types`. + =c= [`exclude_types`](_#hooks-exclude_types) + =c= (optional: default `[]`) exclude files that were matched by [`types`](#hooks-types). =r= - =c= `always_run` + =c= [`always_run`](_#hooks-always_run) =c= (optional: default `false`) if `true` this hook will run even if there are no matching files. =r= - =c= `verbose` + =c= [`verbose`](_#hooks-verbose) =c= (optional) if `true`, forces the output of the hook to be printed even when the hook passes. _new in 1.6.0_. =r= - =c= `pass_filenames` + =c= [`pass_filenames`](_#hooks-pass_filenames) =c= (optional: default `true`) if `false` no arguments will be passed to the hook. =r= - =c= `require_serial` + =c= [`require_serial`](_#hooks-require_serial) =c= (optional: default `false`) if `true` this hook will execute using a single process instead of in parallel. _new in 1.13.0_. =r= - =c= `description` + =c= [`description`](_#hooks-description) =c= (optional: default `''`) description of the hook. used for metadata purposes only. =r= - =c= `language_version` + =c= [`language_version`](_#hooks-language_version) =c= (optional: default `default`) see [Overriding language version](#overriding-language-version). =r= - =c= `minimum_pre_commit_version` + =c= [`minimum_pre_commit_version`](_#hooks-minimum_pre_commit_version) =c= (optional: default `'0'`) allows one to indicate a minimum compatible pre-commit version. =r= - =c= `args` + =c= [`args`](_#hooks-args) =c= (optional: default `[]`) list of additional parameters to pass to the hook. ``` @@ -481,7 +481,7 @@ For example: ## Developing hooks interactively -Since the `repo` property of `.pre-commit-config.yaml` can refer to anything +Since the [`repo`](#repos-repo) property of `.pre-commit-config.yaml` can refer to anything that `git clone ...` understands, it's often useful to point it at a local directory while developing hooks. @@ -548,8 +548,8 @@ _new in 1.21.0_ The hook repository must contain an `environment.yml` file which will be used via `conda env create --file environment.yml ...` to create the environment. -The `conda` language also supports `additional_dependencies` and will pass any -of the values directly into `conda install`. This language can therefore be +The `conda` language also supports [`additional_dependencies`](#config-additional_dependencies) +and will pass any of the values directly into `conda install`. This language can therefore be used with [local](#repository-local-hooks) hooks. __Support:__ `conda` hooks work as long as there is a system-installed `conda` @@ -562,7 +562,7 @@ The hook repository must have a `Dockerfile`. It will be installed via `docker build .`. Running Docker hooks requires a running Docker engine on your host. For -configuring Docker hooks, your `entry` should correspond to an executable +configuring Docker hooks, your [`entry`](#hooks-entry) should correspond to an executable inside the Docker container, and will be used to override the default container entrypoint. Your Docker `CMD` will not run when pre-commit passes a file list as arguments to the run container command. Docker allows you to use any @@ -586,10 +586,10 @@ A more lightweight approach to `docker` hooks. The `docker_image` `docker_image` hooks can be conveniently configured as [local](#repository-local-hooks) hooks. -The `entry` specifies the docker tag to use. If an image has an +The [`entry`](#hooks-entry) specifies the docker tag to use. If an image has an `ENTRYPOINT` defined, nothing special is needed to hook up the executable. If the container does not specify an `ENTRYPOINT` or you want to change the -entrypoint you can specify it as well in your `entry`. +entrypoint you can specify it as well in your [`entry`](#hooks-entry). For example: @@ -613,11 +613,11 @@ For example: _new in 1.11.0_ -A lightweight `language` to forbid files by filename. The `fail` language is +A lightweight [`language`](#hooks-language) to forbid files by filename. The `fail` language is especially useful for [local](#repository-local-hooks) hooks. -The `entry` will be printed when the hook fails. It is suggested to provide -a brief description for `name` and more verbose fix instructions in `entry`. +The [`entry`](#hooks-entry) will be printed when the hook fails. It is suggested to provide +a brief description for [`name`](#hooks-name) and more verbose fix instructions in [`entry`](#hooks-entry). Here's an example which prevents any file except those ending with `.rst` from being added to the `changelog` directory: @@ -636,7 +636,7 @@ being added to the `changelog` directory: The hook repository must contain go source code. It will be installed via `go get ./...`. pre-commit will create an isolated `GOPATH` for each hook and -the `entry` should match an executable which will get installed into the +the [`entry`](#hooks-entry) should match an executable which will get installed into the `GOPATH`'s `bin` directory. __Support:__ golang hooks are known to work on any system which has go @@ -646,7 +646,7 @@ installed. It has been tested on linux, macOS, and windows. The hook repository must have a `package.json`. It will be installed via `npm install .`. The installed package will provide an executable that will -match the `entry` – usually through `bin` in package.json. +match the [`entry`](#hooks-entry) – usually through `bin` in package.json. __Support:__ node hooks work without any system-level dependencies. It has been tested on linux and macOS and _may_ work under cygwin. @@ -664,11 +664,11 @@ that comes with Perl. Hook repositories must have something that `cpan` supports, typically `Makefile.PL` or `Build.PL`, which it uses to install an executable to -use in the `entry` definition for your hook. The repository will be installed +use in the [`entry`](#hooks-entry) definition for your hook. The repository will be installed via `cpan -T .` (with the installed files stored in your pre-commit cache, not polluting other Perl installations). -When specifying `additional_dependencies` for Perl, you can use any of the +When specifying [`additional_dependencies`](#config-additional_dependencies) for Perl, you can use any of the [install argument formats understood by `cpan`](https://perldoc.perl.org/5.30.0/CPAN.html#get%2c-make%2c-test%2c-install%2c-clean-modules-or-distributions). __Support:__ Perl hooks currently require a pre-existing Perl installation, @@ -679,7 +679,7 @@ Windows. The hook repository must be installable via `pip install .` (usually by either `setup.py` or `pyproject.toml`). The installed package will provide an -executable that will match the `entry` – usually through `console_scripts` or +executable that will match the [`entry`](#hooks-entry) – usually through `console_scripts` or `scripts` in setup.py. __Support:__ python hooks work without any system-level dependencies. It @@ -691,9 +691,9 @@ _new in 1.9.0_ _new in 2.4.0_: The `python_venv` language is now an alias to `python` since `virtualenv>=20` creates equivalently structured environments. Previously, -this `language` created environments using the [venv] module. +this [`language`](#hooks-language) created environments using the [venv] module. -This `language` will be removed eventually so it is suggested to use `python` +This [`language`](#hooks-language) will be removed eventually so it is suggested to use `python` instead. [venv]: https://docs.python.org/3/library/venv.html @@ -705,7 +705,7 @@ has been tested on linux, macOS, windows, and cygwin. The hook repository must have a `*.gemspec`. It will be installed via `gem build *.gemspec && gem install *.gem`. The installed package will -produce an executable that will match the `entry` – usually through +produce an executable that will match the [`entry`](#hooks-entry) – usually through `executables` in your gemspec. __Support:__ ruby hooks work without any system-level dependencies. It has @@ -720,11 +720,11 @@ Rust hooks are installed using the system installation of Hook repositories must have a `Cargo.toml` file which produces at least one binary ([example](https://github.com/chriskuehl/example-rust-pre-commit-hook)), -whose name should match the `entry` definition for your hook. The repo will be +whose name should match the [`entry`](#hooks-entry) definition for your hook. The repo will be installed via `cargo install --bins` (with the binaries stored in your pre-commit cache, not polluting your user-level Cargo installations). -When specifying `additional_dependencies` for Rust, you can use the syntax +When specifying [`additional_dependencies`](#config-additional_dependencies) for Rust, you can use the syntax `{package_name}:{package_version}` to specify a new library dependency (used to build _your_ hook repo), or the special syntax `cli:{package_name}:{package_version}` for a CLI dependency (built separately, @@ -736,7 +736,7 @@ has been tested on linux, Windows, and macOS. ### swift The hook repository must have a `Package.swift`. It will be installed via -`swift build -c release`. The `entry` should match an executable created by +`swift build -c release`. The [`entry`](#hooks-entry) should match an executable created by building the repository. __Support:__ swift hooks are known to work on any system which has swift @@ -748,7 +748,7 @@ _new in 1.2.0_ A cross-platform python implementation of `grep` – pygrep hooks are a quick way to write a simple hook which prevents commits by file matching. Specify -the regex as the `entry`. The `entry` may be any python +the regex as the [`entry`](#hooks-entry). The [`entry`](#hooks-entry) may be any python [regular expression](#regular-expressions). For case insensitive regexes you can apply the `(?i)` flag as the start of your entry, or use `args: [-i]`. @@ -760,7 +760,7 @@ on. ### script Script hooks provide a way to write simple scripts which validate files. The -`entry` should be a path relative to the root of the hook repository. +[`entry`](#hooks-entry) should be a path relative to the root of the hook repository. This hook type will not be given a virtual environment to work with – if it needs additional dependencies the consumer must install them manually. @@ -800,7 +800,7 @@ Options: - `--bleeding-edge`: update to the bleeding edge of `master` instead of the latest tagged version (the default behaviour). -- `--freeze`: _new in 1.21.0_): Store "frozen" hashes in `rev` instead of tag +- `--freeze`: _new in 1.21.0_): Store "frozen" hashes in [`rev`](#repos-rev) instead of tag names. - `--repo REPO`: _new in 1.4.1_: Only update this repository. _new in 1.7.0_: This option may be specified multiple times. @@ -1194,7 +1194,7 @@ post-checkout hook from Git. ## Confining hooks to run at certain stages -Since the `default_stages` top level configuration property of the +Since the [`default_stages`](#top_level-default_stages) top level configuration property of the `.pre-commit-config.yaml` file is set to all stages by default, when installing hooks using the `-t`/`--hook-type` option (see [pre-commit install [options]](#pre-commit-install)), all hooks will be installed by default @@ -1202,13 +1202,13 @@ to run at the stage defined through that option. for instance, `pre-commit install --hook-type pre-push` will install by default all hooks to run at the `push` stage. -Hooks can however be confined to a stage by setting the `stages` property in -your `.pre-commit-config.yaml`. The `stages` property is an array and can -contain any of `commit`, `merge-commit`, `push`, `prepare-commit-msg`, +Hooks can however be confined to a stage by setting the [`stages`](#config-stages) +property in your `.pre-commit-config.yaml`. The [`stages`](#config-stages) property +is an array and can contain any of `commit`, `merge-commit`, `push`, `prepare-commit-msg`, `commit-msg` and `manual`. If you do not want to have hooks installed by default on the stage passed -during a `pre-commit install --hook-type ...`, please set the `default_stages` +during a `pre-commit install --hook-type ...`, please set the [`default_stages`](#top_level-default_stages) top level configuration property to the desired stages, also as an array. _new in 1.8.0_: An additional `manual` stage is available for one off execution @@ -1220,7 +1220,7 @@ be executed by running `pre-commit run --hook-stage manual `. ## Passing arguments to hooks Sometimes hooks require arguments to run correctly. You can pass static -arguments by specifying the `args` property in your `.pre-commit-config.yaml` +arguments by specifying the [`args`](#config-args) property in your `.pre-commit-config.yaml` as follows: ```yaml @@ -1236,7 +1236,7 @@ This will pass `--max-line-length=131` to `flake8`. ### Arguments pattern in hooks If you are writing your own custom hook, your hook should expect to receive -the `args` value and then a list of staged files. +the [`args`](#config-args) value and then a list of staged files. For example, assuming a `.pre-commit-config.yaml`: @@ -1254,7 +1254,7 @@ When you next run `pre-commit`, your script will be called: path/to/script-or-system-exe --myarg1=1 --myarg1=2 dir/file1 dir/file2 file3 ``` -If the `args` property is empty or not defined, your script will be called: +If the [`args`](#config-args) property is empty or not defined, your script will be called: ``` path/to/script-or-system-exe dir/file1 dir/file2 file3 @@ -1270,16 +1270,17 @@ Repository-local hooks are useful when: repository (such as your app's virtualenv for pylint). - The official repository for a linter doesn't have the pre-commit metadata. -You can configure repository-local hooks by specifying the `repo` as the +You can configure repository-local hooks by specifying the [`repo`](#repos-repo) as the sentinel `local`. -local hooks can use any language which supports `additional_dependencies` or -`docker_image` / `fail` / `pygrep` / `script` / `system`. +local hooks can use any language which supports [`additional_dependencies`](#config-additional_dependencies) +or `docker_image` / `fail` / `pygrep` / `script` / `system`. This enables you to install things which previously would require a trivial mirror repository. -A `local` hook must define `id`, `name`, `language`, `entry`, and `files` / -`types` as specified under [Creating new hooks](#new-hooks). +A `local` hook must define [`id`](#hooks-id), [`name`](#hooks-name), [`language`](#hooks-language), +[`entry`](#hooks-entry), and [`files`](#hooks-files) / [`types`](#hooks-types) +as specified under [Creating new hooks](#new-hooks). Here's an example configuration with a few `local` hooks: @@ -1322,17 +1323,17 @@ The currently available `meta` hooks: ```table =r= - =c= `check-hooks-apply` + =c= [`check-hooks-apply`](_#meta-check_hooks_apply) =c= ensures that the configured hooks apply to at least one file in the repository. _new in 1.4.0_. =r= - =c= `check-useless-excludes` + =c= [`check-useless-excludes`](_#meta-check_useless_excludes) =c= ensures that `exclude` directives apply to _any_ file in the repository. _new in 1.4.0_. =r= - =c= `identity` + =c= [`identity`](_#meta-identity) =c= a simple hook which prints all arguments passed to it, useful for debugging. _new in 1.14.0_. @@ -1484,7 +1485,7 @@ language. For each language, they default to using the system installed language (So for example if I’m running `python3.7` and a hook specifies `python`, pre-commit will run the hook using `python3.7`). Sometimes you don’t want the default system installed version so you can override this on a -per-hook basis by setting the `language_version`. +per-hook basis by setting the [`language_version`](#config-language_version). ```yaml - repo: https://github.com/pre-commit/mirrors-scss-lint @@ -1507,8 +1508,8 @@ Valid values for specific languages are listed below: - node: See [nodeenv](https://github.com/ekalinin/nodeenv#advanced). - ruby: See [ruby-build](https://github.com/sstephenson/ruby-build/tree/master/share/ruby-build). -_new in 1.14.0_: you can now set `default_language_version` at the -[top level](#pre-commit-configyaml---top-level) in your configuration to +_new in 1.14.0_: you can now set [`default_language_version`](#top_level-default_language_version) +at the [top level](#pre-commit-configyaml---top-level) in your configuration to control the default versions across all hooks of a language. ```yaml @@ -1687,9 +1688,9 @@ latest versions with [`pre-commit autoupdate`](#pre-commit-autoupdate). If you need the absolute latest version of a hook (instead of the latest tagged version), pass the `--bleeding-edge` parameter to `autoupdate`. -`pre-commit` assumes that the value of `rev` is an immutable ref (such as a +`pre-commit` assumes that the value of [`rev`](#repos-rev) is an immutable ref (such as a tag or SHA) and will cache based on that. Using a branch name (or `HEAD`) for -the value of `rev` is not supported and will only represent the state of +the value of [`rev`](#repos-rev) is not supported and will only represent the state of that mutable ref at the time of hook installation (and will *NOT* update automatically). ''')} diff --git a/template_lib.py b/template_lib.py index 5466484b..fcceeada 100644 --- a/template_lib.py +++ b/template_lib.py @@ -16,6 +16,7 @@ ROW = '=r=' COL = ' =c= ' INDENT = ' ' * 8 +SELF_LINK_PREFIX = '_#' def _render_table(code: str) -> str: @@ -88,6 +89,15 @@ def _render_cmd(code: str) -> str: class Renderer(markdown_code_blocks.CodeRenderer): + def link( + self, link: str, text: Optional[str], title: Optional[str], + ) -> str: + if link.startswith(SELF_LINK_PREFIX): + a_id = link[len(SELF_LINK_PREFIX):] + return f'{title}' + else: + return super().link(link, text, title) + def header(self, text: str, level: int, raw: str) -> str: match = ID_RE.search(raw) if match: From 977ada18d389580413b7dd6e46e77fc5ac9fd395 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 22 Jun 2020 11:51:39 -0700 Subject: [PATCH 362/854] Add a getting help section --- index.mako | 13 +++++++++++++ template_lib.py | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/index.mako b/index.mako index 5c68121f..d84a42e9 100644 --- a/index.mako +++ b/index.mako @@ -1707,6 +1707,19 @@ forks / mirrors. Feel free to submit bug reports, pull requests, and feature requests. +## Getting help + +There are several ways to get help for pre-commit: + +- Ask a question on [stackoverflow tagged `pre-commit.com`] +- Create an issue on [pre-commit/pre-commit] +- Ask in the #pre-commit channel in [asottile's twitch discord] + +[stackoverflow tagged `pre-commit.com`]: https://stackoverflow.com/questions/tagged/pre-commit.com +[pre-commit/pre-commit]: https://github.com/pre-commit/pre-commit/issues/ +[asottile's twitch discord]: https://discord.gg/xDKGPaW + + ## Contributors - website by [Molly Finkle](https://github.com/mfnkl) diff --git a/template_lib.py b/template_lib.py index fcceeada..dfb0a692 100644 --- a/template_lib.py +++ b/template_lib.py @@ -110,6 +110,13 @@ def header(self, text: str, level: int, raw: str) -> str: f' ' ) + def codespan(self, text: str) -> str: + if text.startswith(''): + # we trust this content + return text + else: + return super().codespan(text) + def block_code(self, code: str, lang: Optional[str]) -> str: copyable = False if lang is not None: From c52accfb14034a280e158d2a42ef8b2dc372ff5e Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 25 Jun 2020 15:50:44 -0700 Subject: [PATCH 363/854] fix azure pipelines link --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index d84a42e9..c5ed196d 100644 --- a/index.mako +++ b/index.mako @@ -1593,7 +1593,7 @@ note: azure pipelines uses immutable caches so the python version and `.pre-commit-config.yaml` hash must be included in the cache key. for a repository template, see [asottile@job--pre-commit.yml]. -[job--pre-commit.yml]: https://github.com/asottile/azure-pipeline-templates/blob/master/job--pre-commit.yml +[asottile@job--pre-commit.yml]: https://github.com/asottile/azure-pipeline-templates/blob/master/job--pre-commit.yml ```yaml jobs: From ca7eec66172b21bffb708f95f429021c559def93 Mon Sep 17 00:00:00 2001 From: Xaver Kroischke <39721804+xaver-k@users.noreply.github.com> Date: Thu, 9 Jul 2020 14:00:26 +0200 Subject: [PATCH 364/854] added basic gitlab CI caching example --- index.mako | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/index.mako b/index.mako index c5ed196d..ab4f068b 100644 --- a/index.mako +++ b/index.mako @@ -1633,6 +1633,19 @@ immutable caches: key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} ``` +### gitlab CI example + +See the [Gitlab caching best practices](https://docs.gitlab.com/ee/ci/caching/#good-caching-practices) to fine tune the cache scope. + +```yaml +my_job: + variables: + PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit + cache: + paths: + - ${PRE_COMMIT_HOME} +``` + ## Usage with tox [tox](https://tox.readthedocs.io/) is useful for configuring test / CI tools From 08c69331dad04972aa000491783f1b22c44db533 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 9 Jul 2020 14:35:01 -0700 Subject: [PATCH 365/854] clarify behaviour of autoupdate using the default branch --- index.mako | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.mako b/index.mako index ab4f068b..dfe8e30a 100644 --- a/index.mako +++ b/index.mako @@ -351,7 +351,7 @@ trailing-whitespace hook. You can update your hooks to the latest version automatically by running [`pre-commit autoupdate`](#pre-commit-autoupdate). By default, this will -bring the hooks to the latest tag on the master branch. +bring the hooks to the latest tag on the default branch. ''')} @@ -798,10 +798,10 @@ Auto-update pre-commit config to the latest repos' versions. Options: -- `--bleeding-edge`: update to the bleeding edge of `master` instead of the - latest tagged version (the default behaviour). -- `--freeze`: _new in 1.21.0_): Store "frozen" hashes in [`rev`](#repos-rev) instead of tag - names. +- `--bleeding-edge`: update to the bleeding edge of the default branch instead + of the latest tagged version (the default behaviour). +- `--freeze`: _new in 1.21.0_): Store "frozen" hashes in [`rev`](#repos-rev) + instead of tag names. - `--repo REPO`: _new in 1.4.1_: Only update this repository. _new in 1.7.0_: This option may be specified multiple times. From 58fa84902a18b99b493ac4a594c54c78c5708840 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 9 Jul 2020 14:39:11 -0700 Subject: [PATCH 366/854] remove obsolete "with all defaults present" --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index dfe8e30a..e55b296d 100644 --- a/index.mako +++ b/index.mako @@ -261,7 +261,7 @@ from. =c= A list of [hook mappings](#pre-commit-configyaml---hooks). ``` -A sample repository with all defaults present: +A sample repository: ```yaml repos: From 02fd986d86f5fd2bf1289884b710387c779aa386 Mon Sep 17 00:00:00 2001 From: Peter Mosmans Date: Fri, 10 Jul 2020 10:47:56 +0200 Subject: [PATCH 367/854] feat: add Jenkinsfile (jenkinslint) hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 35c2308d..0b4d2cb2 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -136,3 +136,4 @@ - https://github.com/maltzj/google-style-precommit-hook - https://github.com/jvstein/pre-commit-dotnet-format - https://github.com/hakancelik96/unimport +- https://github.com/PeterMosmans/jenkinslint From c235f431e24aaf6490d6c0f73d29633f95a907e3 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Sun, 12 Jul 2020 08:53:34 +0100 Subject: [PATCH 368/854] Removed deprecated "mirrors-isort" repository from all-repos.yaml. --- all-repos.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 0b4d2cb2..47032d30 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -5,7 +5,6 @@ - https://github.com/pre-commit/mirrors-csslint - https://github.com/pre-commit/mirrors-eslint - https://github.com/pre-commit/mirrors-fixmyjs -- https://github.com/pre-commit/mirrors-isort - https://github.com/pre-commit/mirrors-jshint - https://github.com/pre-commit/mirrors-mypy - https://github.com/pre-commit/mirrors-puppet-lint From 9424660abe47aa3a88ff50b204c8b05b1efa9573 Mon Sep 17 00:00:00 2001 From: James Remeika Date: Thu, 25 Jun 2020 20:41:29 -0400 Subject: [PATCH 369/854] Adds a caching example for CircleCI --- index.mako | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/index.mako b/index.mako index e55b296d..88f06676 100644 --- a/index.mako +++ b/index.mako @@ -1646,6 +1646,33 @@ my_job: - ${PRE_COMMIT_HOME} ``` +### circleci example + +like [azure pipelines](#azure-pipelines-example), circleci also uses +immutable caches: + +```yaml + steps: + - run: + command: | + cp .pre-commit-config.yaml pre-commit-cache-key.txt + python --version --version >> pre-commit-cache-key.txt + - restore_cache: + keys: + - v1-pc-cache-{{ checksum "pre-commit-cache-key.txt" }} + + # ... + + - save_cache: + key: v1-pc-cache-{{ checksum "pre-commit-cache-key.txt" }} + paths: + - ~/.cache/pre-commit +``` + +(source: [@chriselison]) + +[@chriselison]: https://github.com/Unity-Technologies/ml-agents/pull/3094/files#diff-1d37e48f9ceff6d8030570cd36286a61 + ## Usage with tox [tox](https://tox.readthedocs.io/) is useful for configuring test / CI tools From 3bd42e2731e01d5e44464049c76b341d6e83c5cf Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 23 Jul 2020 09:59:49 -0700 Subject: [PATCH 370/854] temporarily disable https://github.com/hakancelik96/unimport --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 47032d30..f548d91e 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -134,5 +134,5 @@ - https://github.com/hcodes/yaspeller - https://github.com/maltzj/google-style-precommit-hook - https://github.com/jvstein/pre-commit-dotnet-format -- https://github.com/hakancelik96/unimport +# - https://github.com/hakancelik96/unimport - https://github.com/PeterMosmans/jenkinslint From f905fef1a51a17aa6ab4ec7601db7111f2327ca0 Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Thu, 23 Jul 2020 11:31:03 -0500 Subject: [PATCH 371/854] docs: add swiftformat hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index f548d91e..18910d51 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -136,3 +136,4 @@ - https://github.com/jvstein/pre-commit-dotnet-format # - https://github.com/hakancelik96/unimport - https://github.com/PeterMosmans/jenkinslint +- https://github.com/nicklockwood/SwiftFormat From 8e9d9d568c7434b2ed6c3caee6cae3ecf080cc14 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Mon, 27 Jul 2020 14:12:02 +0300 Subject: [PATCH 372/854] Add mdformat hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 18910d51..d66a660c 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -137,3 +137,4 @@ # - https://github.com/hakancelik96/unimport - https://github.com/PeterMosmans/jenkinslint - https://github.com/nicklockwood/SwiftFormat +- https://github.com/hukkinj1/mdformat From 364f5a0e6c91dfe96f5a10028d52cb5522bcfe89 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 27 Jul 2020 15:57:22 -0700 Subject: [PATCH 373/854] remove stray ` --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 88f06676..9e170acc 100644 --- a/index.mako +++ b/index.mako @@ -1142,7 +1142,7 @@ _new in 1.16.0_: pre-commit can be used to manage [prepare-commit-msg] hooks. To use `prepare-commit-msg` hooks with pre-commit, run: ```console -$ pre-commit install --hook-type prepare-commit-msg` +$ pre-commit install --hook-type prepare-commit-msg pre-commit installed at .git/hooks/prepare-commit-msg ``` From 82c71bb3fb117f70f2e3a5e4bb14aeeb4fca5643 Mon Sep 17 00:00:00 2001 From: Eagu Kim Date: Thu, 30 Jul 2020 11:03:22 +0900 Subject: [PATCH 374/854] Add a PHP hook for PHP Mess Detector at https://gitlab.com/daverona/pre-commit-php --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index d66a660c..d9f0b2e7 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -138,3 +138,4 @@ - https://github.com/PeterMosmans/jenkinslint - https://github.com/nicklockwood/SwiftFormat - https://github.com/hukkinj1/mdformat +- https://gitlab.com/daverona/pre-commit-php From 2ad45b6933ee6124472c3c9e30504c074ae35e8a Mon Sep 17 00:00:00 2001 From: Eagu Kim Date: Thu, 30 Jul 2020 12:08:02 +0900 Subject: [PATCH 375/854] Change repo addresses --- all-repos.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/all-repos.yaml b/all-repos.yaml index d9f0b2e7..65e360db 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -98,7 +98,7 @@ - https://github.com/myint/docformatter - https://github.com/lorenzwalthert/precommit - https://github.com/FelixSeptem/pre-commit-golang -- https://gitlab.com/daverona/pre-commit-cpp +- https://gitlab.com/daverona/pre-commit/cpp - https://github.com/codingjoe/relint - https://github.com/nix-community/nixpkgs-fmt - https://github.com/d6e/beancount-check @@ -138,4 +138,4 @@ - https://github.com/PeterMosmans/jenkinslint - https://github.com/nicklockwood/SwiftFormat - https://github.com/hukkinj1/mdformat -- https://gitlab.com/daverona/pre-commit-php +- https://gitlab.com/daverona/pre-commit/php From 4831adc319852f38b0d173b4b26f069000b530b1 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 10 Aug 2020 08:10:41 -0700 Subject: [PATCH 376/854] remove deprecated isort-related repos --- all-repos.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/all-repos.yaml b/all-repos.yaml index 65e360db..f5d946b6 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -20,7 +20,6 @@ - https://github.com/asottile/pyupgrade - https://github.com/asottile/reorder_python_imports - https://github.com/asottile/yesqa -- https://github.com/asottile/seed-isort-config - https://github.com/asottile/blacken-docs - https://github.com/asottile/dead - https://github.com/asottile/setup-cfg-fmt @@ -50,7 +49,6 @@ - https://github.com/doublify/pre-commit-clang-format - https://github.com/doublify/pre-commit-go - https://github.com/doublify/pre-commit-hindent -- https://github.com/doublify/pre-commit-isort - https://github.com/doublify/pre-commit-rust - https://github.com/kintoandar/pre-commit - https://github.com/awebdeveloper/pre-commit-stylelint From 5aa20aeda694cd5f044339ebb1ceca5637bcd103 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Wed, 12 Aug 2020 21:27:56 -0700 Subject: [PATCH 377/854] Update wording for uncommitted files in try-repo --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 9e170acc..afeeb964 100644 --- a/index.mako +++ b/index.mako @@ -493,7 +493,7 @@ _note_: you may need to provide `--commit-msg-filename` when using this command with hook types `prepare-commit-msg` and `commit-msg`. _new in 1.14.0_: a commit is no longer necessary to `try-repo` on a local -directory. `pre-commit` will clone any uncommitted changes. +directory. `pre-commit` will clone any tracked uncommitted changes. ```pre-commit ~/work/hook-repo $ git checkout origin/master -b feature From 3b3a6a3fda79c8963b1c4d349cd84132b61011e2 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 13 Aug 2020 22:28:53 -0700 Subject: [PATCH 378/854] Fix circleci example attribution --- index.mako | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.mako b/index.mako index afeeb964..c16fa5eb 100644 --- a/index.mako +++ b/index.mako @@ -1669,9 +1669,9 @@ immutable caches: - ~/.cache/pre-commit ``` -(source: [@chriselison]) +(source: [@chriselion]) -[@chriselison]: https://github.com/Unity-Technologies/ml-agents/pull/3094/files#diff-1d37e48f9ceff6d8030570cd36286a61 +[@chriselion]: https://github.com/Unity-Technologies/ml-agents/pull/3094/files#diff-1d37e48f9ceff6d8030570cd36286a61 ## Usage with tox From d6d0923740858234618f905b54c24011f9740d4e Mon Sep 17 00:00:00 2001 From: Peter Cock Date: Fri, 14 Aug 2020 21:39:42 +0100 Subject: [PATCH 379/854] Add doc8 and prospector --- all-repos.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/all-repos.yaml b/all-repos.yaml index f5d946b6..8053ddb1 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -76,6 +76,8 @@ - https://github.com/PyCQA/bandit - https://github.com/PyCQA/pydocstyle - https://github.com/PyCQA/pylint +- https://github.com/PyCQA/doc8 +- https://github.com/PyCQA/prospector - https://github.com/miki725/importanize - https://github.com/motet-a/jinjalint - https://github.com/milin/giticket From bbb417566222456191e83d3af69a90c184b02f2b Mon Sep 17 00:00:00 2001 From: Anders Eknert Date: Sun, 16 Aug 2020 00:25:36 +0200 Subject: [PATCH 380/854] Add pre-commit hooks for Open Policy Agent (OPA) --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 8053ddb1..2c9b25ee 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -139,3 +139,4 @@ - https://github.com/nicklockwood/SwiftFormat - https://github.com/hukkinj1/mdformat - https://gitlab.com/daverona/pre-commit/php +- https://github.com/anderseknert/pre-commit-opa From 21da0b1edda5e13e29110d61b16ae13f0f61b9e2 Mon Sep 17 00:00:00 2001 From: Laurent Sorber Date: Mon, 17 Aug 2020 12:44:54 +0200 Subject: [PATCH 381/854] Add auto Jira smart commit --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 2c9b25ee..e9ec8195 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -140,3 +140,4 @@ - https://github.com/hukkinj1/mdformat - https://gitlab.com/daverona/pre-commit/php - https://github.com/anderseknert/pre-commit-opa +- https://github.com/radix-ai/auto-smart-commit From 19270ff94ea18ad75aa0a1050fdb39e4700377d4 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Thu, 20 Aug 2020 17:47:37 -0700 Subject: [PATCH 382/854] Add autoflake repo to hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index e9ec8195..5909dbd5 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -141,3 +141,4 @@ - https://gitlab.com/daverona/pre-commit/php - https://github.com/anderseknert/pre-commit-opa - https://github.com/radix-ai/auto-smart-commit +- https://github.com/myint/autoflake From d0ac417df11d8f711c05874a5fa1c4849a373af6 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 20 Aug 2020 21:01:08 -0700 Subject: [PATCH 383/854] put myint repos together --- all-repos.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/all-repos.yaml b/all-repos.yaml index 5909dbd5..43718d23 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -96,6 +96,8 @@ - https://github.com/seddonym/import-linter - https://github.com/marco-c/taskcluster_yml_validator - https://github.com/myint/docformatter +- https://github.com/myint/rstcheck +- https://github.com/myint/autoflake - https://github.com/lorenzwalthert/precommit - https://github.com/FelixSeptem/pre-commit-golang - https://gitlab.com/daverona/pre-commit/cpp @@ -130,7 +132,6 @@ - https://github.com/jazzband/pip-tools - https://github.com/pappasam/toml-sort - https://github.com/arenadotio/pre-commit-ocamlformat -- https://github.com/myint/rstcheck - https://github.com/hcodes/yaspeller - https://github.com/maltzj/google-style-precommit-hook - https://github.com/jvstein/pre-commit-dotnet-format @@ -141,4 +142,3 @@ - https://gitlab.com/daverona/pre-commit/php - https://github.com/anderseknert/pre-commit-opa - https://github.com/radix-ai/auto-smart-commit -- https://github.com/myint/autoflake From 37d60aaf4c883fbca2b0d3333f9cfdc40239ed2c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 21 Aug 2020 21:40:05 -0400 Subject: [PATCH 384/854] docs: update hook-stage description --- index.mako | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.mako b/index.mako index c16fa5eb..62d3345a 100644 --- a/index.mako +++ b/index.mako @@ -950,6 +950,7 @@ Options: between `FROM_REF...TO_REF` in git. - _new in 2.2.0_: prior to 2.2.0 the arguments were `--source` and `--origin`. +- `--hook-stage STAGE`: select a [`stage` to run](#confining-hooks-to-run-at-certain-stages). - `--show-diff-on-failure`: when hooks fail, run `git diff` directly afterward. - `-v`, `--verbose`: produce hook output independent of success. Include hook ids in output. @@ -1198,7 +1199,7 @@ Since the [`default_stages`](#top_level-default_stages) top level configuration `.pre-commit-config.yaml` file is set to all stages by default, when installing hooks using the `-t`/`--hook-type` option (see [pre-commit install [options]](#pre-commit-install)), all hooks will be installed by default -to run at the stage defined through that option. for instance, +to run at the stage defined through that option. For instance, `pre-commit install --hook-type pre-push` will install by default all hooks to run at the `push` stage. @@ -1215,7 +1216,7 @@ _new in 1.8.0_: An additional `manual` stage is available for one off execution that won't run in any hook context. This special stage is useful for taking advantage of `pre-commit`'s cross-platform / cross-language package management without running it on every commit. Hooks confined to `stages: [manual]` can -be executed by running `pre-commit run --hook-stage manual `. +be executed by running `pre-commit run --hook-stage manual [hookid]`. ## Passing arguments to hooks From c93961d4f941bf3679c9ab96329cd532c56d730f Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Sat, 22 Aug 2020 11:52:20 -0700 Subject: [PATCH 385/854] Change example to use modern flake8 hook The hook that this project is referring to was removed. It's best to point people to the newer flake8 repo and a modern version. --- index.mako | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.mako b/index.mako index 62d3345a..f3ff6429 100644 --- a/index.mako +++ b/index.mako @@ -1225,8 +1225,8 @@ arguments by specifying the [`args`](#config-args) property in your `.pre-commit as follows: ```yaml -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v1.2.3 +- repo: https://gitlab.com/PyCQA/flake8 + rev: 3.8.3 hooks: - id: flake8 args: [--max-line-length=131] From 621f9e38bc36e3c8f61f68f013785a6daf67b3bc Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 2 Sep 2020 09:16:23 -0700 Subject: [PATCH 386/854] fix stray bracket --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index f3ff6429..45100ab8 100644 --- a/index.mako +++ b/index.mako @@ -800,7 +800,7 @@ Options: - `--bleeding-edge`: update to the bleeding edge of the default branch instead of the latest tagged version (the default behaviour). -- `--freeze`: _new in 1.21.0_): Store "frozen" hashes in [`rev`](#repos-rev) +- `--freeze`: _new in 1.21.0_: Store "frozen" hashes in [`rev`](#repos-rev) instead of tag names. - `--repo REPO`: _new in 1.4.1_: Only update this repository. _new in 1.7.0_: This option may be specified multiple times. From 5190e5304afc3baddf1a4b42e1268b663a9d1a6c Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 5 Sep 2020 14:38:03 -0700 Subject: [PATCH 387/854] fix origin.HEAD, that's not a thing --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 45100ab8..1fced3b5 100644 --- a/index.mako +++ b/index.mako @@ -1560,7 +1560,7 @@ pre-commit can also be used as a tool for continuous integration. For instance, adding `pre-commit run --all-files` as a CI step will ensure everything stays in tip-top shape. To check only files which have changed, which may be faster, use something like -`pre-commit run --from-ref origin.HEAD --to-ref HEAD` +`pre-commit run --from-ref origin/HEAD --to-ref HEAD` ## Managing CI Caches From 66f5b49a76be8a63f94d1406e7d6ec0c64b28e0d Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen Date: Tue, 15 Sep 2020 22:52:05 +0300 Subject: [PATCH 388/854] Update mdformat repository owner --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 43718d23..651185b7 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -138,7 +138,7 @@ # - https://github.com/hakancelik96/unimport - https://github.com/PeterMosmans/jenkinslint - https://github.com/nicklockwood/SwiftFormat -- https://github.com/hukkinj1/mdformat +- https://github.com/executablebooks/mdformat - https://gitlab.com/daverona/pre-commit/php - https://github.com/anderseknert/pre-commit-opa - https://github.com/radix-ai/auto-smart-commit From e0bea46827c3ec39c87691a5becfd4084560292b Mon Sep 17 00:00:00 2001 From: vinay karanam Date: Sat, 19 Sep 2020 17:39:38 +0530 Subject: [PATCH 389/854] Added curlylint to all-repos.yaml --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 651185b7..848dfcda 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -142,3 +142,4 @@ - https://gitlab.com/daverona/pre-commit/php - https://github.com/anderseknert/pre-commit-opa - https://github.com/radix-ai/auto-smart-commit +- https://github.com/thibaudcolas/curlylint From 3757529a0b697c3b24cbbc7381da777c35893cdd Mon Sep 17 00:00:00 2001 From: Raphael Boidol Date: Tue, 22 Sep 2020 22:50:55 +0200 Subject: [PATCH 390/854] Document `stages` for new hooks --- index.mako | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.mako b/index.mako index 1fced3b5..849b09dd 100644 --- a/index.mako +++ b/index.mako @@ -465,6 +465,12 @@ file that tells pre-commit: =r= =c= [`args`](_#hooks-args) =c= (optional: default `[]`) list of additional parameters to pass to the hook. +=r= + =c= [`stages`](_#hooks-stages) + =c= (optional: default (all stages)) confines the hook to the `commit`, `merge-commit`, + `push`, `prepare-commit-msg`, `commit-msg`, `post-checkout`, `post-commit`, or + `manual` stage. See + [Confining hooks to run at certain stages](#confining-hooks-to-run-at-certain-stages). ``` From b560190cd99dec8decbbbbef9c44e1e8e58b1a25 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 23 Sep 2020 09:16:39 -0700 Subject: [PATCH 391/854] Adds cmake-format-precommit to list of all_repos Adds the offiical cmake-format-precommit hook to the list of repos. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 848dfcda..691a78b5 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -143,3 +143,4 @@ - https://github.com/anderseknert/pre-commit-opa - https://github.com/radix-ai/auto-smart-commit - https://github.com/thibaudcolas/curlylint +- https://github.com/cheshirekow/cmake-format-precommit From 94028ea5fbc14eaf5c210544ae3ea17a6ffd3cb1 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 23 Sep 2020 13:03:16 -0400 Subject: [PATCH 392/854] Remove outdated pre-commit hook Remove outdated pre-commit hook --- all-repos.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 691a78b5..8d14f6f8 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -104,7 +104,6 @@ - https://github.com/codingjoe/relint - https://github.com/nix-community/nixpkgs-fmt - https://github.com/d6e/beancount-check -- https://github.com/iconmaster5326/cmake-format-pre-commit-hook # - https://github.com/thg-consulting/inspectortiger - https://gitlab.com/iamlikeme/nbhooks - https://github.com/Kuniwak/vint From 8ed00c9e311913f2dde070baab5ba814f3be1f5e Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 23 Sep 2020 19:16:32 -0700 Subject: [PATCH 393/854] chriskuehl/identify was moved into pre-commit! --- index.mako | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.mako b/index.mako index 849b09dd..4a279d6e 100644 --- a/index.mako +++ b/index.mako @@ -1400,7 +1400,7 @@ with `files`. `types` is specified per hook as an array of tags. The tags are discovered through a set of heuristics by the -[identify](https://github.com/chriskuehl/identify) library. `identify` was +[identify](https://github.com/pre-commit/identify) library. `identify` was chosen as it is a small portable pure python library. Some of the common tags you'll find from identify: @@ -1411,8 +1411,8 @@ Some of the common tags you'll find from identify: - `executable` - whether the file has the executable bit set - `text` - whether the file looks like a text file - `binary` - whether the file looks like a binary file -- [tags by extension / naming convention](https://github.com/chriskuehl/identify/blob/master/identify/extensions.py) -- [tags by shebang (`#!`)](https://github.com/chriskuehl/identify/blob/master/identify/interpreters.py) +- [tags by extension / naming convention](https://github.com/pre-commit/identify/blob/master/identify/extensions.py) +- [tags by shebang (`#!`)](https://github.com/pre-commit/identify/blob/master/identify/interpreters.py) To discover the type of any file on disk, you can use `identify`'s cli: @@ -1426,7 +1426,7 @@ $ identify-cli --filename-only some-random-file; echo $? ``` If a file extension you use is not supported, please -[submit a pull request](https://github.com/chriskuehl/identify)! +[submit a pull request](https://github.com/pre-commit/identify)! `types` and `files` are evaluated with `AND` when filtering. Tags within `types` are also evaluated using `AND`. From 75fe0527b2d12d157183171baf6de60b012c6854 Mon Sep 17 00:00:00 2001 From: Altynbek Orumbayev Date: Thu, 24 Sep 2020 21:59:42 +0200 Subject: [PATCH 394/854] Adds pydantic to schema hook --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 8d14f6f8..d63ffe74 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -143,3 +143,4 @@ - https://github.com/radix-ai/auto-smart-commit - https://github.com/thibaudcolas/curlylint - https://github.com/cheshirekow/cmake-format-precommit +- https://github.com/aorumbayev/pydantic-to-schema From aae2fe5813fe68b5058100beabc28837654ee222 Mon Sep 17 00:00:00 2001 From: Ethan Glasser-Camp Date: Fri, 25 Sep 2020 17:33:42 -0400 Subject: [PATCH 395/854] Use the "literal" block style instead of the "folded" one Verbose regular expressions allow comments, but if we use "folded" multiline strings, then the comment will also comment out the remainder of the regular expression. --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 4a279d6e..4846c355 100644 --- a/index.mako +++ b/index.mako @@ -1477,7 +1477,7 @@ the `(?x)` regex flag. ```yaml # ... - id: my-hook - exclude: > + exclude: | (?x)^( path/to/file1.py| path/to/file2.py| From 1216c60abf000dffda6948e22236a24b79c65fc5 Mon Sep 17 00:00:00 2001 From: Ruairidh MacLeod Date: Sun, 27 Sep 2020 23:11:34 +0000 Subject: [PATCH 396/854] add dotnet language entry --- index.mako | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.mako b/index.mako index 4846c355..973f22dd 100644 --- a/index.mako +++ b/index.mako @@ -534,6 +534,7 @@ Hello from foo hook! - [conda](#conda) - [docker](#docker) - [docker_image](#docker_image) +- [dotnet](#dotnet) - [fail](#fail) - [golang](#golang) - [node](#node) @@ -615,6 +616,16 @@ For example: entry: my.registry.example.com/docker-image-3:latest my-exe ``` +### dotnet + +_new in 2.8.0_ + +dotnet hooks are installed using the system installation of the dotnet CLI. + +Hook repositories must contain a dotnet CLI tool which can be `pack`ed and `install`ed as per [this](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools-how-to-create) example. The `entry` should match an executable created by building the repository. Additional dependencies are not currently supported. + +__Support:__ dotnet hooks are known to work on any system which has the dotnet CLI installed. It has been tested on linux and windows. + ### fail _new in 1.11.0_ From 4cd6054766ce2c05a2e70530a1fed49a8c2ead92 Mon Sep 17 00:00:00 2001 From: Hadi Zaki Alqattan Date: Sat, 3 Oct 2020 20:28:35 +0300 Subject: [PATCH 397/854] Add pycln to the list of hook repos. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index d63ffe74..57fd5bbd 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -144,3 +144,4 @@ - https://github.com/thibaudcolas/curlylint - https://github.com/cheshirekow/cmake-format-precommit - https://github.com/aorumbayev/pydantic-to-schema +- https://github.com/hadialqattan/pycln From be6409390467bf82d08c4a7367ec55f3ec5a28f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Mond=C3=A9jar?= Date: Wed, 7 Oct 2020 10:40:03 +0200 Subject: [PATCH 398/854] Update isort repository link --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index 57fd5bbd..06e8691f 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -88,7 +88,7 @@ - https://github.com/syntaqx/git-hooks - https://github.com/Calinou/pre-commit-luacheck - https://github.com/belminf/pre-commit-chef -- https://github.com/timothycrosley/isort +- https://github.com/PyCQA/isort - https://github.com/pocc/pre-commit-hooks - https://github.com/dwightgunning/pre-commit-nglint - https://github.com/codespell-project/codespell From 39dfd9077ae4a69e652611a014a3e229ac0456cc Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 9 Oct 2020 15:01:26 +0100 Subject: [PATCH 399/854] Add nbQA to list of hooks --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 06e8691f..b84adcb8 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -145,3 +145,4 @@ - https://github.com/cheshirekow/cmake-format-precommit - https://github.com/aorumbayev/pydantic-to-schema - https://github.com/hadialqattan/pycln +- https://github.com/nbQA-dev/nbQA From b5ad0c983b115757e920ca373ae49d8766809ca2 Mon Sep 17 00:00:00 2001 From: erfannariman Date: Wed, 7 Oct 2020 23:43:45 +0200 Subject: [PATCH 400/854] add explanation about local hook and arguments --- index.mako | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 4846c355..c048cb26 100644 --- a/index.mako +++ b/index.mako @@ -444,7 +444,7 @@ file that tells pre-commit: the hook passes. _new in 1.6.0_. =r= =c= [`pass_filenames`](_#hooks-pass_filenames) - =c= (optional: default `true`) if `false` no arguments will be passed to + =c= (optional: default `true`) if `false` no filenames will be passed to the hook. =r= =c= [`require_serial`](_#hooks-require_serial) @@ -1267,6 +1267,22 @@ If the [`args`](#config-args) property is empty or not defined, your script will path/to/script-or-system-exe dir/file1 dir/file2 file3 ``` +When creating local hooks, there's no reason to put command arguments +into [`args`](#config-args) as there is nothing which can override them -- +instead put your arguments directly in the hook [`entry`](#hooks-entry). + +For example: + +```yaml +- repo: local + hooks: + - id: check-requirements + name: check requirements files + language: system + entry: python -m scripts.check_requirements --compare + files: ^requirements.*.txt$ +``` + ## Repository local hooks Repository-local hooks are useful when: From 5fe33f5c9def9d4d217f1b153bd18e05b5f768b6 Mon Sep 17 00:00:00 2001 From: Ruairidh MacLeod Date: Wed, 21 Oct 2020 15:56:52 +0100 Subject: [PATCH 401/854] Update prettier hook repo See https://github.com/prettier/prettier/issues/9459 --- all-repos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/all-repos.yaml b/all-repos.yaml index b84adcb8..42b750c0 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -54,7 +54,7 @@ - https://github.com/awebdeveloper/pre-commit-stylelint - https://github.com/awebdeveloper/pre-commit-tslint - https://github.com/awebdeveloper/pre-commit-prettier -- https://github.com/prettier/prettier +- https://github.com/prettier/pre-commit - https://github.com/adrienverge/yamllint - https://github.com/thlorenz/doctoc - https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook From ac59d040ece23238628790afe24cbaefe48ae6f8 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 28 Oct 2020 22:30:40 -0700 Subject: [PATCH 402/854] documentation updates for 2.8.0 --- base.mako | 2 +- index.mako | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/base.mako b/base.mako index 640d2add..c238a9e1 100644 --- a/base.mako +++ b/base.mako @@ -46,7 +46,7 @@

      A framework for managing and maintaining multi-language pre-commit hooks.

      Build Status Azure DevOps Coverage -pre-commit

      +pre-commit.ci status

      diff --git a/index.mako b/index.mako index e6d2aecc..73113cf1 100644 --- a/index.mako +++ b/index.mako @@ -77,6 +77,14 @@ requirements-dev.txt): pre-commit ``` +As a 0-dependency [zipapp]: + +- locate and download the `.pyz` file from the [github releases] +- run `python pre-commit-#.#.#.pyz ...` in place of `pre-commit ...` + +[zipapp]: https://docs.python.org/3/library/zipapp.html +[github releases]: https://github.com/pre-commit/pre-commit/releases + Using [homebrew](https://brew.sh): ```bash @@ -532,6 +540,7 @@ Hello from foo hook! ## Supported languages - [conda](#conda) +- [coursier](#coursier) - [docker](#docker) - [docker_image](#docker_image) - [dotnet](#dotnet) @@ -563,6 +572,13 @@ __Support:__ `conda` hooks work as long as there is a system-installed `conda` binary (such as [`miniconda`](https://docs.conda.io/en/latest/miniconda.html)). It has been tested on linux, macOS, and windows. +### coursier + +_new in 2.8.0_ + +__Support:__ `coursier` hooks are known to work on any system which has the `cs` +package manager installed. It has been tested on linux. + ### docker The hook repository must have a `Dockerfile`. It will be installed via @@ -622,9 +638,13 @@ _new in 2.8.0_ dotnet hooks are installed using the system installation of the dotnet CLI. -Hook repositories must contain a dotnet CLI tool which can be `pack`ed and `install`ed as per [this](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools-how-to-create) example. The `entry` should match an executable created by building the repository. Additional dependencies are not currently supported. +Hook repositories must contain a dotnet CLI tool which can be `pack`ed and +`install`ed as per [this](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools-how-to-create) +example. The `entry` should match an executable created by building the +repository. Additional dependencies are not currently supported. -__Support:__ dotnet hooks are known to work on any system which has the dotnet CLI installed. It has been tested on linux and windows. +__Support:__ dotnet hooks are known to work on any system which has the dotnet +CLI installed. It has been tested on linux and windows. ### fail @@ -770,6 +790,7 @@ the regex as the [`entry`](#hooks-entry). The [`entry`](#hooks-entry) may be an can apply the `(?i)` flag as the start of your entry, or use `args: [-i]`. _new in 1.8.0_: For multiline matches, use `args: [--multiline]`. +_new in 2.8.0_: To require all files to match, use `args: [--negate]`. __Support:__ pygrep hooks are supported on all platforms which pre-commit runs on. @@ -809,6 +830,11 @@ All pre-commit commands take the following options: - `-c CONFIG`, `--config CONFIG`: path to alternate config file - `-h`, `--help`: show help and available options. +_new in 2.8.0_: `pre-commit` now exits with more specific codes: +- `1`: a detected / expected error +- `3`: an unexpected error +- `130`: the process was interrupted by `^C` + ## pre-commit autoupdate [options] [](#pre-commit-autoupdate) Auto-update pre-commit config to the latest repos' versions. From 58b6eab84de1cddb5b227125d909b7bf5aa01d72 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 28 Oct 2020 22:59:41 -0700 Subject: [PATCH 403/854] replace azure pipelines with pre-commit.ci --- README.md | 2 +- azure-pipelines.yml | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 azure-pipelines.yml diff --git a/README.md b/README.md index 99c0da9a..4942a13b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ pre-commit.com ============== -[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/pre-commit.pre-commit.com?branchName=master)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=64&branchName=master) +[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pre-commit/pre-commit.com/master.svg)](https://results.pre-commit.ci/latest/github/pre-commit/pre-commit.com/master) [![Build Status](https://github.com/pre-commit/pre-commit.com/workflows/deploy/badge.svg)](https://github.com/pre-commit/pre-commit.com/actions) This powers https://pre-commit.com diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 416cca42..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,16 +0,0 @@ -trigger: - branches: - include: [master, test-me-*] - tags: - include: ['*'] - -resources: - repositories: - - repository: asottile - type: github - endpoint: github - name: asottile/azure-pipeline-templates - ref: refs/tags/v1.0.0 - -jobs: -- template: job--pre-commit.yml@asottile From 2b27fa34aace7e1d5375af6a86f7f90ad056c122 Mon Sep 17 00:00:00 2001 From: Tomer Date: Fri, 30 Oct 2020 15:39:30 +0200 Subject: [PATCH 404/854] Add godot gdscript toolkit to hooks list --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 42b750c0..de921d82 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -146,3 +146,4 @@ - https://github.com/aorumbayev/pydantic-to-schema - https://github.com/hadialqattan/pycln - https://github.com/nbQA-dev/nbQA +- https://github.com/Scony/godot-gdscript-toolkit From ddadd113023258d424cb35ff3aadd1953e8df650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Avila?= Date: Mon, 2 Nov 2020 10:18:14 -0300 Subject: [PATCH 405/854] Add add-msg-issue-preffix-hook to supported The hook searches the current branch for something looking like a jira issue and prepends the commit message. It is a prepare-commit-msg hook. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index de921d82..47513395 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -147,3 +147,4 @@ - https://github.com/hadialqattan/pycln - https://github.com/nbQA-dev/nbQA - https://github.com/Scony/godot-gdscript-toolkit +- https://github.com/avilaton/add-msg-issue-prefix-hook From c3e0216adeccaeae23f34e0ec63a1df23a0df61f Mon Sep 17 00:00:00 2001 From: Dustin Shimono <5289+dustinsand@users.noreply.github.com> Date: Mon, 2 Nov 2020 17:13:45 -0500 Subject: [PATCH 406/854] add repo to JVM hooks Currently contains one hook to run Detekt on Kotlin source files. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 47513395..f74cc524 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -148,3 +148,4 @@ - https://github.com/nbQA-dev/nbQA - https://github.com/Scony/godot-gdscript-toolkit - https://github.com/avilaton/add-msg-issue-prefix-hook +- https://github.com/dustinsand/pre-commit-jvm From e1ff2468ea81b3d49cc2449c172702bd403b2d9e Mon Sep 17 00:00:00 2001 From: Joseph Moniz Date: Fri, 6 Nov 2020 10:40:55 -0500 Subject: [PATCH 407/854] first pass at coursier doc --- index.mako | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 73113cf1..cfce8a9b 100644 --- a/index.mako +++ b/index.mako @@ -576,8 +576,17 @@ It has been tested on linux, macOS, and windows. _new in 2.8.0_ +The hook repository muist have a `.pre-commit-channel` folder and that folder must contain +the coursier +[application descriptors](https://get-coursier.io/docs/2.0.0-RC6-10/cli-install.html#application-descriptor-reference) +for the hook to install. For configuring coursier hooks, your +[`entry`](#hooks-entry) should correspond to an executable installed from the +repositories `.pre-commit-channel` folder. + __Support:__ `coursier` hooks are known to work on any system which has the `cs` -package manager installed. It has been tested on linux. +package manager installed. The specific coursier applications you install may depend +on various versions of the JVM, consult the hooks documentation for clarificaiton. +This integration has been tested on linus ### docker From d7edd1aaf63afbc538c556597bdb5803005107aa Mon Sep 17 00:00:00 2001 From: Christian Knittl-Frank Date: Fri, 6 Nov 2020 18:18:51 +0100 Subject: [PATCH 408/854] Add CleverCSV to list of repos This PR adds the CleverCSV mirror repository --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index f74cc524..c2f4d5bd 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -149,3 +149,4 @@ - https://github.com/Scony/godot-gdscript-toolkit - https://github.com/avilaton/add-msg-issue-prefix-hook - https://github.com/dustinsand/pre-commit-jvm +- https://github.com/alan-turing-institute/CleverCSV-pre-commit From 599d0bd765b8b461f92b85dfc9a29a34e0928ada Mon Sep 17 00:00:00 2001 From: Joseph Date: Fri, 6 Nov 2020 13:04:50 -0500 Subject: [PATCH 409/854] Apply suggestions from code review Co-authored-by: Anthony Sottile --- index.mako | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.mako b/index.mako index cfce8a9b..6c7537c9 100644 --- a/index.mako +++ b/index.mako @@ -576,17 +576,17 @@ It has been tested on linux, macOS, and windows. _new in 2.8.0_ -The hook repository muist have a `.pre-commit-channel` folder and that folder must contain +The hook repository must have a `.pre-commit-channel` folder and that folder must contain the coursier [application descriptors](https://get-coursier.io/docs/2.0.0-RC6-10/cli-install.html#application-descriptor-reference) for the hook to install. For configuring coursier hooks, your [`entry`](#hooks-entry) should correspond to an executable installed from the -repositories `.pre-commit-channel` folder. +repository's `.pre-commit-channel` folder. __Support:__ `coursier` hooks are known to work on any system which has the `cs` package manager installed. The specific coursier applications you install may depend -on various versions of the JVM, consult the hooks documentation for clarificaiton. -This integration has been tested on linus +on various versions of the JVM, consult the hooks' documentation for clarification. +It has been tested on linux. ### docker From 577c868379b4c5bb6df99ace6c7b38210d9e8405 Mon Sep 17 00:00:00 2001 From: joshvernon Date: Fri, 6 Nov 2020 19:41:01 -0600 Subject: [PATCH 410/854] Add elixir-pre-commit-hooks to all_repos.yaml --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index c2f4d5bd..7ec60fbe 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -150,3 +150,4 @@ - https://github.com/avilaton/add-msg-issue-prefix-hook - https://github.com/dustinsand/pre-commit-jvm - https://github.com/alan-turing-institute/CleverCSV-pre-commit +- https://gitlab.com/jvenom/elixir-pre-commit-hooks From 8cbd8da9409f3f277c6689abd0e4242db67cc67e Mon Sep 17 00:00:00 2001 From: Milind Shakya Date: Sun, 8 Nov 2020 19:12:22 -0500 Subject: [PATCH 411/854] Add gitown --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 7ec60fbe..4bdf8867 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -81,6 +81,7 @@ - https://github.com/miki725/importanize - https://github.com/motet-a/jinjalint - https://github.com/milin/giticket +- https://github.com/milin/gitown - https://github.com/sqlalchemyorg/zimports - https://github.com/peterdemin/pip-compile-multi - https://github.com/homebysix/pre-commit-macadmin From d550016665ca3d93633e22ec026a4041ffd4202e Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 15 Nov 2020 10:04:35 -0800 Subject: [PATCH 412/854] Use pre-commit's mirrors-prettier --- all-repos.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/all-repos.yaml b/all-repos.yaml index 4bdf8867..dd88399b 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -7,6 +7,7 @@ - https://github.com/pre-commit/mirrors-fixmyjs - https://github.com/pre-commit/mirrors-jshint - https://github.com/pre-commit/mirrors-mypy +- https://github.com/pre-commit/mirrors-prettier - https://github.com/pre-commit/mirrors-puppet-lint - https://github.com/pre-commit/mirrors-ruby-lint - https://github.com/pre-commit/mirrors-scss-lint @@ -53,8 +54,6 @@ - https://github.com/kintoandar/pre-commit - https://github.com/awebdeveloper/pre-commit-stylelint - https://github.com/awebdeveloper/pre-commit-tslint -- https://github.com/awebdeveloper/pre-commit-prettier -- https://github.com/prettier/pre-commit - https://github.com/adrienverge/yamllint - https://github.com/thlorenz/doctoc - https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook From 7e50c081cfd9d6caadfc67fc24ca853109fe1c3f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2020 17:07:34 +0000 Subject: [PATCH 413/854] [pre-commit.ci] pre-commit autoupdate --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 186801ac..50775fd3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,21 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.5.0 + rev: v3.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: debug-statements - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.0 + rev: 3.8.4 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v1.5.2 + rev: v1.5.4 hooks: - id: autopep8 - repo: https://github.com/asottile/reorder_python_imports - rev: v2.3.0 + rev: v2.3.6 hooks: - id: reorder-python-imports args: [--py36-plus] @@ -23,7 +23,7 @@ repos: - id: reorder-python-imports files: install-local.py - repo: https://github.com/asottile/pyupgrade - rev: v2.4.1 + rev: v2.7.4 hooks: - id: pyupgrade args: [--py36-plus] @@ -35,11 +35,11 @@ repos: hooks: - id: add-trailing-comma - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.770 + rev: v0.790 hooks: - id: mypy - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.0.0 + rev: v7.13.0-1 hooks: - id: eslint args: [--fix] From 2d85a86a97748b49626704ea08c4a5bea571734e Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 19 Nov 2020 17:13:21 -0800 Subject: [PATCH 414/854] Add link to GitHub Sponsors + Open Collective at the time of writing I am currently unemployed. I'd love to make open source a full time career. if you or your company is deriving value from this free software, please consider [sponsoring] or [supporting]. [sponsoring]: https://github.com/sponsors/asottile [supporting]: https://opencollective.com/pre-commit Committed via https://github.com/asottile/all-repos --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..9408e44d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: asottile +open_collective: pre-commit From 46b512610fd2d8fbefab7c2526fe654059969cfc Mon Sep 17 00:00:00 2001 From: Serge Matveenko Date: Fri, 20 Nov 2020 19:27:57 +0300 Subject: [PATCH 415/854] Add some Dart/Flutter related hooks to `all-repos.yaml` --- all-repos.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/all-repos.yaml b/all-repos.yaml index dd88399b..3b9a24a8 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -151,3 +151,6 @@ - https://github.com/dustinsand/pre-commit-jvm - https://github.com/alan-turing-institute/CleverCSV-pre-commit - https://gitlab.com/jvenom/elixir-pre-commit-hooks +- https://github.com/Cretezy/flutter-format-pre-commit +- https://github.com/dluksza/flutter-analyze-pre-commit +- https://github.com/fluttercommunity/import_sorter From 424a1228f90766622500fd8365d03678f1b0d9a6 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 20 Nov 2020 13:06:59 -0800 Subject: [PATCH 416/854] upgrade mistune to 2.x --- index.mako | 22 +++++++++++----------- requirements-dev.txt | 4 +--- template_lib.py | 27 ++++++++++++++------------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/index.mako b/index.mako index 6c7537c9..051ac94b 100644 --- a/index.mako +++ b/index.mako @@ -844,7 +844,7 @@ _new in 2.8.0_: `pre-commit` now exits with more specific codes: - `3`: an unexpected error - `130`: the process was interrupted by `^C` -## pre-commit autoupdate [options] [](#pre-commit-autoupdate) +## pre-commit autoupdate [options] #pre-commit-autoupdate Auto-update pre-commit config to the latest repos' versions. @@ -901,13 +901,13 @@ $ grep rev: .pre-commit-config.yaml rev: 34a269fd7650d264e4de7603157c10d0a9bb8211 # frozen: v1.25.2 ``` -## pre-commit clean [options] [](#pre-commit-clean) +## pre-commit clean [options] #pre-commit-clean Clean out cached pre-commit files. Options: (no additional options) -## pre-commit gc [options] [](#pre-commit-gc) +## pre-commit gc [options] #pre-commit-gc _new in 1.14.0_ @@ -919,7 +919,7 @@ the cache directory. Options: (no additional options) -## pre-commit init-templatedir DIRECTORY [options] [](#pre-commit-init-templatedir) +## pre-commit init-templatedir DIRECTORY [options] #pre-commit-init-templatedir _new in 1.18.0_ @@ -942,7 +942,7 @@ pre-commit init-templatedir ~/.git-template Now whenever a repository is cloned or created, it will have the hooks set up already! -## pre-commit install [options] [](#pre-commit-install) +## pre-commit install [options] #pre-commit-install Install the pre-commit script. @@ -967,7 +967,7 @@ Some example useful invocations: existing git hook scripts with pre-commit, and also installs hook environments. -## pre-commit install-hooks [options] [](#pre-commit-install-hooks) +## pre-commit install-hooks [options] #pre-commit-install-hooks Install all missing environments for the available hooks. Unless this command or `install --install-hooks` is executed, each hook's environment is created the @@ -981,7 +981,7 @@ the hook environments in one command, use `pre-commit install --install-hooks`. Options: (no additional options) -## pre-commit migrate-config [options] [](#pre-commit-migrate-config) +## pre-commit migrate-config [options] #pre-commit-migrate-config _new in 1.0.0_ @@ -989,7 +989,7 @@ Migrate list configuration to the new map configuration format. Options: (no additional options) -## pre-commit run [hook-id] [options] [](#pre-commit-run) +## pre-commit run [hook-id] [options] #pre-commit-run Run hooks. @@ -1019,13 +1019,13 @@ Some example useful invocations: have changed between `HEAD^^^` and `HEAD`. This form is useful when leveraged in a pre-receive hook. -## pre-commit sample-config [options] [](#pre-commit-sample-config) +## pre-commit sample-config [options] #pre-commit-sample-config Produce a sample `.pre-commit-config.yaml`. Options: (no additional options) -## pre-commit try-repo REPO [options] [](#pre-commit-try-repo) +## pre-commit try-repo REPO [options] #pre-commit-try-repo _new in 1.3.0_ @@ -1053,7 +1053,7 @@ Some example useful invocations: - See [`pre-commit run`](#pre-commit-run) for more useful `run` invocations which are also supported by `pre-commit try-repo`. -## pre-commit uninstall [options] [](#pre-commit-uninstall) +## pre-commit uninstall [options] #pre-commit-uninstall Uninstall the pre-commit script. diff --git a/requirements-dev.txt b/requirements-dev.txt index 2f9cb64c..928973ba 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,6 @@ mako libsass -markdown-code-blocks +markdown-code-blocks>=3.0.0 markdown-to-presentation>=0.0.12 -# remove once merged and release -git+https://github.com/lepture/mistune@449c2b5 pre-commit>=1.21.0 pygments-pre-commit>=1.4.0 diff --git a/template_lib.py b/template_lib.py index dfb0a692..1ddabf66 100644 --- a/template_lib.py +++ b/template_lib.py @@ -9,7 +9,7 @@ import markupsafe -ID_RE = re.compile(r'\[\]\(#([a-z0-9-]+)\)') +ID_RE = re.compile(r' #([a-z0-9-]+)$') SPECIAL_CHARS_RE = re.compile('[^a-z0-9 _-]') @@ -94,16 +94,17 @@ def link( ) -> str: if link.startswith(SELF_LINK_PREFIX): a_id = link[len(SELF_LINK_PREFIX):] - return f'{title}' + return f'{text}' else: return super().link(link, text, title) - def header(self, text: str, level: int, raw: str) -> str: - match = ID_RE.search(raw) + def heading(self, text: str, level: int) -> str: + match = ID_RE.search(text) + text = ID_RE.sub('', text) if match: - h_id = match.group(1) + h_id = match[1] else: - h_id = SPECIAL_CHARS_RE.sub('', raw.lower()).replace(' ', '-') + h_id = SPECIAL_CHARS_RE.sub('', text.lower()).replace(' ', '-') return ( f'' f' {text} ' @@ -117,18 +118,18 @@ def codespan(self, text: str) -> str: else: return super().codespan(text) - def block_code(self, code: str, lang: Optional[str]) -> str: + def block_code(self, code: str, info: Optional[str] = None) -> str: copyable = False - if lang is not None: + if info is not None: copyable_s = '#copyable' - copyable = lang.endswith(copyable_s) - lang, _, _ = lang.partition(copyable_s) - if lang == 'table': + copyable = info.endswith(copyable_s) + info, _, _ = info.partition(copyable_s) + if info == 'table': ret = _render_table(code) - elif lang == 'cmd': + elif info == 'cmd': ret = _render_cmd(code) else: - ret = super().block_code(code, lang) + ret = super().block_code(code, info) if copyable: return f'

      {ret}
      ' else: From 48d64d424195f371f89d748c326e934e18f4d58a Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 20 Nov 2020 15:05:50 -0800 Subject: [PATCH 417/854] hide paragraph marker unless hovered --- scss/main.scss | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scss/main.scss b/scss/main.scss index 514a67f1..22838ffb 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -213,3 +213,15 @@ h1, display: block; } } + +h1, +h2, +h3 { + small { + display: none; + } + + &:hover small { + display: inline; + } +} From 5e5e8e787cbaa82ac949b6e5b4c0b3601c0109e5 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 21 Nov 2020 13:45:43 -0800 Subject: [PATCH 418/854] documentation updates for 2.9.0 --- index.mako | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/index.mako b/index.mako index 051ac94b..80d4e996 100644 --- a/index.mako +++ b/index.mako @@ -309,7 +309,11 @@ repository's configuration. =c= (optional) file exclude pattern. =r= =c= [`types`](_#config-types) - =c= (optional) override the default file types to run on. See + =c= (optional) override the default file types to run on (AND). See + [Filtering files with types](#filtering-files-with-types). +=r= + =c= [`types_or`](_#config-types_or) + =c= (optional) override the default file types to run on (OR). See [Filtering files with types](#filtering-files-with-types). =r= =c= [`exclude_types`](_#config-exclude_types) @@ -437,7 +441,11 @@ file that tells pre-commit: =c= (optional: default `^$`) exclude files that were matched by [`files`](#hooks-files). =r= =c= [`types`](_#hooks-types) - =c= (optional: default `[file]`) list of file types to run on. See + =c= (optional: default `[file]`) list of file types to run on (AND). See + [Filtering files with types](#filtering-files-with-types). +=r= + =c= [`types_or`](_#hooks-types_or) + =c= (optional: default `[file]`) list of file types to run on (OR). See [Filtering files with types](#filtering-files-with-types). =r= =c= [`exclude_types`](_#hooks-exclude_types) @@ -1490,8 +1498,9 @@ $ identify-cli --filename-only some-random-file; echo $? If a file extension you use is not supported, please [submit a pull request](https://github.com/pre-commit/identify)! -`types` and `files` are evaluated with `AND` when filtering. Tags within -`types` are also evaluated using `AND`. +`types`, `types_or`, and `files` are evaluated together with `AND` when +filtering. Tags within `types` are also evaluated using `AND`. +Tags within `types_or` are evaluated using `OR`. For example: @@ -1502,6 +1511,16 @@ For example: will match a file `foo/1.py` but will not match `setup.py`. +Another example: + +```yaml + files: ^foo/ + types_or: [javascript, jsx, ts, tsx] +``` + +will match any of `foo/bar.js` / `foo/bar.jsx` / `foo/bar.ts` / `foo/bar.tsx` +but not `baz.js`. + If you want to match a file path that isn't included in a `type` when using an existing hook you'll need to revert back to `files` only matching by overriding the `types` setting. Here's an example of using `check-json` against non-json @@ -1816,6 +1835,14 @@ forks / mirrors. Feel free to submit bug reports, pull requests, and feature requests. +## Sponsoring + +If you or your company would like to support the development of pre-commit one +can contribute in the following ways: + +- [GitHub Sponsors (asottile)](https://github.com/sponsors/asottile) +- [Open Collective](https://opencollective.com/pre-commit) + ## Getting help There are several ways to get help for pre-commit: From 7a28f1e6ad0e0fdaf68e1ec07cee06cf3631db74 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 21 Nov 2020 14:06:54 -0800 Subject: [PATCH 419/854] add the "new in" text for `types_or` --- index.mako | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 80d4e996..1e97fa87 100644 --- a/index.mako +++ b/index.mako @@ -315,6 +315,7 @@ repository's configuration. =c= [`types_or`](_#config-types_or) =c= (optional) override the default file types to run on (OR). See [Filtering files with types](#filtering-files-with-types). + _new in 2.9.0_. =r= =c= [`exclude_types`](_#config-exclude_types) =c= (optional) file types to exclude. @@ -447,6 +448,7 @@ file that tells pre-commit: =c= [`types_or`](_#hooks-types_or) =c= (optional: default `[file]`) list of file types to run on (OR). See [Filtering files with types](#filtering-files-with-types). + _new in 2.9.0_. =r= =c= [`exclude_types`](_#hooks-exclude_types) =c= (optional: default `[]`) exclude files that were matched by [`types`](#hooks-types). @@ -1500,7 +1502,8 @@ If a file extension you use is not supported, please `types`, `types_or`, and `files` are evaluated together with `AND` when filtering. Tags within `types` are also evaluated using `AND`. -Tags within `types_or` are evaluated using `OR`. + +_new in 2.9.0_: Tags within `types_or` are evaluated using `OR`. For example: From 3393589d6b68469bb4b271a3d7dbec0c756b27d6 Mon Sep 17 00:00:00 2001 From: Manuel Leonhardt Date: Sun, 22 Nov 2020 21:04:26 +0100 Subject: [PATCH 420/854] Add editorconfig-checker hooks repo editorconfig-checker is tool to verify that your files are in harmony with your .editorconfig. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 3b9a24a8..ed56705b 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -154,3 +154,4 @@ - https://github.com/Cretezy/flutter-format-pre-commit - https://github.com/dluksza/flutter-analyze-pre-commit - https://github.com/fluttercommunity/import_sorter +- https://github.com/editorconfig-checker/editorconfig-checker.python From 21b694a9e30e09636f61d24424545eb9adf0f4f4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Nov 2020 16:40:45 +0000 Subject: [PATCH 421/854] [pre-commit.ci] pre-commit autoupdate --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50775fd3..fe2b639f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: hooks: - id: mypy - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.13.0-1 + rev: v7.14.0 hooks: - id: eslint args: [--fix] From 85d3b7adf50232295bbe16304afae76c234ff7e6 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 25 Nov 2020 20:28:36 -0800 Subject: [PATCH 422/854] correct default for types_or (2.9.2) --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 1e97fa87..d80c6585 100644 --- a/index.mako +++ b/index.mako @@ -446,7 +446,7 @@ file that tells pre-commit: [Filtering files with types](#filtering-files-with-types). =r= =c= [`types_or`](_#hooks-types_or) - =c= (optional: default `[file]`) list of file types to run on (OR). See + =c= (optional: default `[]`) list of file types to run on (OR). See [Filtering files with types](#filtering-files-with-types). _new in 2.9.0_. =r= From ec8e42556183ff2c92aeb89a4fee92e246c46f08 Mon Sep 17 00:00:00 2001 From: Finn Bayer Date: Sun, 29 Nov 2020 00:52:55 +0100 Subject: [PATCH 423/854] added init-templatedir example windows cmd/ps added example which uses windows environment variables instead of the ~ --- index.mako | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.mako b/index.mako index d80c6585..271f6472 100644 --- a/index.mako +++ b/index.mako @@ -949,6 +949,18 @@ git config --global init.templateDir ~/.git-template pre-commit init-templatedir ~/.git-template ``` +For Windows cmd.exe use `%HOMEPATH%` instead of `~`: + +```batch +pre-commit init-templatedir %HOMEPATH%\.git-template +``` + +For Windows PowerShell use `$HOME` instead of `~`: + +```powershell +pre-commit init-templatedir $HOME\.git-template +``` + Now whenever a repository is cloned or created, it will have the hooks set up already! From a25c5346ff40627865c2b68bdceba3be5609870e Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Tue, 1 Dec 2020 23:41:58 +0700 Subject: [PATCH 424/854] Fix GitHub actions example Use set-output instead of set-env, since it is removed from GHA. --- index.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.mako b/index.mako index 271f6472..40fd073e 100644 --- a/index.mako +++ b/index.mako @@ -1729,7 +1729,7 @@ immutable caches: ```yaml - name: set PY - run: echo "::set-env name=PY::$(python -VV | sha256sum | cut -d' ' -f1)" + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - uses: actions/cache@v1 with: path: ~/.cache/pre-commit From 5d195c870ad08de4360fc478a6958e499dc89b44 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Dec 2020 20:30:37 +0000 Subject: [PATCH 425/854] [pre-commit.ci] pre-commit autoupdate --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fe2b639f..4dc20bdd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: hooks: - id: mypy - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.14.0 + rev: v7.15.0 hooks: - id: eslint args: [--fix] From 411e4031c81103670478d31aac9717975c406f9e Mon Sep 17 00:00:00 2001 From: Pablo Diehl Date: Thu, 10 Dec 2020 08:25:58 -0300 Subject: [PATCH 426/854] Add pre-commit-lua-formatter hook This commit adds a hook that runs LuaFormatter on Lua files. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index ed56705b..93a1d99b 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -155,3 +155,4 @@ - https://github.com/dluksza/flutter-analyze-pre-commit - https://github.com/fluttercommunity/import_sorter - https://github.com/editorconfig-checker/editorconfig-checker.python +- https://gitlab.com/pablodiehl/pre-commit-lua-formatter From 16dce8fbd4ce19d25ac8fc49f39b51084ef9ad67 Mon Sep 17 00:00:00 2001 From: Franco Masotti Date: Sat, 19 Dec 2020 17:45:07 +0100 Subject: [PATCH 427/854] Add md-toc hook. --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index 93a1d99b..a1cc8bef 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -156,3 +156,4 @@ - https://github.com/fluttercommunity/import_sorter - https://github.com/editorconfig-checker/editorconfig-checker.python - https://gitlab.com/pablodiehl/pre-commit-lua-formatter +- https://github.com/frnmst/md-toc From 75b8c5326cb4e041b7d95632cc0b433e1bd60c1c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 21 Dec 2020 16:43:59 +0000 Subject: [PATCH 428/854] [pre-commit.ci] pre-commit autoupdate --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4dc20bdd..140fb442 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.3.0 + rev: v3.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -39,7 +39,7 @@ repos: hooks: - id: mypy - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.15.0 + rev: v7.16.0 hooks: - id: eslint args: [--fix] From 5e6a362a1f42fed5d729dd3618ec4b0d9fd03395 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Wed, 23 Dec 2020 12:39:41 -0800 Subject: [PATCH 429/854] Add check-manifest --- all-repos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/all-repos.yaml b/all-repos.yaml index a1cc8bef..892922a6 100644 --- a/all-repos.yaml +++ b/all-repos.yaml @@ -157,3 +157,4 @@ - https://github.com/editorconfig-checker/editorconfig-checker.python - https://gitlab.com/pablodiehl/pre-commit-lua-formatter - https://github.com/frnmst/md-toc +- https://github.com/mgedmin/check-manifest From 9e5482a57b5df5374d2a96d687fc3666a4805868 Mon Sep 17 00:00:00 2001 From: Paul Fischer Date: Sat, 19 Dec 2020 09:37:50 +0100 Subject: [PATCH 430/854] added id and type filter for hooks --- assets/filter_repos.js | 41 +++++++++++++++++++++++++++++++++++++++++ hooks.mako | 26 +++++++++++++++++++++++--- make_templates.py | 9 ++++++++- 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 assets/filter_repos.js diff --git a/assets/filter_repos.js b/assets/filter_repos.js new file mode 100644 index 00000000..be9fc414 --- /dev/null +++ b/assets/filter_repos.js @@ -0,0 +1,41 @@ +'use strict'; + +(() => { + const searchInput = document.getElementById('search-hook-id'); + const selectInput = document.getElementById('select-hook-type'); + + const hooks = document.getElementById('hooks'); + const repos = hooks.getElementsByTagName('ul'); + + const filterHooks = () => { + const id = searchInput.value.toLowerCase(); + const type = selectInput.value; + + for (let i = 0; i < repos.length; i += 1) { + const repo = repos[i]; + let hasVisibleHooks = false; + const repoHooks = repo.getElementsByTagName('li'); + + if (repoHooks) { + for (let j = 0; j < repoHooks.length; j += 1) { + const repoHook = repoHooks[j]; + const hookId = repoHook.dataset.id.toLowerCase(); + const hookTypes = repoHook.dataset.types; + + if (hookId.includes(id) && hookTypes.includes(type)) { + repoHook.hidden = false; + hasVisibleHooks = true; + } else { + repoHook.hidden = true; + } + } + } + + repo.hidden = !hasVisibleHooks; + hooks.querySelector(`h3[data-repo="${repo.dataset.repo}"]`).hidden = !hasVisibleHooks; + } + }; + + searchInput.addEventListener('input', filterHooks); + selectInput.addEventListener('change', filterHooks); +})(); diff --git a/hooks.mako b/hooks.mako index 5e180596..01645cca 100644 --- a/hooks.mako +++ b/hooks.mako @@ -3,6 +3,22 @@ +
      +
      + + +
      +
      + + +
      +
      +

      To add to this list, fork this repository.

      @@ -11,15 +27,16 @@ To add to this list, fork json.

      +
      % for repository, hooks in all_hooks.items(): -

      +

      ${repository.replace('https://', '')}

      -
        +
          % for hook_dict in hooks: -
        • +
        • ${hook_dict['id']} % if 'description' in hook_dict: - ${hook_dict['description']} @@ -30,3 +47,6 @@ Also available in json. % endfor
        % endfor +
      + + diff --git a/make_templates.py b/make_templates.py index 8935944a..e99db308 100644 --- a/make_templates.py +++ b/make_templates.py @@ -25,7 +25,14 @@ def get_env() -> Dict[str, Any]: open('all-hooks.json').read(), object_pairs_hook=collections.OrderedDict, ) - return {'all_hooks': all_hooks} + all_types = { + hook_type + for properties in all_hooks.values() + for hook_type in ( + properties[0].get("types", []) + properties[0].get("types_or", []) + ) + } + return {'all_hooks': all_hooks, 'all_types': all_types} def main() -> int: From 2206e3831e87c368aadc3dbf6f1669ff9b0fde1c Mon Sep 17 00:00:00 2001 From: Paul Fischer Date: Sat, 26 Dec 2020 22:02:01 +0100 Subject: [PATCH 431/854] updated to bootstrap 4 --- base.mako | 132 +++++++++++++++---------- hooks.mako | 10 +- index.mako | 24 ++--- logo.png | Bin 1629 -> 0 bytes package.json | 2 +- scss/_variables.scss | 48 ++++------ scss/main.scss | 224 +++++++++++++++---------------------------- 7 files changed, 196 insertions(+), 244 deletions(-) delete mode 100644 logo.png diff --git a/base.mako b/base.mako index c238a9e1..7ee61b16 100644 --- a/base.mako +++ b/base.mako @@ -2,69 +2,99 @@ - - - - - + + + + + + + pre-commit - -
    -