|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +libvcs is a lite, typed Python tool for: |
| 8 | +- Detecting and parsing URLs for Git, Mercurial, and Subversion repositories |
| 9 | +- Providing command abstractions for git, hg, and svn |
| 10 | +- Synchronizing repositories locally |
| 11 | +- Creating pytest fixtures for testing with temporary repositories |
| 12 | + |
| 13 | +The library powers [vcspull](https://www.github.com/vcs-python/vcspull/). |
| 14 | + |
| 15 | +## Development Environment |
| 16 | + |
| 17 | +This project uses: |
| 18 | +- Python 3.9+ |
| 19 | +- [uv](https://github.com/astral-sh/uv) for dependency management |
| 20 | +- [ruff](https://github.com/astral-sh/ruff) for linting and formatting |
| 21 | +- [mypy](https://github.com/python/mypy) for type checking |
| 22 | +- [pytest](https://docs.pytest.org/) for testing |
| 23 | + |
| 24 | +## Common Commands |
| 25 | + |
| 26 | +### Setting Up Environment |
| 27 | + |
| 28 | +```bash |
| 29 | +# Install dependencies |
| 30 | +uv pip install --editable . |
| 31 | +uv pip sync |
| 32 | + |
| 33 | +# Install with development dependencies |
| 34 | +uv pip install --editable . -G dev |
| 35 | +``` |
| 36 | + |
| 37 | +### Running Tests |
| 38 | + |
| 39 | +```bash |
| 40 | +# Run all tests |
| 41 | +make test |
| 42 | +# or directly with pytest |
| 43 | +uv run pytest |
| 44 | + |
| 45 | +# Run a single test file |
| 46 | +uv run pytest tests/sync/test_git.py |
| 47 | + |
| 48 | +# Run a specific test |
| 49 | +uv run pytest tests/sync/test_git.py::test_remotes |
| 50 | + |
| 51 | +# Run tests with test watcher |
| 52 | +make start |
| 53 | +# or |
| 54 | +uv run ptw . |
| 55 | +``` |
| 56 | + |
| 57 | +### Linting and Type Checking |
| 58 | + |
| 59 | +```bash |
| 60 | +# Run ruff for linting |
| 61 | +make ruff |
| 62 | +# or directly |
| 63 | +uv run ruff check . |
| 64 | + |
| 65 | +# Format code with ruff |
| 66 | +make ruff_format |
| 67 | +# or directly |
| 68 | +uv run ruff format . |
| 69 | + |
| 70 | +# Run mypy for type checking |
| 71 | +make mypy |
| 72 | +# or directly |
| 73 | +uv run mypy src tests |
| 74 | +``` |
| 75 | + |
| 76 | +### Documentation |
| 77 | + |
| 78 | +```bash |
| 79 | +# Build documentation |
| 80 | +make build_docs |
| 81 | + |
| 82 | +# Start documentation server with auto-reload |
| 83 | +make start_docs |
| 84 | + |
| 85 | +# Update documentation CSS/JS |
| 86 | +make design_docs |
| 87 | +``` |
| 88 | + |
| 89 | +## Code Architecture |
| 90 | + |
| 91 | +libvcs is organized into three main modules: |
| 92 | + |
| 93 | +1. **URL Detection and Parsing** (`libvcs.url`) |
| 94 | + - Base URL classes in `url/base.py` |
| 95 | + - VCS-specific implementations in `url/git.py`, `url/hg.py`, and `url/svn.py` |
| 96 | + - URL registry in `url/registry.py` |
| 97 | + - Constants in `url/constants.py` |
| 98 | + |
| 99 | +2. **Command Abstraction** (`libvcs.cmd`) |
| 100 | + - Command classes for git, hg, and svn in `cmd/git.py`, `cmd/hg.py`, and `cmd/svn.py` |
| 101 | + - Built on top of Python's subprocess module (via `_internal/subprocess.py`) |
| 102 | + |
| 103 | +3. **Repository Synchronization** (`libvcs.sync`) |
| 104 | + - Base sync classes in `sync/base.py` |
| 105 | + - VCS-specific sync implementations in `sync/git.py`, `sync/hg.py`, and `sync/svn.py` |
| 106 | + |
| 107 | +4. **Internal Utilities** (`libvcs._internal`) |
| 108 | + - Subprocess wrappers in `_internal/subprocess.py` |
| 109 | + - Data structures in `_internal/dataclasses.py` and `_internal/query_list.py` |
| 110 | + - Runtime helpers in `_internal/run.py` and `_internal/shortcuts.py` |
| 111 | + |
| 112 | +5. **pytest Plugin** (`libvcs.pytest_plugin`) |
| 113 | + - Provides fixtures for creating temporary repositories for testing |
| 114 | + |
| 115 | +## Testing Strategy |
| 116 | + |
| 117 | +libvcs uses pytest for testing with many custom fixtures. The pytest plugin (`pytest_plugin.py`) defines fixtures for creating temporary repositories for testing. These include: |
| 118 | + |
| 119 | +- `create_git_remote_repo`: Creates a git repository for testing |
| 120 | +- `create_hg_remote_repo`: Creates a Mercurial repository for testing |
| 121 | +- `create_svn_remote_repo`: Creates a Subversion repository for testing |
| 122 | + |
| 123 | +These fixtures handle setup and teardown automatically, creating isolated test environments. |
| 124 | + |
| 125 | +For running tests with actual VCS commands, tests will be skipped if the corresponding VCS binary is not installed. |
0 commit comments