libvcs

Typed Python utilities for Git, SVN, and Mercurial. Parse URLs, execute commands, and synchronize repositories – all with a consistent, type-friendly API.

Quickstart

Install and parse your first VCS URL in 5 minutes.

Quickstart
URL Parsing

Parse, validate, and normalize git/hg/svn URLs.

URL Parser - libvcs.url
Commands

Typed wrappers for git, hg, and svn CLI operations.

Commands - libvcs.cmd
Sync

Clone and update local repositories.

Sync - libvcs.sync
pytest Plugin

Fixtures for isolated VCS test repos.

pytest Plugin
Project

Contributing, code style, release process.

Project

Install

$ pip install libvcs
$ uv add libvcs

Tip

libvcs is pre-1.0. Pin to a range: libvcs>=0.39,<0.40

See Quickstart for all methods and first steps.

At a glance

from libvcs.url.git import GitURL

url = GitURL(url="[email protected]:vcs-python/libvcs.git")
url.hostname  # 'github.com'
url.path      # 'vcs-python/libvcs'

GitURL.is_valid(url="https://github.com/vcs-python/libvcs.git")
# True

libvcs gives you typed dataclasses for every parsed URL, thin CLI wrappers for git / hg / svn, and high-level sync that clones or updates a local checkout in one call.

Layer

Module

Purpose

URL parsing

libvcs.url

Detect, validate, normalize VCS URLs

Commands

libvcs.cmd

Execute individual VCS CLI operations

Sync

libvcs.sync

Clone and update local repositories

Testing

libvcs ships a pytest plugin with session-scoped fixtures for Git, SVN, and Mercurial repositories:

def test_my_tool(create_git_remote_repo):
    repo_path = create_git_remote_repo()
    assert repo_path.exists()