Skip to content

Commit 8e00e25

Browse files
committed
Fix commit retrieval by tag
It is not correct to return tag data like the tag's message when commit data requested. This changes fixes commit retrieval by tag for both the latest commit in the UI and the commit info on tag webhook events. Fixes: go-gitea#21687 Replaces: go-gitea#21693
1 parent 6f3efdf commit 8e00e25

File tree

2 files changed

+0
-42
lines changed

2 files changed

+0
-42
lines changed

modules/git/repo_commit_gogit.go

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -68,38 +68,6 @@ func (repo *Repository) IsCommitExist(name string) bool {
6868
return err == nil
6969
}
7070

71-
func convertPGPSignatureForTag(t *object.Tag) *CommitGPGSignature {
72-
if t.PGPSignature == "" {
73-
return nil
74-
}
75-
76-
var w strings.Builder
77-
var err error
78-
79-
if _, err = fmt.Fprintf(&w,
80-
"object %s\ntype %s\ntag %s\ntagger ",
81-
t.Target.String(), t.TargetType.Bytes(), t.Name); err != nil {
82-
return nil
83-
}
84-
85-
if err = t.Tagger.Encode(&w); err != nil {
86-
return nil
87-
}
88-
89-
if _, err = fmt.Fprintf(&w, "\n\n"); err != nil {
90-
return nil
91-
}
92-
93-
if _, err = fmt.Fprintf(&w, t.Message); err != nil {
94-
return nil
95-
}
96-
97-
return &CommitGPGSignature{
98-
Signature: t.PGPSignature,
99-
Payload: strings.TrimSpace(w.String()) + "\n",
100-
}
101-
}
102-
10371
func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
10472
var tagObject *object.Tag
10573

@@ -123,12 +91,6 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
12391
commit := convertCommit(gogitCommit)
12492
commit.repo = repo
12593

126-
if tagObject != nil {
127-
commit.CommitMessage = strings.TrimSpace(tagObject.Message)
128-
commit.Author = &tagObject.Tagger
129-
commit.Signature = convertPGPSignatureForTag(tagObject)
130-
}
131-
13294
tree, err := gogitCommit.Tree()
13395
if err != nil {
13496
return nil, err

modules/git/repo_commit_nogogit.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ func (repo *Repository) getCommitFromBatchReader(rd *bufio.Reader, id SHA1) (*Co
108108
return nil, err
109109
}
110110

111-
commit.CommitMessage = strings.TrimSpace(tag.Message)
112-
commit.Author = tag.Tagger
113-
commit.Signature = tag.Signature
114-
115111
return commit, nil
116112
case "commit":
117113
commit, err := CommitFromReader(repo, id, io.LimitReader(rd, size))

0 commit comments

Comments
 (0)