summaryrefslogtreecommitdiffstats
path: root/vendor/code.gitea.io
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-03-11 11:44:58 +0800
committerGitHub <noreply@github.com>2019-03-11 11:44:58 +0800
commit4334fe754e4a338a13073f649707acd26d1f4a12 (patch)
treecea77d699b0af6b9d3c3fab591514a889c869a4c /vendor/code.gitea.io
parent2315019fefb07dfe08e4ecefa199fd947c0c79b8 (diff)
downloadgitea-4334fe754e4a338a13073f649707acd26d1f4a12.tar.gz
gitea-4334fe754e4a338a13073f649707acd26d1f4a12.zip
update git vendor to fix wrong release commit id and add migrations (#6224)
* update git vendor to fix wrong release commit id and add migrations * fix count * fix migration release * fix tests
Diffstat (limited to 'vendor/code.gitea.io')
-rw-r--r--vendor/code.gitea.io/git/cache.go11
-rw-r--r--vendor/code.gitea.io/git/commit_info.go20
-rw-r--r--vendor/code.gitea.io/git/repo_commit.go9
-rw-r--r--vendor/code.gitea.io/git/repo_tag.go4
4 files changed, 36 insertions, 8 deletions
diff --git a/vendor/code.gitea.io/git/cache.go b/vendor/code.gitea.io/git/cache.go
new file mode 100644
index 0000000000..dbbbafae4c
--- /dev/null
+++ b/vendor/code.gitea.io/git/cache.go
@@ -0,0 +1,11 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package git
+
+// LastCommitCache cache
+type LastCommitCache interface {
+ Get(repoPath, ref, entryPath string) (*Commit, error)
+ Put(repoPath, ref, entryPath string, commit *Commit) error
+}
diff --git a/vendor/code.gitea.io/git/commit_info.go b/vendor/code.gitea.io/git/commit_info.go
index 6b42b57c90..971082be1f 100644
--- a/vendor/code.gitea.io/git/commit_info.go
+++ b/vendor/code.gitea.io/git/commit_info.go
@@ -72,13 +72,20 @@ func (state *getCommitsInfoState) getTargetedEntryPath() string {
}
// repeatedly perform targeted searches for unpopulated entries
-func targetedSearch(state *getCommitsInfoState, done chan error) {
+func targetedSearch(state *getCommitsInfoState, done chan error, cache LastCommitCache) {
for {
entryPath := state.getTargetedEntryPath()
if len(entryPath) == 0 {
done <- nil
return
}
+ if cache != nil {
+ commit, err := cache.Get(state.headCommit.repo.Path, state.headCommit.ID.String(), entryPath)
+ if err == nil && commit != nil {
+ state.update(entryPath, commit)
+ continue
+ }
+ }
command := NewCommand("rev-list", "-1", state.headCommit.ID.String(), "--", entryPath)
output, err := command.RunInDir(state.headCommit.repo.Path)
if err != nil {
@@ -96,6 +103,9 @@ func targetedSearch(state *getCommitsInfoState, done chan error) {
return
}
state.update(entryPath, commit)
+ if cache != nil {
+ cache.Put(state.headCommit.repo.Path, state.headCommit.ID.String(), entryPath, commit)
+ }
}
}
@@ -118,9 +128,9 @@ func initGetCommitInfoState(entries Entries, headCommit *Commit, treePath string
}
// GetCommitsInfo gets information of all commits that are corresponding to these entries
-func (tes Entries) GetCommitsInfo(commit *Commit, treePath string) ([][]interface{}, error) {
+func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCommitCache) ([][]interface{}, error) {
state := initGetCommitInfoState(tes, commit, treePath)
- if err := getCommitsInfo(state); err != nil {
+ if err := getCommitsInfo(state, cache); err != nil {
return nil, err
}
if len(state.commits) < len(state.entryPaths) {
@@ -188,7 +198,7 @@ func (state *getCommitsInfoState) update(entryPath string, commit *Commit) bool
const getCommitsInfoPretty = "--pretty=format:%H %ct %s"
-func getCommitsInfo(state *getCommitsInfoState) error {
+func getCommitsInfo(state *getCommitsInfoState, cache LastCommitCache) error {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel()
@@ -215,7 +225,7 @@ func getCommitsInfo(state *getCommitsInfoState) error {
numThreads := runtime.NumCPU()
done := make(chan error, numThreads)
for i := 0; i < numThreads; i++ {
- go targetedSearch(state, done)
+ go targetedSearch(state, done, cache)
}
scanner := bufio.NewScanner(readCloser)
diff --git a/vendor/code.gitea.io/git/repo_commit.go b/vendor/code.gitea.io/git/repo_commit.go
index bfbf5c6dae..fbb8f97a1d 100644
--- a/vendor/code.gitea.io/git/repo_commit.go
+++ b/vendor/code.gitea.io/git/repo_commit.go
@@ -32,7 +32,14 @@ func (repo *Repository) GetBranchCommitID(name string) (string, error) {
// GetTagCommitID returns last commit ID string of given tag.
func (repo *Repository) GetTagCommitID(name string) (string, error) {
- return repo.GetRefCommitID(TagPrefix + name)
+ stdout, err := NewCommand("rev-list", "-n", "1", name).RunInDir(repo.Path)
+ if err != nil {
+ if strings.Contains(err.Error(), "unknown revision or path") {
+ return "", ErrNotExist{name, ""}
+ }
+ return "", err
+ }
+ return strings.TrimSpace(stdout), nil
}
// parseCommitData parses commit information from the (uncompressed) raw
diff --git a/vendor/code.gitea.io/git/repo_tag.go b/vendor/code.gitea.io/git/repo_tag.go
index 77867f46c1..84825d7dc3 100644
--- a/vendor/code.gitea.io/git/repo_tag.go
+++ b/vendor/code.gitea.io/git/repo_tag.go
@@ -76,12 +76,12 @@ func (repo *Repository) getTag(id SHA1) (*Tag, error) {
// GetTag returns a Git tag by given name.
func (repo *Repository) GetTag(name string) (*Tag, error) {
- stdout, err := NewCommand("show-ref", "--tags", name).RunInDir(repo.Path)
+ idStr, err := repo.GetTagCommitID(name)
if err != nil {
return nil, err
}
- id, err := NewIDFromString(strings.Split(stdout, " ")[0])
+ id, err := NewIDFromString(idStr)
if err != nil {
return nil, err
}