gitpoll
Overview
gitpoll monitors the remote equivalent of a local Git repository branch for changes. It checks the repository at specified intervals, executing scripts or shell commands before and after pulling updates, suitable for simple automation of deployment or other tasks.
Features
- Monitors a Git repository for changes at specified intervals.
- Executes pre-action and post-action scripts or shell commands before/atfer pulling changes.
- All behavior is configurable via command-line options.
Installation
Requirements
- Python 3.5 or higher
Setup
Install from PyPI using pip:
pip install gitpoll
Clone the repository and install using pip:
git clone https://github.com/cc-d/gitpoll.git
cd gitpoll && pip install .
Install Dev Dependencies:
pip install gitpoll[dev]
Usage
usage: gitpoll [-h] [-i INTERVAL] [-n] [-p PRE_ACTION] [-P POST_ACTION] [-f] [repo_path]
Monitors a Git repository for changes and executes scripts before and after pulling updates.
positional arguments:
repo_path Path to the Git repository to monitor.
options:
-h, --help show this help message and exit
-i INTERVAL, --interval INTERVAL
Interval in seconds to check for changes.
-n, --no-pull Do not pull changes from the repository.
-p PRE_ACTION, --pre-action PRE_ACTION
Command or path to the pre-action shell script or command.
-P POST_ACTION, --post-action POST_ACTION
Command or path to the post-action shell script or command.
-f, --force Force execution pre and post actions regardless of changes.
Environment Variables
GITPOLL_LOG_LEVEL: Set the log level (default:INFO)
Basic Usage
To monitor a repository and execute actions based on changes:
gitpoll /path/to/repo -i 300
To poll for changes/execute actions once simply leave out the --interval
mym2@Carys-MacBook-Pro gitpoll % gitpoll ~/gitpoll
Running once...
05-06 16:47:50 INFO main:_log_exit Single run completed.
Advanced Usage
Monitor a repository at /home/user/myrepo, check every 300 seconds, and run specified scripts:
gitpoll /home/user/myrepo -i 300 -p /path/to/pre_script.sh -P /path/to/post_script.sh
Pre/Post Actions
These are executed as if being executed from the current shell gitpoll is running within. Either a .sh script location or the shell command itself.
-p test.sh
is valid as well as
-p 'sudo systemctl restart x'
No-Pull Mode
Execute pre and post actions without pulling changes from the repository:
gitpoll /path/to/repo --no-pull
Force Mode
Force execution of pre and post actions even if no changes are detected:
gitpoll /path/to/repo --force
Testing
Tests are not complete, I wrote these to have tests period, I'll probably redo them later.
Install the dev dependencies and run the tests:
pip install gitpoll[dev]
tests.py .................. [100%]
---------- coverage: platform darwin, python 3.11.5-final-0 ----------
Name Stmts Miss Cover
-----------------------------------------
gitpoll/__init__.py 1 0 100%
gitpoll/args.py 11 0 100%
gitpoll/config.py 6 0 100%
gitpoll/git.py 24 2 92%
gitpoll/log.py 13 0 100%
gitpoll/main.py 58 11 81%
gitpoll/shell.py 48 5 90%
gitpoll/version.py 1 0 100%
-----------------------------------------
TOTAL 162 18 89%
Contributing
Contributions are welcome. Please fork the repository and submit pull requests, bug reports, feature requests, etc.
License
MIT
Metadata
Release files for gitpoll 1.11.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gitpoll-1.11.1.tar.gz | 8.7 kB | Without provenance | Details for gitpoll-1.11.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gitpoll-1.11.1-py3-none-any.whl | Python 3 | none | any | Details for gitpoll-1.11.1-py3-none-any.whl |
Total release size: 17.3 kB
Release files / gitpoll-1.11.1.tar.gz
| Download URL | gitpoll-1.11.1.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b16113a00a54cfc58571f9a2e332d288bd55318b9b052a260bc72c8c35e9361
|
|
BLAKE2b-256 checksum How to use checksums |
50ca63723181b7889b6697f2bde998ca08c1151263a084581416b0e3aeca654e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.9
|
Release files / gitpoll-1.11.1-py3-none-any.whl
| Download URL | gitpoll-1.11.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a12b16f26e4399707f897fe0382a73369383d0c53bff0898cc47fdbd9e25ac1e
|
|
BLAKE2b-256 checksum How to use checksums |
91274447e1f39d6d98673bad6d916b719bce46b93c1170a1c54cbbfe6d732400
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.9
|
Security for gitpoll 1.11.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.