Skip to content

Fix tag commit message #21693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions modules/git/repo_commit_gogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package git

import (
"fmt"
"strings"

"github.com/go-git/go-git/v5/plumbing"
Expand Down Expand Up @@ -68,38 +67,6 @@ func (repo *Repository) IsCommitExist(name string) bool {
return err == nil
}

func convertPGPSignatureForTag(t *object.Tag) *CommitGPGSignature {
if t.PGPSignature == "" {
return nil
}

var w strings.Builder
var err error

if _, err = fmt.Fprintf(&w,
"object %s\ntype %s\ntag %s\ntagger ",
t.Target.String(), t.TargetType.Bytes(), t.Name); err != nil {
return nil
}

if err = t.Tagger.Encode(&w); err != nil {
return nil
}

if _, err = fmt.Fprintf(&w, "\n\n"); err != nil {
return nil
}

if _, err = fmt.Fprintf(&w, t.Message); err != nil {
return nil
}

return &CommitGPGSignature{
Signature: t.PGPSignature,
Payload: strings.TrimSpace(w.String()) + "\n",
}
}

func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
var tagObject *object.Tag

Expand All @@ -123,12 +90,6 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
commit := convertCommit(gogitCommit)
commit.repo = repo

if tagObject != nil {
commit.CommitMessage = strings.TrimSpace(tagObject.Message)
commit.Author = &tagObject.Tagger
commit.Signature = convertPGPSignatureForTag(tagObject)
}

tree, err := gogitCommit.Tree()
if err != nil {
return nil, err
Expand Down
4 changes: 0 additions & 4 deletions modules/git/repo_commit_nogogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ func (repo *Repository) getCommitFromBatchReader(rd *bufio.Reader, id SHA1) (*Co
return nil, err
}

commit.CommitMessage = strings.TrimSpace(tag.Message)
commit.Author = tag.Tagger
commit.Signature = tag.Signature

return commit, nil
case "commit":
commit, err := CommitFromReader(repo, id, io.LimitReader(rd, size))
Expand Down
1 change: 0 additions & 1 deletion modules/git/repo_tag_nogogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (repo *Repository) getTag(tagID SHA1, name string) (*Tag, error) {
return nil, err
}

tag.Name = name
tag.ID = tagID
tag.Type = tp

Expand Down
10 changes: 10 additions & 0 deletions modules/git/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ l:
case "type":
// A commit can have one or more parents
tag.Type = string(line[spacepos+1:])
case "tag":
tag.Name = string(line[spacepos+1:])
case "tagger":
sig, err := newSignatureFromCommitline(line[spacepos+1:])
if err != nil {
Expand All @@ -83,6 +85,14 @@ l:
tag.Message = tag.Message[:idx+1]
}
}

tag.Message = strings.TrimSpace(tag.Message)
if tag.Message == "" {
tag.Message = tag.Name
} else if tag.Name != "" {
tag.Message = tag.Name + "\n\n" + tag.Message
}

return tag, nil
}

Expand Down