mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-22 04:33:42 +09:00
Merge branch 'master' into add-api-issues-subscriptions
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
comment_service "code.gitea.io/gitea/services/comments"
|
||||
)
|
||||
@@ -196,8 +195,6 @@ func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOpti
|
||||
return
|
||||
}
|
||||
|
||||
notification.NotifyCreateIssueComment(ctx.User, ctx.Repo.Repository, issue, comment)
|
||||
|
||||
ctx.JSON(201, comment.APIFormat())
|
||||
}
|
||||
|
||||
@@ -305,8 +302,6 @@ func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption)
|
||||
return
|
||||
}
|
||||
|
||||
notification.NotifyUpdateComment(ctx.User, comment, oldContent)
|
||||
|
||||
ctx.JSON(200, comment.APIFormat())
|
||||
}
|
||||
|
||||
@@ -396,7 +391,5 @@ func deleteIssueComment(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
notification.NotifyDeleteComment(ctx.User, comment)
|
||||
|
||||
ctx.Status(204)
|
||||
}
|
||||
|
||||
@@ -339,12 +339,40 @@ func PrepareCompareDiff(
|
||||
return false
|
||||
}
|
||||
|
||||
// parseBaseRepoInfo parse base repository if current repo is forked.
|
||||
// The "base" here means the repository where current repo forks from,
|
||||
// not the repository fetch from current URL.
|
||||
func parseBaseRepoInfo(ctx *context.Context, repo *models.Repository) error {
|
||||
if !repo.IsFork {
|
||||
return nil
|
||||
}
|
||||
if err := repo.GetBaseRepo(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := repo.BaseRepo.GetOwnerName(); err != nil {
|
||||
return err
|
||||
}
|
||||
baseGitRepo, err := git.OpenRepository(models.RepoPath(repo.BaseRepo.OwnerName, repo.BaseRepo.Name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.Data["BaseRepoBranches"], err = baseGitRepo.GetBranches()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CompareDiff show different from one commit to another commit
|
||||
func CompareDiff(ctx *context.Context) {
|
||||
headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx)
|
||||
if ctx.Written() {
|
||||
return
|
||||
}
|
||||
if err := parseBaseRepoInfo(ctx, headRepo); err != nil {
|
||||
ctx.ServerError("parseBaseRepoInfo", err)
|
||||
return
|
||||
}
|
||||
|
||||
nothingToCompare := PrepareCompareDiff(ctx, headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch)
|
||||
if ctx.Written() {
|
||||
|
||||
@@ -1066,7 +1066,7 @@ func UpdateIssueContent(ctx *context.Context) {
|
||||
}
|
||||
|
||||
content := ctx.Query("content")
|
||||
if err := issue.ChangeContent(ctx.User, content); err != nil {
|
||||
if err := issue_service.ChangeContent(issue, ctx.User, content); err != nil {
|
||||
ctx.ServerError("ChangeContent", err)
|
||||
return
|
||||
}
|
||||
@@ -1324,8 +1324,6 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
|
||||
return
|
||||
}
|
||||
|
||||
notification.NotifyCreateIssueComment(ctx.User, ctx.Repo.Repository, issue, comment)
|
||||
|
||||
log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID)
|
||||
}
|
||||
|
||||
@@ -1375,8 +1373,6 @@ func UpdateCommentContent(ctx *context.Context) {
|
||||
ctx.ServerError("UpdateAttachments", err)
|
||||
}
|
||||
|
||||
notification.NotifyUpdateComment(ctx.User, comment, oldContent)
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
"content": string(markdown.Render([]byte(comment.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
|
||||
"attachments": attachmentsHTML(ctx, comment.Attachments),
|
||||
@@ -1404,13 +1400,11 @@ func DeleteComment(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err = models.DeleteComment(comment, ctx.User); err != nil {
|
||||
if err = comment_service.DeleteComment(comment, ctx.User); err != nil {
|
||||
ctx.ServerError("DeleteCommentByID", err)
|
||||
return
|
||||
}
|
||||
|
||||
notification.NotifyDeleteComment(ctx.User, comment)
|
||||
|
||||
ctx.Status(200)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user