1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-09 19:18:20 +00:00

Merge branch 'master' of github.com:gogits/gogs into dev

Conflicts:
	web.go
This commit is contained in:
Lunny Xiao
2014-04-10 22:21:12 +08:00
44 changed files with 1084 additions and 413 deletions

View File

@@ -135,10 +135,11 @@ type route struct {
}
type Config struct {
ReposRoot string
GitBinPath string
UploadPack bool
ReceivePack bool
ReposRoot string
GitBinPath string
UploadPack bool
ReceivePack bool
OnPushSucceed func()
}
type handler struct {
@@ -223,21 +224,26 @@ func serviceRpc(rpc string, hr handler) {
in, err := cmd.StdinPipe()
if err != nil {
log.Print(err)
return
}
stdout, err := cmd.StdoutPipe()
if err != nil {
log.Print(err)
return
}
err = cmd.Start()
if err != nil {
log.Print(err)
return
}
in.Write(input)
io.Copy(w, stdout)
cmd.Wait()
hr.Config.OnPushSucceed()
}
func getInfoRefs(hr handler) {

View File

@@ -9,6 +9,7 @@ import (
"net/url"
"strings"
"github.com/Unknwon/com"
"github.com/go-martini/martini"
"github.com/gogits/gogs/models"
@@ -99,7 +100,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
issue, err := models.CreateIssue(ctx.User.Id, ctx.Repo.Repository.Id, form.MilestoneId, form.AssigneeId,
ctx.Repo.Repository.NumIssues, form.IssueName, form.Labels, form.Content, false)
if err != nil {
ctx.Handle(200, "issue.CreateIssue", err)
ctx.Handle(200, "issue.CreateIssue(CreateIssue)", err)
return
}
@@ -107,14 +108,31 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
if err = models.NotifyWatchers(&models.Action{ActUserId: ctx.User.Id, ActUserName: ctx.User.Name, ActEmail: ctx.User.Email,
OpType: models.OP_CREATE_ISSUE, Content: fmt.Sprintf("%d|%s", issue.Index, issue.Name),
RepoId: ctx.Repo.Repository.Id, RepoName: ctx.Repo.Repository.Name, RefName: ""}); err != nil {
ctx.Handle(200, "issue.CreateIssue", err)
ctx.Handle(200, "issue.CreateIssue(NotifyWatchers)", err)
return
}
// Mail watchers.
// Mail watchers and mentions.
if base.Service.NotifyMail {
if err = mailer.SendNotifyMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository, issue); err != nil {
ctx.Handle(200, "issue.CreateIssue", err)
tos, err := mailer.SendIssueNotifyMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository, issue)
if err != nil {
ctx.Handle(200, "issue.CreateIssue(SendIssueNotifyMail)", err)
return
}
tos = append(tos, ctx.User.LowerName)
ms := base.MentionPattern.FindAllString(issue.Content, -1)
newTos := make([]string, 0, len(ms))
for _, m := range ms {
if com.IsSliceContainsStr(tos, m[1:]) {
continue
}
newTos = append(newTos, m[1:])
}
if err = mailer.SendIssueMentionMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository,
issue, models.GetUserEmailsByNames(newTos)); err != nil {
ctx.Handle(200, "issue.CreateIssue(SendIssueMentionMail)", err)
return
}
}
@@ -147,7 +165,7 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
return
}
issue.Poster = u
issue.RenderedContent = string(base.RenderMarkdown([]byte(issue.Content), ""))
issue.RenderedContent = string(base.RenderMarkdown([]byte(issue.Content), ctx.Repo.RepoLink))
// Get comments.
comments, err := models.GetIssueComments(issue.Id)
@@ -164,7 +182,7 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
return
}
comments[i].Poster = u
comments[i].Content = string(base.RenderMarkdown([]byte(comments[i].Content), ""))
comments[i].Content = string(base.RenderMarkdown([]byte(comments[i].Content), ctx.Repo.RepoLink))
}
ctx.Data["Title"] = issue.Name
@@ -193,7 +211,7 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
return
}
if ctx.User.Id != issue.PosterId {
if ctx.User.Id != issue.PosterId && !ctx.Repo.IsOwner {
ctx.Handle(404, "issue.UpdateIssue", nil)
return
}
@@ -211,7 +229,7 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
ctx.JSON(200, map[string]interface{}{
"ok": true,
"title": issue.Name,
"content": string(base.RenderMarkdown([]byte(issue.Content), "")),
"content": string(base.RenderMarkdown([]byte(issue.Content), ctx.Repo.RepoLink)),
})
}

View File

@@ -12,6 +12,7 @@ import (
func Releases(ctx *middleware.Context) {
ctx.Data["Title"] = "Releases"
ctx.Data["IsRepoToolbarReleases"] = true
ctx.Data["IsRepoReleaseNew"] = false
tags, err := models.GetTags(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
if err != nil {
ctx.Handle(404, "repo.Releases(GetTags)", err)
@@ -20,3 +21,10 @@ func Releases(ctx *middleware.Context) {
ctx.Data["Releases"] = tags
ctx.HTML(200, "release/list")
}
func ReleasesNew(ctx *middleware.Context) {
ctx.Data["Title"] = "New Release"
ctx.Data["IsRepoToolbarReleases"] = true
ctx.Data["IsRepoReleaseNew"] = true
ctx.HTML(200, "release/new")
}