Contributing to CodeMap
First off, thank you for considering contributing to CodeMap! We welcome contributions from everyone, and we're excited to see how you can help make this AI-powered developer toolkit even better.
This document provides guidelines for contributing to the project. Please read it carefully to ensure a smooth and effective contribution process.
Table of Contents
- Contributing to CodeMap
- Table of Contents
- How Can I Contribute?
- Getting Started
- Branching Strategy (Simplified Git Flow)
- Code Contribution Workflow
- Coding Standards
- Testing
- Commit Message Guidelines
- Pull Request Process
- Release Process
- Questions?
How Can I Contribute?
Reporting Bugs
If you encounter a bug, please help us by reporting it!
- Check Existing Issues: Before creating a new issue, please search the GitHub Issues to see if the bug has already been reported.
- Create a New Issue: If the bug hasn't been reported, create a new issue. Please include:
- A clear and descriptive title.
- Your operating system and Python version.
- Steps to reproduce the bug reliably.
- What you expected to happen.
- What actually happened (including any error messages or tracebacks).
- Screenshots or code snippets if relevant.
Suggesting Enhancements
We welcome suggestions for new features or improvements to existing ones.
- Check Existing Issues/Discussions: Search the GitHub Issues and Discussions to see if your idea has already been proposed.
- Create a New Issue/Discussion: If not, open a new issue or start a discussion thread. Describe:
- The enhancement you're proposing.
- The problem it solves or the use case it addresses.
- Any potential implementation ideas (optional).
Code Contributions
If you'd like to contribute code (bug fixes, new features), please follow the workflow outlined below.
Getting Started
Before you start coding, make sure you have set up your development environment correctly by following the Development Setup Guide.
Branching Strategy (Simplified Git Flow)
We use a simplified Git Flow model to manage branches and releases, with automated releases powered by Python Semantic Release.
gitGraph
commit
branch dev
checkout dev
commit
branch feature/new-feature
checkout feature/new-feature
commit
commit
checkout dev
merge feature/new-feature tag: "v0.2.0-next.1"
branch feature/another-feature
checkout feature/another-feature
commit
checkout dev
merge feature/another-feature tag: "v0.2.0-next.2"
branch release/v0.2.0
checkout release/v0.2.0
commit
checkout main
merge release/v0.2.0 tag: "v0.2.0"
checkout dev
merge main
branch hotfix/critical-fix
checkout hotfix/critical-fix
commit
checkout main
merge hotfix/critical-fix tag: "v0.2.1"
checkout dev
merge main
Core Branches
main
:- Represents the latest stable production-ready release.
- Pushes to
main
trigger automatic stable version releases. - Protected branch with required reviews. Changes come via approved PRs from
release/*
orhotfix/*
branches.
dev
:- The primary integration branch for ongoing development and upcoming features.
- Pushes to
dev
trigger automatic pre-release versions with the-next
tag. - All feature branches are merged into
dev
. - Continuously tested via CI.
Supporting Branches
- Feature branches (
feature/*
):- Branched off
dev
. - Used for developing new features or significant changes.
- Named descriptively (e.g.,
feature/add-pr-update-command
). - Merged back into
dev
via Pull Requests (PRs).
- Branched off
- Release branches (
release/*
):- Branched off
dev
when preparing for a new stable release. - Used for final testing, documentation updates, and version stabilization.
- Format:
release/vX.Y.0
(e.g.,release/v1.2.0
). - Merged into
main
via PR, which triggers automatic release. - No need for manual version bumping as this is handled by semantic-release.
- Branched off
- Hotfix branches (
hotfix/*
):- Branched off
main
. - Used for critical bug fixes needed in the production version.
- Merged into
main
via PR, triggering automatic patch release. - Also merged back into
dev
(usually by merging the updatedmain
).
- Branched off
Workflow Examples
-
New Feature Development:
# Start from the dev branch git checkout dev git pull origin dev # Create your feature branch git checkout -b feature/your-feature-name # --- Make your changes --- # Push your feature branch git push -u origin feature/your-feature-name # Open a Pull Request to merge `feature/your-feature-name` into `dev` # When merged, a new pre-release version may be created automatically
-
Release Preparation:
git checkout dev git pull origin dev # Create a release branch (no need to bump versions manually) git checkout -b release/v1.3.0 # Make any final adjustments, documentation updates, etc. # Push the release branch git push -u origin release/v1.3.0 # Create a PR from release/v1.3.0 to main # When the PR is approved and merged: # 1. A new release will be automatically created # 2. The package will be built and published to PyPI # 3. Main should be merged back to dev to sync the version changes git checkout dev git pull origin dev git merge origin/main git push origin dev
-
Hotfix Process:
git checkout main git pull origin main # Create a hotfix branch git checkout -b hotfix/critical-bug-fix # Fix the bug and commit using conventional commit format # (preferably using `codemap commit`) # Push the hotfix branch git push -u origin hotfix/critical-bug-fix # Create a PR from hotfix/critical-bug-fix to main # When merged, a patch release will be automatically created # After the hotfix is released, sync changes back to dev git checkout dev git pull origin dev git merge origin/main git push origin dev
Code Contribution Workflow
- Fork & Clone: Fork the repository on GitHub and clone your fork locally.
git clone https://github.com/YOUR_USERNAME/codemap.git cd codemap git remote add upstream https://github.com/SarthakMishra/codemap.git
- Setup: Follow the Development Setup instructions.
- Branch: Create a new branch based on the correct base branch (
dev
for features/improvements,main
only for agreed-upon hotfixes).# For features/improvements git checkout dev git pull upstream dev # Keep dev up-to-date git checkout -b feature/your-descriptive-name # For hotfixes (usually maintainers) # git checkout main # git pull upstream main # git checkout -b hotfix/your-fix-name
- Code: Make your changes. Write clean, well-commented code. Add or update tests as necessary.
- Format & Lint: Ensure your code adheres to the project's style guidelines.
task format task lint # Or run all checks task ci
- Test: Run the test suite to ensure your changes haven't broken anything.
task test # Check coverage task coverage
- Commit: Commit your changes using meaningful commit messages. We strongly encourage using the
codemap commit
command to generate conventional commit messages.# Stage your changes git add . # Use the interactive commit tool codemap commit # Or if you prefer manual commits, follow conventional commit format # git commit -m "feat(cli): add option for custom output format"
- Push: Push your branch to your fork.
git push -u origin feature/your-descriptive-name
- Pull Request: Open a Pull Request (PR) from your fork's branch to the
upstream/dev
branch (orupstream/main
for hotfixes). Provide a clear description of your changes.
Coding Standards
- Follow PEP 8 for Python code.
- Use type hints (
typing
module). - Write docstrings for public modules, classes, and functions (see project docs rules).
- Use
ruff
for linting and formatting (task format
,task lint
).
Testing
- Write tests using
pytest
. - Aim for good test coverage (
task coverage
). - Ensure all tests pass (
task test
) before submitting a PR.
Commit Message Guidelines
We follow the Conventional Commits specification.
- Format:
<type>[optional scope]: <description>
- Example:
feat(commit): add semantic diff splitting strategy
- Use
codemap commit
: The easiest way to ensure compliance is to use the built-incodemap commit
command.
Pull Request Process
- Ensure all CI checks (linting, testing) pass.
- Provide a clear title and description for your PR.
- Link any related issues.
- Request reviews from maintainers.
- Address any feedback promptly.
- Once approved, a maintainer will merge the PR.
Release Process
Releases are managed automatically using Python Semantic Release.
Automatic Releases
- Merging a PR into
dev
may trigger a pre-release (e.g.,v1.2.0-next.1
). - Merging a PR from a
release/*
orhotfix/*
branch intomain
will trigger a stable release (e.g.,v1.2.0
orv1.2.1
). - The release process includes:
- Bumping the version based on commit messages.
- Generating a changelog.
- Tagging the commit in Git.
- Creating a GitHub Release.
- Building the package.
- Publishing to PyPI.
Release Preparation
Maintainers will create release/*
branches off dev
when ready to stabilize for a release. This branch allows for final testing and documentation updates before merging to main
.
Hotfix Process
Critical bugs in main
are fixed using hotfix/*
branches, which are merged directly back into main
to trigger a patch release.
Questions?
If you have questions, feel free to open an issue or start a discussion on GitHub.