Python GIT tool to check pending changes and get last commit info
Project description
Python GIT tool to check pending changes and get last commit info
gitchecker.check_status_and_get_commit_info() checks if there is
any pending changes in GIT repository status and returns the last commit info:
- sha (string): commit SHA (7 digits length)
- author (string): author name
- authored_datetime (datetime): author datetime
- committer (string): committer name
- committed_datetime (datetime): committer datetime
By default it raises an Exception if there are any pending changes but
it can be configured to only show a warning instead.
Requirements
- Python 3.5 or newer
- Git 1.7.0 or newer, because gitpython dependency
Install
pip install gitchecker
Demo Usage
import gitchecker
commit_info = \
gitchecker.check_status_and_get_commit_info(repo_path="",
warning_instead_of_error=False,
ignore_untracked_files=False,
ignore_files_regex=None,
logger=None)
print("commit", commit_info)
The displayed values of the parameters are the default ones.
If a logger is provided, it will be used only if it has an error()
or warning() method. The required method depends on the value of
warning_instead_of_error. If no logger provided or no proper
log function exists in logger , print() will be used instead.
Ignoring untracked files (ignore_untracked_files=True) or
Ignoring by regex (ignore_files_regex="regex") will ignore them completely,
not raising errors and not showing warnings.
Testing
The GIT status must be clean to run functional test.
python setup.py test
To run only unit tests, use:
python -m pytest --pep8 --cov=gitchecker --cov-report=term-missing --cov-report=html -vv -x -k unit
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitchecker-2.0.0.tar.gz.
File metadata
- Download URL: gitchecker-2.0.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1920dbd712d47e10f9bcd5a26810d7eb706b300d2c7560a68cfac05678157f2b
|
|
| MD5 |
3a333f9f540e0cc3f0ea27109b95a1e6
|
|
| BLAKE2b-256 |
dd6b33973c7982edefbfb99ac927f14fab40006640818061f14c5c9ccda92f4b
|
File details
Details for the file gitchecker-2.0.0-py3-none-any.whl.
File metadata
- Download URL: gitchecker-2.0.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9b72537fbc7999ae333be25bbd2508aba3f23378a8d8b9cb9eb47b6e09a5939
|
|
| MD5 |
e1bb82424b1c8d654087df4b6f7c43ef
|
|
| BLAKE2b-256 |
73d469ec3cb2c864b9c7042e78e6473f39b588c1d29481b3c8994fdabb06e4df
|