A python library implementing the git http transfer protocol.
Project description
repligit
repligit is a Python library that implements the Git transfer protocol. It enables users to query remote repositories, mirror repositories between two locations without storing state locally, and incrementally archive repositories to disk. repligit is used by Hubcast to mirror repositories from GitHub to GitLab for secure CI/CD on local hardware.
Installation
You can install repligit from PyPI using pip:
pip install repligit
Features
- Query remote Git repositories.
- Mirror repositories between different Git hosting services.
- Incrementally archive repositories to disk.
- Implements Git transfer protocol in pure Python.
Example Usage
from repligit import fetch_pack, ls_remote, send_pack
def main():
src_remote_url = "https://github.com/spack/spack.git"
dest_remote_url = "https://gitlab.com/test-org/test-repo.git"
branch_name = "main"
target_ref = f"refs/heads/{branch_name}"
# Authentication credentials
# Note: Only provide credentials when authentication is required
# src_username = "<username>" # Uncomment if source repo requires auth
# src_password = "<token>" # Uncomment if source repo requires auth
dest_username = "<username>" # For destination repo write access
dest_password = "<token>" # For destination repo write access
# List references from source repository (without authentication)
gh_refs = ls_remote(src_remote_url)
# List references from destination repository (with authentication)
gl_refs = ls_remote(
dest_remote_url,
username=dest_username,
password=dest_password
)
want_sha = gh_refs[target_ref]
have_shas = gl_refs.values()
from_sha = gl_refs.get(target_ref) or ("0" * 40)
if want_sha in have_shas:
print("Everything is up to date")
return
# Fetch the packfile from source repository
packfile = fetch_pack(
src_remote_url,
want_sha,
have_shas,
# username=src_username, # Uncomment if source repo requires auth
# password=src_password, # Uncomment if source repo requires auth
)
# Upload packfile to destination repository
send_pack(
dest_remote_url,
target_ref,
from_sha,
want_sha,
packfile,
username=dest_username,
password=dest_password,
)
if __name__ == "__main__":
main()
License
Licensed under the Apache License, Version 2.0 w/LLVM Exception (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
LLNL-CODE-2003682
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 repligit-0.1.0.tar.gz.
File metadata
- Download URL: repligit-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9beac1a14542704f2e5af6a2f3d391d8adf2112ae3c70e98339db251a9e1079e
|
|
| MD5 |
04699783f75a3b4f8a904c35b3cc611f
|
|
| BLAKE2b-256 |
386cfea571ffa21fa8f46db5dcc3347fd5ca8a6076dd9d0e0a5495a324877ea3
|
Provenance
The following attestation bundles were made for repligit-0.1.0.tar.gz:
Publisher:
publish.yml on LLNL/repligit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
repligit-0.1.0.tar.gz -
Subject digest:
9beac1a14542704f2e5af6a2f3d391d8adf2112ae3c70e98339db251a9e1079e - Sigstore transparency entry: 198274921
- Sigstore integration time:
-
Permalink:
LLNL/repligit@db988cdb544ac5f1aa50b40d072a8ac1adea4df6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/LLNL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@db988cdb544ac5f1aa50b40d072a8ac1adea4df6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file repligit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: repligit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cad2afc184a5379107a6c3bcc01346712e41ac30a683f770c027d71e85cd3277
|
|
| MD5 |
a7daf62cad0955eb8ca8eab84d72bbdb
|
|
| BLAKE2b-256 |
fa1ae06b4df1c2c39cf3cde06f487f8754b7477c3f0399c9e04929af60e6417e
|
Provenance
The following attestation bundles were made for repligit-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on LLNL/repligit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
repligit-0.1.0-py3-none-any.whl -
Subject digest:
cad2afc184a5379107a6c3bcc01346712e41ac30a683f770c027d71e85cd3277 - Sigstore transparency entry: 198274923
- Sigstore integration time:
-
Permalink:
LLNL/repligit@db988cdb544ac5f1aa50b40d072a8ac1adea4df6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/LLNL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@db988cdb544ac5f1aa50b40d072a8ac1adea4df6 -
Trigger Event:
release
-
Statement type: