Skip to content
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

Add guidelines about commit messages and merging/squashing commits #5691

Conversation

tigrannajaryan
Copy link
Member

Our commit messages often are quite lacking. A typical approach is writing single line commit
messages and pushing multiple such commits to a PR. When commits are squashed the commit
messages are concatenated, and we end up with useless commit messages.

Here is an example of a commit message body (I am omitting the first line and the commit hash
to avoid blaming anyone in particular - we are all guilty):

    * add docstring

    * fix typo

    * fix impi

    * apply review feedback

This is a useless commit message, in fact, it is worse than an empty one.

I tried to keep the added paragraph in the CONTRIBUTING.md short. If you think more details and
convincing is necessary I can make it more elaborate. Note that the text I added doesn't just
call for good commit messages but has some hints about the commit and PR creation, squashing and
merging processes that make it easier to end up with better commit messages.

@tigrannajaryan tigrannajaryan requested a review from a team as a code owner July 15, 2022 14:56
@tigrannajaryan
Copy link
Member Author

@open-telemetry/collector-contrib-approvers please also review.

@tigrannajaryan tigrannajaryan added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jul 15, 2022
@codecov
Copy link

codecov bot commented Jul 15, 2022

Codecov Report

Merging #5691 (758ee77) into main (9cb33dd) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #5691   +/-   ##
=======================================
  Coverage   91.53%   91.53%           
=======================================
  Files         192      192           
  Lines       11398    11398           
=======================================
  Hits        10433    10433           
  Misses        770      770           
  Partials      195      195           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9cb33dd...758ee77. Read the comment docs.

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Show resolved Hide resolved
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a suggestion around calling out maintainers specifically (around squashing commits). Please take a look if the wording makes sense. I'm ok with adding this as a guideline.

CONTRIBUTING.md Outdated Show resolved Hide resolved
Our commit messages often are quite lacking. A typical approach is writing single line commit
messages and pushing multiple such commits to a PR. When commits are squashed the commit
messages are concatenated, and we end up with useless commit messages.

Here is an example of a commit message body (I am omitting the first line and the commit hash
to avoid blaming anyone in particular - we are all guilty):

```
    * add docstring

    * fix typo

    * fix impi

    * apply review feedback
```

This is a useless commit message, in fact, it is worse than an empty one.

I tried to keep the added paragraph in the CONTRIBUTING.md short. If you think more details and
convincing is necessary I can make it more elaborate. Note that the text I added doesn't just
call for good commit messages but has some hints about the commit and PR creation, squashing and
merging processes that make it easier to end up with better commit messages.
@tigrannajaryan
Copy link
Member Author

Let's see what commit message we end up with when this is merged :-)

Comment on lines +192 to +197
Use descriptive commit messages. Here are [some recommendations](https://cbea.ms/git-commit/)
on how to write good commit messages.
When creating PRs GitHub will automatically copy commit messages into the PR description,
so it is a useful habit to write good commit messages before the PR is created.
Also, unless you actually want to tell a story with multiple commits make sure to squash
into a single commit before creating the PR.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Controversial opinion] we should never need more than one commit, if you need more commits it means you actually need more PRs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't disagree, especially because we force squashing the commits when merging, so multiple commits are only useful as a tool to aid reviewing (i.e. tell a story about how the PR was created). I wanted to leave this option open, although I don't think we use it much (or ever).

@tigrannajaryan
Copy link
Member Author

@open-telemetry/collector-approvers any other comments or good to merge?

@tigrannajaryan tigrannajaryan merged commit 3a7a763 into open-telemetry:main Jul 20, 2022
@tigrannajaryan tigrannajaryan deleted the feature/tigran/commit-messages branch July 20, 2022 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants