Skip to main content

Pre-commit hook to prevent accidental submodule regressions

Project description

prevent-submodule-regression

Pre-commit hook to prevent accidental submodule regressions

Description

Do you find yourself (or your collaborators) constantly rolling back submodule SHAs because someone forgot to git submodule update before running git add . or git commit -a …?

This pre-commit plugin will prevent those nasty surprises from making their way into your repositories.

Installation

As a git hook

The simplest way to use this package is as a plugin to pre-commit.

A sample configuration:

repos:
  # […]
  - repo: https://github.com/erikogan/prevent-submodule-regression
    rev: v0.1.3
    hooks:
      - id: prevent-submodule-regression
        # By default hooks only operate on plain files, which do not include
        # submodules. This setting has been added to the hook configuration,
        # and should only be necessary if you are running a version older than
        # 0.1.3. Keeping it here for posterity, it can safely be skipped.
        types: [directory]

Example failure output:

submodule example with colorized output

As a standalone script

pip install prevent-submodule-regression [path…]

If you run the script with no arguments, it will automatically find all the configured submodules. You can also pass it a list of files to check.

It will currently ignore any path that is not staged to be commit. A future version of the script will have an argument to override that behavior.

TODO

In no particular order:

  • Actual tests
  • Ways to override the error and allow you to commit a regression.
    • Command-line
    • Environment variables
  • Ways to override (or disable) colorization codes
    • Command-line
    • Environment variables
  • Usage information via --help
  • Actual command-line flag parsing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prevent-submodule-regression-0.1.3.tar.gz (9.0 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page