{"id":1990537,"url":"https://github.com/vcs-python/libvcs","last_synced_at":"2025-04-05T06:03:37.074Z","repository":{"id":37335649,"uuid":"61519113","full_name":"vcs-python/libvcs","owner":"vcs-python","description":"⚙️ Lite, typed, pythonic utilities for git, svn, mercurial, etc.","archived":false,"fork":false,"pushed_at":"2025-03-23T21:20:16.000Z","size":4066,"stargazers_count":51,"open_issues_count":52,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T05:03:40.232Z","etag":null,"topics":["api","git","hg","library","mercurial","parsing","python","python-3","pythonic","subversion","svn","url-parser","vcs"],"latest_commit_sha":null,"homepage":"https://libvcs.git-pull.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vcs-python.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":"docs/contributing/index.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-20T05:25:31.000Z","updated_at":"2025-03-23T21:20:20.000Z","dependencies_parsed_at":"2024-01-20T15:54:08.190Z","dependency_job_id":"eec94388-e71c-4904-a153-2cb88c53fa27","html_url":"https://github.com/vcs-python/libvcs","commit_stats":{"total_commits":1562,"total_committers":7,"mean_commits":"223.14285714285714","dds":0.0934699103713188,"last_synced_commit":"80e459d76890ae2d2e2145abe0353460ea042883"},"previous_names":[],"tags_count":159,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vcs-python%2Flibvcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vcs-python%2Flibvcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vcs-python%2Flibvcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vcs-python%2Flibvcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vcs-python","download_url":"https://codeload.github.com/vcs-python/libvcs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294516,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","git","hg","library","mercurial","parsing","python","python-3","pythonic","subversion","svn","url-parser","vcs"],"created_at":"2024-01-20T15:37:37.174Z","updated_at":"2025-04-05T06:03:37.059Z","avatar_url":"https://github.com/vcs-python.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# `libvcs` \u0026middot; [![Python Package](https://img.shields.io/pypi/v/libvcs.svg)](https://pypi.org/project/libvcs/) [![License](https://img.shields.io/github/license/vcs-python/libvcs.svg)](https://github.com/vcs-python/libvcs/blob/master/LICENSE) [![Code Coverage](https://codecov.io/gh/vcs-python/libvcs/branch/master/graph/badge.svg)](https://codecov.io/gh/vcs-python/libvcs)\n\nlibvcs is a lite, [typed](https://docs.python.org/3/library/typing.html), pythonic tool box for\ndetection and parsing of URLs, commanding, and syncing with `git`, `hg`, and `svn`. Powers\n[vcspull](https://www.github.com/vcs-python/vcspull/).\n\n## Overview\n\n### Key Features\n\n- **URL Detection and Parsing**: Validate and parse Git, Mercurial, and Subversion URLs.\n- **Command Abstraction**: Interact with VCS systems through a Python API.\n- **Repository Synchronization**: Clone and update repositories locally via\n  Python API.\n- **py.test fixtures**: Create temporary local repositories and working copies for testing for unit tests.\n\n_Supports Python 3.9 and above, Git (including AWS CodeCommit), Subversion, and Mercurial._\n\nTo **get started**, see the [quickstart guide](https://libvcs.git-pull.com/quickstart.html) for more information.\n\n```console\n$ pip install --user libvcs\n```\n\n## URL Detection and Parsing\n\nEasily validate and parse VCS URLs using the\n[`libvcs.url`](https://libvcs.git-pull.com/url/index.html) module:\n\n### Validate URLs\n\n```python\n\u003e\u003e\u003e from libvcs.url.git import GitURL\n\n\u003e\u003e\u003e GitURL.is_valid(url='https://github.com/vcs-python/libvcs.git')\nTrue\n```\n\n### Parse and adjust Git URLs:\n\n```python\n\u003e\u003e\u003e from libvcs.url.git import GitURL\n\n\u003e\u003e\u003e git_location = GitURL(url='git@github.com:vcs-python/libvcs.git')\n\n\u003e\u003e\u003e git_location\nGitURL(url=git@github.com:vcs-python/libvcs.git,\n        user=git,\n        hostname=github.com,\n        path=vcs-python/libvcs,\n        suffix=.git,\n        rule=core-git-scp)\n```\n\nSwitch repo libvcs -\u003e vcspull:\n\n```python\n\u003e\u003e\u003e from libvcs.url.git import GitURL\n\n\u003e\u003e\u003e git_location = GitURL(url='git@github.com:vcs-python/libvcs.git')\n\n\u003e\u003e\u003e git_location.path = 'vcs-python/vcspull'\n\n\u003e\u003e\u003e git_location.to_url()\n'git@github.com:vcs-python/vcspull.git'\n\n# Switch them to gitlab:\n\u003e\u003e\u003e git_location.hostname = 'gitlab.com'\n\n# Export to a `git clone` compatible URL.\n\u003e\u003e\u003e git_location.to_url()\n'git@gitlab.com:vcs-python/vcspull.git'\n```\n\nSee more in the [parser document](https://libvcs.git-pull.com/parse/index.html).\n\n## Command Abstraction\n\nAbstracts CLI commands for `git(1)`, `hg(1)`, `svn(1)` via a lightweight [`subprocess`](https://docs.python.org/3/library/subprocess.html) wrapper.\n\n### Run Git Commands\n\n```python\nimport pathlib\nfrom libvcs.cmd.git import Git\n\ngit = Git(path=pathlib.Path.cwd() / 'my_git_repo')\ngit.clone(url='https://github.com/vcs-python/libvcs.git')\n```\n\nAbove: [`libvcs.cmd.git.Git`](https://libvcs.git-pull.com/cmd/git.html#libvcs.cmd.git.Git) using\n[`Git.clone()`](http://libvcs.git-pull.com/cmd/git.html#libvcs.cmd.git.Git.clone).\n\n## Repository Synchronization\n\nSynchronize your repositories using the\n[`libvcs.sync`](https://libvcs.git-pull.com/sync/) module.\n\n### Clone and Update Repositories\n\n```python\nimport pathlib\nfrom libvcs.sync.git import GitSync\n\nrepo = GitSync(\n   url=\"https://github.com/vcs-python/libvcs\",\n   path=pathlib.Path().cwd() / \"my_repo\",\n   remotes={\n       'gitlab': 'https://gitlab.com/vcs-python/libvcs'\n   }\n)\n\n# Update / clone repo:\n\u003e\u003e\u003e repo.update_repo()\n\n# Get revision:\n\u003e\u003e\u003e repo.get_revision()\nu'5c227e6ab4aab44bf097da2e088b0ff947370ab8'\n```\n\nAbove: [`libvcs.sync.git.GitSync`](https://libvcs.git-pull.com/projects/git.html#libvcs.sync.git.GitSync) repository\nobject using\n[`GitSync.update_repo()`](https://libvcs.git-pull.com/sync/git.html#libvcs.sync.git.GitSync.update_repo)\nand\n[`GitSync.get_revision()`](https://libvcs.git-pull.com/sync/git.html#libvcs.sync.git.GitSync.get_revision).\n\n## Pytest plugin: Temporary VCS repositories for testing\n\nlibvcs [pytest plugin](https://libvcs.git-pull.com/pytest-plugin.html) provides [py.test fixtures] to swiftly create local VCS repositories and working repositories to test with. Repositories are automatically cleaned on test teardown.\n\n[py.test fixtures]: https://docs.pytest.org/en/8.2.x/explanation/fixtures.html\n\n### Use temporary, local VCS in py.test\n\n```python\nimport pathlib\n\nfrom libvcs.pytest_plugin import CreateRepoPytestFixtureFn\nfrom libvcs.sync.git import GitSync\n\n\ndef test_repo_git_remote_checkout(\n    create_git_remote_repo: CreateRepoPytestFixtureFn,\n    tmp_path: pathlib.Path,\n    projects_path: pathlib.Path,\n) -\u003e None:\n    git_server = create_git_remote_repo()\n    git_repo_checkout_dir = projects_path / \"my_git_checkout\"\n    git_repo = GitSync(path=str(git_repo_checkout_dir), url=f\"file://{git_server!s}\")\n\n    git_repo.obtain()\n    git_repo.update_repo()\n\n    assert git_repo.get_revision() == \"initial\"\n\n    assert git_repo_checkout_dir.exists()\n    assert pathlib.Path(git_repo_checkout_dir / \".git\").exists()\n```\n\nUnder the hood: fixtures bootstrap a temporary `$HOME` environment in a\n[`TmpPathFactory`](https://docs.pytest.org/en/7.1.x/reference/reference.html#tmp-path-factory-factory-api)\nfor automatic cleanup and `pytest-xdist` compatibility..\n\n## Donations\n\nYour donations fund development of new features, testing and support. Your money will go directly to\nmaintenance and development of the project. If you are an individual, feel free to give whatever\nfeels right for the value you get out of the project.\n\nSee donation options at \u003chttps://www.git-pull.com/support.html\u003e.\n\n## More information\n\n- Python support: 3.9+, pypy\n- VCS supported: git(1), svn(1), hg(1)\n- Source: \u003chttps://github.com/vcs-python/libvcs\u003e\n- Docs: \u003chttps://libvcs.git-pull.com\u003e\n- Changelog: \u003chttps://libvcs.git-pull.com/history.html\u003e\n- APIs for git, hg, and svn:\n  - [`libvcs.url`](https://libvcs.git-pull.com/url/): URL Parser\n  - [`libvcs.cmd`](https://libvcs.git-pull.com/cmd/): Commands\n  - [`libvcs.sync`](https://libvcs.git-pull.com/sync/): Clone and update\n- Issues: \u003chttps://github.com/vcs-python/libvcs/issues\u003e\n- Test Coverage: \u003chttps://codecov.io/gh/vcs-python/libvcs\u003e\n- pypi: \u003chttps://pypi.python.org/pypi/libvcs\u003e\n- Open Hub: \u003chttps://www.openhub.net/p/libvcs\u003e\n- License: [MIT](https://opensource.org/licenses/MIT).\n\n[![Docs](https://github.com/vcs-python/libvcs/workflows/docs/badge.svg)](https://libvcs.git-pull.com/)\n[![Build Status](https://github.com/vcs-python/libvcs/workflows/tests/badge.svg)](https://github.com/vcs-python/libvcs/actions?query=workflow%3A%22tests%22)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvcs-python%2Flibvcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvcs-python%2Flibvcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvcs-python%2Flibvcs/lists"}