diff options
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/issue.go | 10 | ||||
-rw-r--r-- | routers/repo/lfs.go | 4 | ||||
-rw-r--r-- | routers/repo/pull.go | 48 | ||||
-rw-r--r-- | routers/repo/webhook.go | 5 |
4 files changed, 31 insertions, 36 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index f1336ac791..1d8d9c0366 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -114,7 +114,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti viewType := ctx.Query("type") sortType := ctx.Query("sort") types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned"} - if !com.IsSliceContainsStr(types, viewType) { + if !util.IsStringInSlice(viewType, types, true) { viewType = "all" } @@ -981,7 +981,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { } log.Trace("Issue created: %d/%d", repo.ID, issue.ID) - ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + fmt.Sprint(issue.Index)) } // commentTag returns the CommentTag for a comment in/with the given repo, poster and issue @@ -1061,10 +1061,10 @@ func ViewIssue(ctx *context.Context) { // Make sure type and URL matches. if ctx.Params(":type") == "issues" && issue.IsPull { - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) return } else if ctx.Params(":type") == "pulls" && !issue.IsPull { - ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + fmt.Sprint(issue.Index)) return } @@ -1411,7 +1411,7 @@ func ViewIssue(ctx *context.Context) { log.Error("IsProtectedBranch: %v", err) } else if !protected { canDelete = true - ctx.Data["DeleteBranchLink"] = ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index) + "/cleanup" + ctx.Data["DeleteBranchLink"] = ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index) + "/cleanup" } } } diff --git a/routers/repo/lfs.go b/routers/repo/lfs.go index c74b088e2e..dc3ab4f54c 100644 --- a/routers/repo/lfs.go +++ b/routers/repo/lfs.go @@ -26,8 +26,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" - - "github.com/unknwon/com" ) const ( @@ -579,7 +577,7 @@ func LFSAutoAssociate(ctx *context.Context) { } var err error metas[i] = &models.LFSMetaObject{} - metas[i].Size, err = com.StrTo(oid[idx+1:]).Int64() + metas[i].Size, err = strconv.ParseInt(oid[idx+1:], 10, 64) if err != nil { ctx.ServerError("LFSAutoAssociate", fmt.Errorf("Illegal oid input: %s %v", oid, err)) return diff --git a/routers/repo/pull.go b/routers/repo/pull.go index b3a1478884..1594e9a9c4 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -31,8 +31,6 @@ import ( "code.gitea.io/gitea/services/gitdiff" pull_service "code.gitea.io/gitea/services/pull" repo_service "code.gitea.io/gitea/services/repository" - - "github.com/unknwon/com" ) const ( @@ -732,7 +730,7 @@ func UpdatePullRequest(ctx *context.Context) { // ToDo: add check if maintainers are allowed to change branch ... (need migration & co) if !allowedUpdate { ctx.Flash.Error(ctx.Tr("repo.pulls.update_not_allowed")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) return } @@ -752,18 +750,18 @@ func UpdatePullRequest(ctx *context.Context) { return } ctx.Flash.Error(flashError) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) return } ctx.Flash.Error(err.Error()) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) return } time.Sleep(1 * time.Second) ctx.Flash.Success(ctx.Tr("repo.pulls.update_branch_success")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) } // MergePullRequest response for merging pull request @@ -775,11 +773,11 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { if issue.IsClosed { if issue.IsPull { ctx.Flash.Error(ctx.Tr("repo.pulls.is_closed")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) return } ctx.Flash.Error(ctx.Tr("repo.issues.closed_title")) - ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + fmt.Sprint(issue.Index)) return } @@ -792,25 +790,25 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { } if !allowedMerge { ctx.Flash.Error(ctx.Tr("repo.pulls.update_not_allowed")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) return } if !pr.CanAutoMerge() { ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_not_ready")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) return } if pr.HasMerged { ctx.Flash.Error(ctx.Tr("repo.pulls.has_merged")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(issue.Index)) return } if pr.IsWorkInProgress() { ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_wip")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } @@ -824,14 +822,14 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { return } else if !isRepoAdmin { ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_not_ready")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } } if ctx.HasError() { ctx.Flash.Error(ctx.Data["ErrorMsg"].(string)) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } @@ -863,14 +861,14 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { if !noDeps { ctx.Flash.Error(ctx.Tr("repo.issues.dependency.pr_close_blocked")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } if err = pull_service.Merge(pr, ctx.User, ctx.Repo.GitRepo, models.MergeStyle(form.Do), message); err != nil { if models.IsErrInvalidMergeStyle(err) { ctx.Flash.Error(ctx.Tr("repo.pulls.invalid_merge_option")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } else if models.IsErrMergeConflicts(err) { conflictError := err.(models.ErrMergeConflicts) @@ -884,7 +882,7 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { return } ctx.Flash.Error(flashError) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } else if models.IsErrRebaseConflicts(err) { conflictError := err.(models.ErrRebaseConflicts) @@ -898,17 +896,17 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { return } ctx.Flash.Error(flashError) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } else if models.IsErrMergeUnrelatedHistories(err) { log.Debug("MergeUnrelatedHistories error: %v", err) ctx.Flash.Error(ctx.Tr("repo.pulls.unrelated_histories")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } else if git.IsErrPushOutOfDate(err) { log.Debug("MergePushOutOfDate error: %v", err) ctx.Flash.Error(ctx.Tr("repo.pulls.merge_out_of_date")) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } else if git.IsErrPushRejected(err) { log.Debug("MergePushRejected error: %v", err) @@ -928,7 +926,7 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { } ctx.Flash.Error(flashError) } - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) return } ctx.ServerError("Merge", err) @@ -941,7 +939,7 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) { } log.Trace("Pull request merged: %d", pr.ID) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pr.Index)) } func stopTimerIfAvailable(user *models.User, issue *models.Issue) error { @@ -1052,7 +1050,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) } ctx.Flash.Error(flashError) } - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pullIssue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pullIssue.Index)) return } ctx.ServerError("NewPullRequest", err) @@ -1060,7 +1058,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) } log.Trace("Pull request created: %d/%d", repo.ID, pullIssue.ID) - ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pullIssue.Index)) + ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + fmt.Sprint(pullIssue.Index)) } // TriggerTask response for a trigger task request @@ -1159,7 +1157,7 @@ func CleanUpPullRequest(ctx *context.Context) { defer func() { ctx.JSON(200, map[string]interface{}{ - "redirect": pr.BaseRepo.Link() + "/pulls/" + com.ToStr(issue.Index), + "redirect": pr.BaseRepo.Link() + "/pulls/" + fmt.Sprint(issue.Index), }) }() diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 49aec8184b..0c3fd1267d 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -20,9 +20,8 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/webhook" - - "github.com/unknwon/com" ) const ( @@ -100,7 +99,7 @@ func getOrgRepoCtx(ctx *context.Context) (*orgRepoCtx, error) { func checkHookType(ctx *context.Context) string { hookType := strings.ToLower(ctx.Params(":type")) - if !com.IsSliceContainsStr(setting.Webhook.Types, hookType) { + if !util.IsStringInSlice(hookType, setting.Webhook.Types, true) { ctx.NotFound("checkHookType", nil) return "" } |