Extract CommitDescription from Commit.Description

A later commit describes a detached HEAD in the same way. Make it work
for hashes shorter than 7 characters. The Name of a detached HEAD is
"HEAD" if `git branch --points-at=HEAD` doesn't report it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan HallerandClaude Opus 5.5 committed 2026-11-14 15:34:44 +01:00
1 parent 9dcef62ff2
commit 6348e8a6af
1 file changed
+7 -1
+7 -1
View File
@@ -151,7 +151,13 @@ func (c *Commit) ID() string {
}
func (c *Commit) Description() string {
return fmt.Sprintf("%s %s", c.Hash()[:7], c.Name)
return CommitDescription(c.Hash(), c.Name)
}
// CommitDescription returns the short hash and the subject of a commit, e.g.
// "6f71c57 Fix the thing".
func CommitDescription(hash string, subject string) string {
return fmt.Sprintf("%s %s", hash[:min(7, len(hash))], subject)
}
func (c *Commit) IsMerge() bool {