Lite, typed, python utilities for Git, SVN, Mercurial, etc.
Project description
libvcs
·
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:
>>> 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:
>>> r.update_repo()
Get revision:
>>> r.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
- Python support: 3.9+, pypy
- VCS supported: git(1), svn(1), hg(1)
- Source: https://github.com/vcs-python/libvcs
- Docs: https://libvcs.git-pull.com
- Changelog: https://libvcs.git-pull.com/history.html
- APIs for git, hg, and svn:
libvcs.parse
: Detect and Parselibvcs.cmd
: Commandslibvcs.projects
: High-level synchronization commands
- Issues: https://github.com/vcs-python/libvcs/issues
- Test Coverage: https://codecov.io/gh/vcs-python/libvcs
- pypi: https://pypi.python.org/pypi/libvcs
- Open Hub: https://www.openhub.net/p/libvcs
- License: MIT.
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
Built Distribution
Hashes for libvcs-0.14.0a8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92081b0468d2f576610216fe802f89198ab8aab5c83f851db2086ba4cfca3f92 |
|
MD5 | 0ba695d2111ce56e7fcada1f5d13fdb5 |
|
BLAKE2b-256 | 49aca1bb075cd493ee115c67289b4f364f79689fb5a58dceeb8d8b471391c832 |