-
Notifications
You must be signed in to change notification settings - Fork 0
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
When to split commits? #12
Comments
I would suggest that any changes needed by a ticket should probably be in the same commit. In your list I would split the last two examples. You could also split all commits, but then you need to take care to commit in the appropriate order. |
Yes, IMHO it's going to be almost impossible to avoid those situations so we should think in a workaround.
And then use the highest priority type as a "summary". In that case if the commit will add a new feature and a unit test for it, then it's fine to use feat because it has a higher priority compared with test.
|
I think that is a solution that solves what @scardanzan proposed, but maybe it has the drawback of not respecting the atomic commits proposal. |
Maybe the statement of my question was ambiguous: I didn't refer to splitting as "make two commits from one" but "given changes A and B, should they go in the same commit?" (in general, it's possible to avoid unrelated changes from landing in the same commit, and they should be avoided). The question then is "are A and B unrelated changes?".
The concept of dominance is interesting, but we should be careful since it's also a two-edged sword that might be misunderstood as allowing multiple-purpose commits, which are not a good practice (#1). Since the convention documents good practices, it should be clear on whether/when the good practice is splitting the commits or whether/when the good practice is not splitting the commits, and where is the gray area. Many of the combinations among commits type are not possible in a logically atomic commit:
Regarding
The only remaining cases are splitting If you think so, we can restrict the discussion to these cases. |
That was an unusual situation, since the commits were already there and we were rewriting them for tidying up the commit history (and by the way, also for validating the guidelines). Had the guidelines been written earlier, it would have been clear whether those changes belonged to the same commit or should have been committed separately. One rule of thumb I use is if the subject accurately describes the changes (regardless of whether they are in the same file or not). For instance, FlowingCode/ChipFieldAddon@b685ee3 consists of the following changes, with a commit message of "add demo layout": (A) add demo layout -> UI code
That commit was rewritten as: (Note that the right order should have been E, A+B, C, D) Anything that changes C or D cannot be in the same commit as A, B or E (otherwise that would be a multi-purpose commit). When to split the remaining changes is part of this question. IMHO
|
Great discussion. Regarding logically atomic commits I agree with the definition and we should stick to that. Like you said, this is a development convention definition. The teams that adhere to this should review the commits and enforce the rules but they might take into account other factors, like priorities and judgments in special and corner cases. Given that, we can focus on the types that can be considered in the same commit. I have the following comments:
We should discuss about
What about revert? should we just paste the original commit message after revert? ... maybe we should discuss this in a separated issue, but it sounds relevant because a revert might be the most dominant type. I think the situation it's pretty clear with Regarding Thoughts? |
If the feature itself is complex, and the refactor adds value even without the feature, it may make sense to commit them separately (so that the code base can benefit from the refactor, even if the feature is reverted).
versus:
If it is difficult to realize before implementing the feature AND it would include a significant overhead to Note it's an AND (
How does Conventional Commits handle revert commits?
» I wouldn't add anything about reverts at this moment because:
I'll come back to this later, after reviewing some cases based on the agreement we have on the difference between
I'm still not sure if we need to define dominance as a concept, or let it permeate through the definitions instead. (Maybe we can move part of this discussion to separate issues in order to tackle them one at a time) |
Great answer. |
Regarding Other changes that can be applied to the document are: Add the following paragraph to the introduction
Reorder the list of types. Based on dominance, but without defining dominance as a concept
In the context of our discussion above, this classification has the following properties:
Regardless of these changes, we can keep this issue open, and review it later . |
Totally agree with everything! Nice work! |
Mention the concept of logically atomic commit and reorder the list of commit types according to the discussion in #12
✔ Changes applied as discussed above. (This issue, however, remains opens in order to collect additional discussion.) |
Mention the concept of logically atomic commit and reorder the list of commit types according to the discussion in #12
Mention the concept of logically atomic commit and reorder the list of commit types according to the discussion in #12
In #1 we discussed about multiple purpose commits. The agreement was that multiple purpose commits are not a good practice, based on the following comment from Conventional Commits:
In the context of Conventional Commits (which only defines
fix
andfeat
), the sentence above amounts to "do not squash two fixes in a single commit, and do not squash a fix and feature in a single commit", i.e. Atomic Commits. [1] [2]On the other side, since we adopt additional types, the domain of "commits that conform to more than one of the commit types" is now broader. For instance:
feat
) and add unit tests (test
) for that feature.feat
) that requires adding/upgrading a external dependencies (build
).build
) and implement a feature on top of that framework / general purpose library (feat
).fix
that requires upgrading a dependency (build
) and writefix
and realize that a external dependency was rather old, thus upgrade it just in case (build
)fix
a missing null check and by the way replace all tabs to spaces in the whole file (style
).The text was updated successfully, but these errors were encountered: