Skip to content

Commit c171248

Browse files
committed
Remove duplicated tag.Commit function and use repo.GetTagCommit
1 parent 8998913 commit c171248

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

modules/git/repo_tree_nogogit.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ func (repo *Repository) getTree(id ObjectID) (*Tree, error) {
3535
if err != nil {
3636
return nil, err
3737
}
38-
commit, err := tag.Commit(repo)
38+
39+
if _, err := wr.Write([]byte(tag.Object.String() + "\n")); err != nil {
40+
return nil, err
41+
}
42+
commit, err := repo.getCommitFromBatchReader(wr, rd, tag.Object)
3943
if err != nil {
4044
return nil, err
4145
}

modules/git/tag.go

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ type Tag struct {
2121
Signature *CommitSignature
2222
}
2323

24-
// Commit return the commit of the tag reference
25-
func (tag *Tag) Commit(gitRepo *Repository) (*Commit, error) {
26-
return gitRepo.getCommit(tag.Object)
27-
}
28-
2924
func parsePayloadSignature(data []byte, messageStart int) (payload, msg, sign string) {
3025
pos := messageStart
3126
signStart, signEnd := -1, -1

modules/repository/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func PushUpdateAddTag(ctx context.Context, repo *repo_model.Repository, gitRepo
126126
if err != nil {
127127
return fmt.Errorf("unable to GetTag: %w", err)
128128
}
129-
commit, err := tag.Commit(gitRepo)
129+
commit, err := gitRepo.GetTagCommit(tag.Name)
130130
if err != nil {
131131
return fmt.Errorf("unable to get tag Commit: %w", err)
132132
}

routers/api/v1/repo/tag.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func GetAnnotatedTag(ctx *context.APIContext) {
110110
if tag, err := ctx.Repo.GitRepo.GetAnnotatedTag(sha); err != nil {
111111
ctx.APIError(http.StatusBadRequest, err)
112112
} else {
113-
commit, err := tag.Commit(ctx.Repo.GitRepo)
113+
commit, err := ctx.Repo.GitRepo.GetTagCommit(tag.Name)
114114
if err != nil {
115115
ctx.APIError(http.StatusBadRequest, err)
116116
}

services/repository/push.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
385385
if err != nil {
386386
return fmt.Errorf("GetTag: %w", err)
387387
}
388-
commit, err := tag.Commit(gitRepo)
388+
commit, err := gitRepo.GetTagCommit(tag.Name)
389389
if err != nil {
390390
return fmt.Errorf("Commit: %w", err)
391391
}

0 commit comments

Comments
 (0)