- Notifications
You must be signed in to change notification settings - Fork11
⚙️ Lite, typed, pythonic utilities for git, svn, mercurial, etc.
License
vcs-python/libvcs
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
libvcs is a lite,typed, pythonic tool box fordetection and parsing of URLs, commanding, and syncing withgit,hg, andsvn. Powersvcspull.
- URL Detection and Parsing: Validate and parse Git, Mercurial, and Subversion URLs.
- Command Abstraction: Interact with VCS systems through a Python API.
- Repository Synchronization: Clone and update repositories locally viaPython API.
- py.test fixtures: Create temporary local repositories and working copies for testing for unit tests.
Supports Python 3.10 and above, Git (including AWS CodeCommit), Subversion, and Mercurial.
Toget started, see thequickstart guide for more information.
$pip install --user libvcsEasily validate and parse VCS URLs using thelibvcs.url module:
>>>fromlibvcs.url.gitimportGitURL>>>GitURL.is_valid(url='https://github.com/vcs-python/libvcs.git')True
>>>fromlibvcs.url.gitimportGitURL>>>git_location=GitURL(url='git@github.com:vcs-python/libvcs.git')>>>git_locationGitURL(url=git@github.com:vcs-python/libvcs.git,user=git,hostname=github.com,path=vcs-python/libvcs,suffix=.git,rule=core-git-scp)
Switch repo libvcs -> vcspull:
>>>fromlibvcs.url.gitimportGitURL>>>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 theparser document.
Abstracts CLI commands forgit(1),hg(1),svn(1) via a lightweightsubprocess wrapper.
importpathlibfromlibvcs.cmd.gitimportGitgit=Git(path=pathlib.Path.cwd()/'my_git_repo')git.clone(url='https://github.com/vcs-python/libvcs.git')
Above:libvcs.cmd.git.Git usingGit.clone().
Synchronize your repositories using thelibvcs.sync module.
importpathlibfromlibvcs.sync.gitimportGitSyncrepo=GitSync(url="https://github.com/vcs-python/libvcs",path=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'
Above:libvcs.sync.git.GitSync repositoryobject usingGitSync.update_repo()andGitSync.get_revision().
libvcspytest plugin providespy.test fixtures to swiftly create local VCS repositories and working repositories to test with. Repositories are automatically cleaned on test teardown.
importpathlibfromlibvcs.pytest_pluginimportCreateRepoPytestFixtureFnfromlibvcs.sync.gitimportGitSyncdeftest_repo_git_remote_checkout(create_git_remote_repo:CreateRepoPytestFixtureFn,tmp_path:pathlib.Path,projects_path:pathlib.Path,)->None:git_server=create_git_remote_repo()git_repo_checkout_dir=projects_path/"my_git_checkout"git_repo=GitSync(path=str(git_repo_checkout_dir),url=f"file://{git_server!s}")git_repo.obtain()git_repo.update_repo()assertgit_repo.get_revision()=="initial"assertgit_repo_checkout_dir.exists()assertpathlib.Path(git_repo_checkout_dir/".git").exists()
Under the hood: fixtures bootstrap a temporary$HOME environment in aTmpPathFactoryfor automatic cleanup andpytest-xdist compatibility..
Your donations fund development of new features, testing and support. Your money will go directly tomaintenance and development of the project. If you are an individual, feel free to give whateverfeels right for the value you get out of the project.
See donation options athttps://tony.sh/support.html.
- 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.url: URL Parserlibvcs.cmd: Commandslibvcs.sync: Clone and update
- 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.
About
⚙️ Lite, typed, pythonic utilities for git, svn, mercurial, etc.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.