Skip to content

Broken summary for commit messages with empty first line #2091

Closed
@melak

Description

@melak

Summary generation for commit messages with superfluous empty lines on the top (don't ask - old repositories imported from SVN) seems to be "broken" in that no summary (or rather, an empty summary) is generated. (Well, it's not exactly broken of course, because garbage in, garbage out, but it could be made better.)

From a cursory look, a patch along the lines of

diff --git a/vendor/code.gitea.io/git/commit.go b/vendor/code.gitea.io/git/commit.go
index fa5e185..c910ba3 100644
--- a/vendor/code.gitea.io/git/commit.go
+++ b/vendor/code.gitea.io/git/commit.go
@@ -34,7 +34,7 @@ func (c *Commit) Message() string {

 // Summary returns first line of commit message.
 func (c *Commit) Summary() string {
-       return strings.Split(c.CommitMessage, "\n")[0]
+       return strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0];
 }

 // ParentID returns oid of n-th parent (0-based index).

would fix the problem without any obvious unwanted side effects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions