diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-01-06 09:51:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-06 09:51:15 +0800 |
commit | 61306fa737f693c3b325d9a8da047ba0b939537e (patch) | |
tree | 91d85ffddf960a7cb64343ed47277027f9227110 /vendor/code.gitea.io | |
parent | 79d527195d98d74867a067ce93a4dace2b86d2bb (diff) | |
download | gitea-61306fa737f693c3b325d9a8da047ba0b939537e.tar.gz gitea-61306fa737f693c3b325d9a8da047ba0b939537e.zip |
Make releases faster than before and resolved #490 (#588)
* make releases faster than before and resolved #490
* fix comment
Diffstat (limited to 'vendor/code.gitea.io')
-rw-r--r-- | vendor/code.gitea.io/git/MAINTAINERS | 1 | ||||
-rw-r--r-- | vendor/code.gitea.io/git/repo_tag.go | 82 | ||||
-rw-r--r-- | vendor/code.gitea.io/git/tag.go | 25 |
3 files changed, 107 insertions, 1 deletions
diff --git a/vendor/code.gitea.io/git/MAINTAINERS b/vendor/code.gitea.io/git/MAINTAINERS index 18cf1ffd77..f405e412bd 100644 --- a/vendor/code.gitea.io/git/MAINTAINERS +++ b/vendor/code.gitea.io/git/MAINTAINERS @@ -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) diff --git a/vendor/code.gitea.io/git/repo_tag.go b/vendor/code.gitea.io/git/repo_tag.go index dfaa41f0cf..33a833d3aa 100644 --- a/vendor/code.gitea.io/git/repo_tag.go +++ b/vendor/code.gitea.io/git/repo_tag.go @@ -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") diff --git a/vendor/code.gitea.io/git/tag.go b/vendor/code.gitea.io/git/tag.go index f2a3d31d27..500fd27491 100644 --- a/vendor/code.gitea.io/git/tag.go +++ b/vendor/code.gitea.io/git/tag.go @@ -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) +} |