1 stable release
1.0.0 | Dec 23, 2024 |
---|
#22 in #watch
162 downloads per month
73KB
2K
SLoC
A Rust implementation of the original gitwatch script - with a few additional features.
Features
- Watch a local Git repository and automatically commit changes
- Optionally push to a remote
- Use a custom commit message or generate one via a script
- Configure a debounce time to limit commit frequency
Example use case
I use the tool to watch my notes and automatically
in action: asciicinema
Usage
Basic usage:
gitwatch watch /path/to/repo --commit-message "Auto commit"
Configuration
❯ gitwatch watch --help
Watch a repository and commit changes
Usage: gitwatch watch [OPTIONS] [REPOSITORY]
Arguments:
[REPOSITORY] Path to the Git repository to monitor for changes [default: .]
Options:
-m, --commit-message <MESSAGE>
Static commit message to use for all commits
--commit-message-script <SCRIPT>
Path to executable script that generates commit messages.
The path can be absolute or relative to the repository.
The script is executed with the repository as working directory
and must output the message to stdout.
--commit-on-start <COMMIT_ON_START>
Automatically commit any existing changes on start [default: true] [possible values: true, false]
--debounce-seconds <DEBOUNCE_SECONDS>
Number of seconds to wait before processing multiple changes to the same file.
Higher values reduce commit frequency but group more changes together. [default: 1]
--dry-run
Run without performing actual Git operations (staging, committing, etc.)
-i, --ignore-regex <IGNORE_REGEX>
Regular expression pattern for files to exclude from watching.
Matches are performed against repository-relative file paths.
Note: the .git folder & gitignored files are ignored by default.
Example: "\.tmp$" to ignore temporary files.
--log-level <LOG_LEVEL>
Set the log level [default: info] [possible values: trace, debug, info, warn, error]
-r, --remote <REMOTE>
Name of the remote to push to (if specified).
Example: "origin".
--retries <RETRIES>
Number of retry attempts when errors occur.
Use -1 for infinite retries. [default: 3]
-w, --watch <WATCH>
Enable continuous monitoring of filesystem changes.
Set to false for one-time commit of current changes. [default: true] [possible values: true, false]
-h, --help
Print help
Config file
Alternatively to the CLI flags, most options can be specified in a gitwatch.yml
file, inside the watched repository.
See docs/gitwatch.example.yaml for reference.
Installation
Precompiled binaries are available for Linux and macOS.
On Nix:
TODO
Using cargo:
cargo install commitlint-rs
As a container:
cargo install commitlint-rs
Shell completion
TODO
Credits
This is a Rust implementation of the original gitwatch bash script.
Additional features
--commit-message-script
--retries
--dry-run
--commit-on-start
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
See CONTRIBUTING.md for some development hints.
Dependencies
~17–27MB
~447K SLoC