|
|
@ -187,7 +187,7 @@ func (repo *Repository) GetTag(name string) (*Tag, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetTagInfos returns all tag infos of the repository.
|
|
|
|
// GetTagInfos returns all tag infos of the repository.
|
|
|
|
func (repo *Repository) GetTagInfos() ([]*Tag, error) { |
|
|
|
func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, error) { |
|
|
|
// TODO this a slow implementation, makes one git command per tag
|
|
|
|
// TODO this a slow implementation, makes one git command per tag
|
|
|
|
stdout, err := NewCommand("tag").RunInDir(repo.Path) |
|
|
|
stdout, err := NewCommand("tag").RunInDir(repo.Path) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -195,6 +195,18 @@ func (repo *Repository) GetTagInfos() ([]*Tag, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tagNames := strings.Split(strings.TrimRight(stdout, "\n"), "\n") |
|
|
|
tagNames := strings.Split(strings.TrimRight(stdout, "\n"), "\n") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if page != 0 { |
|
|
|
|
|
|
|
skip := (page - 1) * pageSize |
|
|
|
|
|
|
|
if skip >= len(tagNames) { |
|
|
|
|
|
|
|
return nil, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (len(tagNames) - skip) < pageSize { |
|
|
|
|
|
|
|
pageSize = len(tagNames) - skip |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tagNames = tagNames[skip : skip+pageSize] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var tags = make([]*Tag, 0, len(tagNames)) |
|
|
|
var tags = make([]*Tag, 0, len(tagNames)) |
|
|
|
for _, tagName := range tagNames { |
|
|
|
for _, tagName := range tagNames { |
|
|
|
tagName = strings.TrimSpace(tagName) |
|
|
|
tagName = strings.TrimSpace(tagName) |
|
|
|