Skip to content

Commit a26d6c1

Browse files
authored
Update CONTRIBUTING.md
Clarifies linting and auto formatting in CONTRIBUTING.md Closes #7
1 parent 811eb30 commit a26d6c1

File tree

1 file changed

+104
-10
lines changed

1 file changed

+104
-10
lines changed

CONTRIBUTING.md

Lines changed: 104 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ documentation improvements, and code enhancements.
88

99
- [Code of Conduct](#code-of-conduct)
1010
- [How to Contribute](#how-to-contribute)
11+
- [Requirements](#requirements)
1112
- [Reporting Issues](#reporting-issues)
1213
- [Suggesting Features](#suggesting-features)
1314
- [Submitting Pull Requests](#submitting-pull-requests)
1415
- [Coding Standards](#coding-standards)
1516
- [Testing](#testing)
1617
- [Running Tests](#running-tests)
1718
- [Additional Tips](#additional-tips)
19+
- [Linting](#linting)
20+
- [Auto Formatting](#auto-formatting)
1821
- [Style Guidelines](#style-guidelines)
1922
- [Acknowledgments](#acknowledgments)
2023

@@ -25,11 +28,33 @@ expectations for participation in this project.
2528

2629
## How to Contribute
2730

31+
### Requirements
32+
33+
Contributing is meant to be as painless as possible. However, for the
34+
sake of a nicely readable and unified codebase, there are some extra
35+
steps needed before anybody can contribute. While the actual application
36+
itself only requires Python 3 and Git, contributing will require you to
37+
install additional applications. The following are required in order to
38+
pass our CI builder:
39+
40+
- [`ruff`](https://github.com/astral-sh/ruff)
41+
- [`black`](https://github.com/psf/black)
42+
43+
We understand these opinionated tools may be a bit controversial,
44+
but these tools help keep consistency and maintain some semblance
45+
of standardization across the codebase. If you code does not pass the
46+
CI builder, it will not be allowed to be merged in, so please keep that
47+
in mind when submitting code.
48+
2849
### Reporting Issues
2950

3051
If you encounter any bugs or have suggestions for improvements,
31-
please [open an issue](https://github.com/tomice/git-py-stats/issues).
32-
When reporting an issue, please include the following:
52+
please [open an issue](https://github.com/git-quick-stats/git-py-stats/issues).
53+
We recommend opening up an issue regardless of how minor the change
54+
may be, as it allows us to better track changes in the project.
55+
You can even submit a pull request immediately after to address the issue.
56+
57+
When reporting an issue, please try to include the following:
3358

3459
- A clear and descriptive title.
3560
- A detailed description of the problem or suggestion.
@@ -40,7 +65,13 @@ When reporting an issue, please include the following:
4065

4166
Have an idea for a new feature? We'd love to hear it! Please create an issue
4267
with the tag `feature request` and provide as much detail as possible about
43-
the proposed functionality.
68+
the proposed functionality. One of the maintainers should get back to you
69+
within a timely manner to discuss the new features.
70+
71+
Please note that this project strives to maintain feature parity with the
72+
parent project, [`git-quick-stats`](https://github.com/git-quick-stats/git-quick-stats/).
73+
Depending on the change, we may ask you to first submit the feature request
74+
to the parent project before we adopt it.
4475

4576
### Submitting Pull Requests
4677

@@ -82,15 +113,21 @@ Contributions are made via pull requests. Here's how to submit one:
82113
git commit -m "Add feature: description of your feature"
83114
```
84115

85-
6. **Push to Your Fork**
116+
Please note that GitHub has [built-in keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue)
117+
that allow you to automatically link an issue to a commit message.
118+
Making use of these makes it easier to see exactly what each
119+
commit is attempting to address.
120+
121+
7. **Push to Your Fork**
86122

87123
```bash
88124
git push origin feature/your-feature-name
89125
```
90126

91-
7. **Open a Pull Request**
127+
8. **Open a Pull Request**
92128

93-
Navigate to the original repository and click on "New Pull Request".
129+
Navigate to the original repository and click on "New Pull Request",
130+
or try [this link](https://github.com/git-quick-stats/git-py-stats/compare).
94131
Provide a clear description of your changes and reference any related issues
95132
should they exist.
96133

@@ -139,15 +176,15 @@ Ensure that all tests pass before submitting a pull request.
139176
within the `git_py_stats/tests/` directory:
140177

141178
```bash
142-
python3 -m unittest discover -s git_py_stats/tests
179+
python -m unittest discover -s git_py_stats/tests
143180
```
144181

145182
3. **Run a Specific Test File**:
146183

147184
To run a specific test file, you can use:
148185

149186
```bash
150-
python3 -m unittest git_py_stats.tests.test_generate_cmds
187+
python -m unittest git_py_stats.tests.test_generate_cmds
151188
```
152189

153190
### Additional Tips
@@ -156,20 +193,77 @@ Ensure that all tests pass before submitting a pull request.
156193
- To view more detailed output, use the `-v` (verbose) flag:
157194

158195
```bash
159-
python3 -m unittest discover -s git_py_stats/tests -v
196+
python -m unittest discover -s git_py_stats/tests -v
160197
```
161198

162199
- To run all tests automatically and display a summary of results:
163200

164201
```bash
165-
python3 -m unittest discover -s git_py_stats/tests
202+
python -m unittest discover -s git_py_stats/tests
166203
```
167204

168205
- If you need help writing tests, here are tutorials and books that might help:
169206
- [Python's unittest docs](https://docs.python.org/3/library/unittest.html)
170207
- [Python's unittest.mock docs](https://docs.python.org/3/library/unittest.mock.html)
171208
- [Obey the Testing Goat](https://www.obeythetestinggoat.com/pages/book.html#toc)
172209

210+
## Linting
211+
212+
As stated before, we use `ruff` for linting. Installing `ruff` will depend on
213+
your system and how you want to manage your dependencies in general. Ubuntu
214+
and Fedora can use [snaps](https://snapcraft.io/install/ruff/ubuntu),
215+
Arch can use [pacman](https://archlinux.org/packages/extra/x86_64/ruff/),
216+
and of course, anybody can use [PyPI](https://pypi.org/project/ruff/).
217+
218+
Ultimately, it is up to you how you wish to install `ruff`, but it is required
219+
to pass in order to be able to get past our CI builder.
220+
221+
Once `ruff` is installed, you can invoke it by running the following command
222+
inside the `git-py-stats` repo:
223+
224+
```sh
225+
ruff check git_py_stats
226+
```
227+
228+
If it passes, `ruff` will print out "All checks passed!" If it gives an
229+
error, it will point you to where the issue is and mention the problem.
230+
231+
Sometimes, minor issues can be fixed using the `--fix` flag. `ruff` will
232+
try to point these out and fix them for you. Feel free to use this option,
233+
but realize it might conflict with `black`, so always try to run the linter
234+
and get that to pass before running it through the auto formatter.
235+
236+
## Auto Formatting
237+
238+
Like earlier, we are opinionated on how the code should look. As such, we
239+
have a highly opinionated auto formatter thanks to `black`. Just like with
240+
`ruff`, installing `black` will depend on your system and how you want to
241+
manage dependencies. You can see how to install it on a slew of different
242+
operating systems [here](https://snapcraft.io/black). Like nearly all Python
243+
projects, there is also a [PyPI](https://pypi.org/project/black/) equivalent.
244+
245+
Install this however you wish, but your code must pass `black`'s default
246+
auto formatter settings in order to be able to pass our CI builder.
247+
248+
Once `black` is installed, you can invoke it by running the following command
249+
inside the `git-py-stats` repo:
250+
251+
```sh
252+
black .
253+
```
254+
255+
It should report back something similar to the following:
256+
257+
```sh
258+
All done! ✨ 🍰 ✨
259+
21 files left unchanged.
260+
```
261+
262+
That's it! If there were any changes, commit them. Do *not* try to re-adjust
263+
anything as that might break the auto formatting you just applied.
264+
265+
Once that's done, your code is finally ready for a pull request!
266+
173267
## Style Guidelines
174268
175269
- Write clear and concise code.

0 commit comments

Comments
 (0)