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 a git commit guide #8965

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wmontwe
Copy link
Member

@wmontwe wmontwe commented Mar 18, 2025

Resolves #8964

@wmontwe wmontwe requested a review from kewisch as a code owner March 18, 2025 13:38
@wmontwe wmontwe force-pushed the add-git-commit-guide branch from d539a4b to e481327 Compare March 18, 2025 13:42
- Explain *what* the change does and *why* it was needed.
- Describe any important details, such as edge cases addressed.
- Reference relevant issue numbers or discussions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding an example for commit message that follows above structure would be helpful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I think having examples would help.

Comment on lines +71 to +77
### 5. Ensure Commits Are Self-Contained

Each commit should:

- Be complete and independently buildable.
- Not introduce temporary hacks or broken functionality.
- Ideally, pass tests to maintain project integrity.
Copy link
Member

Choose a reason for hiding this comment

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

You mention most of these before, potentially we could consolidate here to not make the guide too long. In section 2 you mention each commit should be functional and not leave it in a broken state. This covers the first item, and potentially the third, and with a light stretch also the second.

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'll rework the sections.

Comment on lines +87 to +90
### 7. Use Atomic Commits

Atomic commits mean that each commit represents a single unit of change that can be reverted independently. This
practice ensures that if an issue arises, it is easier to pinpoint and undo the specific problematic change.
Copy link
Member

Choose a reason for hiding this comment

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

Based on how we've worked before I had the understanding that we're working atomic at the level of a merge, but that individual commits within the merge might not be completely functional.

I think this is worth clarifying. If we really require atomic commits to each individual level, then we might as well do rebases instead of merges because each commit should work as it is and we can just back out the offending commit.

If we're working at the merges level, then while we shouldn't intentionally break between commits, we'd be backing out the merge and bisecting based on merges.

There is also some overlap between (6) and (2) where we're again saying it needs to work inbetween commits.

Copy link
Member Author

@wmontwe wmontwe Mar 26, 2025

Choose a reason for hiding this comment

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

This doesn't mean to have something completely functional, but it should compile, tests should succeed and all quality tools issues should be resolved. This is meant to prevent commits like:

  1. Add funtionality
  2. Add test for functionality
  3. Fix broken tests
  4. Fix linter issues
  5. Fix code formatting
  6. ...

These changes should be part of one commit.

I'll reword it.

Copy link
Member

Choose a reason for hiding this comment

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

So for example in #8987 I should have merged the two commits, because the actions fixes would otherwise cause a broken state?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a special case. If it is detectable using our build, quality checks and tests then yes, otherwise I think it's fine.

@kewisch kewisch self-assigned this Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write Git Commit Guide
3 participants