Skip to content

Commit a65e57a

Browse files
authored
Merge pull request #6437 from kenjis/add-docs-on-PR-commits
docs: add about PR commits
2 parents 622f829 + c382096 commit a65e57a

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

contributing/pull_request.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,17 @@ The best way to contribute is to fork the CodeIgniter4 repository, and "clone" t
249249
7. Fix existing bugs on the [Issue tracker](https://github.com/codeigniter4/CodeIgniter4/issues) after confirming that no one else is working on them.
250250
8. [Commit](https://help.github.com/en/desktop/contributing-to-projects/committing-and-reviewing-changes-to-your-project) the changed files in your contribution branch.
251251
- `> git commit`
252-
- Commit messages are expected to be descriptive of what you changed specifically. Commit messages like "Fixes #1234" would be asked by the reviewer to be revised.
253-
9. If there are intermediate commits that are not meaningful to the overall PR, such as "Fixed error on style guide", "Fixed phpstan error", "Fixing mistake in code", and other related commits, it is advised to squash your commits so that we can have a clean commit history.
254-
10. If you have touched PHP code, run static analysis.
252+
- Commit messages are expected to be descriptive of why and what you changed specifically. Commit messages like "Fixes #1234" would be asked by the reviewer to be revised. [Atomic commit](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention) is recommended. See [Contribution Workflow](./workflow.md#commit-messages) for details.
253+
9. If you have touched PHP code, run static analysis.
255254
- `> composer analyze`
256255
- `> vendor/bin/rector process`
257-
11. Run unit tests on the specific file you modified. If there are no existing tests yet, please create one.
256+
10. Run unit tests on the specific file you modified. If there are no existing tests yet, please create one.
258257
- `> vendor/bin/phpunit tests/system/path/to/file/you/modified`
259258
- Make sure the tests pass to have a higher chance of merging.
260-
12. [Push](https://docs.github.com/en/github/using-git/pushing-commits-to-a-remote-repository) your contribution branch to your fork.
259+
11. [Push](https://docs.github.com/en/github/using-git/pushing-commits-to-a-remote-repository) your contribution branch to your fork.
261260
- `> git push origin <new-branch-name>`
262-
13. Send a [pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork).
263-
14. Label your pull request with the appropriate label if you can.
261+
12. Send a [pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork).
262+
13. Label your pull request with the appropriate label if you can.
264263

265264
See [Contribution workflow](./workflow.md) for Git workflow details.
266265

contributing/signing.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,4 @@ bash shell to use the **-S** option to force the secure signing.
5252
## Commit Messages
5353

5454
Regardless of how you sign a commit, commit messages are important too.
55-
They communicate the intent of a specific change, concisely. They make
56-
it easier to review code, and to find out why a change was made if the
57-
code history is examined later.
58-
59-
The audience for your commit messages will be the codebase maintainers,
60-
any code reviewers, and debuggers trying to figure out when a bug might
61-
have been introduced.
62-
63-
Make your commit messages meaningful.
55+
See [Contribution Workflow](./workflow.md#commit-messages) for details.

contributing/workflow.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,48 @@ Your local changes need to be *committed* to save them in your local
139139
repository. This is where [contribution signing](./signing.md) comes
140140
in.
141141

142+
Now we don't have detailed rules on commits and its messages. But
143+
[atomic commit](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention) is recommended.
144+
Keep your commits atomic. One commit for one change.
145+
146+
There are some references for writing good commit messages:
147+
148+
- [Git Best Practices — AFTER Technique - DZone DevOps](https://dzone.com/articles/git-best-practices-after-technique-1)
149+
- [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716)
150+
- [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
151+
152+
If there are intermediate commits that are not meaningful to the overall PR,
153+
such as "Fix error on style guide", "Fix phpstan error", "Fix mistake in code",
154+
and other related commits, you can squash your commits so that we can have a clean commit history.
155+
But it is not a must.
156+
157+
### Commit Messages
158+
159+
Commit messages are important. They communicate the intent of a specific change, concisely.
160+
They make it easier to review code, and to find out why a change was made
161+
if the code history is examined later.
162+
163+
The audience for your commit messages will be the codebase maintainers,
164+
any code reviewers, and debuggers trying to figure out when a bug might
165+
have been introduced.
166+
167+
Make your commit messages meaningful.
168+
169+
Commit messages are expected to be descriptive of **why** and what you changed specifically.
170+
Commit messages like "Fixes #1234" would be asked by the reviewer to be revised.
171+
142172
You can have as many commits in a branch as you need to "get it right".
143173
For instance, to commit your work from a debugging session:
144174

145175
```console
146176
> git add .
147-
> git commit -S -m "Find and fix the broken reference problem"
177+
> git commit -S -m "Fix the broken reference problem"
148178
```
149179

150180
Just make sure that your commits in a feature branch are all related.
151181

182+
### When you work on two features
183+
152184
If you are working on two features at a time, then you will want to
153185
switch between them to keep the contributions separate. For instance:
154186

@@ -164,7 +196,7 @@ switch between them to keep the contributions separate. For instance:
164196
> git switch develop
165197
```
166198

167-
The last checkout makes sure that you end up in your *develop* branch as
199+
The last switch makes sure that you end up in your *develop* branch as
168200
a starting point for your next session working with your repository.
169201
This is a good practice, as it is not always obvious which branch you
170202
are working in.

0 commit comments

Comments
 (0)