Code Monkey home page Code Monkey logo

pre-commit.com's Introduction

pre-commit.com's People

Contributors

adamchainz avatar arontier-egkim avatar asottile avatar atugushev avatar bagerard avatar chriselion avatar chriskuehl avatar comkieffer avatar ddelange avatar elidupuis avatar hugovk avatar iconmaster5326 avatar janosh avatar jonasbb avatar jtcarnes avatar jumanjiman avatar lorenzwalthert avatar lucas-c avatar marcogorelli avatar mblayman avatar mjay-taskize avatar mxr avatar pre-commit-ci[bot] avatar rkm avatar rpdelaney avatar scop avatar sirosen avatar skylion007 avatar struys avatar wwuck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pre-commit.com's Issues

Add CI Badge

We should add the coverage and build status badges on the site

install-local.py is failing with `DistributionNotFound: No distributions at all found for wheel`

Non Administrative Installation (curl http://pre-commit.com/install-local.py | python via http://pre-commit.com/#install) is failing with DistributionNotFound: No distributions at all found for wheel:

No distributions at all found for wheel
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/virtualenv_support/pip-1.5.5-py2.py3-none-any.whl/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.6/dist-packages/virtualenv_support/pip-1.5.5-py2.py3-none-any.whl/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.6/dist-packages/virtualenv_support/pip-1.5.5-py2.py3-none-any.whl/pip/req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/usr/lib/python2.6/dist-packages/virtualenv_support/pip-1.5.5-py2.py3-none-any.whl/pip/index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for wheel

Looks like virtualenv issue.

setup.cfg is not being read for pydocstyle

The setup.cfg contains the below mentioned code but still the directories which were supposed to get skipped are being tested for style:
This works fine with flake8 but it's failing for pydocstyle

[pydocstyle]
match-dir = ^((?!doc|tests).)*$
ignore = D105, D107, D203, D204, D213

This is the hook I used (I also tried using a look hook but it didn't work).

-   repo: https://github.com/PyCQA/pydocstyle
    rev: 5.0.2
    hooks:
    -   id: pydocstyle

Adding DocSearch as search experience

As requested pre-commit/pre-commit#659

Congratulations, your search is now ready!
I've successfully configured the underlying crawler and it will now run every 24h.

You're now a few steps away from having it working on your website:

  • Copy the following CSS/JS snippets and add them to your page
<!-- at the end of the HEAD -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
<!-- at the end of the BODY -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script type="text/javascript"> docsearch({
  apiKey: '5f052a6b9f5c2b81614512796afa7000',
  indexName: 'pre-commit',
  inputSelector: '### REPLACE ME ####',
  debug: false // Set debug to true if you want to inspect the dropdown
});
</script>

Feel free to get back to us if you have any issues or questions regarding the integration.
We'd also be happy to get your feedback and thoughts about DocSearch - so we can continue to improve it.

Let us know if you need anything

"language_version" values in examples are not quoted as explicit yaml strings

Site gives examples like "language_version: 2.1.5" e.g. here

cfgv checker expects string.

So if language_version starts with digit like

repos:
  - repo: https://
    rev: beef
    hooks:
      - id: some-id
        language_version: 3.7

it causes errors like this

An error has occurred: InvalidConfigError: 
...
==> At key: hooks
==> At Hook(id='some-id')
==> At key: language_version
=====> Expected string got float
Check the log at /home/.../.cache/pre-commit/pre-commit.log

Document configuration v2

Some callouts:

  • pre-commit migrate-config
  • now a map instead of a list so ~*~*new features*~*~ can be implemented
  • fail_fast: ... and global exclude: ...

Hamburger Menu

We should add the bootstrap hamburger menu to the frontend of the site for mobile support

Project name is very hard to google

It may be a bit late for a change, but I wanted to point out that as someone getting started with pre-commit, the project name is very hard to use.

Since pre-commit is the name of the git feature that this framework exercises, most searches for "pre-commit" will only return references to the underlying git feature, and not this framework. In particular, this makes it hard to find example configuration files, or other peoples' plugins that are designed to provide hooks for the framework. It's hard to even talk to the uninitiated in e.g. a blog post -- "I'm using pre-commit to manage pre-commit hooks, and here's why it's great."

Other projects have faced this issue and developed conventions for talking about the project online (e.g. "golang" for "go"). I don't know if it's possible to come up with some convention like that to make references to the project more semantically unique.

Opening this as a "pre-commit.com" issue, since it seems that the public facing website for the project is the place that would suggest and promote such a convention if one could be found.

Group hooks by type

It would be really handy to have the hooks grouped by what it specified in the types field in the JSON data. That way if I'm looking to see what hooks apply to Python I can look in that section. I would assume this would be its own <h2> section after the current by-repository list.

Add Demo Repo

Two tasks in here:

  • Update the demo repo with screenshots
  • Update the frontend to link to the demo

Incorrect terminology

In your documentation and perhaps also in your code, you use "sha" when you appear to mean "hash", or more likely "commit".

Using the wrong word causes potential for confusion, and is also - in this case - a hostage to fortune, because there is no guarantee that future (versions of) version control repositories will use hashes from the Secure Hash Algorithm ("SHA") family of hashing algorithms to refer to commits.

This may be a minor bug, but it is still a bug.

It would be great if you could refactor your code and documentation to fix it in the next patch release, and stop supporting the incorrect term (e.g. where it appears in .pre-commit-config.yaml) in the next major release.

installation failed

today after running the installation command the script fails silently

curl https://pre-commit.com/install-local.py | python3 -

here's the command's output (user name replaced with ***):

$ curl https://pre-commit.com/install-local.py | python3 -
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
100  3250  100  3250    0     0  26422      0 --:--:-- --:--:-- --:--:-- 26422
Using base prefix '/usr'
New python executable in /home/***/.pre-commit-venv/bin/python3
Also creating executable in /home/***/.pre-commit-venv/bin/python
Installing setuptools, pip, wheel...
done.
Downloading 
https://files.pythonhosted.org/packages/a4/e3/1f067de470e3a86875ed915438dc3bd781fb0346254f541190a09472b677/virtualenv-16.7.10.tar.gz
Done.

it seems to exit silently on line 98 of the install-local.py script:

if not virtualenv(venv_path):
    return 1

Undocumented default hook type in `pre-commit install`

It's somewhat confusing that pre-commit install actually only installs the pre-commit hook type, and that if you want other hook types you need to install those with a separate invocation of pre-commit install --hook-type {type}.

Neither the pre-commit install docs, nor the CLI output of pre-commit install --help are very helpful:

usage: pre-commit install [-h] [--color {auto,always,never}] [-c CONFIG] [-f]
                          [--install-hooks]
                          [-t {pre-commit,pre-push,prepare-commit-msg,commit-msg}]
                          [--allow-missing-config]

optional arguments:
  -h, --help            show this help message and exit
  --color {auto,always,never}
                        Whether to use color in output. Defaults to `auto`.
  -c CONFIG, --config CONFIG
                        Path to alternate config file
  -f, --overwrite       Overwrite existing hooks / remove migration mode.
  --install-hooks       Whether to install hook environments for all
                        environments in the config file.
  -t {pre-commit,pre-push,prepare-commit-msg,commit-msg}, --hook-type {pre-commit,pre-push,prepare-commit-msg,commit-msg}
  --allow-missing-config
                        Whether to allow a missing `pre-commit` configuration
                        file or exit with a failure code.

Introduction: Please add "4. (optional) Run against a single file"

At the moment there is this heading on the start-page:

  1. (optional) Run against all the files

I think running it against all files is too much at the beginning.

Why not like this?

4. (optional) Run against one file

5. (optional) Run against all the files

I think this would improve the first-time-user-experience.

Thank you for this great tool!

Documentation Request: Add "args" option to Creating New Hooks section

I couldn't figure out how to pass arguments to a pre-commit hook, and looking at the table of configuration options I did not see the args option listed.

After digging deeper I did find it buried in the Advanced Features section, but this seems like a common enough parameter that it should be called out with the rest of the API.

At a minimum it could just link to this section, ie:

args See Advanced features (link)

I'm happy to add this to the docs, but I don't see where to do that in the repo.

Split up the doc pages

I've been wanting to do this for a while since the homepage is getting pretty long.

Basically what I want the homepage to be is a quickstart guide and have there be separate pages that go more in-depth

A wordier pre-commit install

Here is the result of installing hooks with pre-commit:

$ pre-commit install
pre-commit installed at .git/hooks/pre-commit

Would it now be a good idea to have it return a list of the hooks installed and in what stages?

For instance for the following .pre-commit-config.yaml file:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.1.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: debug-statements

one would get the following messages:

$ pre-commit install
pre-commit installed the following hooks at .git/hooks/commit-msg:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: debug-statements

Minor documentation improvements

Hi,

Those are just ideas on ways to improve pre-commit documentation / ergonomy:

Idea: A bot to run pre-commit and commit formatted code

It would be great to have a GitHub bot that could execute pre-commit run ... on a PR then add a commit to the PR with the formatting changes, if there are any.

This would act as a last resort, ensuring that both maintainers and contributors don't need to care about formatting code.

Does this exist? If not, is there any interest in collaborating on something like this?

Prior discussions

Understanding `install` vs `install --install-hooks`

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

I'm having difficulty assuring myself that I'm parsing this correctly. Possibly related to #239. The addition of -f in the second example is notably unhelpful when trying to use this example to understand the contrast between install vs install --install-hooks. The docs for -f say it will "overwrite existing hooks / remove migration mode", which (plus the convention of what -f means in general) suggests that any operation with this switch should not be idempotent.

Could someone help explain the difference in more detail?

There's also this:

$ pre-commit --help install
usage: pre-commit [-h] [-V]
                  {autoupdate,clean,gc,init-templatedir,install,install-hooks,migrate-config,run,sample-config,try-repo,uninstall,help}
[...]
    install             Install the pre-commit script.
    install-hooks       Install hook environments for all environments in the
                        config file. You may find `pre-commit install
                        --install-hooks` more useful.

When would I find it more useful? Always? Should I consider install --install-hooks the default for initial setup?

what is the base directory for "log_file" output #1553

Originally reported as pre-commit/pre-commit#1553

I'm running pytest using the following definition:

-   repo: local
    hooks:
    -   id: simple-pytest
        description: run pytest
        name: simple-pytest
        entry: pytest
        language: system
        types: [python]
        pass_filenames: false
        stages: [push]
        log_file: pytest.log

and I see pre-commit list pytest during the git push after I make a change to a .py source file and git add and git commit. But I cannot find a pytest.log file anywhere.

When I run pytest manually:

pytest > manual-pytest.log

The manual-pytest.log file is created in the current working directory.

This is on Ubuntu 18.04.4, with python 3.6.9, pytest 5.4.3

Conclusion: pytest is not failing -- that is why log file is created.

install-local.py seems to have a syntax error

I've got error below and failed to install pre-commit. Probably install-local.py would have a syntax error. Does anyone know how to avoid the error?

$ curl https://pre-commit.com/install-local.py | python -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3212  100  3212    0     0   4549      0 --:--:-- --:--:-- --:--:--  4549
  File "<stdin>", line 61
    file=sys.stderr,
        ^
SyntaxError: invalid syntax

My python version is:

$ python --version
Python 2.7.17

pre-commit.com main page may mislead users about the tool purpose

I am raising this improvement request about updating pre-commit.com main page in order to make it clear that pre-commit tool is not a git-hook, thins being only one more or less important feature of the product and clearly a fully optional one.

While presenting the tool to others in the last ~2 years I was almost always asked about this subject with vart majority of audience being confused because they assumed that the tool is yet-another-git-hook. Most of them already had previous experience with a git-hook, which was not always the best of them.

pre-commit is a great tool and like one of my collegues nailed it it may happen to have one of the misleading product naming know. Obviously the product rename would be insane, but this does not mean that we should not advertise it for what it is and present exactly its benefits and use-cases, especially for someone visiting the first time pre-commit.com which may not know much about the tool.

Issues identified in homepage:

  • the tagline contains "pre-commit hooks", not sure if hooks are desirable mention, or if even pre-commit would be mandatory, I personally try to find a way to avoid repeating the tool name there an use something regerign to: linters, quick sanity checking tools,.... ?
  • first screenshot is at https://pre-commit.com/#usage and exemplifies installation of hooks (optional feature), not the manual execution pre-commit run -a, which is likely to be less controversial.
  • If we manage toinclude a screenshot example that even contains a linting failure that would be in the first page screen (so people would not need to scroll considerably to see it), it could help with early adopters as its friendly output is a big selling point -- clearly installation is less important than seeing how it looks.
  • Side-by-side comparison with tox which would explain people why pre-commit plays well with tox and is not a replacement, as it is addressing (or avoiding) few design limitations presetn in tox. This would be a huge selling point for lots of python developers which can usually find hard to understand what would be the benefit of using pre-commit when they have one or several tox environments that are ralready running linters (likely most of them already supported by pre-commit).

Allow setting of PRE_COMMIT_HOME in configuration file

Looking for a GitLab CI snippet, I stumbled upon #343 and wondered why the cache directory cannot be set in the .pre-commit-config.yaml file or even default to the current project's top-level directory. Environment variables could be used to override that if desired.

My thinking behind this is that I might have multiple projects using pre-commit with wildly different repo versions. Now, imagine running pre-commit gc in one project wiping repos that are used by another project. I don't know if/how pre-commit handles this under the covers, but I think keeping project specific things within each project's checkout would solve this.

Putting everything in a project's .cache/ by default and allowing project's to set a different value in their .pre-commit-config.yaml would nicely solve this and make dealing with caches during CI a bit easier to deal with too.

Error: Cannot find module 'please-upgrade-node'

With this PR: hugovk/tinytext#59
With this config: https://github.com/hugovk/tinytext/blob/master/.pre-commit-config.yaml

The Prettier hook failed:

pyupgrade................................................................Passed
black....................................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
check blanket noqa.......................................................Passed
Check for merge conflicts................................................Passed
Check Toml...............................................................Passed
Check Yaml...............................................................Passed
mypy.....................................................................Passed
prettier.................................................................Failed
- hook id: prettier
- exit code: 1

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'please-upgrade-node'
Require stack:
- /pc/clone/89rCdSwwReu-UQrdqlPxWw/src/cli/index.js
- /pc/clone/89rCdSwwReu-UQrdqlPxWw/bin/prettier.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/pc/clone/89rCdSwwReu-UQrdqlPxWw/src/cli/index.js:4:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/pc/clone/89rCdSwwReu-UQrdqlPxWw/src/cli/index.js',
    '/pc/clone/89rCdSwwReu-UQrdqlPxWw/bin/prettier.js'
  ]
}

https://results.pre-commit.ci/run/github/89922502/1603910359.7titBuVPQISl6WxqA7LTkA

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.