remote_hooks 1.1.6 copy "remote_hooks: ^1.1.6" to clipboard
remote_hooks: ^1.1.6 copied to clipboard

A CLI tool to share & install git hooks from remote repository

pub package

Getting Started #

Add remote_hooks to your project's dev_dependencies:

$ dart pub add dev:remote_hooks
copied to clipboard

Then, interact with it inside your project using:

$ dart run remote_hooks -h
copied to clipboard

Alternatively, install it globally:

$ dart pub global activate remote_hooks
copied to clipboard

Once installed globally, you can use it anywhere:

$ remote_hooks -h
copied to clipboard

Features #

Store Git hooks in a shared repository to ensure consistency and reusability across team members and multiple projects.

Usage #

Hooks installation #

$ remote_hooks install -h

Usage: remote_hooks install [arguments]
-h, --help    Print this usage information.
-u, --url     Url to the remote repository
-r, --ref     Repository ref to checkout
copied to clipboard

For example, you can use this command to install hooks from a remote repository.

$ remote_hooks install -u git@github.com:SilentCatD/where-you-store-hooks.git
copied to clipboard

Specify ref with -r to switch branches or check out a specific commit. This helps with using different hooks for different projects.

Once installed via the command line, even without any other configuration files specified, you can reinstall using the install command without needing to specify the -u flag.

Uninstall hooks #

To uninstall, use:

$ remote_hooks uninstall
copied to clipboard

Configuration #

You can also store the url and ref information in a config file. At the root of your repository, create a remotehooks.yaml file. Inside, you can specify these two keys:

git-url: git@github.com:SilentCatD/where-you-store-hooks.git
ref: develop
copied to clipboard

Hooks repository structure (Remote repository) #

Contents of the remote hooks repository will be copied to .git/hooks. In the remote repository, you can add a .hooksignore file to exclude specific files and folders from being copied.

Patterns defined inside .hooksignore and .gitignore will be merged to create a final exclusion list.

The file extension of files at the root level is not important, as they will be omitted when copying.

Example of a repository structure for pre-commit and pre-push hooks written in Python:

├── .gitignore
├── .hooksignore
├── hooks_utils
│ ├── formatter_utils.py
│ └── printer_utils.py
├── pre-commit.py
└── pre-push.py
copied to clipboard

Install & uninstall scripts #

Aside from regular hooks trigger, additional scripts can be add to the remote repository to be ran during remote_hooks install and remote_hooks uninstall. These script must be executable and can be used to clean up resources or generate log information.

To achieve this, in the root of the remote repository, you can add 2 extra additional scripts:

├── .gitignore
├── .hooksignore
├── pre-commit.py
└── pre-push.py
└── post-install.py (new)
└── pre-uninstall.py (new)
copied to clipboard

The file extension is not important and will also be omitted when copying to .git/hooks.

Additional information #

For additional command details, use remote_hooks -h

$ remote_hooks <command> -h
copied to clipboard
2
likes
150
points
74
downloads

Publisher

verified publishersilentcat.dev

Weekly Downloads

2024.09.13 - 2025.03.28

A CLI tool to share & install git hooks from remote repository

Repository (GitHub)
View/report issues

Topics

#cli #githooks #pre-commit #generator

Documentation

API reference

License

MIT (license)

Dependencies

args, cli_util, io, meta, path, uuid, yaml

More

Packages that depend on remote_hooks