Skip to main content

Lite, typed, python utilities for Git, SVN, Mercurial, etc.

Project description

libvcs · Python Package License Code Coverage

libvcs is a lite, typed, pythonic tool box for detection and parsing of URLs, commanding, and syncing with git, hg, and svn. Powers vcspull.

Overview

Features for Git, Subversion, and Mercurial:

  • Detect and parse VCS URLs
  • Command VCS via python API
  • Sync repos locally

To get started, see the quickstart for more.

$ pip install --user libvcs

URL Parsing (experimental)

You can validate and parse Git, Mercurial, and Subversion URLs through libvcs.parse:

Validate:

>>> from libvcs.parse.git import GitURL

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

Parse and adjust a Git URL:

from libvcs.parse.git import GitURL

>>> git_location = GitURL(url='git@github.com:vcs-python/libvcs.git')

>>> git_location
GitURL(url=git@github.com:vcs-python/libvcs.git,
        hostname=github.com,
        path=vcs-python/libvcs,
        user=git,
        suffix=.git,
        matcher=core-git-scp)

Switch repo libvcs -> vcspull:

from libvcs.parse.git import GitURL

>>> git_location = GitURL(url='git@github.com:vcs-python/libvcs.git')

>>> git_location.path = 'vcs-python/vcspull'

>>> git_location.to_url()
'git@github.com:vcs-python/vcspull.git'

# Switch them to gitlab:
>>> git_location.hostname = 'gitlab.com'

# Export to a `git clone` compatible URL.
>>> git_location.to_url()
'git@gitlab.com:vcs-python/vcspull.git'

See more in the parser document.

Commands (experimental)

Simple subprocess wrappers around git(1), hg(1), svn(1). Here is Git w/ Git.clone:

import pathlib
from libvcs.cmd.git import Git

git = Git(dir=pathlib.Path.cwd() / 'my_git_repo')
git.clone(url='https://github.com/vcs-python/libvcs.git')

Projects

Create a GitProject object of the project to inspect / checkout / update:

import pathlib
from libvcs.projects.git import GitProject

repo = GitProject(
   url="https://github.com/vcs-python/libvcs",
   dir=pathlib.Path().cwd() / "my_repo",
   remotes={
       'gitlab': 'https://gitlab.com/vcs-python/libvcs'
   }
)

# Update / clone repo:
>>> repo.update_repo()

# Get revision:
>>> repo.get_revision()
u'5c227e6ab4aab44bf097da2e088b0ff947370ab8'

Donations

Your donations fund development of new features, testing and support. Your money will go directly to maintenance and development of the project. If you are an individual, feel free to give whatever feels right for the value you get out of the project.

See donation options at https://www.git-pull.com/support.html.

More information

Docs Build Status

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

libvcs-0.15.0a1.tar.gz (56.8 kB view details)

Uploaded Source

Built Distribution

libvcs-0.15.0a1-py3-none-any.whl (55.8 kB view details)

Uploaded Python 3

File details

Details for the file libvcs-0.15.0a1.tar.gz.

File metadata

  • Download URL: libvcs-0.15.0a1.tar.gz
  • Upload date:
  • Size: 56.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for libvcs-0.15.0a1.tar.gz
Algorithm Hash digest
SHA256 b706e67100808ef3305ee07d4782b6e2aa5afb7eeb79380ad5631a4f1f2c71ee
MD5 a6ec7efd73b686d1471282b39969473d
BLAKE2b-256 738852e2b4722a88ea1ba222f994cbc285f9ee6d5dd1ff4cc397cf35b1469a98

See more details on using hashes here.

Provenance

File details

Details for the file libvcs-0.15.0a1-py3-none-any.whl.

File metadata

  • Download URL: libvcs-0.15.0a1-py3-none-any.whl
  • Upload date:
  • Size: 55.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for libvcs-0.15.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe4f9e71044128474c69cba17de247138de38ac0692e6f987a70c35a30582457
MD5 a40d016a7b848c721614fc283dfc2bd7
BLAKE2b-256 d152b714f6377f59208a8a2584594b63daf1175c900088ca209a1fdc33e86714

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page