Should commit messages be written in present or pa

2019-01-30 07:26发布

So which is it that you think is better and more intuitive?

Fixed the XXX bug in YYY
Fix the XXX bug in YYY
Fixes the XXX bug in YYY
Fixing the XXX bug in YYY

Please provide your rationales. Note I am asking from your general perspective, meaning you should not try to associate this with your preferred svn/cvs tools or programming languages, but rather think of it as something that should/can be applied to any tools and programming languages.

12条回答
ら.Afraid
2楼-- · 2019-01-30 07:41

I prefer to see commit messages in present tense. That way the message describes what the diff does (because you might pull that diff or even that whole commit into a different branch). Thus, the commit message does not describe what it "did" do... It describes what the commit itself "does" do. So it should be in present tense.

Imagine looking at a diff in isolation and trying to decide whether you will apply it. It makes no sense for it to have a title in the past tense.

查看更多
相关推荐>>
3楼-- · 2019-01-30 07:42
Fix the XXX bug in YYY
Teach the XXX to be more ZZZ
Correct typos in javadoc

In general: {imperative verb} the {affected object} {optional qualifiers}

Imperative form fits all use cases when I'm considering a patchset.

  • What are you going to do here?
  • What does this patchset do?
  • Why was this patchset created? (to fix the xxx bug...)
  • I need to fix the xxx bug in yyy. Is there a commit on another branch that does this already?

Regardless of your choice, I find consistency helps readability immensely. Pick one and stick with it.

查看更多
唯我独甜
4楼-- · 2019-01-30 07:46

IMHO if you want it to be descriptive without need to consider the context, then "Fixed" is definitely the only right variant.

Regarding the intuitiveness - if I look at some changelog I will definitely understand that you mean the bug fixed as I know the context in which the word is used, but my brain will catch it much more quickly if the word is written in this self-specifying way.

"Fixing" is the worst choice IMHO as it can be interpreted not only as describing what the patch does (is for) but as a bug status as well which would mean that it is being worked at and is not yet solved.

查看更多
三岁会撩人
5楼-- · 2019-01-30 07:48

I think "Fixes XXX bug" makes more sense than "Fix XXX bug" if the reason for using the present tense is to "make it more descriptive of what the commit does" rather than what the committer did.

查看更多
smile是对你的礼貌
6楼-- · 2019-01-30 07:51

I think of these messages as they appear to other developers. They don't yet have the changes applied, and there is the implicit question, "what will applying this changeset/patch do?" It will "Fix the XXX bug in YYY"!

For other verbs writing them as a command seems more natural, and works better if you have a specific goal up-front—you can literally write the commit summary along with up-front tests before the work is done.

I don't put a huge amount of weight on it, but for me this is the path of least resistance while maintaining consistentency.

查看更多
小情绪 Triste *
7楼-- · 2019-01-30 07:51

I think that writing about the current commit in present tense is a good idea, because it makes it more clear when you refer to prior commits in the past tense.

查看更多
登录 后发表回答