scrippy_git
Git client for the Scrippy framework.
Prerequisites
- Python >= 3.11
- Git
Python Modules
List of Required Modules
The modules listed below will be automatically installed.
- GitPython >= 3.1.43
Installation
Manual
git clone https://codeberg.org/scrippy/scrippy-git.git
cd scrippy-git
python -m pip install -r requirements.txt
make install
With pip
pip install scrippy-git
Usage
The scrippy_git.git module provides the Repo object for easy manipulation of a Git repository over SSH or HTTPS.
SSH
import os
from scrippy_git import git
username = "git"
host = "gitlab.monty.py"
port = 2242
reponame = "luiggi.vercotti/monty_python.git"
branch = "master"
workspace_path = "/tmp"
repo = git.Repo(username, host, port, reponame)
local_path = os.path.join(workspace_path, "monty_python")
repo.clone(branch=branch, path=local_path)
test_fname = os.path.join(local_path, "dead_parrot.txt")
with open(test_fname, mode="w") as test_file:
test_file.write("Nobody expects the Spanish inquisition !")
commit_message = "Inquisition shall not be expected"
repo.commit_push(commit_message)
The env parameter of clone() sets environment variables used by every subsequent Git command (clone, pull, push...), for instance to use a specific SSH key:
env = {"GIT_SSH_COMMAND": "ssh -i /path/to/private.key"}
repo.clone(branch=branch, path=local_path, env=env)
HTTPS
With protocol="https", password is used to authenticate on the remote Git server. It is usually an authentication token, username being the token name or the literal oauth2 depending on your Git provider. Special characters in username and password are URL-encoded.
repo = git.Repo(username="oauth2",
host="gitlab.monty.py",
reponame="luiggi.vercotti/monty_python.git",
protocol="https",
password="my-secret-token")
Default ports
When port is not set, it defaults to 22 with the ssh protocol and to 443 with the https protocol.
Behavior
commit()adds every change (including untracked files) and commits them. On a clean repository it raises aScrippyGitError, unlesserror_on_clean_repo=Falseis given, in which case it only logs a warning.pull()uses the Git default strategy (merge, equivalent topull.rebase=false): diverged branches are reconciled with a merge commit.push()raises aScrippyGitErrorwhen the push is rejected (e.g. the remote branch has diverged and has not been pulled).commit_push()chainscommit(),pull()andpush().commit(),pull(),push()andcommit_push()raise aScrippyGitErrorwhen called beforeclone().- An unsupported
protocol(other thansshorhttps) raises aScrippyGitError.
All errors are raised as scrippy_git.ScrippyGitError.
Tests
Integration tests require a Gitolite server provided as a Docker image:
cd tests/docker
make build run
cd ../..
chmod 600 tests/ssh/scrippy.rsa
SCRIPPY_GIT_TEST_HOST=localhost make tests
The SCRIPPY_GIT_TEST_HOST environment variable sets the host name of the test Gitolite server (default: gitolite, as used by the CI).
Metadata
Release files for scrippy-git 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| scrippy_git-2.0.0.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scrippy_git-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.0 kB
Release files / scrippy_git-2.0.0.tar.gz
| Download URL | scrippy_git-2.0.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6c211534458838a04c148bbb1984f1a129f8aa3400146aa5cadf9e325a4d5c8
|
|
BLAKE2b-256 checksum How to use checksums |
2e7e4ea0e928e83b20346549dcea40f12236217a78e4ad7da21872029e2d0844
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|
Release files / scrippy_git-2.0.0-py3-none-any.whl
| Download URL | scrippy_git-2.0.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ad7dd35a83c7bfc763c3779b7048b2e68845b96cd18320a88a6477e8fde272b
|
|
BLAKE2b-256 checksum How to use checksums |
3287ef2cb49adffaa481fb995260e0732069554cec8d3501b70d96e4e7c972d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.17
|