File tree 2 files changed +29
-12
lines changed
2 files changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -103,26 +103,18 @@ func (repo *Repository) GetTagInfos() ([]*Tag, error) {
103
103
}
104
104
105
105
tagNames := strings .Split (stdout , "\n " )
106
- var tags []* Tag
106
+ var tags = make ( []* Tag , 0 , len ( tagNames ))
107
107
for _ , tagName := range tagNames {
108
108
tagName = strings .TrimSpace (tagName )
109
109
if len (tagName ) == 0 {
110
110
continue
111
111
}
112
- commitID , err := NewCommand ("rev-parse" , tagName ).RunInDir (repo .Path )
113
- if err != nil {
114
- return nil , err
115
- }
116
- commit , err := repo .GetCommit (commitID )
112
+
113
+ tag , err := repo .GetTag (tagName )
117
114
if err != nil {
118
115
return nil , err
119
116
}
120
- tags = append (tags , & Tag {
121
- Name : tagName ,
122
- Message : commit .Message (),
123
- Object : commit .ID ,
124
- Tagger : commit .Author ,
125
- })
117
+ tags = append (tags , tag )
126
118
}
127
119
sortTagsByTime (tags )
128
120
return tags , nil
Original file line number Diff line number Diff line change
1
+ // Copyright 2019 The Gitea Authors. All rights reserved.
2
+ // Use of this source code is governed by a MIT-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package git
6
+
7
+ import (
8
+ "path/filepath"
9
+ "testing"
10
+
11
+ "github.com/stretchr/testify/assert"
12
+ )
13
+
14
+ func TestRepository_GetTags (t * testing.T ) {
15
+ bareRepo1Path := filepath .Join (testReposDir , "repo1_bare" )
16
+ bareRepo1 , err := OpenRepository (bareRepo1Path )
17
+ assert .NoError (t , err )
18
+
19
+ tags , err := bareRepo1 .GetTagInfos ()
20
+ assert .NoError (t , err )
21
+ assert .Len (t , tags , 1 )
22
+ assert .EqualValues (t , "test" , tags [0 ].Name )
23
+ assert .EqualValues (t , "3ad28a9149a2864384548f3d17ed7f38014c9e8a" , tags [0 ].ID .String ())
24
+ assert .EqualValues (t , "commit" , tags [0 ].Type )
25
+ }
You can’t perform that action at this time.
0 commit comments