mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-27 12:53:57 +01:00
Update code.gitea.io/git
This commit is contained in:
parent
f6b58964d7
commit
0cf89a83c1
3 changed files with 24 additions and 71 deletions
86
vendor/code.gitea.io/git/repo_tag.go
generated
vendored
86
vendor/code.gitea.io/git/repo_tag.go
generated
vendored
|
@ -6,7 +6,6 @@ package git
|
|||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mcuadros/go-version"
|
||||
)
|
||||
|
@ -95,84 +94,37 @@ 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.LastIndexByte(left[start+1:], ')')
|
||||
if end < 0 {
|
||||
return nil, nil
|
||||
}
|
||||
end = end + start + 1
|
||||
part := strings.IndexByte(left[start+5:end], ',')
|
||||
if part > 0 {
|
||||
tag.Name = strings.TrimSpace(left[start+5 : start+5+part])
|
||||
} else {
|
||||
tag.Name = strings.TrimSpace(left[start+5 : 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)
|
||||
func (repo *Repository) GetTagInfos() ([]*Tag, error) {
|
||||
// TODO this a slow implementation, makes one git command per tag
|
||||
stdout, err := NewCommand("tag").RunInDir(repo.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tagSlices := strings.Split(stdout, "\n")
|
||||
tagNames := strings.Split(stdout, "\n")
|
||||
var tags []*Tag
|
||||
for _, line := range tagSlices {
|
||||
line := strings.Trim(line, `"`)
|
||||
tag, err := parseTag(line, opt)
|
||||
for _, tagName := range tagNames {
|
||||
tagName = strings.TrimSpace(tagName)
|
||||
if len(tagName) == 0 {
|
||||
continue
|
||||
}
|
||||
commitID, err := NewCommand("rev-parse", tagName).RunInDir(repo.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tag != nil {
|
||||
tag.repo = repo
|
||||
tags = append(tags, tag)
|
||||
commit, err := repo.GetCommit(commitID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tags = append(tags, &Tag{
|
||||
Name: tagName,
|
||||
Message: commit.Message(),
|
||||
Object: commit.ID,
|
||||
Tagger: commit.Author,
|
||||
})
|
||||
}
|
||||
|
||||
sortTagsByTime(tags)
|
||||
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
|
|
3
vendor/code.gitea.io/git/tree_entry.go
generated
vendored
3
vendor/code.gitea.io/git/tree_entry.go
generated
vendored
|
@ -5,6 +5,7 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -215,7 +216,7 @@ func (state *getCommitInfoState) update(path string) error {
|
|||
return nil
|
||||
}
|
||||
var entryPath string
|
||||
if index := strings.IndexRune(relPath, '/'); index >= 0 {
|
||||
if index := strings.IndexRune(relPath, os.PathSeparator); index >= 0 {
|
||||
entryPath = filepath.Join(state.treePath, relPath[:index])
|
||||
} else {
|
||||
entryPath = path
|
||||
|
|
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
|
@ -3,10 +3,10 @@
|
|||
"ignore": "test appengine",
|
||||
"package": [
|
||||
{
|
||||
"checksumSHA1": "XfPYMmq34V2MFja1HC7nnYU5SAc=",
|
||||
"checksumSHA1": "f0HMnzIIPNck4xa1ERsnZaHM8YI=",
|
||||
"path": "code.gitea.io/git",
|
||||
"revision": "7b07391b09e9642f470b134c2a5e35ee7d0d3491",
|
||||
"revisionTime": "2017-06-01T00:33:00Z"
|
||||
"revision": "a709880af924a8ea77e2ce7688743db69b3566a1",
|
||||
"revisionTime": "2017-06-06T06:50:37Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "nLhT+bLMj8uLICP+EZbrdoQe6mM=",
|
||||
|
|
Loading…
Reference in a new issue