josa42 / atom-blame

Show git blame as a gutter in Atom editor
https://atom.io/packages/blame
MIT License
22 stars 18 forks source link

Multi-line commit messages shown as one line #17

Closed aharpervc closed 8 years ago

aharpervc commented 8 years ago

I have a lot of commits in the form

shorter commit title
- longer commit explanation
- with several line breaks

Right now this extension shows everything in 1 long line, which is sometimes larger than the editor window is wide so it gets cut off.

It would be better to make sure line breaks are processed in the tooltip the same as in the commit message.

josa42 commented 8 years ago

I am not so sure what's the right solution for this.

Actually, its common to have a new line between subject and description.

Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description.

Source: git-commit Reference

Git also does the same thing:

screen shot 2016-01-28 at 10 10 26

On the other hand, github treats the same message like this:

screen shot 2016-01-28 at 10 12 28

aharpervc commented 8 years ago

If the tooltips looked like GitHub that'd be great

aharpervc commented 8 years ago

I see that you published a new version... looks great :+1:

aharpervc commented 8 years ago

I spoke too soon. There's still a case where multiline commits show up as one line in the tooltip and get ellipsis'd. It's in the form: main first line\n- longer second line. Interestingly, other multiline commits look fine.

josa42 commented 8 years ago

The only thing I did was to make sure the tooltip doesn't get to wide.

The other issue is not that easy. For the parsing the commit message I currently use git itself.

For this message:

shorter commit title
- longer commit explanation
- with several line breaks

Git returns this:

let subject = "shorter commit title - longer commit explanation - with several line breaks"
let message = ""

If you would have added a newline between subject and message, like it is recommended in the git man:

shorter commit title

- longer commit explanation
- with several line breaks

Git returns the desired result:

let subject = "shorter commit title"
let message = " - longer commit explanation\n - with several line breaks"

So in my opinion it is absolutely right the way it is right now.

aharpervc commented 8 years ago

Are you saying that git isn't telling you that there's a \n after the word title in your example? If there's no \n, then I guess git is busted. If there is a \n, then I believe the tooltip should render it as a line break. I wonder how GitHub is able to figure out that a line break should be presented...

josa42 commented 8 years ago

What I am saying is, that since you have no blank line between subject and body, git considers it all to be the subject. In the subject all newlines get eliminated.

I am pretty sure this is on purpose. Since a subject is not supposed to have newlines.

I the body newlines are shown just fine.

aharpervc commented 8 years ago

I wonder how GitHub figures it out?

josa42 commented 8 years ago

You can always take the first line of the raw commit.

aharpervc commented 8 years ago

perfect :+1: