-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre commit setup #61
Merged
Merged
Pre commit setup #61
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ad07246
add .env to .gitignore
patillacode 7ed75d1
add pre-commit-config
patillacode 331de0f
add pre-commit dependency
patillacode 1123502
order pre-commit mirrors
patillacode 2f241fe
fix README.md + add CONTRIBUTING.md
patillacode 55e71f4
add link to CONTRIBUTING.md
patillacode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# Contributing to GPT Engineer | ||
|
||
By participating in this project, you agree to abide by the [code of conduct](CODE_OF_CONDUCT.md). | ||
|
||
## Getting Started | ||
|
||
To get started with contributing, please follow these steps: | ||
|
||
1. Fork the repository and clone it to your local machine. | ||
2. Install any necessary dependencies. | ||
3. Create a new branch for your changes: `git checkout -b my-branch-name`. | ||
4. Make your desired changes or additions. | ||
5. Run the tests to ensure everything is working as expected. | ||
6. Commit your changes: `git commit -m "Descriptive commit message"`. | ||
7. Push to the branch: `git push origin my-branch-name`. | ||
8. Submit a pull request to the `main` branch of the original repository. | ||
|
||
|
||
## Code Style | ||
|
||
Please make sure to follow the established code style guidelines for this project. Consistent code style helps maintain readability and makes it easier for others to contribute to the project. | ||
|
||
To enforce this we use [`pre-commit`](https://pre-commit.com/) to run [`black`](https://black.readthedocs.io/en/stable/index.html) and [`ruff`](https://beta.ruff.rs/docs/) on every commit. | ||
|
||
`pre-commit` is part of our `requirements.txt` file so you should already have it installed. If you don't, you can install the library via pip with: | ||
|
||
```bash | ||
$ pip install -r requirements.txt | ||
``` | ||
|
||
And then install the `pre-commit` hooks with: | ||
```bash | ||
$ pre-commit install | ||
|
||
pre-commit installed at .git/hooks/pre-commit | ||
|
||
``` | ||
|
||
If you are not familiar with the concept of [git hooks](https://git-scm.com/docs/githooks) and/or [`pre-commit`](https://pre-commit.com/) please read the documentation to understand how they work. | ||
|
||
As an introduction of the actual workflow, here is an example of the process you will encounter when you make a commit: | ||
|
||
Let's add a file we have modified with some errors, see how the pre-commit hooks run `black` and fails. | ||
`black` is set to automatically fix the issues it finds: | ||
```bash | ||
$ git add chat_to_files.py | ||
$ git commit -m "commit message" | ||
black....................................................................Failed | ||
- hook id: black | ||
- files were modified by this hook | ||
|
||
reformatted chat_to_files.py | ||
|
||
All done! ✨ 🍰 ✨ | ||
1 file reformatted. | ||
``` | ||
|
||
You can see that `chat_to_files.py` is both staged and not staged for commit. This is because `black` has formatted it and now it is different from the version you have in your working directory. To fix this you can simply run `git add chat_to_files.py` again and now you can commit your changes. | ||
```bash | ||
$ git status | ||
On branch pre-commit-setup | ||
Changes to be committed: | ||
(use "git restore --staged <file>..." to unstage) | ||
modified: chat_to_files.py | ||
|
||
Changes not staged for commit: | ||
(use "git add <file>..." to update what will be committed) | ||
(use "git restore <file>..." to discard changes in working directory) | ||
modified: chat_to_files.py | ||
``` | ||
|
||
|
||
Now let's add the file again to include the latest commits and see how `ruff` fails. | ||
```bash | ||
$ git add chat_to_files.py | ||
$ git commit -m "commit message" | ||
black....................................................................Passed | ||
ruff.....................................................................Failed | ||
- hook id: ruff | ||
- exit code: 1 | ||
- files were modified by this hook | ||
|
||
Found 2 errors (2 fixed, 0 remaining). | ||
``` | ||
|
||
Same as before, you can see that `chat_to_files.py` is both staged and not staged for commit. This is because `ruff` has formatted it and now it is different from the version you have in your working directory. To fix this you can simply run `git add chat_to_files.py` again and now you can commit your changes. | ||
```bash | ||
$ git add chat_to_files.py | ||
$ git commit -m "commit message" | ||
black....................................................................Passed | ||
ruff.....................................................................Passed | ||
fix end of files.........................................................Passed | ||
[pre-commit-setup f00c0ce] testing | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
``` | ||
|
||
Now your file has been committed and you can push your changes. | ||
|
||
At the beggining this might seem like a tedious process (having to add the file again after `black` and `ruff` have modified it) but it is actually very useful. It allows you to see what changes `black` and `ruff` have made to your files and make sure that they are correct before you commit them. | ||
|
||
|
||
|
||
## Issue Tracker | ||
|
||
If you encounter any bugs, issues, or have feature requests, please [create a new issue](https://github.com/AntonOsika/gpt-engineer/issues/new) on the project's GitHub repository. Provide a clear and descriptive title along with relevant details to help us address the problem or understand your request. | ||
|
||
|
||
## Licensing | ||
|
||
By contributing to GPT Engineer, you agree that your contributions will be licensed under the [LICENSE](../LICENSE) file of the project. | ||
|
||
Thank you for your interest in contributing to GPT Engineer! We appreciate your support and look forward to your contributions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ build/ | |
*.egg | ||
|
||
# Virtual environments | ||
.env | ||
venv/ | ||
ENV/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
fail_fast: true | ||
|
||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
args: [--config, pyproject.toml] | ||
types: [python] | ||
exclude: .+/migrations((/.+)|(\.py)) | ||
|
||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
rev: "v0.0.272" | ||
hooks: | ||
- id: ruff | ||
args: [--fix, --exit-non-zero-on-fix] | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-toml | ||
id: check-yaml | ||
id: detect-private-key | ||
id: end-of-file-fixer | ||
id: trailing-whitespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
black==23.3.0 | ||
openai==0.27.8 | ||
pre-commit==3.3.3 | ||
ruff==0.0.272 | ||
typer==0.9.0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am aware that we don't have a
CODE_OF_CONDUCT.md
file yet.See #48