aboutsummaryrefslogtreecommitdiff
path: root/internal/route/repo/issue.go
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-03-08 19:09:31 +0800
committerGitHub <noreply@github.com>2020-03-08 19:09:31 +0800
commit6437d0180b97a26319b50c2e22927dac7c94fcdd (patch)
tree3d0d097e7f498e4b970065096e7500876d365a8b /internal/route/repo/issue.go
parentc65b5b9f84dee21dc362311b299694e8e00f6ac6 (diff)
git: migrate to github.com/gogs/git-module@v1.0.0 (#5958)
* WIP * Finish `internal/db/git_diff.go` * FInish internal/db/mirror.go * Finish internal/db/pull.go * Finish internal/db/release.go * Finish internal/db/repo.go * Finish internal/db/repo_branch.go * Finish internal/db/repo_editor.go * Finish internal/db/update.go * Save my work * Add license header * Compile! * Merge master * Finish internal/cmd/hook.go * Finish internal/conf/static.go * Finish internal/context/repo.go * Finish internal/db/action.go * Finish internal/db/git_diff.go * Fix submodule URL inferring * Finish internal/db/mirror.go * Updat to beta.4 * css: update fonts * Finish internal/db/pull.go * Finish internal/db/release.go * Finish internal/db/repo_branch.go * Finish internal/db/wiki.go * gitutil: enhance infer submodule UR * Finish internal/route/api/v1/repo/commits.go * mirror: only collect branch commits after sync * mirror: fix tag support * Finish internal/db/repo.go * Finish internal/db/repo_editor.go * Finish internal/db/update.go * Finish internal/gitutil/pull_request.go * Make it compile * Finish internal/route/repo/setting.go * Finish internal/route/repo/branch.go * Finish internal/route/api/v1/repo/file.go * Finish internal/route/repo/download.go * Finish internal/route/repo/editor.go * Use helper * Finish internal/route/repo/issue.go * Finish internal/route/repo/pull.go * Finish internal/route/repo/release.go * Finish internal/route/repo/repo.go * Finish internal/route/repo/wiki.go * Finish internal/route/repo/commit.go * Finish internal/route/repo/view.go * Finish internal/gitutil/tag.go * go.sum
Diffstat (limited to 'internal/route/repo/issue.go')
-rw-r--r--internal/route/repo/issue.go19
1 files changed, 5 insertions, 14 deletions
diff --git a/internal/route/repo/issue.go b/internal/route/repo/issue.go
index 5495402a..fea9af98 100644
--- a/internal/route/repo/issue.go
+++ b/internal/route/repo/issue.go
@@ -6,8 +6,6 @@ package repo
import (
"fmt"
- "io"
- "io/ioutil"
"net/http"
"net/url"
"strings"
@@ -303,30 +301,23 @@ func RetrieveRepoMetas(c *context.Context, repo *db.Repository) []*db.Label {
}
func getFileContentFromDefaultBranch(c *context.Context, filename string) (string, bool) {
- var r io.Reader
- var bytes []byte
-
if c.Repo.Commit == nil {
var err error
- c.Repo.Commit, err = c.Repo.GitRepo.GetBranchCommit(c.Repo.Repository.DefaultBranch)
+ c.Repo.Commit, err = c.Repo.GitRepo.BranchCommit(c.Repo.Repository.DefaultBranch)
if err != nil {
return "", false
}
}
- entry, err := c.Repo.Commit.GetTreeEntryByPath(filename)
- if err != nil {
- return "", false
- }
- r, err = entry.Blob().Data()
+ entry, err := c.Repo.Commit.TreeEntry(filename)
if err != nil {
return "", false
}
- bytes, err = ioutil.ReadAll(r)
+ p, err := entry.Blob().Bytes()
if err != nil {
return "", false
}
- return string(bytes), true
+ return string(p), true
}
func setTemplateIfExists(c *context.Context, ctxDataKey string, possibleFiles []string) {
@@ -656,7 +647,7 @@ func viewIssue(c *context.Context, isPullList bool) {
}
c.Data["IsPullBranchDeletable"] = pull.BaseRepoID == pull.HeadRepoID &&
- c.Repo.IsWriter() && c.Repo.GitRepo.IsBranchExist(pull.HeadBranch) &&
+ c.Repo.IsWriter() && c.Repo.GitRepo.HasBranch(pull.HeadBranch) &&
!branchProtected
c.Data["DeleteBranchLink"] = c.Repo.MakeURL(url.URL{