diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-09-22 12:39:00 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-09-22 12:39:00 -0600 |
commit | 6cfa6622f31953bd75bfae4c9b10915e3dd6bd78 (patch) | |
tree | 71c6d9b9e76ba0abc9ae6031a316f644246461d7 /commit.go | |
parent | 1a1832b77d53849a0aa8216627301aaf9e18d6f8 (diff) |
Go documentation for all public functions
Diffstat (limited to 'commit.go')
-rw-r--r-- | commit.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -5,6 +5,7 @@ import ( "time" ) +// Commit represents a git commit. type Commit struct { Repo *Repository @@ -22,15 +23,22 @@ type Commit struct { Message string } +// ParentHash returns a ref name usable to reach the commit's parent. func (c *Commit) ParentHash() string { return c.Hash + "^" } +// ShortMessage returns the first line of the commit message. func (c *Commit) ShortMessage() string { short, _, _ := strings.Cut(c.Message, "\n") return short } +// RestOfMessage returns all but the first line of the commit message. +// +// It will trim any newline prefixes however, so be aware that +// c.ShortMessage + "\n" + c.RestOfMessage may not produce the original +// commit message. For that use c.Message. func (c *Commit) RestOfMessage() string { _, rest, _ := strings.Cut(c.Message, "\n") return strings.TrimPrefix(rest, "\n") |