pub package

Getting Started

Add remote_hooks to your project's dev_dependencies:

$ dart pub add dev:remote_hooks

Then, interact with it inside your project using:

$ dart run remote_hooks -h

Alternatively, install it globally:

$ dart pub global activate remote_hooks

Once installed globally, you can use it anywhere:

$ remote_hooks -h

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

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

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

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

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

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)

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