aboutsummaryrefslogtreecommitdiff
path: root/routers/repo
diff options
context:
space:
mode:
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/issue.go16
-rw-r--r--routers/repo/release.go22
-rw-r--r--routers/repo/repo.go34
3 files changed, 63 insertions, 9 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 6cad2c25..be925426 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -31,7 +31,8 @@ func Issues(ctx *middleware.Context) {
ctx.Data["IssueCreatedCount"] = 0
var posterId int64 = 0
- if ctx.Query("type") == "created_by" {
+ isCreatedBy := ctx.Query("type") == "created_by"
+ if isCreatedBy {
if !ctx.IsSigned {
ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI))
ctx.Redirect("/user/login/", 302)
@@ -53,6 +54,7 @@ func Issues(ctx *middleware.Context) {
}
var createdByCount int
+ showIssues := make([]models.Issue, 0, len(issues))
// Get posters.
for i := range issues {
u, err := models.GetUserById(issues[i].PosterId)
@@ -60,15 +62,19 @@ func Issues(ctx *middleware.Context) {
ctx.Handle(200, "issue.Issues(get poster): %v", err)
return
}
- issues[i].Poster = u
+ if isCreatedBy && u.Id != posterId {
+ continue
+ }
if u.Id == posterId {
createdByCount++
}
+ issues[i].Poster = u
+ showIssues = append(showIssues, issues[i])
}
- ctx.Data["Issues"] = issues
+ ctx.Data["Issues"] = showIssues
ctx.Data["IssueCount"] = ctx.Repo.Repository.NumIssues
- ctx.Data["OpenCount"] = ctx.Repo.Repository.NumIssues - ctx.Repo.Repository.NumClosedIssues
+ ctx.Data["OpenCount"] = ctx.Repo.Repository.NumOpenIssues
ctx.Data["ClosedCount"] = ctx.Repo.Repository.NumClosedIssues
ctx.Data["IssueCreatedCount"] = createdByCount
ctx.Data["IsShowClosed"] = ctx.Query("state") == "closed"
@@ -107,7 +113,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
// Mail watchers.
if base.Service.NotifyMail {
- if err = mailer.SendNotifyMail(ctx.User.Id, ctx.Repo.Repository.Id, ctx.User.Name, ctx.Repo.Repository.Name, issue.Name, issue.Content); err != nil {
+ if err = mailer.SendNotifyMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository, issue); err != nil {
ctx.Handle(200, "issue.CreateIssue", err)
return
}
diff --git a/routers/repo/release.go b/routers/repo/release.go
new file mode 100644
index 00000000..8e8b93c9
--- /dev/null
+++ b/routers/repo/release.go
@@ -0,0 +1,22 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package repo
+
+import (
+ "github.com/gogits/gogs/models"
+ "github.com/gogits/gogs/modules/middleware"
+)
+
+func Releases(ctx *middleware.Context) {
+ ctx.Data["Title"] = "Releases"
+ ctx.Data["IsRepoToolbarReleases"] = true
+ tags, err := models.GetTags(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
+ if err != nil {
+ ctx.Handle(404, "repo.Releases(GetTags)", err)
+ return
+ }
+ ctx.Data["Releases"] = tags
+ ctx.HTML(200, "release/list")
+}
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index f45d063b..bc41345a 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -5,6 +5,7 @@
package repo
import (
+ "fmt"
"path"
"path/filepath"
"strings"
@@ -278,19 +279,44 @@ func SettingPost(ctx *middleware.Context) {
switch ctx.Query("action") {
case "update":
+ isNameChanged := false
+ newRepoName := ctx.Query("name")
+ // Check if repository name has been changed.
+ if ctx.Repo.Repository.Name != newRepoName {
+ isExist, err := models.IsRepositoryExist(ctx.Repo.Owner, newRepoName)
+ if err != nil {
+ ctx.Handle(404, "repo.SettingPost(update: check existence)", err)
+ return
+ } else if isExist {
+ ctx.RenderWithErr("Repository name has been taken in your repositories.", "repo/setting", nil)
+ return
+ } else if err = models.ChangeRepositoryName(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newRepoName); err != nil {
+ ctx.Handle(404, "repo.SettingPost(change repository name)", err)
+ return
+ }
+ log.Trace("%s Repository name changed: %s/%s -> %s", ctx.Req.RequestURI, ctx.User.Name, ctx.Repo.Repository.Name, newRepoName)
+
+ isNameChanged = true
+ ctx.Repo.Repository.Name = newRepoName
+ }
+
ctx.Repo.Repository.Description = ctx.Query("desc")
ctx.Repo.Repository.Website = ctx.Query("site")
if err := models.UpdateRepository(ctx.Repo.Repository); err != nil {
ctx.Handle(404, "repo.SettingPost(update)", err)
return
}
+
ctx.Data["IsSuccess"] = true
- ctx.HTML(200, "repo/setting")
- log.Trace("%s Repository updated: %s/%s", ctx.Req.RequestURI, ctx.User.LowerName, ctx.Repo.Repository.LowerName)
+ if isNameChanged {
+ ctx.Redirect(fmt.Sprintf("/%s/%s/settings", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name))
+ } else {
+ ctx.HTML(200, "repo/setting")
+ }
+ log.Trace("%s Repository updated: %s/%s", ctx.Req.RequestURI, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
case "delete":
if len(ctx.Repo.Repository.Name) == 0 || ctx.Repo.Repository.Name != ctx.Query("repository") {
- ctx.Data["ErrorMsg"] = "Please make sure you entered repository name is correct."
- ctx.HTML(200, "repo/setting")
+ ctx.RenderWithErr("Please make sure you entered repository name is correct.", "repo/setting", nil)
return
}