mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	* make releases faster than before and resolved #490 * fix comment
This commit is contained in:
		
							
								
								
									
										1
									
								
								vendor/code.gitea.io/git/MAINTAINERS
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								vendor/code.gitea.io/git/MAINTAINERS
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,5 +1,6 @@
 | 
			
		||||
Alexey Makhov <amakhov@avito.ru> (@makhov)
 | 
			
		||||
Andrey Nering <andrey.nering@gmail.com> (@andreynering)
 | 
			
		||||
Bo-Yi Wu <appleboy.tw@gmail.com> (@appleboy)
 | 
			
		||||
Kees de Vries <bouwko@gmail.com> (@Bwko)
 | 
			
		||||
Kim Carlbäcker <kim.carlbacker@gmail.com> (@bkcsoft)
 | 
			
		||||
LefsFlare <nobody@nobody.tld> (@LefsFlarey)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										82
									
								
								vendor/code.gitea.io/git/repo_tag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										82
									
								
								vendor/code.gitea.io/git/repo_tag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -6,6 +6,7 @@ package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/mcuadros/go-version"
 | 
			
		||||
)
 | 
			
		||||
@@ -94,6 +95,87 @@ func (repo *Repository) GetTag(name string) (*Tag, error) {
 | 
			
		||||
	return tag, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TagOption describes tag options
 | 
			
		||||
type TagOption struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// parseTag parse the line
 | 
			
		||||
// 2016-10-14 20:54:25 +0200  (tag: translation/20161014.01) d3b76dcf2 Dirk Baeumer dirkb@microsoft.com Merge in translations
 | 
			
		||||
func parseTag(line string, opt TagOption) (*Tag, error) {
 | 
			
		||||
	line = strings.TrimSpace(line)
 | 
			
		||||
	if len(line) < 40 {
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var (
 | 
			
		||||
		err error
 | 
			
		||||
		tag Tag
 | 
			
		||||
		sig Signature
 | 
			
		||||
	)
 | 
			
		||||
	sig.When, err = time.Parse("2006-01-02 15:04:05 -0700", line[0:25])
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	left := strings.TrimSpace(line[25:])
 | 
			
		||||
	start := strings.Index(left, "(tag: ")
 | 
			
		||||
	if start < 0 {
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
	end := strings.IndexByte(left[start+1:], ')')
 | 
			
		||||
	if end < 0 {
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
	end = end + start + 1
 | 
			
		||||
	part := strings.IndexByte(left[start+6:end], ',')
 | 
			
		||||
	if part > 0 {
 | 
			
		||||
		tag.Name = strings.TrimSpace(left[start+6 : start+6+part])
 | 
			
		||||
	} else {
 | 
			
		||||
		tag.Name = strings.TrimSpace(left[start+6 : end])
 | 
			
		||||
	}
 | 
			
		||||
	next := strings.IndexByte(left[end+2:], ' ')
 | 
			
		||||
	if next < 0 {
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
	tag.Object = MustIDFromString(strings.TrimSpace(left[end+2 : end+2+next]))
 | 
			
		||||
	next = end + 2 + next
 | 
			
		||||
 | 
			
		||||
	emailStart := strings.IndexByte(left[next:], '<')
 | 
			
		||||
	sig.Name = strings.TrimSpace(left[next:][:emailStart-1])
 | 
			
		||||
	emailEnd := strings.IndexByte(left[next:], '>')
 | 
			
		||||
	sig.Email = strings.TrimSpace(left[next:][emailStart+1 : emailEnd])
 | 
			
		||||
	tag.Tagger = &sig
 | 
			
		||||
	tag.Message = strings.TrimSpace(left[next+emailEnd+1:])
 | 
			
		||||
	return &tag, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetTagInfos returns all tag infos of the repository.
 | 
			
		||||
func (repo *Repository) GetTagInfos(opt TagOption) ([]*Tag, error) {
 | 
			
		||||
	cmd := NewCommand("log", "--tags", "--simplify-by-decoration", `--pretty=format:"%ci %d %H %cn<%ce> %s"`)
 | 
			
		||||
	stdout, err := cmd.RunInDir(repo.Path)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tagSlices := strings.Split(stdout, "\n")
 | 
			
		||||
	var tags []*Tag
 | 
			
		||||
	for _, line := range tagSlices {
 | 
			
		||||
		line := strings.Trim(line, `"`)
 | 
			
		||||
		tag, err := parseTag(line, opt)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		if tag != nil {
 | 
			
		||||
			tag.repo = repo
 | 
			
		||||
			tags = append(tags, tag)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	sortTagsByTime(tags)
 | 
			
		||||
 | 
			
		||||
	return tags, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetTags returns all tags of the repository.
 | 
			
		||||
func (repo *Repository) GetTags() ([]string, error) {
 | 
			
		||||
	cmd := NewCommand("tag", "-l")
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								vendor/code.gitea.io/git/tag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								vendor/code.gitea.io/git/tag.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -4,7 +4,10 @@
 | 
			
		||||
 | 
			
		||||
package git
 | 
			
		||||
 | 
			
		||||
import "bytes"
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"sort"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Tag represents a Git tag.
 | 
			
		||||
type Tag struct {
 | 
			
		||||
@@ -64,3 +67,23 @@ l:
 | 
			
		||||
	}
 | 
			
		||||
	return tag, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type tagSorter []*Tag
 | 
			
		||||
 | 
			
		||||
func (ts tagSorter) Len() int {
 | 
			
		||||
	return len([]*Tag(ts))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (ts tagSorter) Less(i, j int) bool {
 | 
			
		||||
	return []*Tag(ts)[i].Tagger.When.After([]*Tag(ts)[j].Tagger.When)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (ts tagSorter) Swap(i, j int) {
 | 
			
		||||
	[]*Tag(ts)[i], []*Tag(ts)[j] = []*Tag(ts)[j], []*Tag(ts)[i]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// sortTagsByTime
 | 
			
		||||
func sortTagsByTime(tags []*Tag) {
 | 
			
		||||
	sorter := tagSorter(tags)
 | 
			
		||||
	sort.Sort(sorter)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user