Skip to content

erikogan/prevent-submodule-regression

Repository files navigation

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

About

Pre-commit hook to prevent accidental submodule regressions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages