What semantic commit type is better to use, when I remove a feature: feat
, refactor
or something else?
you should use refactor
,
- feat: introduces a new feature to the codebase
- fix: patches a bug in your codebase
- refactor: A code change that neither fixes a bug nor adds a feature
you can refer to angular/CONTRIBUTING Commit Message Guidelines
Use feat when you add or remove a feature.
According to wikipedia, "code refactoring is the process of restructuring existing computer code without changing its external behavior".
If you remove a feature you change code behavior so it can not be a refactor.
By definition, it is refactor
, since:
refactor: A code change that neither fixes a bug nor adds a feature
Removing a feature is certainly a code change, and it neither fixes a bug nor adds a feature.
However, people usually have an assumption that refactor tends to not introduce breaking changes. And removing a feature tends to always break the API, since a feature is removed from the API, and this breaks all existing system depending on that feature.
What about other types? Absence of a feature itself may be considered as a feature. For example, if someone dislike the idea of password login (it is annoying to input a password every time to login), then they may consider not having the feature of password login as a feature. Thus removing a feature can be considered as adding a new feature.
At the same time, if an absence of a feature itself may be considered as a feature, then the existence of that feature may be considered as a bug. So removing a feature may be considered as fixing a bug. Thus removing a feature is both feat
and fix
.
Alternatively, we can pretend that the problem does not exist. A well designed library should not have an unwanted feature. And since other libraries and applications may depend on this feature, features should never be removed. But this ideal principle does not apply to every library.
So my suggestion is giving this type of commit a new name.
fix
a bug, but it does fix
some issue (e.g. improves UI, or removes obscure feature requiring too much code complexity to support). So, if one doesn't want to introduce a new prefix, I think fix
is a good default. On the other hand, there is also refactor!: ...
with an exclamation mark to denote breaking changes. –
Stochmal Exclamation marks can be used to denote breaking changes. Removing a feature is a breaking change. Thus, there is refactor!
:
refactor!: a BREAKING CHANGE that neither fixes a bug nor adds a feature
Use refactor
,because you reconstruction your code.
like:
refactor(core): Add warning when signal equality is false for object
There is a reference about Git Commit Msg for you
© 2022 - 2024 — McMap. All rights reserved.
test:
? Or stillrefactor:
? – Metallic