Thank you for your interest in contributing to pr-diff-walk! This document provides guidelines and instructions for contributing.
- Python 3.10 or higher
- pip or uv for package management
- Git
# Clone the repository
git clone https://github.com/felixLandlord/prDiffWalk.git
cd prDiffWalk
# Install in development mode with dev dependencies
pip install -e ".[dev]"
# Run tests to verify setup
pytestprDiffWalk/
├── src/pr_diff_walk/ # Main source code
│ ├── cli.py # CLI entry point
│ ├── service.py # Core analysis service
│ ├── base.py # Base integration class
│ ├── schemas.py # Data models
│ ├── git_clients/ # Git provider clients
│ └── integrations/ # Language-specific parsers
├── tests/ # Test suite
│ ├── test_*.py # Unit tests
│ └── integrations/ # Integration tests
├── docs/ # Documentation
├── scripts/ # Utility scripts
├── README.md # Main documentation
└── pyproject.toml # Package configuration
git checkout -b feature/your-feature-name
# or
git checkout -b fix/issue-you-are-fixing- Follow the existing code style and conventions
- Write clean, readable code with appropriate type hints
- Add comments only when necessary for clarity
# Run all tests
pytest
# Run with coverage
pytest --cov=src/pr_diff_walk --cov-report=html
# Run specific test file
pytest tests/test_service.py -v
# Run linting
ruff check src/git add .
git commit -m "feat: add support for new language integration"Use conventional commits:
feat:New featurefix:Bug fixdocs:Documentation changesrefactor:Code refactoringtest:Test changeschore:Maintenance tasks
Language integrations are in src/pr_diff_walk/integrations/. To add support for a new language:
Create src/pr_diff_walk/integrations/your_lang.py:
import re
from pathlib import Path
from typing import Iterable, List, Optional, Set
from ..base import LanguageIntegration
from ..schemas import EntityDef, EntityRef, ImportEdge, LanguageConfig, RepositoryFiles
YOUR_LANG_EXTENSIONS = {".ext"}
def _your_lang_config() -> LanguageConfig:
return LanguageConfig(
name="your_lang",
extensions=YOUR_LANG_EXTENSIONS,
file_patterns=["*.ext"],
module_marker="module.json",
package_indicator="package.json",
import_patterns={
"import": r"^import\s+['\"](.+)['\"]",
},
entity_kinds={"function", "class", "variable"},
)
class YourLangIntegration(LanguageIntegration):
def __init__(self):
super().__init__(_your_lang_config())
def iter_code_files(self, root: Path, repo: RepositoryFiles) -> Iterable[Path]:
# Iterate over files with your language extension
...
def parse_imports(self, file_path: str, lines: List[str], repo_files: Set[str]) -> List[ImportEdge]:
# Parse import statements and return ImportEdge objects
...
def parse_entities(self, file_path: str, lines: List[str]) -> List[EntityDef]:
# Parse entity definitions (functions, classes, etc.)
...
def resolve_import_to_file(self, current_file: str, spec: str, repo_files: Set[str]) -> Optional[str]:
# Convert import spec to file path
...Update src/pr_diff_walk/integrations/__init__.py:
- Import your integration class
- Add to
AVAILABLE_INTEGRATIONSdict - Add to
LANGUAGE_TO_INTEGRATIONandEXTENSION_TO_INTEGRATIONmappings
Create tests/integrations/test_your_lang.py:
import pytest
from pr_diff_walk.integrations.your_lang import YourLangIntegration
class TestYourLangIntegration:
def test_parse_entities(self):
integration = YourLangIntegration()
code = "function hello() {}"
entities = integration.parse_entities("test.ext", code.splitlines())
assert len(entities) == 1
assert entities[0].name == "hello"
def test_parse_imports(self):
integration = YourLangIntegration()
code = 'import "module"'
edges = integration.parse_imports("test.ext", code.splitlines(), set())
assert len(edges) == 1- Add to CLI
listcommand descriptions - Update README.md integration table
- Add language-specific example if helpful
- Use type hints for all function parameters and return values
- Follow PEP 8 with 100 character line length
- Use descriptive variable names
- Keep functions focused and small
- Write docstrings for public APIs
When reporting bugs:
- Include your Python version
- Include the pr-diff-walk version (
pip show pr-diff-walk) - Provide a minimal reproducible example
- Include any relevant error messages
Feel free to open an issue for questions or discussions about the project.