summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-09 20:46:05 -0500
committerUnknwon <u@gogs.io>2015-12-09 20:46:05 -0500
commit9a2e43bff28ac92f180109fe900a6997614ea5a8 (patch)
tree564dbb6fb30c153e43b0e18499d80e7d93dd0bee /routers
parentbd5dc626e82e18d3e619d918e579dc130edcd1fa (diff)
downloadgitea-9a2e43bff28ac92f180109fe900a6997614ea5a8.tar.gz
gitea-9a2e43bff28ac92f180109fe900a6997614ea5a8.zip
move out git module and #1573 send push hook
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/file.go5
-rw-r--r--routers/repo/commit.go9
-rw-r--r--routers/repo/download.go7
-rw-r--r--routers/repo/pull.go11
-rw-r--r--routers/repo/release.go28
-rw-r--r--routers/repo/repo.go13
-rw-r--r--routers/repo/setting.go3
-rw-r--r--routers/repo/view.go21
-rw-r--r--routers/repo/wiki.go8
9 files changed, 56 insertions, 49 deletions
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index 0279718bbb..13a6c6c275 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -5,8 +5,9 @@
package repo
import (
+ "github.com/gogits/git-shell"
+
"github.com/gogits/gogs/models"
- "github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/routers/repo"
)
@@ -20,7 +21,7 @@ func GetRawFile(ctx *middleware.Context) {
blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreeName)
if err != nil {
- if err == git.ErrNotExist {
+ if git.IsErrNotExist(err) {
ctx.Error(404)
} else {
ctx.APIError(500, "GetBlobByPath", err)
diff --git a/routers/repo/commit.go b/routers/repo/commit.go
index 101cb5c557..0f0e220382 100644
--- a/routers/repo/commit.go
+++ b/routers/repo/commit.go
@@ -10,9 +10,10 @@ import (
"github.com/Unknwon/paginater"
+ "github.com/gogits/git-shell"
+
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
- "github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting"
)
@@ -55,7 +56,7 @@ func Commits(ctx *middleware.Context) {
if page <= 1 {
page = 1
}
- ctx.Data["Page"] = paginater.New(commitsCount, git.CommitsRangeSize, page, 5)
+ ctx.Data["Page"] = paginater.New(int(commitsCount), git.CommitsRangeSize, page, 5)
// Both `git log branchName` and `git log commitId` work.
commits, err := ctx.Repo.Commit.CommitsByRange(page)
@@ -123,7 +124,7 @@ func FileHistory(ctx *middleware.Context) {
if page <= 1 {
page = 1
}
- ctx.Data["Page"] = paginater.New(commitsCount, git.CommitsRangeSize, page, 5)
+ ctx.Data["Page"] = paginater.New(int(commitsCount), git.CommitsRangeSize, page, 5)
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page)
if err != nil {
@@ -159,7 +160,7 @@ func Diff(ctx *middleware.Context) {
parents := make([]string, commit.ParentCount())
for i := 0; i < commit.ParentCount(); i++ {
- sha, err := commit.ParentId(i)
+ sha, err := commit.ParentID(i)
parents[i] = sha.String()
if err != nil {
ctx.Handle(404, "repo.Diff", err)
diff --git a/routers/repo/download.go b/routers/repo/download.go
index d657d9b18c..3c3256b388 100644
--- a/routers/repo/download.go
+++ b/routers/repo/download.go
@@ -8,8 +8,9 @@ import (
"io"
"path"
+ "github.com/gogits/git-shell"
+
"github.com/gogits/gogs/modules/base"
- "github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/middleware"
)
@@ -21,7 +22,7 @@ func ServeData(ctx *middleware.Context, name string, reader io.Reader) error {
}
_, isTextFile := base.IsTextFile(buf)
- if ! isTextFile {
+ if !isTextFile {
_, isImageFile := base.IsImageFile(buf)
if !isImageFile {
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+path.Base(ctx.Repo.TreeName))
@@ -45,7 +46,7 @@ func ServeBlob(ctx *middleware.Context, blob *git.Blob) error {
func SingleDownload(ctx *middleware.Context) {
blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreeName)
if err != nil {
- if err == git.ErrNotExist {
+ if git.IsErrNotExist(err) {
ctx.Handle(404, "GetBlobByPath", nil)
} else {
ctx.Handle(500, "GetBlobByPath", err)
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 8d6b4c7d7b..d8163a4078 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -12,10 +12,11 @@ import (
"github.com/Unknwon/com"
+ "github.com/gogits/git-shell"
+
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
- "github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting"
@@ -328,9 +329,9 @@ func ViewPullFiles(ctx *middleware.Context) {
return
}
- headCommitID, err := headGitRepo.GetCommitIdOfBranch(pull.HeadBranch)
+ headCommitID, err := headGitRepo.GetBranchCommitID(pull.HeadBranch)
if err != nil {
- ctx.Handle(500, "GetCommitIdOfBranch", err)
+ ctx.Handle(500, "GetBranchCommitID", err)
return
}
@@ -492,9 +493,9 @@ func PrepareCompareDiff(
// Get diff information.
ctx.Data["CommitRepoLink"] = headRepo.RepoLink()
- headCommitID, err := headGitRepo.GetCommitIdOfBranch(headBranch)
+ headCommitID, err := headGitRepo.GetBranchCommitID(headBranch)
if err != nil {
- ctx.Handle(500, "GetCommitIdOfBranch", err)
+ ctx.Handle(500, "GetBranchCommitID", err)
return false
}
ctx.Data["AfterCommitID"] = headCommitID
diff --git a/routers/repo/release.go b/routers/repo/release.go
index a3b9887ea1..880385708f 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -34,7 +34,7 @@ func Releases(ctx *middleware.Context) {
}
// Temproray cache commits count of used branches to speed up.
- countCache := make(map[string]int)
+ countCache := make(map[string]int64)
tags := make([]*models.Release, len(rawTags))
for i, rawTag := range rawTags {
@@ -45,7 +45,7 @@ func Releases(ctx *middleware.Context) {
if rel.TagName == rawTag {
rel.Publisher, err = models.GetUserByID(rel.PublisherID)
if err != nil {
- ctx.Handle(500, "GetUserById", err)
+ ctx.Handle(500, "GetUserByID", err)
return
}
// FIXME: duplicated code.
@@ -53,14 +53,14 @@ func Releases(ctx *middleware.Context) {
if ctx.Repo.BranchName != rel.Target {
// Get count if not exists.
if _, ok := countCache[rel.Target]; !ok {
- commit, err := ctx.Repo.GitRepo.GetCommitOfBranch(ctx.Repo.BranchName)
+ commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.BranchName)
if err != nil {
- ctx.Handle(500, "GetCommitOfBranch", err)
+ ctx.Handle(500, "GetBranchCommit", err)
return
}
countCache[ctx.Repo.BranchName], err = commit.CommitsCount()
if err != nil {
- ctx.Handle(500, "CommitsCount2", err)
+ ctx.Handle(500, "CommitsCount", err)
return
}
}
@@ -77,9 +77,9 @@ func Releases(ctx *middleware.Context) {
}
if tags[i] == nil {
- commit, err := ctx.Repo.GitRepo.GetCommitOfTag(rawTag)
+ commit, err := ctx.Repo.GitRepo.GetTagCommit(rawTag)
if err != nil {
- ctx.Handle(500, "GetCommitOfTag2", err)
+ ctx.Handle(500, "GetTagCommit", err)
return
}
@@ -89,7 +89,7 @@ func Releases(ctx *middleware.Context) {
Sha1: commit.ID.String(),
}
- tags[i].NumCommits, err = ctx.Repo.GitRepo.CommitsCount(commit.ID.String())
+ tags[i].NumCommits, err = commit.CommitsCount()
if err != nil {
ctx.Handle(500, "CommitsCount", err)
return
@@ -105,7 +105,7 @@ func Releases(ctx *middleware.Context) {
rel.Publisher, err = models.GetUserByID(rel.PublisherID)
if err != nil {
- ctx.Handle(500, "GetUserById", err)
+ ctx.Handle(500, "GetUserByID", err)
return
}
// FIXME: duplicated code.
@@ -113,14 +113,14 @@ func Releases(ctx *middleware.Context) {
if ctx.Repo.BranchName != rel.Target {
// Get count if not exists.
if _, ok := countCache[rel.Target]; !ok {
- commit, err := ctx.Repo.GitRepo.GetCommitOfBranch(ctx.Repo.BranchName)
+ commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.BranchName)
if err != nil {
- ctx.Handle(500, "GetCommitOfBranch", err)
+ ctx.Handle(500, "GetBranchCommit", err)
return
}
countCache[ctx.Repo.BranchName], err = commit.CommitsCount()
if err != nil {
- ctx.Handle(500, "CommitsCount2", err)
+ ctx.Handle(500, "CommitsCount", err)
return
}
}
@@ -158,9 +158,9 @@ func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
return
}
- commit, err := ctx.Repo.GitRepo.GetCommitOfBranch(form.Target)
+ commit, err := ctx.Repo.GitRepo.GetBranchCommit(form.Target)
if err != nil {
- ctx.Handle(500, "GetCommitOfBranch", err)
+ ctx.Handle(500, "GetBranchCommit", err)
return
}
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index e134fd29e6..c70d55a625 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -12,10 +12,11 @@ import (
"github.com/Unknwon/com"
+ "github.com/gogits/git-shell"
+
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
- "github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/setting"
@@ -294,21 +295,21 @@ func Download(ctx *middleware.Context) {
)
gitRepo := ctx.Repo.GitRepo
if gitRepo.IsBranchExist(refName) {
- commit, err = gitRepo.GetCommitOfBranch(refName)
+ commit, err = gitRepo.GetBranchCommit(refName)
if err != nil {
- ctx.Handle(500, "Download", err)
+ ctx.Handle(500, "GetBranchCommit", err)
return
}
} else if gitRepo.IsTagExist(refName) {
- commit, err = gitRepo.GetCommitOfTag(refName)
+ commit, err = gitRepo.GetTagCommit(refName)
if err != nil {
- ctx.Handle(500, "Download", err)
+ ctx.Handle(500, "GetTagCommit", err)
return
}
} else if len(refName) == 40 {
commit, err = gitRepo.GetCommit(refName)
if err != nil {
- ctx.Handle(404, "Download", nil)
+ ctx.Handle(404, "GetCommit", nil)
return
}
} else {
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index e4c4f897a0..d393472ee2 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -8,10 +8,11 @@ import (
"strings"
"time"
+ "github.com/gogits/git-shell"
+
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
"github.com/gogits/gogs/modules/base"
- "github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/mailer"
"github.com/gogits/gogs/modules/middleware"
diff --git a/routers/repo/view.go b/routers/repo/view.go
index 361d77a85a..f019256d3e 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -13,9 +13,10 @@ import (
"github.com/Unknwon/paginater"
+ "github.com/gogits/git-shell"
+
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
- "github.com/gogits/gogs/modules/git"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/template"
@@ -59,7 +60,7 @@ func Home(ctx *middleware.Context) {
}
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treename)
- if err != nil && err != git.ErrNotExist {
+ if err != nil && git.IsErrNotExist(err) {
ctx.Handle(404, "GetTreeEntryByPath", err)
return
}
@@ -126,7 +127,7 @@ func Home(ctx *middleware.Context) {
return
}
- entries, err := tree.ListEntries(treename)
+ entries, err := tree.ListEntries()
if err != nil {
ctx.Handle(500, "ListEntries", err)
return
@@ -135,10 +136,10 @@ func Home(ctx *middleware.Context) {
files := make([][]interface{}, 0, len(entries))
for _, te := range entries {
- if te.Type != git.COMMIT {
- c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
+ if te.Type != git.OBJECT_COMMIT {
+ c, err := ctx.Repo.Commit.GetCommitByPath(filepath.Join(treePath, te.Name()))
if err != nil {
- ctx.Handle(500, "GetCommitOfRelPath", err)
+ ctx.Handle(500, "GetCommitByPath", err)
return
}
files = append(files, []interface{}{te, c})
@@ -153,9 +154,9 @@ func Home(ctx *middleware.Context) {
smUrl = sm.Url
}
- c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
+ c, err := ctx.Repo.Commit.GetCommitByPath(filepath.Join(treePath, te.Name()))
if err != nil {
- ctx.Handle(500, "GetCommitOfRelPath", err)
+ ctx.Handle(500, "GetCommitByPath", err)
return
}
files = append(files, []interface{}{te, git.NewSubModuleFile(c, smUrl, te.ID.String())})
@@ -209,9 +210,9 @@ func Home(ctx *middleware.Context) {
lastCommit := ctx.Repo.Commit
if len(treePath) > 0 {
- c, err := ctx.Repo.Commit.GetCommitOfRelPath(treePath)
+ c, err := ctx.Repo.Commit.GetCommitByPath(treePath)
if err != nil {
- ctx.Handle(500, "GetCommitOfRelPath", err)
+ ctx.Handle(500, "GetCommitByPath", err)
return
}
lastCommit = c
diff --git a/routers/repo/wiki.go b/routers/repo/wiki.go
index 5e160518a0..6b3f2e3413 100644
--- a/routers/repo/wiki.go
+++ b/routers/repo/wiki.go
@@ -42,9 +42,9 @@ func renderWikiPage(ctx *middleware.Context, isViewPage bool) (*git.Repository,
ctx.Handle(500, "OpenRepository", err)
return nil, ""
}
- commit, err := wikiRepo.GetCommitOfBranch("master")
+ commit, err := wikiRepo.GetBranchCommit("master")
if err != nil {
- ctx.Handle(500, "GetCommitOfBranch", err)
+ ctx.Handle(500, "GetBranchCommit", err)
return nil, ""
}
@@ -147,9 +147,9 @@ func WikiPages(ctx *middleware.Context) {
ctx.Handle(500, "OpenRepository", err)
return
}
- commit, err := wikiRepo.GetCommitOfBranch("master")
+ commit, err := wikiRepo.GetBranchCommit("master")
if err != nil {
- ctx.Handle(500, "GetCommitOfBranch", err)
+ ctx.Handle(500, "GetBranchCommit", err)
return
}