mirror of
https://github.com/go-gitea/gitea
synced 2025-07-30 06:08:35 +00:00
@@ -1412,7 +1412,7 @@ func ViewIssue(ctx *context.Context) {
|
||||
if ctx.Doer != nil {
|
||||
iw.UserID = ctx.Doer.ID
|
||||
iw.IssueID = issue.ID
|
||||
iw.IsWatching, err = issues_model.CheckIssueWatch(ctx.Doer, issue)
|
||||
iw.IsWatching, err = issues_model.CheckIssueWatch(ctx, ctx.Doer, issue)
|
||||
if err != nil {
|
||||
ctx.ServerError("CheckIssueWatch", err)
|
||||
return
|
||||
@@ -1530,7 +1530,7 @@ func ViewIssue(ctx *context.Context) {
|
||||
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
|
||||
if ctx.IsSigned {
|
||||
// Deal with the stopwatch
|
||||
ctx.Data["IsStopwatchRunning"] = issues_model.StopwatchExists(ctx.Doer.ID, issue.ID)
|
||||
ctx.Data["IsStopwatchRunning"] = issues_model.StopwatchExists(ctx, ctx.Doer.ID, issue.ID)
|
||||
if !ctx.Data["IsStopwatchRunning"].(bool) {
|
||||
var exists bool
|
||||
var swIssue *issues_model.Issue
|
||||
@@ -2708,7 +2708,7 @@ func ListIssues(ctx *context.Context) {
|
||||
|
||||
var labelIDs []int64
|
||||
if splitted := strings.Split(ctx.FormString("labels"), ","); len(splitted) > 0 {
|
||||
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx.Repo.Repository.ID, splitted)
|
||||
labelIDs, err = issues_model.GetLabelIDsInRepoByNames(ctx, ctx.Repo.Repository.ID, splitted)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@@ -2720,7 +2720,7 @@ func ListIssues(ctx *context.Context) {
|
||||
for i := range part {
|
||||
// uses names and fall back to ids
|
||||
// non existent milestones are discarded
|
||||
mile, err := issues_model.GetMilestoneByRepoIDANDName(ctx.Repo.Repository.ID, part[i])
|
||||
mile, err := issues_model.GetMilestoneByRepoIDANDName(ctx, ctx.Repo.Repository.ID, part[i])
|
||||
if err == nil {
|
||||
mileIDs = append(mileIDs, mile.ID)
|
||||
continue
|
||||
@@ -3037,7 +3037,7 @@ func NewComment(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err := stopTimerIfAvailable(ctx.Doer, issue); err != nil {
|
||||
if err := stopTimerIfAvailable(ctx, ctx.Doer, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
|
@@ -145,7 +145,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
l.Color = form.Color
|
||||
|
||||
l.SetArchived(form.IsArchived)
|
||||
if err := issues_model.UpdateLabel(l); err != nil {
|
||||
if err := issues_model.UpdateLabel(ctx, l); err != nil {
|
||||
ctx.ServerError("UpdateLabel", err)
|
||||
return
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
|
||||
// DeleteLabel delete a label
|
||||
func DeleteLabel(ctx *context.Context) {
|
||||
if err := issues_model.DeleteLabel(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := issues_model.DeleteLabel(ctx, ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteLabel: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
|
||||
@@ -173,7 +173,7 @@ func UpdateIssueLabel(ctx *context.Context) {
|
||||
switch action := ctx.FormString("action"); action {
|
||||
case "clear":
|
||||
for _, issue := range issues {
|
||||
if err := issue_service.ClearLabels(issue, ctx.Doer); err != nil {
|
||||
if err := issue_service.ClearLabels(ctx, issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("ClearLabels", err)
|
||||
return
|
||||
}
|
||||
@@ -208,14 +208,14 @@ func UpdateIssueLabel(ctx *context.Context) {
|
||||
|
||||
if action == "attach" {
|
||||
for _, issue := range issues {
|
||||
if err = issue_service.AddLabel(issue, ctx.Doer, label); err != nil {
|
||||
if err = issue_service.AddLabel(ctx, issue, ctx.Doer, label); err != nil {
|
||||
ctx.ServerError("AddLabel", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, issue := range issues {
|
||||
if err = issue_service.RemoveLabel(issue, ctx.Doer, label); err != nil {
|
||||
if err = issue_service.RemoveLabel(ctx, issue, ctx.Doer, label); err != nil {
|
||||
ctx.ServerError("RemoveLabel", err)
|
||||
return
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ func IssueStopwatch(c *context.Context) {
|
||||
|
||||
var showSuccessMessage bool
|
||||
|
||||
if !issues_model.StopwatchExists(c.Doer.ID, issue.ID) {
|
||||
if !issues_model.StopwatchExists(c, c.Doer.ID, issue.ID) {
|
||||
showSuccessMessage = true
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func IssueStopwatch(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := issues_model.CreateOrStopIssueStopwatch(c.Doer, issue); err != nil {
|
||||
if err := issues_model.CreateOrStopIssueStopwatch(c, c.Doer, issue); err != nil {
|
||||
c.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
@@ -55,12 +55,12 @@ func CancelStopwatch(c *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := issues_model.CancelStopwatch(c.Doer, issue); err != nil {
|
||||
if err := issues_model.CancelStopwatch(c, c.Doer, issue); err != nil {
|
||||
c.ServerError("CancelStopwatch", err)
|
||||
return
|
||||
}
|
||||
|
||||
stopwatches, err := issues_model.GetUserStopwatches(c.Doer.ID, db.ListOptions{})
|
||||
stopwatches, err := issues_model.GetUserStopwatches(c, c.Doer.ID, db.ListOptions{})
|
||||
if err != nil {
|
||||
c.ServerError("GetUserStopwatches", err)
|
||||
return
|
||||
|
@@ -47,7 +47,7 @@ func IssueWatch(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := issues_model.CreateOrUpdateIssueWatch(ctx.Doer.ID, issue.ID, watch); err != nil {
|
||||
if err := issues_model.CreateOrUpdateIssueWatch(ctx, ctx.Doer.ID, issue.ID, watch); err != nil {
|
||||
ctx.ServerError("CreateOrUpdateIssueWatch", err)
|
||||
return
|
||||
}
|
||||
|
@@ -232,13 +232,13 @@ func MigratePost(ctx *context.Context) {
|
||||
opts.Releases = false
|
||||
}
|
||||
|
||||
err = repo_model.CheckCreateRepository(ctx.Doer, ctxUser, opts.RepoName, false)
|
||||
err = repo_model.CheckCreateRepository(ctx, ctx.Doer, ctxUser, opts.RepoName, false)
|
||||
if err != nil {
|
||||
handleMigrateError(ctx, ctxUser, err, "MigratePost", tpl, form)
|
||||
return
|
||||
}
|
||||
|
||||
err = task.MigrateRepository(ctx.Doer, ctxUser, opts)
|
||||
err = task.MigrateRepository(ctx, ctx.Doer, ctxUser, opts)
|
||||
if err == nil {
|
||||
ctx.Redirect(ctxUser.HomeLink() + "/" + url.PathEscape(opts.RepoName))
|
||||
return
|
||||
@@ -260,7 +260,7 @@ func setMigrationContextData(ctx *context.Context, serviceType structs.GitServic
|
||||
}
|
||||
|
||||
func MigrateRetryPost(ctx *context.Context) {
|
||||
if err := task.RetryMigrateTask(ctx.Repo.Repository.ID); err != nil {
|
||||
if err := task.RetryMigrateTask(ctx, ctx.Repo.Repository.ID); err != nil {
|
||||
log.Error("Retry task failed: %v", err)
|
||||
ctx.ServerError("task.RetryMigrateTask", err)
|
||||
return
|
||||
@@ -269,7 +269,7 @@ func MigrateRetryPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func MigrateCancelPost(ctx *context.Context) {
|
||||
migratingTask, err := admin_model.GetMigratingTask(ctx.Repo.Repository.ID)
|
||||
migratingTask, err := admin_model.GetMigratingTask(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
log.Error("GetMigratingTask: %v", err)
|
||||
ctx.Redirect(ctx.Repo.Repository.Link())
|
||||
@@ -277,7 +277,7 @@ func MigrateCancelPost(ctx *context.Context) {
|
||||
}
|
||||
if migratingTask.Status == structs.TaskStatusRunning {
|
||||
taskUpdate := &admin_model.Task{ID: migratingTask.ID, Status: structs.TaskStatusFailed, Message: "canceled"}
|
||||
if err = taskUpdate.UpdateCols("status", "message"); err != nil {
|
||||
if err = taskUpdate.UpdateCols(ctx, "status", "message"); err != nil {
|
||||
ctx.ServerError("task.UpdateCols", err)
|
||||
return
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ func Milestones(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
stats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}), keyword)
|
||||
stats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(ctx, builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}), keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneStats", err)
|
||||
return
|
||||
@@ -74,7 +74,7 @@ func Milestones(ctx *context.Context) {
|
||||
ctx.Data["ClosedCount"] = stats.ClosedCount
|
||||
|
||||
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
|
||||
if err := miles.LoadTotalTrackedTimes(); err != nil {
|
||||
if err := miles.LoadTotalTrackedTimes(ctx); err != nil {
|
||||
ctx.ServerError("LoadTotalTrackedTimes", err)
|
||||
return
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func NewMilestonePost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location())
|
||||
if err = issues_model.NewMilestone(&issues_model.Milestone{
|
||||
if err = issues_model.NewMilestone(ctx, &issues_model.Milestone{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
Name: form.Title,
|
||||
Content: form.Content,
|
||||
@@ -214,7 +214,7 @@ func EditMilestonePost(ctx *context.Context) {
|
||||
m.Name = form.Title
|
||||
m.Content = form.Content
|
||||
m.DeadlineUnix = timeutil.TimeStamp(deadline.Unix())
|
||||
if err = issues_model.UpdateMilestone(m, m.IsClosed); err != nil {
|
||||
if err = issues_model.UpdateMilestone(ctx, m, m.IsClosed); err != nil {
|
||||
ctx.ServerError("UpdateMilestone", err)
|
||||
return
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
|
||||
}
|
||||
id := ctx.ParamsInt64(":id")
|
||||
|
||||
if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx.Repo.Repository.ID, id, toClose); err != nil {
|
||||
if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
|
||||
if issues_model.IsErrMilestoneNotExist(err) {
|
||||
ctx.NotFound("", err)
|
||||
} else {
|
||||
@@ -249,7 +249,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
|
||||
|
||||
// DeleteMilestone delete a milestone
|
||||
func DeleteMilestone(ctx *context.Context) {
|
||||
if err := issues_model.DeleteMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
if err := issues_model.DeleteMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteMilestoneByRepoID: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success"))
|
||||
|
@@ -1270,7 +1270,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
}
|
||||
log.Trace("Pull request merged: %d", pr.ID)
|
||||
|
||||
if err := stopTimerIfAvailable(ctx.Doer, issue); err != nil {
|
||||
if err := stopTimerIfAvailable(ctx, ctx.Doer, issue); err != nil {
|
||||
ctx.ServerError("CreateOrStopIssueStopwatch", err)
|
||||
return
|
||||
}
|
||||
@@ -1326,9 +1326,9 @@ func CancelAutoMergePullRequest(ctx *context.Context) {
|
||||
ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index))
|
||||
}
|
||||
|
||||
func stopTimerIfAvailable(user *user_model.User, issue *issues_model.Issue) error {
|
||||
if issues_model.StopwatchExists(user.ID, issue.ID) {
|
||||
if err := issues_model.CreateOrStopIssueStopwatch(user, issue); err != nil {
|
||||
func stopTimerIfAvailable(ctx *context.Context, user *user_model.User, issue *issues_model.Issue) error {
|
||||
if issues_model.StopwatchExists(ctx, user.ID, issue.ID) {
|
||||
if err := issues_model.CreateOrStopIssueStopwatch(ctx, user, issue); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@@ -344,7 +344,7 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if !repoTransfer.CanUserAcceptTransfer(ctx.Doer) {
|
||||
if !repoTransfer.CanUserAcceptTransfer(ctx, ctx.Doer) {
|
||||
return errors.New("user does not have enough permissions")
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.success"))
|
||||
} else {
|
||||
if err := models.CancelRepositoryTransfer(ctx.Repo.Repository); err != nil {
|
||||
if err := models.CancelRepositoryTransfer(ctx, ctx.Repo.Repository); err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.rejected"))
|
||||
|
@@ -127,7 +127,7 @@ func ChangeCollaborationAccessMode(ctx *context.Context) {
|
||||
|
||||
// DeleteCollaboration delete a collaboration for a repository
|
||||
func DeleteCollaboration(ctx *context.Context) {
|
||||
if err := repo_service.DeleteCollaboration(ctx.Repo.Repository, ctx.FormInt64("id")); err != nil {
|
||||
if err := repo_service.DeleteCollaboration(ctx, ctx.Repo.Repository, ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteCollaboration: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success"))
|
||||
|
@@ -799,7 +799,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.CancelRepositoryTransfer(ctx.Repo.Repository); err != nil {
|
||||
if err := models.CancelRepositoryTransfer(ctx, ctx.Repo.Repository); err != nil {
|
||||
ctx.ServerError("CancelRepositoryTransfer", err)
|
||||
return
|
||||
}
|
||||
@@ -863,7 +863,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := repo_model.SetArchiveRepoState(repo, true); err != nil {
|
||||
if err := repo_model.SetArchiveRepoState(ctx, repo, true); err != nil {
|
||||
log.Error("Tried to archive a repo: %s", err)
|
||||
ctx.Flash.Error(ctx.Tr("repo.settings.archive.error"))
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
|
||||
@@ -881,7 +881,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := repo_model.SetArchiveRepoState(repo, false); err != nil {
|
||||
if err := repo_model.SetArchiveRepoState(ctx, repo, false); err != nil {
|
||||
log.Error("Tried to unarchive a repo: %s", err)
|
||||
ctx.Flash.Error(ctx.Tr("repo.settings.unarchive.error"))
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
|
||||
|
@@ -45,7 +45,7 @@ func TopicsPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
err := repo_model.SaveTopics(ctx.Repo.Repository.ID, validTopics...)
|
||||
err := repo_model.SaveTopics(ctx, ctx.Repo.Repository.ID, validTopics...)
|
||||
if err != nil {
|
||||
log.Error("SaveTopics failed: %v", err)
|
||||
ctx.JSON(http.StatusInternalServerError, map[string]any{
|
||||
|
@@ -640,7 +640,7 @@ func safeURL(address string) string {
|
||||
func checkHomeCodeViewable(ctx *context.Context) {
|
||||
if len(ctx.Repo.Units) > 0 {
|
||||
if ctx.Repo.Repository.IsBeingCreated() {
|
||||
task, err := admin_model.GetMigratingTask(ctx.Repo.Repository.ID)
|
||||
task, err := admin_model.GetMigratingTask(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
if admin_model.IsErrTaskDoesNotExist(err) {
|
||||
ctx.Data["Repo"] = ctx.Repo
|
||||
@@ -893,7 +893,7 @@ func renderLanguageStats(ctx *context.Context) {
|
||||
}
|
||||
|
||||
func renderRepoTopics(ctx *context.Context) {
|
||||
topics, _, err := repo_model.FindTopics(&repo_model.FindTopicOptions{
|
||||
topics, _, err := repo_model.FindTopics(ctx, &repo_model.FindTopicOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
})
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user