summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-08 22:43:14 +0800
committerUnknwon <u@gogs.io>2015-08-08 22:43:14 +0800
commitdea3a8c6a42ea7e4921c0e4beee5d4fd0437dbe5 (patch)
tree773b28a72cee24e4a02f3d162de8a37a8f912f59 /routers
parentd015d951bd6959f9585d8a83acfe7bba07b7eaad (diff)
downloadgitea-dea3a8c6a42ea7e4921c0e4beee5d4fd0437dbe5.tar.gz
gitea-dea3a8c6a42ea7e4921c0e4beee5d4fd0437dbe5.zip
WIP: create PR - choose branch
Diffstat (limited to 'routers')
-rw-r--r--routers/admin/users.go10
-rw-r--r--routers/api/v1/repo.go12
-rw-r--r--routers/api/v1/repo_hooks.go4
-rw-r--r--routers/home.go2
-rw-r--r--routers/repo/http.go4
-rw-r--r--routers/repo/issue.go56
-rw-r--r--routers/repo/pull.go65
-rw-r--r--routers/repo/release.go12
-rw-r--r--routers/repo/repo.go14
-rw-r--r--routers/repo/setting.go14
-rw-r--r--routers/user/home.go12
11 files changed, 128 insertions, 77 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 12c52236f9..2af3cdbc1f 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -139,9 +139,9 @@ func EditUser(ctx *middleware.Context) {
return
}
- u, err := models.GetUserById(uid)
+ u, err := models.GetUserByID(uid)
if err != nil {
- ctx.Handle(500, "GetUserById", err)
+ ctx.Handle(500, "GetUserByID", err)
return
}
@@ -166,7 +166,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
return
}
- u, err := models.GetUserById(uid)
+ u, err := models.GetUserByID(uid)
if err != nil {
ctx.Handle(500, "GetUserById", err)
return
@@ -219,9 +219,9 @@ func DeleteUser(ctx *middleware.Context) {
return
}
- u, err := models.GetUserById(uid)
+ u, err := models.GetUserByID(uid)
if err != nil {
- ctx.Handle(500, "GetUserById", err)
+ ctx.Handle(500, "GetUserByID", err)
return
}
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go
index fdf05c0529..c6dabfcb86 100644
--- a/routers/api/v1/repo.go
+++ b/routers/api/v1/repo.go
@@ -28,7 +28,7 @@ func ToApiRepository(owner *models.User, repo *models.Repository, permission api
log.Error(4, "CloneLink: %v", err)
}
return &api.Repository{
- Id: repo.Id,
+ Id: repo.ID,
Owner: *ToApiUser(owner),
FullName: owner.Name + "/" + repo.Name,
Private: repo.IsPrivate,
@@ -55,7 +55,7 @@ func SearchRepos(ctx *middleware.Context) {
if ctx.User.Id == opt.Uid {
opt.Private = true
} else {
- u, err := models.GetUserById(opt.Uid)
+ u, err := models.GetUserByID(opt.Uid)
if err != nil {
ctx.JSON(500, map[string]interface{}{
"ok": false,
@@ -89,7 +89,7 @@ func SearchRepos(ctx *middleware.Context) {
return
}
results[i] = &api.Repository{
- Id: repos[i].Id,
+ Id: repos[i].ID,
FullName: path.Join(repos[i].Owner.Name, repos[i].Name),
}
}
@@ -111,7 +111,7 @@ func createRepo(ctx *middleware.Context, owner *models.User, opt api.CreateRepoO
} else {
log.Error(4, "CreateRepository: %v", err)
if repo != nil {
- if err = models.DeleteRepository(ctx.User.Id, repo.Id, ctx.User.Name); err != nil {
+ if err = models.DeleteRepository(ctx.User.Id, repo.ID, ctx.User.Name); err != nil {
log.Error(4, "DeleteRepository: %v", err)
}
}
@@ -172,7 +172,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
ctxUser := u
// Not equal means current user is an organization.
if form.Uid != u.Id {
- org, err := models.GetUserById(form.Uid)
+ org, err := models.GetUserByID(form.Uid)
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.HandleAPI(422, err)
@@ -219,7 +219,7 @@ func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {
repo, err := models.MigrateRepository(ctxUser, form.RepoName, form.Description, form.Private, form.Mirror, remoteAddr)
if err != nil {
if repo != nil {
- if errDelete := models.DeleteRepository(ctxUser.Id, repo.Id, ctxUser.Name); errDelete != nil {
+ if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
diff --git a/routers/api/v1/repo_hooks.go b/routers/api/v1/repo_hooks.go
index afe18a0058..0348c68391 100644
--- a/routers/api/v1/repo_hooks.go
+++ b/routers/api/v1/repo_hooks.go
@@ -17,7 +17,7 @@ import (
// GET /repos/:username/:reponame/hooks
// https://developer.github.com/v3/repos/hooks/#list-hooks
func ListRepoHooks(ctx *middleware.Context) {
- hooks, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id)
+ hooks, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID)
if err != nil {
ctx.JSON(500, &base.ApiJsonErr{"GetWebhooksByRepoId: " + err.Error(), base.DOC_URL})
return
@@ -67,7 +67,7 @@ func CreateRepoHook(ctx *middleware.Context, form api.CreateHookOption) {
}
w := &models.Webhook{
- RepoId: ctx.Repo.Repository.Id,
+ RepoId: ctx.Repo.Repository.ID,
Url: form.Config["url"],
ContentType: models.ToHookContentType(form.Config["content_type"]),
Secret: form.Config["secret"],
diff --git a/routers/home.go b/routers/home.go
index dd604ec7e3..14a123f10b 100644
--- a/routers/home.go
+++ b/routers/home.go
@@ -57,7 +57,7 @@ func Explore(ctx *middleware.Context) {
}
for _, repo := range repos {
if err = repo.GetOwner(); err != nil {
- ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.Id, err))
+ ctx.Handle(500, "GetOwner", fmt.Errorf("%d: %v", repo.ID, err))
return
}
}
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 45b0ec59c9..54ea91cada 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -122,7 +122,7 @@ func Http(ctx *middleware.Context) {
}
return
}
- authUser, err = models.GetUserById(token.Uid)
+ authUser, err = models.GetUserByID(token.Uid)
if err != nil {
ctx.Handle(500, "GetUserById", err)
return
@@ -191,7 +191,7 @@ func Http(ctx *middleware.Context) {
// FIXME: handle error.
if err = models.Update(refName, oldCommitId, newCommitId, authUsername, username, reponame, authUser.Id); err == nil {
- models.HookQueue.AddRepoID(repo.Id)
+ models.HookQueue.AddRepoID(repo.ID)
}
}
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 9d59d19a5f..89eb7e6480 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -44,7 +44,7 @@ var (
)
func RetrieveLabels(ctx *middleware.Context) {
- labels, err := models.GetLabels(ctx.Repo.Repository.Id)
+ labels, err := models.GetLabels(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "RetrieveLabels.GetLabels: %v", err)
return
@@ -95,7 +95,7 @@ func Issues(ctx *middleware.Context) {
selectLabels := ctx.Query("labels")
milestoneID := ctx.QueryInt64("milestone")
isShowClosed := ctx.Query("state") == "closed"
- issueStats := models.GetIssueStats(repo.Id, uid, com.StrTo(selectLabels).MustInt64(), milestoneID, isShowClosed, filterMode)
+ issueStats := models.GetIssueStats(repo.ID, uid, com.StrTo(selectLabels).MustInt64(), milestoneID, isShowClosed, filterMode)
page := ctx.QueryInt("page")
if page <= 1 {
@@ -111,7 +111,7 @@ func Issues(ctx *middleware.Context) {
ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5)
// Get issues.
- issues, err := models.Issues(uid, assigneeID, repo.Id, posterID, milestoneID,
+ issues, err := models.Issues(uid, assigneeID, repo.ID, posterID, milestoneID,
page, isShowClosed, filterMode == models.FM_MENTION, selectLabels, ctx.Query("sortType"))
if err != nil {
ctx.Handle(500, "GetIssues: %v", err)
@@ -119,7 +119,7 @@ func Issues(ctx *middleware.Context) {
}
// Get issue-user pairs.
- pairs, err := models.GetIssueUserPairs(repo.Id, posterID, isShowClosed)
+ pairs, err := models.GetIssueUserPairs(repo.ID, posterID, isShowClosed)
if err != nil {
ctx.Handle(500, "GetIssueUserPairs: %v", err)
return
@@ -153,7 +153,7 @@ func Issues(ctx *middleware.Context) {
ctx.Data["Issues"] = issues
// Get milestones.
- miles, err := models.GetAllRepoMilestones(repo.Id)
+ miles, err := models.GetAllRepoMilestones(repo.ID)
if err != nil {
ctx.Handle(500, "GetAllRepoMilestones: %v", err)
return
@@ -185,12 +185,12 @@ func CreateIssue(ctx *middleware.Context) {
err error
)
// Get all milestones.
- ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.Id, -1, false)
+ ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
if err != nil {
ctx.Handle(500, "GetMilestones.1: %v", err)
return
}
- ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.Id, -1, true)
+ ctx.Data["ClosedMilestones"], err = models.GetMilestones(repo.ID, -1, true)
if err != nil {
ctx.Handle(500, "GetMilestones.2: %v", err)
return
@@ -229,12 +229,12 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
var err error
// Get all milestones.
- _, err = models.GetMilestones(ctx.Repo.Repository.Id, -1, false)
+ _, err = models.GetMilestones(ctx.Repo.Repository.ID, -1, false)
if err != nil {
send(500, nil, err)
return
}
- _, err = models.GetMilestones(ctx.Repo.Repository.Id, -1, true)
+ _, err = models.GetMilestones(ctx.Repo.Repository.ID, -1, true)
if err != nil {
send(500, nil, err)
return
@@ -256,7 +256,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
form.AssigneeId = 0
}
issue := &models.Issue{
- RepoID: ctx.Repo.Repository.Id,
+ RepoID: ctx.Repo.Repository.ID,
Index: int64(ctx.Repo.Repository.NumIssues) + 1,
Name: form.IssueName,
PosterID: ctx.User.Id,
@@ -297,7 +297,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
ActEmail: ctx.User.Email,
OpType: models.CREATE_ISSUE,
Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name),
- RepoID: ctx.Repo.Repository.Id,
+ RepoID: ctx.Repo.Repository.ID,
RepoUserName: ctx.Repo.Owner.Name,
RepoName: ctx.Repo.Repository.Name,
RefName: ctx.Repo.BranchName,
@@ -332,7 +332,7 @@ func CreateIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) {
return
}
}
- log.Trace("%d Issue created: %d", ctx.Repo.Repository.Id, issue.ID)
+ log.Trace("%d Issue created: %d", ctx.Repo.Repository.ID, issue.ID)
send(200, fmt.Sprintf("%s/%s/%s/issues/%d", setting.AppSubUrl, ctx.Params(":username"), ctx.Params(":reponame"), issue.Index), nil)
}
@@ -357,7 +357,7 @@ func ViewIssue(ctx *middleware.Context) {
return
}
- issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
+ issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, idx)
if err != nil {
if err == models.ErrIssueNotExist {
ctx.Handle(404, "GetIssueByIndex", err)
@@ -372,7 +372,7 @@ func ViewIssue(ctx *middleware.Context) {
ctx.Handle(500, "GetLabels", err)
return
}
- labels, err := models.GetLabels(ctx.Repo.Repository.Id)
+ labels, err := models.GetLabels(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "GetLabels.2", err)
return
@@ -394,12 +394,12 @@ func ViewIssue(ctx *middleware.Context) {
}
// Get all milestones.
- ctx.Data["OpenMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, -1, false)
+ ctx.Data["OpenMilestones"], err = models.GetMilestones(ctx.Repo.Repository.ID, -1, false)
if err != nil {
ctx.Handle(500, "GetMilestones.1: %v", err)
return
}
- ctx.Data["ClosedMilestones"], err = models.GetMilestones(ctx.Repo.Repository.Id, -1, true)
+ ctx.Data["ClosedMilestones"], err = models.GetMilestones(ctx.Repo.Repository.ID, -1, true)
if err != nil {
ctx.Handle(500, "GetMilestones.2: %v", err)
return
@@ -439,7 +439,7 @@ func ViewIssue(ctx *middleware.Context) {
// Get posters.
for i := range comments {
- u, err := models.GetUserById(comments[i].PosterId)
+ u, err := models.GetUserByID(comments[i].PosterId)
if err != nil {
ctx.Handle(500, "GetUserById.2: %v", err)
return
@@ -469,7 +469,7 @@ func UpdateIssue(ctx *middleware.Context, form auth.CreateIssueForm) {
return
}
- issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
+ issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, idx)
if err != nil {
if err == models.ErrIssueNotExist {
ctx.Handle(404, "issue.UpdateIssue", err)
@@ -517,7 +517,7 @@ func UpdateIssueLabel(ctx *middleware.Context) {
return
}
- issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, idx)
+ issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, idx)
if err != nil {
if err == models.ErrIssueNotExist {
ctx.Handle(404, "issue.UpdateIssueLabel(GetIssueByIndex)", err)
@@ -762,7 +762,7 @@ func Comment(ctx *middleware.Context) {
return
}
- issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, index)
+ issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, index)
if err != nil {
if err == models.ErrIssueNotExist {
send(404, nil, err)
@@ -820,7 +820,7 @@ func Comment(ctx *middleware.Context) {
cmtType = models.COMMENT_TYPE_REOPEN
}
- if _, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.ID, 0, 0, cmtType, "", nil); err != nil {
+ if _, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.ID, issue.ID, 0, 0, cmtType, "", nil); err != nil {
send(200, nil, err)
return
}
@@ -836,7 +836,7 @@ func Comment(ctx *middleware.Context) {
if len(content) > 0 || len(ctx.Req.MultipartForm.File["attachments"]) > 0 {
switch ctx.Params(":action") {
case "new":
- if comment, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.Id, issue.ID, 0, 0, models.COMMENT_TYPE_COMMENT, content, nil); err != nil {
+ if comment, err = models.CreateComment(ctx.User.Id, ctx.Repo.Repository.ID, issue.ID, 0, 0, models.COMMENT_TYPE_COMMENT, content, nil); err != nil {
send(500, nil, err)
return
}
@@ -872,7 +872,7 @@ func Comment(ctx *middleware.Context) {
ActEmail: ctx.User.Email,
OpType: models.COMMENT_ISSUE,
Content: fmt.Sprintf("%d|%s", issue.Index, strings.Split(content, "\n")[0]),
- RepoID: ctx.Repo.Repository.Id,
+ RepoID: ctx.Repo.Repository.ID,
RepoUserName: ctx.Repo.Owner.LowerName,
RepoName: ctx.Repo.Repository.LowerName,
IsPrivate: ctx.Repo.Repository.IsPrivate,
@@ -927,7 +927,7 @@ func NewLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
}
l := &models.Label{
- RepoId: ctx.Repo.Repository.Id,
+ RepoId: ctx.Repo.Repository.ID,
Name: form.Title,
Color: form.Color,
}
@@ -960,7 +960,7 @@ func UpdateLabel(ctx *middleware.Context, form auth.CreateLabelForm) {
}
func DeleteLabel(ctx *middleware.Context) {
- if err := models.DeleteLabel(ctx.Repo.Repository.Id, ctx.QueryInt64("id")); err != nil {
+ if err := models.DeleteLabel(ctx.Repo.Repository.ID, ctx.QueryInt64("id")); err != nil {
ctx.Flash.Error("DeleteLabel: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
@@ -977,7 +977,7 @@ func Milestones(ctx *middleware.Context) {
ctx.Data["PageIsMilestones"] = true
isShowClosed := ctx.Query("state") == "closed"
- openCount, closedCount := models.MilestoneStats(ctx.Repo.Repository.Id)
+ openCount, closedCount := models.MilestoneStats(ctx.Repo.Repository.ID)
ctx.Data["OpenCount"] = openCount
ctx.Data["ClosedCount"] = closedCount
@@ -994,7 +994,7 @@ func Milestones(ctx *middleware.Context) {
}
ctx.Data["Page"] = paginater.New(total, setting.IssuePagingNum, page, 5)
- miles, err := models.GetMilestones(ctx.Repo.Repository.Id, page, isShowClosed)
+ miles, err := models.GetMilestones(ctx.Repo.Repository.ID, page, isShowClosed)
if err != nil {
ctx.Handle(500, "GetMilestones", err)
return
@@ -1043,7 +1043,7 @@ func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) {
}
if err = models.NewMilestone(&models.Milestone{
- RepoID: ctx.Repo.Repository.Id,
+ RepoID: ctx.Repo.Repository.ID,
Name: form.Title,
Content: form.Content,
Deadline: deadline,
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index a4ebb91a39..c035cc8cba 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -5,26 +5,31 @@
package repo
import (
+ "fmt"
+ "strings"
+
"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"
)
const (
- FORK base.TplName = "repo/pulls/fork"
- PULLS base.TplName = "repo/pulls"
+ FORK base.TplName = "repo/pulls/fork"
+ COMPARE_PULL base.TplName = "repo/pulls/compare"
+ PULLS base.TplName = "repo/pulls"
)
func getForkRepository(ctx *middleware.Context) *models.Repository {
- forkRepo, err := models.GetRepositoryById(ctx.ParamsInt64(":repoid"))
+ forkRepo, err := models.GetRepositoryByID(ctx.ParamsInt64(":repoid"))
if err != nil {
if models.IsErrRepoNotExist(err) {
- ctx.Handle(404, "GetRepositoryById", nil)
+ ctx.Handle(404, "GetRepositoryByID", nil)
} else {
- ctx.Handle(500, "GetRepositoryById", err)
+ ctx.Handle(500, "GetRepositoryByID", err)
}
return nil
}
@@ -78,7 +83,7 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
return
}
- repo, has := models.HasForkedRepo(ctxUser.Id, forkRepo.Id)
+ repo, has := models.HasForkedRepo(ctxUser.Id, forkRepo.ID)
if has {
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
return
@@ -110,10 +115,56 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
return
}
- log.Trace("Repository forked[%d]: %s/%s", forkRepo.Id, ctxUser.Name, repo.Name)
+ log.Trace("Repository forked[%d]: %s/%s", forkRepo.ID, ctxUser.Name, repo.Name)
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
}
+func CompareAndPullRequest(ctx *middleware.Context) {
+ // Get compare information.
+ infos := strings.Split(ctx.Params("*"), "...")
+ if len(infos) != 2 {
+ ctx.Handle(404, "CompareAndPullRequest", nil)
+ return
+ }
+
+ baseBranch := infos[0]
+ ctx.Data["BaseBranch"] = baseBranch
+
+ headInfos := strings.Split(infos[1], ":")
+ if len(headInfos) != 2 {
+ ctx.Handle(404, "CompareAndPullRequest", nil)
+ return
+ }
+ headUser := headInfos[0]
+ headBranch := headInfos[1]
+ ctx.Data["HeadBranch"] = headBranch
+
+ // TODO: check if branches are valid.
+ fmt.Println(baseBranch, headUser, headBranch)
+
+ // TODO: add organization support
+ // Check if current user has fork of repository.
+ headRepo, has := models.HasForkedRepo(ctx.User.Id, ctx.Repo.Repository.ID)
+ if !has {
+ ctx.Handle(404, "HasForkedRepo", nil)
+ return
+ }
+
+ headGitRepo, err := git.OpenRepository(models.RepoPath(ctx.User.Name, headRepo.Name))
+ if err != nil {
+ ctx.Handle(500, "OpenRepository", err)
+ return
+ }
+ headBranches, err := headGitRepo.GetBranches()
+ if err != nil {
+ ctx.Handle(500, "GetBranches", err)
+ return
+ }
+ ctx.Data["HeadBranches"] = headBranches
+
+ ctx.HTML(200, COMPARE_PULL)
+}
+
func Pulls(ctx *middleware.Context) {
ctx.Data["IsRepoToolbarPulls"] = true
ctx.HTML(200, PULLS)
diff --git a/routers/repo/release.go b/routers/repo/release.go
index 52d78b1967..30d5f60b3f 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -29,7 +29,7 @@ func Releases(ctx *middleware.Context) {
return
}
- rels, err := models.GetReleasesByRepoId(ctx.Repo.Repository.Id)
+ rels, err := models.GetReleasesByRepoId(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "GetReleasesByRepoId", err)
return
@@ -45,7 +45,7 @@ func Releases(ctx *middleware.Context) {
continue
}
if rel.TagName == rawTag {
- rel.Publisher, err = models.GetUserById(rel.PublisherId)
+ rel.Publisher, err = models.GetUserByID(rel.PublisherId)
if err != nil {
ctx.Handle(500, "GetUserById", err)
return
@@ -105,7 +105,7 @@ func Releases(ctx *middleware.Context) {
continue
}
- rel.Publisher, err = models.GetUserById(rel.PublisherId)
+ rel.Publisher, err = models.GetUserByID(rel.PublisherId)
if err != nil {
ctx.Handle(500, "GetUserById", err)
return
@@ -185,7 +185,7 @@ func NewReleasePost(ctx *middleware.Context, form auth.NewReleaseForm) {
}
rel := &models.Release{
- RepoId: ctx.Repo.Repository.Id,
+ RepoId: ctx.Repo.Repository.ID,
PublisherId: ctx.User.Id,
Title: form.Title,
TagName: form.TagName,
@@ -217,7 +217,7 @@ func EditRelease(ctx *middleware.Context) {
}
tagName := ctx.Params(":tagname")
- rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
+ rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
if err != nil {
if err == models.ErrReleaseNotExist {
ctx.Handle(404, "GetRelease", err)
@@ -240,7 +240,7 @@ func EditReleasePost(ctx *middleware.Context, form auth.EditReleaseForm) {
}
tagName := ctx.Params(":tagname")
- rel, err := models.GetRelease(ctx.Repo.Repository.Id, tagName)
+ rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
if err != nil {
if err == models.ErrReleaseNotExist {
ctx.Handle(404, "GetRelease", err)
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index dde8b58465..533bd569ad 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -33,7 +33,7 @@ func checkContextUser(ctx *middleware.Context, uid int64) *models.User {
return ctx.User
}
- org, err := models.GetUserById(uid)
+ org, err := models.GetUserByID(uid)
if models.IsErrUserNotExist(err) {
return ctx.User
}
@@ -112,7 +112,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
}
if repo != nil {
- if errDelete := models.DeleteRepository(ctxUser.Id, repo.Id, ctxUser.Name); errDelete != nil {
+ if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
@@ -209,7 +209,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
}
if repo != nil {
- if errDelete := models.DeleteRepository(ctxUser.Id, repo.Id, ctxUser.Name); errDelete != nil {
+ if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID, ctxUser.Name); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete)
}
}
@@ -239,13 +239,13 @@ func Action(ctx *middleware.Context) {
var err error
switch ctx.Params(":action") {
case "watch":
- err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, true)
+ err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.ID, true)
case "unwatch":
- err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, false)
+ err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.ID, false)
case "star":
- err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, true)
+ err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.ID, true)
case "unstar":
- err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, false)
+ err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.ID, false)
case "desc":
if !ctx.Repo.IsOwner() {
ctx.Error(404)
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 1d5e0702ac..551ba11513 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -160,7 +160,7 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
return
}
- if err := models.DeleteRepository(ctx.Repo.Owner.Id, ctx.Repo.Repository.Id, ctx.Repo.Owner.Name); err != nil {
+ if err := models.DeleteRepository(ctx.Repo.Owner.Id, ctx.Repo.Repository.ID, ctx.Repo.Owner.Name); err != nil {
ctx.Handle(500, "DeleteRepository", err)
return
}
@@ -262,7 +262,7 @@ func Webhooks(ctx *middleware.Context) {
return
}
- ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.Id)
+ ws, err := models.GetWebhooksByRepoId(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "GetWebhooksByRepoId", err)
return
@@ -569,7 +569,7 @@ func getOrgRepoCtx(ctx *middleware.Context) (*OrgRepoCtx, error) {
if _, ok := ctx.Data["RepoLink"]; ok {
return &OrgRepoCtx{
OrgId: int64(0),
- RepoId: ctx.Repo.Repository.Id,
+ RepoId: ctx.Repo.Repository.ID,
Link: ctx.Repo.RepoLink,
NewTemplate: HOOK_NEW,
}, nil
@@ -605,7 +605,7 @@ func TriggerHook(ctx *middleware.Context) {
}
return
}
- models.HookQueue.AddRepoID(repo.Id)
+ models.HookQueue.AddRepoID(repo.ID)
}
func GitHooks(ctx *middleware.Context) {
@@ -663,7 +663,7 @@ func SettingsDeployKeys(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsKeys"] = true
- keys, err := models.ListDeployKeys(ctx.Repo.Repository.Id)
+ keys, err := models.ListDeployKeys(ctx.Repo.Repository.ID)
if err != nil {
ctx.Handle(500, "ListDeployKeys", err)
return
@@ -695,7 +695,7 @@ func SettingsDeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
}
}
- if err = models.AddDeployKey(ctx.Repo.Repository.Id, form.Title, content); err != nil {
+ if err = models.AddDeployKey(ctx.Repo.Repository.ID, form.Title, content); err != nil {
ctx.Data["HasError"] = true
switch {
case models.IsErrKeyAlreadyExist(err):
@@ -710,7 +710,7 @@ func SettingsDeployKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
return
}
- log.Trace("Deploy key added: %d", ctx.Repo.Repository.Id)
+ log.Trace("Deploy key added: %d", ctx.Repo.Repository.ID)
ctx.Flash.Success(ctx.Tr("repo.settings.add_key_success", form.Title))
ctx.Redirect(ctx.Repo.RepoLink + "/settings/keys")
}
diff --git a/routers/user/home.go b/routers/user/home.go
index c38dba5205..a36483630e 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -104,7 +104,7 @@ func Dashboard(ctx *middleware.Context) {
for _, act := range actions {
if act.IsPrivate {
// This prevents having to retrieve the repository for each action
- repo := &models.Repository{Id: act.RepoID, IsPrivate: true}
+ repo := &models.Repository{ID: act.RepoID, IsPrivate: true}
if act.RepoUserName != ctx.User.LowerName {
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue
@@ -212,7 +212,7 @@ func Profile(ctx *middleware.Context) {
continue
}
// This prevents having to retrieve the repository for each action
- repo := &models.Repository{Id: act.RepoID, IsPrivate: true}
+ repo := &models.Repository{ID: act.RepoID, IsPrivate: true}
if act.RepoUserName != ctx.User.LowerName {
if has, _ := models.HasAccess(ctx.User, repo, models.ACCESS_MODE_READ); !has {
continue
@@ -295,21 +295,21 @@ func Issues(ctx *middleware.Context) {
continue
}
- repoIds = append(repoIds, repo.Id)
+ repoIds = append(repoIds, repo.ID)
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
issueStats.AllCount += int64(repo.NumOpenIssues)
if isShowClosed {
if repo.NumClosedIssues > 0 {
if filterMode == models.FM_CREATE {
- repo.NumClosedIssues = int(models.GetIssueCountByPoster(ctx.User.Id, repo.Id, isShowClosed))
+ repo.NumClosedIssues = int(models.GetIssueCountByPoster(ctx.User.Id, repo.ID, isShowClosed))
}
showRepos = append(showRepos, repo)
}
} else {
if repo.NumOpenIssues > 0 {
if filterMode == models.FM_CREATE {
- repo.NumOpenIssues = int(models.GetIssueCountByPoster(ctx.User.Id, repo.Id, isShowClosed))
+ repo.NumOpenIssues = int(models.GetIssueCountByPoster(ctx.User.Id, repo.ID, isShowClosed))
}
showRepos = append(showRepos, repo)
}
@@ -350,7 +350,7 @@ func Issues(ctx *middleware.Context) {
}
}
- issues[i].Repo, err = models.GetRepositoryById(issues[i].RepoID)
+ issues[i].Repo, err = models.GetRepositoryByID(issues[i].RepoID)
if err != nil {
if models.IsErrRepoNotExist(err) {
log.Warn("GetRepositoryById[%d]: repository not exist", issues[i].RepoID)