GithubHelp home page GithubHelp logo

vcwild / norminette-hook Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 0.0 19 KB

The Norminette pre-commit hook.

License: MIT License

Python 100.00%
42school norminette pre-commit automation git-hook hook

norminette-hook's Introduction

release license repo size

Norminette Hook

The Norminette pre-commit hook.

โ“ About

Git hooks are actions triggered whenever you do a commit.

After you execute a git commit, the norminette-hook will automatically trigger Norminette on your staged files, and if you are off the norm it will display what needs to be fixed before you can record this commit to your git history.

This ensures that every commit you do will follow the rules, and you don't have to run Norminette manually anymore.

By default, the Norminette hook will only check for files in stage, it is not running for every existing file of your project!

We realized that this is a better design, for you can write tests and other libraries that do not require strict rules.

๐Ÿ“ Requirements

  • Pre-commit must be installed system-wide or in a virtual environment.

NOTE: Currently the plugin is only supported in UNIX-like environments (Linux, BSD, Mac).

๐Ÿ’ฟ Usage

Create a .pre-commit-config.yaml file in the root of your repository.

Add there the following lines:

default_language_version:
  python: python3

repos:
  - repo: https://github.com/vcwild/norminette-hook
    rev: v0.1.1
    hooks:
    - id: norminette-hook

When executing pre-commit run or pre-commit run norminette-hook, the hook will be triggered.

Now install the hook to execute it automatically for each commit.

pre-commit install --install-hooks --overwrite

You are now ready for some next level linting automation! ๐Ÿ‘จโ€๐Ÿš€๐Ÿš€

๐Ÿ™‹ FAQ / Common issues

Error "bash: pre-commit: command not found"

Make sure you have installed pre-commit and it is available in the current shell environment.

How to commit without running Norminette?

If you want to skip commit hooks for whatever reason, simply use:

git commit --no-verify

How to remove this hook?

Simply remove the folder where pre-commit hooks is installed:

rm -f [root_dir]/.git/hooks/pre_commit`

This only removes the hook from executing after every commit. If you want to wipe your pre-commit installation, please follow pre-commit uninstall

๐Ÿค Contributing

Fork the repository and create a pull request.

๐Ÿท๏ธ License

The project is under the MIT License. The software is provided as is, without warranty of any kind.

norminette-hook's People

Contributors

vcwild avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

norminette-hook's Issues

Python on WSL Ubuntu is Python3 and is not executed

Hi there,

Many thanks for your awsome work.
I tried to install norminette-hook on Win10 with WSL Ubuntu 22.04 and I got the following error:

An unexpected error has occurred: CalledProcessError: command: ('python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Executable `python` not found
stderr: (none)
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/pre_commit/error_handler.py", line 73, in error_handler
    yield
  File "/home/user/.local/lib/python3.10/site-packages/pre_commit/main.py", line 386, in main
    return run(args.config, store, args)
  File "/home/user/.local/lib/python3.10/site-packages/pre_commit/commands/run.py", line 424, in run
    install_hook_envs(to_install, store)
  File "/home/user/.local/lib/python3.10/site-packages/pre_commit/repository.py", line 223, in install_hook_envs
    _hook_install(hook)
  File "/home/user/.local/lib/python3.10/site-packages/pre_commit/repository.py", line 79, in _hook_install
    lang.install_environment(
  File "/home/user/.local/lib/python3.10/site-packages/pre_commit/languages/python.py", line 221, in install_environment
    helpers.run_setup_cmd(prefix, install_cmd)
  File "/home/user/.local/lib/python3.10/site-packages/pre_commit/languages/helpers.py", line 48, in run_setup_cmd
    cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/pre_commit/util.py", line 146, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Executable `python` not found
stderr: (none)

I made some tests and I think its because if you run python in ubuntu it isn't recognized. Only if I run python3 I get python running.

Thanks in advance.

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.