Skip to main content

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 = set(gl_refs.values())

    from_sha = gl_refs.get(target_ref) or ("0" * 40)

    if from_sha == want_sha:
        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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repligit-0.4.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

repligit-0.4.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file repligit-0.4.0.tar.gz.

File metadata

  • Download URL: repligit-0.4.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for repligit-0.4.0.tar.gz
Algorithm Hash digest
SHA256 809ae81d7dad0b9f876c8a711be0cc30b76d1d245a8032f375d5856388981207
MD5 aa073860b777b3e98f7b1baaedf1fbaa
BLAKE2b-256 0ab0c620cc48e8b39d1becb97ba11ef0dddbc726be285474196caaa226ece4d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for repligit-0.4.0.tar.gz:

Publisher: publish.yml on llnl/repligit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file repligit-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: repligit-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for repligit-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e03185a146caacee55a213c1c5caa9cf46c49303afcbe9f2ea12ac86a20bac96
MD5 edb89ee0ba8561f40751fb4834197043
BLAKE2b-256 1582ea01fd044e57aaaa7466b2dab80776103eb31dee375e9d8f4082519df588

See more details on using hashes here.

Provenance

The following attestation bundles were made for repligit-0.4.0-py3-none-any.whl:

Publisher: publish.yml on llnl/repligit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.0

2 files

0.4.1

2 files

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page