Skip to content

Commit 319561c

Browse files
committed
Add contributing guidelines
Fixes #410 Assisted-by: Kimi-k2.6
1 parent dd62675 commit 319561c

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
[#1459](https://github.com/libgit2/pygit2/pull/1459)
1414

1515
- Documentation and annotation fixes
16+
[#410](https://github.com/libgit2/pygit2/issues/410)
1617
[#1333](https://github.com/libgit2/pygit2/issues/1333)
1718
[#1458](https://github.com/libgit2/pygit2/issues/1458)
1819
[#1460](https://github.com/libgit2/pygit2/pull/1460)

CONTRIBUTING.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Contributing to pygit2
2+
3+
Thank you for your interest in improving pygit2! This document covers how to submit pull requests and help others in the community.
4+
5+
---
6+
7+
## Pull Requests
8+
9+
We welcome pull requests that fix bugs, add features, improve documentation, or clean up code. To ensure a smooth review process, please follow the steps below.
10+
11+
### Development Setup
12+
13+
See the [install documentation](https://www.pygit2.org/install.html) for instructions on building pygit2 and its libgit2 dependency.
14+
15+
### Making Changes
16+
17+
1. **Fork the repository** and create a feature branch.
18+
2. **Follow the existing code style** (see below).
19+
3. **Add or update tests** for any new or changed behavior. Tests live in `test/` and are run with `pytest`.
20+
4. **Update type stubs** (`pygit2/_pygit2.pyi`) if you modify the C extension's public API.
21+
5. **Update `pygit2/__init__.py`** if you add new public symbols that should be re-exported.
22+
6. **Ensure the test suite passes**:
23+
```bash
24+
pytest
25+
```
26+
7. **Run the linters and type checker**:
27+
```bash
28+
ruff format --diff
29+
ruff check
30+
sh build.sh mypy # or: mypy
31+
sh build.sh stubtest # validate .pyi stubs
32+
```
33+
8. **Build the documentation** if you changed it (requires `sphinx-rtd-theme`):
34+
```bash
35+
make -C docs html
36+
```
37+
9. **Write a clear commit message** explaining the *what* and *why*.
38+
39+
### Code Style
40+
41+
- **Python:** We target Python 3.11+. Use single quotes. Run `ruff format` and `ruff check` before submitting.
42+
- **C:** We use C11. Follow `-std=c11 -Wall`. Match the style of the surrounding code in `src/`.
43+
- **Copyright headers:** All source files must include the standard GPLv2 copyright header. Copy it from an existing file.
44+
- **Docstrings:** Use the style shown in `docs/development.rst`:
45+
```python
46+
def f(a, b):
47+
"""
48+
The general description goes here.
49+
50+
Returns: bla bla.
51+
52+
Parameters:
53+
54+
a : <type>
55+
Bla bla.
56+
57+
b : <type>
58+
Bla bla.
59+
"""
60+
```
61+
62+
### Pull Request Review
63+
64+
- All PRs require review from a maintainer.
65+
- CI will run tests, linting, and type checks automatically.
66+
- Be responsive to feedback and willing to iterate.
67+
- Keep PRs focused. A pull request that does one thing well is easier to review than a large, mixed one.
68+
69+
---
70+
71+
## Helping Others
72+
73+
You do not need to write code to contribute. Helping others is valuable:
74+
75+
- **Answer questions** in open issues and pull requests. If you know the answer, share it.
76+
- **Review PRs.** Even if you are not a maintainer, constructive reviews from the community are welcome.
77+
- **Improve documentation.** Doc fixes, clarifications, and typo corrections can be submitted as PRs just like code.
78+
- **Reproduce reported issues.** Confirming a bug on your system helps maintainers prioritize fixes.
79+
80+
---
81+
82+
## Commit Messages
83+
84+
- Use the present tense and imperative mood (e.g., "Add support for…", not "Added support for…").
85+
- Keep the subject line under 72 characters.
86+
- Reference related issues with `Fixes #123` or `Closes #456` when applicable.
87+
- If you used AI assistance while preparing the change, mention it in the commit message with a tag such as `Assisted-by: Kimi-k2.6` (or the appropriate model name).
88+
89+
---
90+
91+
Thank you for contributing!

0 commit comments

Comments
 (0)