diff options
Diffstat (limited to 'internal/route/repo/issue.go')
-rw-r--r-- | internal/route/repo/issue.go | 19 |
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{ |