|
@@ -56,9 +56,13 @@ const (
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
|
|
|
+ // ErrFileTypeForbidden not allowed file type error
|
|
|
ErrFileTypeForbidden = errors.New("File type is not allowed")
|
|
ErrFileTypeForbidden = errors.New("File type is not allowed")
|
|
|
- ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
|
|
|
|
|
|
|
|
|
|
|
|
+ // ErrTooManyFiles upload too many files
|
|
|
|
|
+ ErrTooManyFiles = errors.New("Maximum number of files to upload exceeded")
|
|
|
|
|
+
|
|
|
|
|
+ // IssueTemplateCandidates issue templates
|
|
|
IssueTemplateCandidates = []string{
|
|
IssueTemplateCandidates = []string{
|
|
|
"ISSUE_TEMPLATE.md",
|
|
"ISSUE_TEMPLATE.md",
|
|
|
".gitote/ISSUE_TEMPLATE.md",
|
|
".gitote/ISSUE_TEMPLATE.md",
|
|
@@ -66,6 +70,7 @@ var (
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+// MustEnableIssues check if repository enable internal issues
|
|
|
func MustEnableIssues(c *context.Context) {
|
|
func MustEnableIssues(c *context.Context) {
|
|
|
if !c.Repo.Repository.EnableIssues {
|
|
if !c.Repo.Repository.EnableIssues {
|
|
|
c.Handle(404, "MustEnableIssues", nil)
|
|
c.Handle(404, "MustEnableIssues", nil)
|
|
@@ -78,6 +83,7 @@ func MustEnableIssues(c *context.Context) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// MustAllowPulls check if repository enable pull requests and user have right to do that
|
|
|
func MustAllowPulls(c *context.Context) {
|
|
func MustAllowPulls(c *context.Context) {
|
|
|
if !c.Repo.Repository.AllowsPulls() {
|
|
if !c.Repo.Repository.AllowsPulls() {
|
|
|
c.Handle(404, "MustAllowPulls", nil)
|
|
c.Handle(404, "MustAllowPulls", nil)
|
|
@@ -91,6 +97,7 @@ func MustAllowPulls(c *context.Context) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// RetrieveLabels find all the labels of a repository
|
|
|
func RetrieveLabels(c *context.Context) {
|
|
func RetrieveLabels(c *context.Context) {
|
|
|
labels, err := models.GetLabelsByRepoID(c.Repo.Repository.ID)
|
|
labels, err := models.GetLabelsByRepoID(c.Repo.Repository.ID)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -264,10 +271,12 @@ func issues(c *context.Context, isPullList bool) {
|
|
|
c.HTML(200, IssuesTPL)
|
|
c.HTML(200, IssuesTPL)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Issues render issues page
|
|
|
func Issues(c *context.Context) {
|
|
func Issues(c *context.Context) {
|
|
|
issues(c, false)
|
|
issues(c, false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Pulls render pull request page
|
|
|
func Pulls(c *context.Context) {
|
|
func Pulls(c *context.Context) {
|
|
|
issues(c, true)
|
|
issues(c, true)
|
|
|
}
|
|
}
|
|
@@ -280,6 +289,7 @@ func renderAttachmentSettings(c *context.Context) {
|
|
|
c.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles
|
|
c.Data["AttachmentMaxFiles"] = setting.AttachmentMaxFiles
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository
|
|
|
func RetrieveRepoMilestonesAndAssignees(c *context.Context, repo *models.Repository) {
|
|
func RetrieveRepoMilestonesAndAssignees(c *context.Context, repo *models.Repository) {
|
|
|
var err error
|
|
var err error
|
|
|
c.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
|
|
c.Data["OpenMilestones"], err = models.GetMilestones(repo.ID, -1, false)
|
|
@@ -300,6 +310,7 @@ func RetrieveRepoMilestonesAndAssignees(c *context.Context, repo *models.Reposit
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// RetrieveRepoMetas find all the meta information of a repository
|
|
|
func RetrieveRepoMetas(c *context.Context, repo *models.Repository) []*models.Label {
|
|
func RetrieveRepoMetas(c *context.Context, repo *models.Repository) []*models.Label {
|
|
|
if !c.Repo.IsWriter() {
|
|
if !c.Repo.IsWriter() {
|
|
|
return nil
|
|
return nil
|
|
@@ -357,6 +368,7 @@ func setTemplateIfExists(c *context.Context, ctxDataKey string, possibleFiles []
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NewIssue render createing issue page
|
|
|
func NewIssue(c *context.Context) {
|
|
func NewIssue(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("repo.issues.new")
|
|
c.Data["Title"] = c.Tr("repo.issues.new")
|
|
|
c.Data["PageIsIssueList"] = true
|
|
c.Data["PageIsIssueList"] = true
|
|
@@ -375,6 +387,7 @@ func NewIssue(c *context.Context) {
|
|
|
c.HTML(200, IssuesNewTPL)
|
|
c.HTML(200, IssuesNewTPL)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// ValidateRepoMetas check and returns repository's meta informations
|
|
|
func ValidateRepoMetas(c *context.Context, f form.NewIssue) ([]int64, int64, int64) {
|
|
func ValidateRepoMetas(c *context.Context, f form.NewIssue) ([]int64, int64, int64) {
|
|
|
var (
|
|
var (
|
|
|
repo = c.Repo.Repository
|
|
repo = c.Repo.Repository
|
|
@@ -511,6 +524,7 @@ func uploadAttachment(c *context.Context, allowedTypes []string) {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// UploadIssueAttachment response for uploading issue's attachment
|
|
|
func UploadIssueAttachment(c *context.Context) {
|
|
func UploadIssueAttachment(c *context.Context) {
|
|
|
if !setting.AttachmentEnabled {
|
|
if !setting.AttachmentEnabled {
|
|
|
c.NotFound()
|
|
c.NotFound()
|
|
@@ -678,8 +692,8 @@ func viewIssue(c *context.Context, isPullList bool) {
|
|
|
c.Repo.IsWriter() && c.Repo.GitRepo.IsBranchExist(pull.HeadBranch) &&
|
|
c.Repo.IsWriter() && c.Repo.GitRepo.IsBranchExist(pull.HeadBranch) &&
|
|
|
!branchProtected
|
|
!branchProtected
|
|
|
|
|
|
|
|
- deleteBranchUrl := template.EscapePound(c.Repo.RepoLink + "/branches/delete/" + pull.HeadBranch)
|
|
|
|
|
- c.Data["DeleteBranchLink"] = fmt.Sprintf("%s?commit=%s&redirect_to=%s", deleteBranchUrl, pull.MergedCommitID, c.Data["Link"])
|
|
|
|
|
|
|
+ deleteBranchURL := template.EscapePound(c.Repo.RepoLink + "/branches/delete/" + pull.HeadBranch)
|
|
|
|
|
+ c.Data["DeleteBranchLink"] = fmt.Sprintf("%s?commit=%s&redirect_to=%s", deleteBranchURL, pull.MergedCommitID, c.Data["Link"])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
c.Data["Participants"] = participants
|
|
c.Data["Participants"] = participants
|
|
@@ -690,11 +704,13 @@ func viewIssue(c *context.Context, isPullList bool) {
|
|
|
c.HTML(200, IssuesViewTPL)
|
|
c.HTML(200, IssuesViewTPL)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// ViewIssue render issue view page
|
|
|
func ViewIssue(c *context.Context) {
|
|
func ViewIssue(c *context.Context) {
|
|
|
c.Data["PageIsIssueConversation"] = true
|
|
c.Data["PageIsIssueConversation"] = true
|
|
|
viewIssue(c, false)
|
|
viewIssue(c, false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// ViewPull render pull view page
|
|
|
func ViewPull(c *context.Context) {
|
|
func ViewPull(c *context.Context) {
|
|
|
viewIssue(c, true)
|
|
viewIssue(c, true)
|
|
|
}
|
|
}
|
|
@@ -715,6 +731,7 @@ func getActionIssue(c *context.Context) *models.Issue {
|
|
|
return issue
|
|
return issue
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// UpdateIssueTitle change issue's title
|
|
|
func UpdateIssueTitle(c *context.Context) {
|
|
func UpdateIssueTitle(c *context.Context) {
|
|
|
issue := getActionIssue(c)
|
|
issue := getActionIssue(c)
|
|
|
if c.Written() {
|
|
if c.Written() {
|
|
@@ -742,6 +759,7 @@ func UpdateIssueTitle(c *context.Context) {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// UpdateIssueContent change issue's content
|
|
|
func UpdateIssueContent(c *context.Context) {
|
|
func UpdateIssueContent(c *context.Context) {
|
|
|
issue := getActionIssue(c)
|
|
issue := getActionIssue(c)
|
|
|
if c.Written() {
|
|
if c.Written() {
|
|
@@ -764,6 +782,7 @@ func UpdateIssueContent(c *context.Context) {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// UpdateIssueLabel change issue's labels
|
|
|
func UpdateIssueLabel(c *context.Context) {
|
|
func UpdateIssueLabel(c *context.Context) {
|
|
|
issue := getActionIssue(c)
|
|
issue := getActionIssue(c)
|
|
|
if c.Written() {
|
|
if c.Written() {
|
|
@@ -805,6 +824,7 @@ func UpdateIssueLabel(c *context.Context) {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// UpdateIssueMilestone change issue's milestone
|
|
|
func UpdateIssueMilestone(c *context.Context) {
|
|
func UpdateIssueMilestone(c *context.Context) {
|
|
|
issue := getActionIssue(c)
|
|
issue := getActionIssue(c)
|
|
|
if c.Written() {
|
|
if c.Written() {
|
|
@@ -832,6 +852,7 @@ func UpdateIssueMilestone(c *context.Context) {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// UpdateIssueAssignee change issue's assignee
|
|
|
func UpdateIssueAssignee(c *context.Context) {
|
|
func UpdateIssueAssignee(c *context.Context) {
|
|
|
issue := getActionIssue(c)
|
|
issue := getActionIssue(c)
|
|
|
if c.Written() {
|
|
if c.Written() {
|
|
@@ -856,6 +877,7 @@ func UpdateIssueAssignee(c *context.Context) {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NewComment create a comment for issue
|
|
|
func NewComment(c *context.Context, f form.CreateComment) {
|
|
func NewComment(c *context.Context, f form.CreateComment) {
|
|
|
issue := getActionIssue(c)
|
|
issue := getActionIssue(c)
|
|
|
if c.Written() {
|
|
if c.Written() {
|
|
@@ -943,6 +965,7 @@ func NewComment(c *context.Context, f form.CreateComment) {
|
|
|
log.Trace("Comment created: %d/%d/%d", c.Repo.Repository.ID, issue.ID, comment.ID)
|
|
log.Trace("Comment created: %d/%d/%d", c.Repo.Repository.ID, issue.ID, comment.ID)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// UpdateCommentContent change comment of issue's content
|
|
|
func UpdateCommentContent(c *context.Context) {
|
|
func UpdateCommentContent(c *context.Context) {
|
|
|
comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
|
|
comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -976,6 +999,7 @@ func UpdateCommentContent(c *context.Context) {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// DeleteComment delete comment of issue
|
|
|
func DeleteComment(c *context.Context) {
|
|
func DeleteComment(c *context.Context) {
|
|
|
comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
|
|
comment, err := models.GetCommentByID(c.ParamsInt64(":id"))
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -999,6 +1023,7 @@ func DeleteComment(c *context.Context) {
|
|
|
c.Status(200)
|
|
c.Status(200)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Labels render issue's labels page
|
|
|
func Labels(c *context.Context) {
|
|
func Labels(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("repo.labels")
|
|
c.Data["Title"] = c.Tr("repo.labels")
|
|
|
c.Data["PageIsIssueList"] = true
|
|
c.Data["PageIsIssueList"] = true
|
|
@@ -1008,6 +1033,7 @@ func Labels(c *context.Context) {
|
|
|
c.HTML(200, LabelsTPL)
|
|
c.HTML(200, LabelsTPL)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// InitializeLabels init labels for a repository
|
|
|
func InitializeLabels(c *context.Context, f form.InitializeLabels) {
|
|
func InitializeLabels(c *context.Context, f form.InitializeLabels) {
|
|
|
if c.HasError() {
|
|
if c.HasError() {
|
|
|
c.Redirect(c.Repo.RepoLink + "/labels")
|
|
c.Redirect(c.Repo.RepoLink + "/labels")
|
|
@@ -1035,6 +1061,7 @@ func InitializeLabels(c *context.Context, f form.InitializeLabels) {
|
|
|
c.Redirect(c.Repo.RepoLink + "/labels")
|
|
c.Redirect(c.Repo.RepoLink + "/labels")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NewLabel create new label for repository
|
|
|
func NewLabel(c *context.Context, f form.CreateLabel) {
|
|
func NewLabel(c *context.Context, f form.CreateLabel) {
|
|
|
c.Data["Title"] = c.Tr("repo.labels")
|
|
c.Data["Title"] = c.Tr("repo.labels")
|
|
|
c.Data["PageIsLabels"] = true
|
|
c.Data["PageIsLabels"] = true
|
|
@@ -1057,6 +1084,7 @@ func NewLabel(c *context.Context, f form.CreateLabel) {
|
|
|
c.Redirect(c.Repo.RepoLink + "/labels")
|
|
c.Redirect(c.Repo.RepoLink + "/labels")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// UpdateLabel update a label's name and color
|
|
|
func UpdateLabel(c *context.Context, f form.CreateLabel) {
|
|
func UpdateLabel(c *context.Context, f form.CreateLabel) {
|
|
|
l, err := models.GetLabelByID(f.ID)
|
|
l, err := models.GetLabelByID(f.ID)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -1078,6 +1106,7 @@ func UpdateLabel(c *context.Context, f form.CreateLabel) {
|
|
|
c.Redirect(c.Repo.RepoLink + "/labels")
|
|
c.Redirect(c.Repo.RepoLink + "/labels")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// DeleteLabel delete a label
|
|
|
func DeleteLabel(c *context.Context) {
|
|
func DeleteLabel(c *context.Context) {
|
|
|
if err := models.DeleteLabel(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
|
|
if err := models.DeleteLabel(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
|
|
|
c.Flash.Error("DeleteLabel: " + err.Error())
|
|
c.Flash.Error("DeleteLabel: " + err.Error())
|
|
@@ -1091,6 +1120,7 @@ func DeleteLabel(c *context.Context) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// Milestones render milestones page
|
|
|
func Milestones(c *context.Context) {
|
|
func Milestones(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("repo.milestones")
|
|
c.Data["Title"] = c.Tr("repo.milestones")
|
|
|
c.Data["PageIsIssueList"] = true
|
|
c.Data["PageIsIssueList"] = true
|
|
@@ -1139,6 +1169,7 @@ func Milestones(c *context.Context) {
|
|
|
c.HTML(200, MilestoneTPL)
|
|
c.HTML(200, MilestoneTPL)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NewMilestone render creating milestone page
|
|
|
func NewMilestone(c *context.Context) {
|
|
func NewMilestone(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("repo.milestones.new")
|
|
c.Data["Title"] = c.Tr("repo.milestones.new")
|
|
|
c.Data["PageIsIssueList"] = true
|
|
c.Data["PageIsIssueList"] = true
|
|
@@ -1185,6 +1216,7 @@ func NewMilestonePost(c *context.Context, f form.CreateMilestone) {
|
|
|
c.Redirect(c.Repo.RepoLink + "/milestones")
|
|
c.Redirect(c.Repo.RepoLink + "/milestones")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// EditMilestone render edting milestone page
|
|
|
func EditMilestone(c *context.Context) {
|
|
func EditMilestone(c *context.Context) {
|
|
|
c.Data["Title"] = c.Tr("repo.milestones.edit")
|
|
c.Data["Title"] = c.Tr("repo.milestones.edit")
|
|
|
c.Data["PageIsMilestones"] = true
|
|
c.Data["PageIsMilestones"] = true
|
|
@@ -1253,6 +1285,7 @@ func EditMilestonePost(c *context.Context, f form.CreateMilestone) {
|
|
|
c.Redirect(c.Repo.RepoLink + "/milestones")
|
|
c.Redirect(c.Repo.RepoLink + "/milestones")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// ChangeMilestonStatus response for change a milestone's status
|
|
|
func ChangeMilestonStatus(c *context.Context) {
|
|
func ChangeMilestonStatus(c *context.Context) {
|
|
|
m, err := models.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
|
|
m, err := models.GetMilestoneByRepoID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -1287,6 +1320,7 @@ func ChangeMilestonStatus(c *context.Context) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// DeleteMilestone delete a milestone
|
|
|
func DeleteMilestone(c *context.Context) {
|
|
func DeleteMilestone(c *context.Context) {
|
|
|
if err := models.DeleteMilestoneOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
|
|
if err := models.DeleteMilestoneOfRepoByID(c.Repo.Repository.ID, c.QueryInt64("id")); err != nil {
|
|
|
c.Flash.Error("DeleteMilestoneByRepoID: " + err.Error())
|
|
c.Flash.Error("DeleteMilestoneByRepoID: " + err.Error())
|