|
|
|
@ -20,10 +20,10 @@ import ( |
|
|
|
|
"github.com/gogits/gogs/models" |
|
|
|
|
"github.com/gogits/gogs/modules/auth" |
|
|
|
|
"github.com/gogits/gogs/modules/base" |
|
|
|
|
"github.com/gogits/gogs/modules/context" |
|
|
|
|
"github.com/gogits/gogs/modules/log" |
|
|
|
|
"github.com/gogits/gogs/modules/mailer" |
|
|
|
|
"github.com/gogits/gogs/modules/markdown" |
|
|
|
|
"github.com/gogits/gogs/modules/middleware" |
|
|
|
|
"github.com/gogits/gogs/modules/setting" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -52,14 +52,14 @@ var ( |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func MustEnableIssues(ctx *middleware.Context) { |
|
|
|
|
func MustEnableIssues(ctx *context.Context) { |
|
|
|
|
if !ctx.Repo.Repository.EnableIssues { |
|
|
|
|
ctx.Handle(404, "MustEnableIssues", nil) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func MustAllowPulls(ctx *middleware.Context) { |
|
|
|
|
func MustAllowPulls(ctx *context.Context) { |
|
|
|
|
if !ctx.Repo.Repository.AllowsPulls() { |
|
|
|
|
ctx.Handle(404, "MustAllowPulls", nil) |
|
|
|
|
return |
|
|
|
@ -72,7 +72,7 @@ func MustAllowPulls(ctx *middleware.Context) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func RetrieveLabels(ctx *middleware.Context) { |
|
|
|
|
func RetrieveLabels(ctx *context.Context) { |
|
|
|
|
labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID) |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.Handle(500, "RetrieveLabels.GetLabels: %v", err) |
|
|
|
@ -85,7 +85,7 @@ func RetrieveLabels(ctx *middleware.Context) { |
|
|
|
|
ctx.Data["NumLabels"] = len(labels) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func Issues(ctx *middleware.Context) { |
|
|
|
|
func Issues(ctx *context.Context) { |
|
|
|
|
isPullList := ctx.Params(":type") == "pulls" |
|
|
|
|
if isPullList { |
|
|
|
|
MustAllowPulls(ctx) |
|
|
|
@ -250,7 +250,7 @@ func Issues(ctx *middleware.Context) { |
|
|
|
|
ctx.HTML(200, ISSUES) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func renderAttachmentSettings(ctx *middleware.Context) { |
|
|
|
|
func renderAttachmentSettings(ctx *context.Context) { |
|
|
|
|
ctx.Data["RequireDropzone"] = true |
|
|
|
|
ctx.Data["IsAttachmentEnabled"] = setting.AttachmentEnabled |
|
|
|
|
ctx.Data["AttachmentAllowedTypes"] = setting.AttachmentAllowedTypes |
|
|
|
@ -258,7 +258,7 @@ func renderAttachmentSettings(ctx *middleware.Context) { |
|
|
|
|
ctx.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func RetrieveRepoMilestonesAndAssignees(ctx *middleware.Context, repo *models.Repository) { |
|
|
|
|
func RetrieveRepoMilestonesAndAssignees(ctx *context.Context, repo *models.Repository) { |
|
|
|
|
var err error |
|
|
|
|
ctx.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false) |
|
|
|
|
if err != nil { |
|
|
|
@ -278,7 +278,7 @@ func RetrieveRepoMilestonesAndAssignees(ctx *middleware.Context, repo *models.Re |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func RetrieveRepoMetas(ctx *middleware.Context, repo *models.Repository) []*models.Label { |
|
|
|
|
func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.Label { |
|
|
|
|
if !ctx.Repo.IsWriter() { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
@ -298,7 +298,7 @@ func RetrieveRepoMetas(ctx *middleware.Context, repo *models.Repository) []*mode |
|
|
|
|
return labels |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getFileContentFromDefaultBranch(ctx *middleware.Context, filename string) (string, bool) { |
|
|
|
|
func getFileContentFromDefaultBranch(ctx *context.Context, filename string) (string, bool) { |
|
|
|
|
var r io.Reader |
|
|
|
|
var bytes []byte |
|
|
|
|
|
|
|
|
@ -325,7 +325,7 @@ func getFileContentFromDefaultBranch(ctx *middleware.Context, filename string) ( |
|
|
|
|
return string(bytes), true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func setTemplateIfExists(ctx *middleware.Context, ctxDataKey string, possibleFiles []string) { |
|
|
|
|
func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles []string) { |
|
|
|
|
for _, filename := range possibleFiles { |
|
|
|
|
content, found := getFileContentFromDefaultBranch(ctx, filename) |
|
|
|
|
if found { |
|
|
|
@ -335,7 +335,7 @@ func setTemplateIfExists(ctx *middleware.Context, ctxDataKey string, possibleFil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewIssue(ctx *middleware.Context) { |
|
|
|
|
func NewIssue(ctx *context.Context) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.issues.new") |
|
|
|
|
ctx.Data["PageIsIssueList"] = true |
|
|
|
|
setTemplateIfExists(ctx, ISSUE_TEMPLATE_KEY, IssueTemplateCandidates) |
|
|
|
@ -351,7 +351,7 @@ func NewIssue(ctx *middleware.Context) { |
|
|
|
|
ctx.HTML(200, ISSUE_NEW) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ValidateRepoMetas(ctx *middleware.Context, form auth.CreateIssueForm) ([]int64, int64, int64) { |
|
|
|
|
func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm) ([]int64, int64, int64) { |
|
|
|
|
var ( |
|
|
|
|
repo = ctx.Repo.Repository |
|
|
|
|
err error |
|
|
|
@ -405,7 +405,7 @@ func ValidateRepoMetas(ctx *middleware.Context, form auth.CreateIssueForm) ([]in |
|
|
|
|
return labelIDs, milestoneID, assigneeID |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func notifyWatchersAndMentions(ctx *middleware.Context, issue *models.Issue) { |
|
|
|
|
func notifyWatchersAndMentions(ctx *context.Context, issue *models.Issue) { |
|
|
|
|
// Update mentions
|
|
|
|
|
mentions := markdown.MentionPattern.FindAllString(issue.Content, -1) |
|
|
|
|
if len(mentions) > 0 { |
|
|
|
@ -446,7 +446,7 @@ func notifyWatchersAndMentions(ctx *middleware.Context, issue *models.Issue) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) { |
|
|
|
|
func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.issues.new") |
|
|
|
|
ctx.Data["PageIsIssueList"] = true |
|
|
|
|
renderAttachmentSettings(ctx) |
|
|
|
@ -494,7 +494,7 @@ func NewIssuePost(ctx *middleware.Context, form auth.CreateIssueForm) { |
|
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UploadIssueAttachment(ctx *middleware.Context) { |
|
|
|
|
func UploadIssueAttachment(ctx *context.Context) { |
|
|
|
|
if !setting.AttachmentEnabled { |
|
|
|
|
ctx.Error(404, "attachment is not enabled") |
|
|
|
|
return |
|
|
|
@ -541,7 +541,7 @@ func UploadIssueAttachment(ctx *middleware.Context) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ViewIssue(ctx *middleware.Context) { |
|
|
|
|
func ViewIssue(ctx *context.Context) { |
|
|
|
|
ctx.Data["RequireDropzone"] = true |
|
|
|
|
renderAttachmentSettings(ctx) |
|
|
|
|
|
|
|
|
@ -706,7 +706,7 @@ func ViewIssue(ctx *middleware.Context) { |
|
|
|
|
ctx.HTML(200, ISSUE_VIEW) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getActionIssue(ctx *middleware.Context) *models.Issue { |
|
|
|
|
func getActionIssue(ctx *context.Context) *models.Issue { |
|
|
|
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) |
|
|
|
|
if err != nil { |
|
|
|
|
if models.IsErrIssueNotExist(err) { |
|
|
|
@ -719,7 +719,7 @@ func getActionIssue(ctx *middleware.Context) *models.Issue { |
|
|
|
|
return issue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdateIssueTitle(ctx *middleware.Context) { |
|
|
|
|
func UpdateIssueTitle(ctx *context.Context) { |
|
|
|
|
issue := getActionIssue(ctx) |
|
|
|
|
if ctx.Written() { |
|
|
|
|
return |
|
|
|
@ -746,7 +746,7 @@ func UpdateIssueTitle(ctx *middleware.Context) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdateIssueContent(ctx *middleware.Context) { |
|
|
|
|
func UpdateIssueContent(ctx *context.Context) { |
|
|
|
|
issue := getActionIssue(ctx) |
|
|
|
|
if ctx.Written() { |
|
|
|
|
return |
|
|
|
@ -768,7 +768,7 @@ func UpdateIssueContent(ctx *middleware.Context) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdateIssueLabel(ctx *middleware.Context) { |
|
|
|
|
func UpdateIssueLabel(ctx *context.Context) { |
|
|
|
|
issue := getActionIssue(ctx) |
|
|
|
|
if ctx.Written() { |
|
|
|
|
return |
|
|
|
@ -809,7 +809,7 @@ func UpdateIssueLabel(ctx *middleware.Context) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdateIssueMilestone(ctx *middleware.Context) { |
|
|
|
|
func UpdateIssueMilestone(ctx *context.Context) { |
|
|
|
|
issue := getActionIssue(ctx) |
|
|
|
|
if ctx.Written() { |
|
|
|
|
return |
|
|
|
@ -836,7 +836,7 @@ func UpdateIssueMilestone(ctx *middleware.Context) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdateIssueAssignee(ctx *middleware.Context) { |
|
|
|
|
func UpdateIssueAssignee(ctx *context.Context) { |
|
|
|
|
issue := getActionIssue(ctx) |
|
|
|
|
if ctx.Written() { |
|
|
|
|
return |
|
|
|
@ -862,7 +862,7 @@ func UpdateIssueAssignee(ctx *middleware.Context) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) { |
|
|
|
|
func NewComment(ctx *context.Context, form auth.CreateCommentForm) { |
|
|
|
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) |
|
|
|
|
if err != nil { |
|
|
|
|
if models.IsErrIssueNotExist(err) { |
|
|
|
@ -968,7 +968,7 @@ func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) { |
|
|
|
|
log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdateCommentContent(ctx *middleware.Context) { |
|
|
|
|
func UpdateCommentContent(ctx *context.Context) { |
|
|
|
|
comment, err := models.GetCommentByID(ctx.ParamsInt64(":id")) |
|
|
|
|
if err != nil { |
|
|
|
|
if models.IsErrCommentNotExist(err) { |
|
|
|
@ -1004,7 +1004,7 @@ func UpdateCommentContent(ctx *middleware.Context) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func Labels(ctx *middleware.Context) { |
|
|
|
|
func Labels(ctx *context.Context) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.labels") |
|
|
|
|
ctx.Data["PageIsIssueList"] = true |
|
|
|
|
ctx.Data["PageIsLabels"] = true |
|
|
|
@ -1012,7 +1012,7 @@ func Labels(ctx *middleware.Context) { |
|
|
|
|
ctx.HTML(200, LABELS) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewLabel(ctx *middleware.Context, form auth.CreateLabelForm) { |
|
|
|
|
func NewLabel(ctx *context.Context, form auth.CreateLabelForm) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.labels") |
|
|
|
|
ctx.Data["PageIsLabels"] = true |
|
|
|
|
|
|
|
|
@ -1034,7 +1034,7 @@ func NewLabel(ctx *middleware.Context, form auth.CreateLabelForm) { |
|
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/labels") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdateLabel(ctx *middleware.Context, form auth.CreateLabelForm) { |
|
|
|
|
func UpdateLabel(ctx *context.Context, form auth.CreateLabelForm) { |
|
|
|
|
l, err := models.GetLabelByID(form.ID) |
|
|
|
|
if err != nil { |
|
|
|
|
switch { |
|
|
|
@ -1056,7 +1056,7 @@ func UpdateLabel(ctx *middleware.Context, form auth.CreateLabelForm) { |
|
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/labels") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func DeleteLabel(ctx *middleware.Context) { |
|
|
|
|
func DeleteLabel(ctx *context.Context) { |
|
|
|
|
if err := models.DeleteLabel(ctx.Repo.Repository.ID, ctx.QueryInt64("id")); err != nil { |
|
|
|
|
ctx.Flash.Error("DeleteLabel: " + err.Error()) |
|
|
|
|
} else { |
|
|
|
@ -1069,7 +1069,7 @@ func DeleteLabel(ctx *middleware.Context) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func Milestones(ctx *middleware.Context) { |
|
|
|
|
func Milestones(ctx *context.Context) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.milestones") |
|
|
|
|
ctx.Data["PageIsIssueList"] = true |
|
|
|
|
ctx.Data["PageIsMilestones"] = true |
|
|
|
@ -1113,7 +1113,7 @@ func Milestones(ctx *middleware.Context) { |
|
|
|
|
ctx.HTML(200, MILESTONE) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewMilestone(ctx *middleware.Context) { |
|
|
|
|
func NewMilestone(ctx *context.Context) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.milestones.new") |
|
|
|
|
ctx.Data["PageIsIssueList"] = true |
|
|
|
|
ctx.Data["PageIsMilestones"] = true |
|
|
|
@ -1122,7 +1122,7 @@ func NewMilestone(ctx *middleware.Context) { |
|
|
|
|
ctx.HTML(200, MILESTONE_NEW) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) { |
|
|
|
|
func NewMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.milestones.new") |
|
|
|
|
ctx.Data["PageIsIssueList"] = true |
|
|
|
|
ctx.Data["PageIsMilestones"] = true |
|
|
|
@ -1158,7 +1158,7 @@ func NewMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) { |
|
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/milestones") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func EditMilestone(ctx *middleware.Context) { |
|
|
|
|
func EditMilestone(ctx *context.Context) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.milestones.edit") |
|
|
|
|
ctx.Data["PageIsMilestones"] = true |
|
|
|
|
ctx.Data["PageIsEditMilestone"] = true |
|
|
|
@ -1182,7 +1182,7 @@ func EditMilestone(ctx *middleware.Context) { |
|
|
|
|
ctx.HTML(200, MILESTONE_NEW) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func EditMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) { |
|
|
|
|
func EditMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) { |
|
|
|
|
ctx.Data["Title"] = ctx.Tr("repo.milestones.edit") |
|
|
|
|
ctx.Data["PageIsMilestones"] = true |
|
|
|
|
ctx.Data["PageIsEditMilestone"] = true |
|
|
|
@ -1225,7 +1225,7 @@ func EditMilestonePost(ctx *middleware.Context, form auth.CreateMilestoneForm) { |
|
|
|
|
ctx.Redirect(ctx.Repo.RepoLink + "/milestones") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ChangeMilestonStatus(ctx *middleware.Context) { |
|
|
|
|
func ChangeMilestonStatus(ctx *context.Context) { |
|
|
|
|
m, err := models.GetMilestoneByID(ctx.ParamsInt64(":id")) |
|
|
|
|
if err != nil { |
|
|
|
|
if models.IsErrMilestoneNotExist(err) { |
|
|
|
@ -1259,7 +1259,7 @@ func ChangeMilestonStatus(ctx *middleware.Context) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func DeleteMilestone(ctx *middleware.Context) { |
|
|
|
|
func DeleteMilestone(ctx *context.Context) { |
|
|
|
|
if err := models.DeleteMilestoneByID(ctx.QueryInt64("id")); err != nil { |
|
|
|
|
ctx.Flash.Error("DeleteMilestoneByID: " + err.Error()) |
|
|
|
|
} else { |
|
|
|
|