diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-09-30 04:39:53 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-09-30 04:39:53 -0400 |
commit | 2a031c13658458df9f8f56ce295a8ba72bf35dff (patch) | |
tree | 5af1a495b55eddef9d8fe8e21d2a0bccc835ec1d /modules | |
parent | 198567eccbd6425235f5c755b5862cbe90b435c2 (diff) | |
download | gitea-2a031c13658458df9f8f56ce295a8ba72bf35dff.tar.gz gitea-2a031c13658458df9f8f56ce295a8ba72bf35dff.zip |
Fix #515
Diffstat (limited to 'modules')
-rw-r--r-- | modules/git/repo_commit.go | 4 | ||||
-rw-r--r-- | modules/git/repo_tag.go | 2 | ||||
-rw-r--r-- | modules/git/tree.go | 5 | ||||
-rw-r--r-- | modules/middleware/repo.go | 5 |
4 files changed, 9 insertions, 7 deletions
diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index cd0181c481..7c47b53dc4 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -40,11 +40,11 @@ func (repo *Repository) GetCommitIdOfTag(tagName string) (string, error) { } func (repo *Repository) GetCommitOfTag(tagName string) (*Commit, error) { - commitId, err := repo.GetCommitIdOfTag(tagName) + tag, err := repo.GetTag(tagName) if err != nil { return nil, err } - return repo.GetCommit(commitId) + return tag.Commit() } // Parse commit information from the (uncompressed) raw diff --git a/modules/git/repo_tag.go b/modules/git/repo_tag.go index dd31e4414f..77ae3db007 100644 --- a/modules/git/repo_tag.go +++ b/modules/git/repo_tag.go @@ -52,6 +52,7 @@ func (repo *Repository) getTag(id sha1) (*Tag, error) { if err != nil { return nil, errors.New(stderr) } + tp = strings.TrimSpace(tp) // Tag is a commit. if ObjectType(tp) == COMMIT { @@ -77,7 +78,6 @@ func (repo *Repository) getTag(id sha1) (*Tag, error) { } tag.Id = id - tag.Object = id tag.repo = repo repo.tagCache[id] = tag diff --git a/modules/git/tree.go b/modules/git/tree.go index a3012443d7..be77bfce02 100644 --- a/modules/git/tree.go +++ b/modules/git/tree.go @@ -109,9 +109,12 @@ func (t *Tree) ListEntries(relpath string) (Entries, error) { } t.entriesParsed = true - stdout, _, err := com.ExecCmdDirBytes(t.repo.Path, + stdout, stderr, err := com.ExecCmdDirBytes(t.repo.Path, "git", "ls-tree", t.Id.String()) if err != nil { + if strings.Contains(err.Error(), "exit status 128") { + return nil, errors.New(strings.TrimSpace(string(stderr))) + } return nil, err } t.entries, err = parseTreeData(t, stdout) diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index c0290b2e8f..c6250f6d59 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -208,10 +208,9 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { } else if gitRepo.IsTagExist(refName) { ctx.Repo.IsTag = true ctx.Repo.BranchName = refName - - ctx.Repo.Commit, err = gitRepo.GetCommitOfTag(refName) + ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetCommitOfTag(refName) if err != nil { - ctx.Handle(500, "RepoAssignment invalid tag", err) + ctx.Handle(500, "Fail to get tag commit", err) return } ctx.Repo.CommitId = ctx.Repo.Commit.Id.String() |