From 6f6682a19f45cbb4db4d90a67b6c5fc85ed07f89 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Fri, 21 Jul 2023 00:01:35 -0500 Subject: [PATCH 1/8] Fix some typos --- models/fixtures/pull_request.yml | 12 ++++++------ models/issues/pull.go | 2 +- models/issues/tracked_time.go | 6 +++--- routers/api/v1/repo/pull.go | 4 ++-- routers/private/hook_pre_receive.go | 2 +- routers/web/repo/issue.go | 2 +- routers/web/repo/pull.go | 4 ++-- services/agit/agit.go | 16 ++++++++-------- services/automerge/automerge.go | 4 ++-- services/convert/issue_comment.go | 4 ++-- services/gitdiff/gitdiff.go | 4 ++-- services/issue/assignee.go | 6 +++--- services/packages/container/blob_uploader.go | 6 +++--- services/pull/check.go | 8 ++++---- services/pull/merge_merge.go | 2 +- tests/integration/api_packages_maven_test.go | 2 +- 16 files changed, 42 insertions(+), 42 deletions(-) diff --git a/models/fixtures/pull_request.yml b/models/fixtures/pull_request.yml index 165437f0328dd..aeacc63d72797 100644 --- a/models/fixtures/pull_request.yml +++ b/models/fixtures/pull_request.yml @@ -1,7 +1,7 @@ - id: 1 type: 0 # gitea pull request - status: 2 # mergable + status: 2 # mergeable issue_id: 2 index: 2 head_repo_id: 1 @@ -15,7 +15,7 @@ - id: 2 type: 0 # gitea pull request - status: 2 # mergable + status: 2 # mergeable issue_id: 3 index: 3 head_repo_id: 1 @@ -28,7 +28,7 @@ - id: 3 type: 0 # gitea pull request - status: 2 # mergable + status: 2 # mergeable issue_id: 8 index: 1 head_repo_id: 11 @@ -41,7 +41,7 @@ - id: 4 type: 0 # gitea pull request - status: 2 # mergable + status: 2 # mergeable issue_id: 9 index: 1 head_repo_id: 48 @@ -54,7 +54,7 @@ - id: 5 # this PR is outdated (one commit behind branch1 ) type: 0 # gitea pull request - status: 2 # mergable + status: 2 # mergeable issue_id: 11 index: 5 head_repo_id: 1 @@ -67,7 +67,7 @@ - id: 6 type: 0 # gitea pull request - status: 2 # mergable + status: 2 # mergeable issue_id: 12 index: 2 head_repo_id: 3 diff --git a/models/issues/pull.go b/models/issues/pull.go index 2acc2b4226e0b..268ff9c48f57a 100644 --- a/models/issues/pull.go +++ b/models/issues/pull.go @@ -814,7 +814,7 @@ func UpdateAllowEdits(ctx context.Context, pr *PullRequest) error { // Mergeable returns if the pullrequest is mergeable. func (pr *PullRequest) Mergeable() bool { - // If a pull request isn't mergable if it's: + // If a pull request isn't mergeable if it's: // - Being conflict checked. // - Has a conflict. // - Received a error while being conflict checked. diff --git a/models/issues/tracked_time.go b/models/issues/tracked_time.go index d117b74bc037e..a8f2a02160cc0 100644 --- a/models/issues/tracked_time.go +++ b/models/issues/tracked_time.go @@ -178,7 +178,7 @@ func AddTime(user *user_model.User, issue *Issue, amount int64, created time.Tim Repo: issue.Repo, Doer: user, // Content before v1.21 did store the formated string instead of seconds, - // so use "|" as delimeter to mark the new format + // so use "|" as delimiter to mark the new format Content: fmt.Sprintf("|%d", amount), Type: CommentTypeAddTimeManual, TimeID: t.ID, @@ -258,7 +258,7 @@ func DeleteIssueUserTimes(issue *Issue, user *user_model.User) error { Repo: issue.Repo, Doer: user, // Content before v1.21 did store the formated string instead of seconds, - // so use "|" as delimeter to mark the new format + // so use "|" as delimiter to mark the new format Content: fmt.Sprintf("|%d", removedTime), Type: CommentTypeDeleteTimeManual, }); err != nil { @@ -289,7 +289,7 @@ func DeleteTime(t *TrackedTime) error { Repo: t.Issue.Repo, Doer: t.User, // Content before v1.21 did store the formated string instead of seconds, - // so use "|" as delimeter to mark the new format + // so use "|" as delimiter to mark the new format Content: fmt.Sprintf("|%d", t.Time), Type: CommentTypeDeleteTimeManual, }); err != nil { diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index a507c1f44d171..50f9f7e95d182 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -778,7 +778,7 @@ func MergePullRequest(ctx *context.APIContext) { } // start with merging by checking - if err := pull_service.CheckPullMergable(ctx, ctx.Doer, &ctx.Repo.Permission, pr, mergeCheckType, form.ForceMerge); err != nil { + if err := pull_service.CheckPullMergeable(ctx, ctx.Doer, &ctx.Repo.Permission, pr, mergeCheckType, form.ForceMerge); err != nil { if errors.Is(err, pull_service.ErrIsClosed) { ctx.NotFound() } else if errors.Is(err, pull_service.ErrUserNotAllowedToMerge) { @@ -787,7 +787,7 @@ func MergePullRequest(ctx *context.APIContext) { ctx.Error(http.StatusMethodNotAllowed, "PR already merged", "") } else if errors.Is(err, pull_service.ErrIsWorkInProgress) { ctx.Error(http.StatusMethodNotAllowed, "PR is a work in progress", "Work in progress PRs cannot be merged") - } else if errors.Is(err, pull_service.ErrNotMergableState) { + } else if errors.Is(err, pull_service.ErrNotMergeableState) { ctx.Error(http.StatusMethodNotAllowed, "PR not in mergeable state", "Please try again later") } else if models.IsErrDisallowedToMerge(err) { ctx.Error(http.StatusMethodNotAllowed, "PR is not ready to be merged", err) diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go index 7f37d73795a05..87c27dd05b1da 100644 --- a/routers/private/hook_pre_receive.go +++ b/routers/private/hook_pre_receive.go @@ -359,7 +359,7 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID string, r }) return } - log.Error("Unable to check if mergable: protected branch %s in %-v and pr #%d. Error: %v", ctx.opts.UserID, branchName, repo, pr.Index, err) + log.Error("Unable to check if mergeable: protected branch %s in %-v and pr #%d. Error: %v", ctx.opts.UserID, branchName, repo, pr.Index, err) ctx.JSON(http.StatusInternalServerError, private.Response{ Err: fmt.Sprintf("Unable to get status of pull request %d. Error: %v", ctx.opts.PullRequestID, err), }) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index bd8959846c0ed..2729d78a439bb 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1659,7 +1659,7 @@ func ViewIssue(ctx *context.Context) { _ = comment.LoadTime() if comment.Content != "" { // Content before v1.21 did store the formated string instead of seconds, - // so "|" is used as delimeter to mark the new format + // so "|" is used as delimiter to mark the new format if comment.Content[0] != '|' { // handle old time comments that have formatted text stored comment.RenderedContent = comment.Content diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index c5f260adfa745..aa2923203ba5c 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1005,7 +1005,7 @@ func MergePullRequest(ctx *context.Context) { } // start with merging by checking - if err := pull_service.CheckPullMergable(ctx, ctx.Doer, &ctx.Repo.Permission, pr, mergeCheckType, form.ForceMerge); err != nil { + if err := pull_service.CheckPullMergeable(ctx, ctx.Doer, &ctx.Repo.Permission, pr, mergeCheckType, form.ForceMerge); err != nil { switch { case errors.Is(err, pull_service.ErrIsClosed): if issue.IsPull { @@ -1019,7 +1019,7 @@ func MergePullRequest(ctx *context.Context) { ctx.Flash.Error(ctx.Tr("repo.pulls.has_merged")) case errors.Is(err, pull_service.ErrIsWorkInProgress): ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_wip")) - case errors.Is(err, pull_service.ErrNotMergableState): + case errors.Is(err, pull_service.ErrNotMergeableState): ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_not_ready")) case models.IsErrDisallowedToMerge(err): ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_not_ready")) diff --git a/services/agit/agit.go b/services/agit/agit.go index 208ea109f4c7b..bbb2c86808d76 100644 --- a/services/agit/agit.go +++ b/services/agit/agit.go @@ -57,19 +57,19 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. } baseBranchName := opts.RefFullNames[i].ForBranchName() - curentTopicBranch := "" + currentTopicBranch := "" if !gitRepo.IsBranchExist(baseBranchName) { // try match refs/for// for p, v := range baseBranchName { if v == '/' && gitRepo.IsBranchExist(baseBranchName[:p]) && p != len(baseBranchName)-1 { - curentTopicBranch = baseBranchName[p+1:] + currentTopicBranch = baseBranchName[p+1:] baseBranchName = baseBranchName[:p] break } } } - if len(topicBranch) == 0 && len(curentTopicBranch) == 0 { + if len(topicBranch) == 0 && len(currentTopicBranch) == 0 { results = append(results, private.HookProcReceiveRefResult{ OriginalRef: opts.RefFullNames[i], OldOID: opts.OldCommitIDs[i], @@ -82,17 +82,17 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. var headBranch string userName := strings.ToLower(opts.UserName) - if len(curentTopicBranch) == 0 { - curentTopicBranch = topicBranch + if len(currentTopicBranch) == 0 { + currentTopicBranch = topicBranch } // because different user maybe want to use same topic, // So it's better to make sure the topic branch name // has user name prefix - if !strings.HasPrefix(curentTopicBranch, userName+"/") { - headBranch = userName + "/" + curentTopicBranch + if !strings.HasPrefix(currentTopicBranch, userName+"/") { + headBranch = userName + "/" + currentTopicBranch } else { - headBranch = curentTopicBranch + headBranch = currentTopicBranch } pr, err := issues_model.GetUnmergedPullRequest(ctx, repo.ID, repo.ID, headBranch, baseBranchName, issues_model.PullRequestFlowAGit) diff --git a/services/automerge/automerge.go b/services/automerge/automerge.go index bf713c44314dd..8d6f5376d3cda 100644 --- a/services/automerge/automerge.go +++ b/services/automerge/automerge.go @@ -228,12 +228,12 @@ func handlePull(pullID int64, sha string) { return } - if err := pull_service.CheckPullMergable(ctx, doer, &perm, pr, pull_service.MergeCheckTypeGeneral, false); err != nil { + if err := pull_service.CheckPullMergeable(ctx, doer, &perm, pr, pull_service.MergeCheckTypeGeneral, false); err != nil { if errors.Is(pull_service.ErrUserNotAllowedToMerge, err) { log.Info("%-v was scheduled to automerge by an unauthorized user", pr) return } - log.Error("%-v CheckPullMergable: %v", pr, err) + log.Error("%-v CheckPullMergeable: %v", pr, err) return } diff --git a/services/convert/issue_comment.go b/services/convert/issue_comment.go index b0145c38e6390..6df470bccaade 100644 --- a/services/convert/issue_comment.go +++ b/services/convert/issue_comment.go @@ -72,8 +72,8 @@ func ToTimelineComment(ctx context.Context, repo *repo_model.Repository, c *issu c.Type == issues_model.CommentTypeStopTracking || c.Type == issues_model.CommentTypeDeleteTimeManual) && c.Content[0] == '|' { - // TimeTracking Comments from v1.21 on store the seconds instead of an formated string - // so we check for the "|" delimeter and convert new to legacy format on demand + // TimeTracking Comments from v1.21 on store the seconds instead of an formatted string + // so we check for the "|" delimiter and convert new to legacy format on demand c.Content = util.SecToTime(c.Content[1:]) } } diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 9e1db6fd4353c..5ae3ef09ee34c 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -168,7 +168,7 @@ func (d *DiffLine) GetExpandDirection() DiffLineExpandDirection { } func getDiffLineSectionInfo(treePath, line string, lastLeftIdx, lastRightIdx int) *DiffLineSectionInfo { - leftLine, leftHunk, rightLine, righHunk := git.ParseDiffHunkString(line) + leftLine, leftHunk, rightLine, rightHunk := git.ParseDiffHunkString(line) return &DiffLineSectionInfo{ Path: treePath, @@ -177,7 +177,7 @@ func getDiffLineSectionInfo(treePath, line string, lastLeftIdx, lastRightIdx int LeftIdx: leftLine, RightIdx: rightLine, LeftHunkSize: leftHunk, - RightHunkSize: righHunk, + RightHunkSize: rightHunk, } } diff --git a/services/issue/assignee.go b/services/issue/assignee.go index 8fe35b560203e..48ba5f8525dd3 100644 --- a/services/issue/assignee.go +++ b/services/issue/assignee.go @@ -19,10 +19,10 @@ import ( // DeleteNotPassedAssignee deletes all assignees who aren't passed via the "assignees" array func DeleteNotPassedAssignee(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, assignees []*user_model.User) (err error) { var found bool - oriAssignes := make([]*user_model.User, len(issue.Assignees)) - _ = copy(oriAssignes, issue.Assignees) + oriAssignees := make([]*user_model.User, len(issue.Assignees)) + _ = copy(oriAssignees, issue.Assignees) - for _, assignee := range oriAssignes { + for _, assignee := range oriAssignees { found = false for _, alreadyAssignee := range assignees { if assignee.ID == alreadyAssignee.ID { diff --git a/services/packages/container/blob_uploader.go b/services/packages/container/blob_uploader.go index bae2e2d6af667..034944874feda 100644 --- a/services/packages/container/blob_uploader.go +++ b/services/packages/container/blob_uploader.go @@ -18,8 +18,8 @@ import ( var ( // errWriteAfterRead occurs if Write is called after a read operation errWriteAfterRead = errors.New("write is unsupported after a read operation") - // errOffsetMissmatch occurs if the file offset is different than the model - errOffsetMissmatch = errors.New("offset mismatch between file and model") + // errOffsetMismatch occurs if the file offset is different than the model + errOffsetMismatch = errors.New("offset mismatch between file and model") ) // BlobUploader handles chunked blob uploads @@ -77,7 +77,7 @@ func (u *BlobUploader) Append(ctx context.Context, r io.Reader) error { return err } if offset != u.BytesReceived { - return errOffsetMissmatch + return errOffsetMismatch } n, err := io.Copy(io.MultiWriter(u.file, u.MultiHasher), r) diff --git a/services/pull/check.go b/services/pull/check.go index b5150ad9a8047..12308d8c14a3a 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -38,7 +38,7 @@ var ( ErrHasMerged = errors.New("has already been merged") ErrIsWorkInProgress = errors.New("work in progress PRs cannot be merged") ErrIsChecking = errors.New("cannot merge while conflict checking is in progress") - ErrNotMergableState = errors.New("not in mergeable state") + ErrNotMergeableState = errors.New("not in mergeable state") ErrDependenciesLeft = errors.New("is blocked by an open dependency") ) @@ -65,8 +65,8 @@ const ( MergeCheckTypeAuto // Auto Merge (Scheduled Merge) After Checks Succeed ) -// CheckPullMergable check if the pull mergable based on all conditions (branch protection, merge options, ...) -func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *access_model.Permission, pr *issues_model.PullRequest, mergeCheckType MergeCheckType, adminSkipProtectionCheck bool) error { +// CheckPullMergeable check if the pull mergeable based on all conditions (branch protection, merge options, ...) +func CheckPullMergeable(stdCtx context.Context, doer *user_model.User, perm *access_model.Permission, pr *issues_model.PullRequest, mergeCheckType MergeCheckType, adminSkipProtectionCheck bool) error { return db.WithTx(stdCtx, func(ctx context.Context) error { if pr.HasMerged { return ErrHasMerged @@ -96,7 +96,7 @@ func CheckPullMergable(stdCtx context.Context, doer *user_model.User, perm *acce } if !pr.CanAutoMerge() && !pr.IsEmpty() { - return ErrNotMergableState + return ErrNotMergeableState } if pr.IsChecking() { diff --git a/services/pull/merge_merge.go b/services/pull/merge_merge.go index 0f7664297aa81..0c37d58f9775e 100644 --- a/services/pull/merge_merge.go +++ b/services/pull/merge_merge.go @@ -9,7 +9,7 @@ import ( "code.gitea.io/gitea/modules/log" ) -// doMergeStyleMerge merges the tracking into the current HEAD - which is assumed to tbe staging branch (equal to the pr.BaseBranch) +// doMergeStyleMerge merges the tracking into the current HEAD - which is assumed to the staging branch (equal to the pr.BaseBranch) func doMergeStyleMerge(ctx *mergeContext, message string) error { cmd := git.NewCommand(ctx, "merge", "--no-ff", "--no-commit").AddDynamicArguments(trackingBranch) if err := runMergeCommand(ctx, repo_model.MergeStyleMerge, cmd); err != nil { diff --git a/tests/integration/api_packages_maven_test.go b/tests/integration/api_packages_maven_test.go index 81112f305a62e..fb147ef4517ac 100644 --- a/tests/integration/api_packages_maven_test.go +++ b/tests/integration/api_packages_maven_test.go @@ -107,7 +107,7 @@ func TestPackageMaven(t *testing.T) { t.Run("UploadVerifySHA1", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - t.Run("Missmatch", func(t *testing.T) { + t.Run("Mismatch", func(t *testing.T) { defer tests.PrintCurrentTest(t)() putFile(t, fmt.Sprintf("/%s/%s.sha1", packageVersion, filename), "test", http.StatusBadRequest) From c8c05087d05a60511758bbfe69f3408d1cd16a93 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Fri, 21 Jul 2023 00:04:21 -0500 Subject: [PATCH 2/8] A few more --- contrib/backport/README | 2 +- docs/content/doc/administration/config-cheat-sheet.en-us.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/backport/README b/contrib/backport/README index 1e84c1bb9743f..1470a9ce018f3 100644 --- a/contrib/backport/README +++ b/contrib/backport/README @@ -11,7 +11,7 @@ The default version will read from `docs/config.yml`. You can override this using the option `--version`. The upstream branches will be fetched, using the remote `origin`. This can -be overrided using `--upstream`, and fetching can be avoided using +be overrode using `--upstream`, and fetching can be avoided using `--no-fetch`. By default the branch created will be called `backport-$PR-$VERSION`. You diff --git a/docs/content/doc/administration/config-cheat-sheet.en-us.md b/docs/content/doc/administration/config-cheat-sheet.en-us.md index a78eff252dfb8..f8dee826cd547 100644 --- a/docs/content/doc/administration/config-cheat-sheet.en-us.md +++ b/docs/content/doc/administration/config-cheat-sheet.en-us.md @@ -1305,7 +1305,7 @@ Defaultly every storage has their default base path like below | actions_log | actions_log/ | | actions_artifacts | actions_artifacts/ | -And bucket, basepath or `SERVE_DIRECT` could be special or overrided, if you want to use a different you can: +And bucket, basepath or `SERVE_DIRECT` could be special or overrode, if you want to use a different you can: ```ini [storage.actions_log] @@ -1390,7 +1390,7 @@ Please note that using `self` is not recommended for most cases, as it could mak Additionally, it requires you to mirror all the actions you need to your Gitea instance, which may not be worth it. Therefore, please use `self` only if you understand what you are doing. -In earlier versions (<= 1.19), `DEFAULT_ACTIONS_URL` cound be set to any custom URLs like `https://gitea.com` or `http://your-git-server,https://gitea.com`, and the default value was `https://gitea.com`. +In earlier versions (<= 1.19), `DEFAULT_ACTIONS_URL` could be set to any custom URLs like `https://gitea.com` or `http://your-git-server,https://gitea.com`, and the default value was `https://gitea.com`. However, later updates removed those options, and now the only options are `github` and `self`, with the default value being `github`. However, if you want to use actions from other git server, you can use a complete URL in `uses` field, it's supported by Gitea (but not GitHub). Like `uses: https://gitea.com/actions/checkout@v3` or `uses: http://your-git-server/actions/checkout@v3`. From d01952f16176f341847cebd1c283fe9c22978728 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Fri, 21 Jul 2023 00:14:25 -0500 Subject: [PATCH 3/8] More fixes in models and modules --- models/actions/run.go | 6 +- models/actions/task.go | 14 +- models/auth/oauth2.go | 2 +- models/auth/oauth2_test.go | 2 +- models/db/index.go | 4 +- models/git/protected_branch_list.go | 6 +- ..._test.go => protected_branch_list_test.go} | 0 models/issues/tracked_time.go | 6 +- .../Test_UnwrapLDAPSourceCfg/login_source.yml | 14 +- models/migrations/migrations.go | 2 +- models/migrations/v1_11/v104.go | 2 +- models/migrations/v1_16/v189.go | 14 +- models/migrations/v1_16/v189_test.go | 10 +- models/migrations/v1_17/v216.go | 2 +- models/unit/unit.go | 4 +- models/user/setting_keys.go | 2 +- modules/actions/github.go | 14 +- modules/actions/workflows.go | 16 +- modules/actions/workflows_test.go | 138 +++++++++--------- .../{code_langauge.go => code_language.go} | 0 modules/git/diff.go | 8 +- modules/git/diff_test.go | 6 +- modules/git/foreachref/format.go | 2 +- modules/git/ref.go | 2 +- modules/indexer/code/git.go | 6 +- modules/lfs/transferadapter.go | 2 +- modules/markup/camo.go | 2 +- modules/markup/camo_test.go | 2 +- modules/markup/markdown/math/inline_parser.go | 2 +- modules/packages/conda/metadata.go | 2 +- modules/packages/rpm/metadata.go | 2 +- modules/process/manager.go | 6 +- modules/secret/secret.go | 2 +- modules/setting/camo.go | 2 +- modules/structs/repo_wiki.go | 2 +- modules/templates/helper_test.go | 4 +- modules/typesniffer/typesniffer_test.go | 4 +- routers/web/org/teams.go | 4 +- routers/web/repo/issue.go | 2 +- services/org/org.go | 6 +- templates/swagger/v1_json.tmpl | 2 +- 41 files changed, 164 insertions(+), 164 deletions(-) rename models/git/{protected_banch_list_test.go => protected_branch_list_test.go} (100%) rename modules/analyze/{code_langauge.go => code_language.go} (100%) diff --git a/models/actions/run.go b/models/actions/run.go index 7b62ff884f4ca..ad73c93ca530e 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -166,11 +166,11 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err // InsertRun inserts a run func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWorkflow) error { - ctx, commiter, err := db.TxContext(ctx) + ctx, committer, err := db.TxContext(ctx) if err != nil { return err } - defer commiter.Close() + defer committer.Close() index, err := db.GetNextResourceIndex(ctx, "action_run_index", run.RepoID) if err != nil { @@ -225,7 +225,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork return err } - return commiter.Commit() + return committer.Commit() } func GetRunByID(ctx context.Context, id int64) (*ActionRun, error) { diff --git a/models/actions/task.go b/models/actions/task.go index 55044ec82d105..f2d4dcccdbd84 100644 --- a/models/actions/task.go +++ b/models/actions/task.go @@ -215,11 +215,11 @@ func GetRunningTaskByToken(ctx context.Context, token string) (*ActionTask, erro } func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask, bool, error) { - dbCtx, commiter, err := db.TxContext(ctx) + dbCtx, committer, err := db.TxContext(ctx) if err != nil { return nil, false, err } - defer commiter.Close() + defer committer.Close() ctx = dbCtx.WithContext(ctx) e := db.GetEngine(ctx) @@ -279,7 +279,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask if gots, err := jobparser.Parse(job.WorkflowPayload); err != nil { return nil, false, fmt.Errorf("parse workflow of job %d: %w", job.ID, err) } else if len(gots) != 1 { - return nil, false, fmt.Errorf("workflow of job %d: not signle workflow", job.ID) + return nil, false, fmt.Errorf("workflow of job %d: not single workflow", job.ID) } else { _, workflowJob = gots[0].Job() } @@ -328,7 +328,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask task.Job = job - if err := commiter.Commit(); err != nil { + if err := committer.Commit(); err != nil { return nil, false, err } @@ -353,11 +353,11 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT stepStates[v.Id] = v } - ctx, commiter, err := db.TxContext(ctx) + ctx, committer, err := db.TxContext(ctx) if err != nil { return nil, err } - defer commiter.Close() + defer committer.Close() e := db.GetEngine(ctx) @@ -418,7 +418,7 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT } } - if err := commiter.Commit(); err != nil { + if err := committer.Commit(); err != nil { return nil, err } diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go index 0f64b56c1635b..d0173f7f3c31c 100644 --- a/models/auth/oauth2.go +++ b/models/auth/oauth2.go @@ -526,7 +526,7 @@ func (err ErrOAuthApplicationNotFound) Unwrap() error { return util.ErrNotExist } -// GetActiveOAuth2ProviderSources returns all actived LoginOAuth2 sources +// GetActiveOAuth2ProviderSources returns all activated LoginOAuth2 sources func GetActiveOAuth2ProviderSources() ([]*Source, error) { sources := make([]*Source, 0, 1) if err := db.GetEngine(db.DefaultContext).Where("is_active = ? and type = ?", true, OAuth2).Find(&sources); err != nil { diff --git a/models/auth/oauth2_test.go b/models/auth/oauth2_test.go index 80d0e9baa4813..fa421fc7240e4 100644 --- a/models/auth/oauth2_test.go +++ b/models/auth/oauth2_test.go @@ -59,7 +59,7 @@ func TestOAuth2Application_ContainsRedirectURI_WithPort(t *testing.T) { // not loopback assert.False(t, app.ContainsRedirectURI("http://192.168.0.1:9954/")) assert.False(t, app.ContainsRedirectURI("http://intranet:3456/")) - // unparseable + // unparsable assert.False(t, app.ContainsRedirectURI(":")) } diff --git a/models/db/index.go b/models/db/index.go index 29254b1f07a06..91747dd43754d 100644 --- a/models/db/index.go +++ b/models/db/index.go @@ -20,8 +20,8 @@ type ResourceIndex struct { } var ( - // ErrResouceOutdated represents an error when request resource outdated - ErrResouceOutdated = errors.New("resource outdated") + // ErrResourceOutdated represents an error when request resource outdated + ErrResourceOutdated = errors.New("resource outdated") // ErrGetResourceIndexFailed represents an error when resource index retries 3 times ErrGetResourceIndexFailed = errors.New("get resource index failed") ) diff --git a/models/git/protected_branch_list.go b/models/git/protected_branch_list.go index eeb307e2454e7..a3e2ada86eb81 100644 --- a/models/git/protected_branch_list.go +++ b/models/git/protected_branch_list.go @@ -50,7 +50,7 @@ func FindRepoProtectedBranchRules(ctx context.Context, repoID int64) (ProtectedB func FindAllMatchedBranches(ctx context.Context, repoID int64, ruleName string) ([]string, error) { results := make([]string, 0, 10) for page := 1; ; page++ { - brancheNames, err := FindBranchNames(ctx, FindBranchOptions{ + branchNames, err := FindBranchNames(ctx, FindBranchOptions{ ListOptions: db.ListOptions{ PageSize: 100, Page: page, @@ -63,12 +63,12 @@ func FindAllMatchedBranches(ctx context.Context, repoID int64, ruleName string) } rule := glob.MustCompile(ruleName) - for _, branch := range brancheNames { + for _, branch := range branchNames { if rule.Match(branch) { results = append(results, branch) } } - if len(brancheNames) < 100 { + if len(branchNames) < 100 { break } } diff --git a/models/git/protected_banch_list_test.go b/models/git/protected_branch_list_test.go similarity index 100% rename from models/git/protected_banch_list_test.go rename to models/git/protected_branch_list_test.go diff --git a/models/issues/tracked_time.go b/models/issues/tracked_time.go index a8f2a02160cc0..18e96f2dea69a 100644 --- a/models/issues/tracked_time.go +++ b/models/issues/tracked_time.go @@ -177,7 +177,7 @@ func AddTime(user *user_model.User, issue *Issue, amount int64, created time.Tim Issue: issue, Repo: issue.Repo, Doer: user, - // Content before v1.21 did store the formated string instead of seconds, + // Content before v1.21 did store the formatted string instead of seconds, // so use "|" as delimiter to mark the new format Content: fmt.Sprintf("|%d", amount), Type: CommentTypeAddTimeManual, @@ -257,7 +257,7 @@ func DeleteIssueUserTimes(issue *Issue, user *user_model.User) error { Issue: issue, Repo: issue.Repo, Doer: user, - // Content before v1.21 did store the formated string instead of seconds, + // Content before v1.21 did store the formatted string instead of seconds, // so use "|" as delimiter to mark the new format Content: fmt.Sprintf("|%d", removedTime), Type: CommentTypeDeleteTimeManual, @@ -288,7 +288,7 @@ func DeleteTime(t *TrackedTime) error { Issue: t.Issue, Repo: t.Issue.Repo, Doer: t.User, - // Content before v1.21 did store the formated string instead of seconds, + // Content before v1.21 did store the formatted string instead of seconds, // so use "|" as delimiter to mark the new format Content: fmt.Sprintf("|%d", t.Time), Type: CommentTypeDeleteTimeManual, diff --git a/models/migrations/fixtures/Test_UnwrapLDAPSourceCfg/login_source.yml b/models/migrations/fixtures/Test_UnwrapLDAPSourceCfg/login_source.yml index 4b72ba145ecb8..31f18ec2c17ef 100644 --- a/models/migrations/fixtures/Test_UnwrapLDAPSourceCfg/login_source.yml +++ b/models/migrations/fixtures/Test_UnwrapLDAPSourceCfg/login_source.yml @@ -7,42 +7,42 @@ - id: 1 type: 1 - is_actived: false + is_activated: false cfg: "{\"Source\":{\"A\":\"string\",\"B\":1}}" expected: "{\"Source\":{\"A\":\"string\",\"B\":1}}" - id: 2 type: 2 - is_actived: true + is_activated: true cfg: "{\"Source\":{\"A\":\"string2\",\"B\":2}}" expected: "{\"A\":\"string2\",\"B\":2}" - id: 3 type: 3 - is_actived: false + is_activated: false cfg: "{\"Source\":{\"A\":\"string3\",\"B\":3}}" expected: "{\"Source\":{\"A\":\"string3\",\"B\":3}}" - id: 4 type: 4 - is_actived: true + is_activated: true cfg: "{\"Source\":{\"A\":\"string4\",\"B\":4}}" expected: "{\"Source\":{\"A\":\"string4\",\"B\":4}}" - id: 5 type: 5 - is_actived: false + is_activated: false cfg: "{\"Source\":{\"A\":\"string5\",\"B\":5}}" expected: "{\"A\":\"string5\",\"B\":5}" - id: 6 type: 2 - is_actived: true + is_activated: true cfg: "{\"A\":\"string6\",\"B\":6}" expected: "{\"A\":\"string6\",\"B\":6}" - id: 7 type: 5 - is_actived: false + is_activated: false cfg: "{\"A\":\"string7\",\"B\":7}" expected: "{\"A\":\"string7\",\"B\":7}" diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index a15b6e4eec8ca..ed84bcbe907b0 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -160,7 +160,7 @@ var migrations = []Migration{ // v103 -> v104 NewMigration("Add WhitelistDeployKeys to protected branch", v1_11.AddWhitelistDeployKeysToBranches), // v104 -> v105 - NewMigration("remove unnecessary columns from label", v1_11.RemoveLabelUneededCols), + NewMigration("remove unnecessary columns from label", v1_11.RemoveLabelUnneededCols), // v105 -> v106 NewMigration("add includes_all_repositories to teams", v1_11.AddTeamIncludesAllRepositories), // v106 -> v107 diff --git a/models/migrations/v1_11/v104.go b/models/migrations/v1_11/v104.go index c76554cf59f7a..74fc30cb33f3c 100644 --- a/models/migrations/v1_11/v104.go +++ b/models/migrations/v1_11/v104.go @@ -9,7 +9,7 @@ import ( "xorm.io/xorm" ) -func RemoveLabelUneededCols(x *xorm.Engine) error { +func RemoveLabelUnneededCols(x *xorm.Engine) error { // Make sure the columns exist before dropping them type Label struct { QueryString string diff --git a/models/migrations/v1_16/v189.go b/models/migrations/v1_16/v189.go index 79e3289ba7f51..632d7b09a7a59 100644 --- a/models/migrations/v1_16/v189.go +++ b/models/migrations/v1_16/v189.go @@ -43,11 +43,11 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error { // LoginSource represents an external way for authorizing users. type LoginSource struct { - ID int64 `xorm:"pk autoincr"` - Type int - IsActived bool `xorm:"INDEX NOT NULL DEFAULT false"` - IsActive bool `xorm:"INDEX NOT NULL DEFAULT false"` - Cfg string `xorm:"TEXT"` + ID int64 `xorm:"pk autoincr"` + Type int + IsActivated bool `xorm:"INDEX NOT NULL DEFAULT false"` + IsActive bool `xorm:"INDEX NOT NULL DEFAULT false"` + Cfg string `xorm:"TEXT"` } const ldapType = 2 @@ -96,14 +96,14 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error { } } - if _, err := x.SetExpr("is_active", "is_actived").Update(&LoginSource{}); err != nil { + if _, err := x.SetExpr("is_active", "is_activated").Update(&LoginSource{}); err != nil { return fmt.Errorf("SetExpr Update failed: %w", err) } if err := sess.Begin(); err != nil { return err } - if err := base.DropTableColumns(sess, "login_source", "is_actived"); err != nil { + if err := base.DropTableColumns(sess, "login_source", "is_activated"); err != nil { return err } diff --git a/models/migrations/v1_16/v189_test.go b/models/migrations/v1_16/v189_test.go index 32ef821d27886..35e1bdd589c20 100644 --- a/models/migrations/v1_16/v189_test.go +++ b/models/migrations/v1_16/v189_test.go @@ -14,11 +14,11 @@ import ( // LoginSource represents an external way for authorizing users. type LoginSourceOriginalV189 struct { - ID int64 `xorm:"pk autoincr"` - Type int - IsActived bool `xorm:"INDEX NOT NULL DEFAULT false"` - Cfg string `xorm:"TEXT"` - Expected string `xorm:"TEXT"` + ID int64 `xorm:"pk autoincr"` + Type int + IsActivated bool `xorm:"INDEX NOT NULL DEFAULT false"` + Cfg string `xorm:"TEXT"` + Expected string `xorm:"TEXT"` } func (ls *LoginSourceOriginalV189) TableName() string { diff --git a/models/migrations/v1_17/v216.go b/models/migrations/v1_17/v216.go index 59b21d9b2c465..268f472a4250f 100644 --- a/models/migrations/v1_17/v216.go +++ b/models/migrations/v1_17/v216.go @@ -4,4 +4,4 @@ package v1_17 //nolint // This migration added non-ideal indices to the action table which on larger datasets slowed things down -// it has been superceded by v218.go +// it has been superseded by v218.go diff --git a/models/unit/unit.go b/models/unit/unit.go index 5f5e20de1e0e0..719e016490817 100644 --- a/models/unit/unit.go +++ b/models/unit/unit.go @@ -350,7 +350,7 @@ func AllUnitKeyNames() []string { return res } -// MinUnitAccessMode returns the minial permission of the permission map +// MinUnitAccessMode returns the minimal permission of the permission map func MinUnitAccessMode(unitsMap map[Type]perm.AccessMode) perm.AccessMode { res := perm.AccessModeNone for t, mode := range unitsMap { @@ -359,7 +359,7 @@ func MinUnitAccessMode(unitsMap map[Type]perm.AccessMode) perm.AccessMode { continue } - // get the minial permission great than AccessModeNone except all are AccessModeNone + // get the minimal permission great than AccessModeNone except all are AccessModeNone if mode > perm.AccessModeNone && (res == perm.AccessModeNone || mode < res) { res = mode } diff --git a/models/user/setting_keys.go b/models/user/setting_keys.go index 72b3974eee435..0e2c93695a573 100644 --- a/models/user/setting_keys.go +++ b/models/user/setting_keys.go @@ -8,7 +8,7 @@ const ( SettingsKeyHiddenCommentTypes = "issue.hidden_comment_types" // SettingsKeyDiffWhitespaceBehavior is the setting key for whitespace behavior of diff SettingsKeyDiffWhitespaceBehavior = "diff.whitespace_behaviour" - // SettingsKeyShowOutdatedComments is the setting key wether or not to show outdated comments in PRs + // SettingsKeyShowOutdatedComments is the setting key whether or not to show outdated comments in PRs SettingsKeyShowOutdatedComments = "comment_code.show_outdated" // UserActivityPubPrivPem is user's private key UserActivityPubPrivPem = "activitypub.priv_pem" diff --git a/modules/actions/github.go b/modules/actions/github.go index 71f81a89034c5..1803a3263a2a0 100644 --- a/modules/actions/github.go +++ b/modules/actions/github.go @@ -25,17 +25,17 @@ const ( ) // canGithubEventMatch check if the input Github event can match any Gitea event. -func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEventType) bool { +func canGithubEventMatch(eventName string, triggeredEvent webhook_module.HookEventType) bool { switch eventName { case GithubEventRegistryPackage: - return triggedEvent == webhook_module.HookEventPackage + return triggeredEvent == webhook_module.HookEventPackage // See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#gollum case GithubEventGollum: - return triggedEvent == webhook_module.HookEventWiki + return triggeredEvent == webhook_module.HookEventWiki case GithubEventIssues: - switch triggedEvent { + switch triggeredEvent { case webhook_module.HookEventIssues, webhook_module.HookEventIssueAssign, webhook_module.HookEventIssueLabel, @@ -47,7 +47,7 @@ func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEvent } case GithubEventPullRequest, GithubEventPullRequestTarget: - switch triggedEvent { + switch triggeredEvent { case webhook_module.HookEventPullRequest, webhook_module.HookEventPullRequestSync, webhook_module.HookEventPullRequestAssign, @@ -59,7 +59,7 @@ func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEvent } case GithubEventPullRequestReview: - switch triggedEvent { + switch triggeredEvent { case webhook_module.HookEventPullRequestReviewApproved, webhook_module.HookEventPullRequestReviewComment, webhook_module.HookEventPullRequestReviewRejected: @@ -70,6 +70,6 @@ func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEvent } default: - return eventName == string(triggedEvent) + return eventName == string(triggeredEvent) } } diff --git a/modules/actions/workflows.go b/modules/actions/workflows.go index 2c7cec5591de3..466cafcd8ca21 100644 --- a/modules/actions/workflows.go +++ b/modules/actions/workflows.go @@ -95,7 +95,7 @@ func GetEventsFromContent(content []byte) ([]*jobparser.Event, error) { return events, nil } -func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader) ([]*DetectedWorkflow, error) { +func DetectWorkflows(commit *git.Commit, triggeredEvent webhook_module.HookEventType, payload api.Payloader) ([]*DetectedWorkflow, error) { entries, err := ListWorkflows(commit) if err != nil { return nil, err @@ -113,8 +113,8 @@ func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventTy continue } for _, evt := range events { - log.Trace("detect workflow %q for event %#v matching %q", entry.Name(), evt, triggedEvent) - if detectMatched(commit, triggedEvent, payload, evt) { + log.Trace("detect workflow %q for event %#v matching %q", entry.Name(), evt, triggeredEvent) + if detectMatched(commit, triggeredEvent, payload, evt) { dwf := &DetectedWorkflow{ EntryName: entry.Name(), TriggerEvent: evt.Name, @@ -128,19 +128,19 @@ func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventTy return workflows, nil } -func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader, evt *jobparser.Event) bool { - if !canGithubEventMatch(evt.Name, triggedEvent) { +func detectMatched(commit *git.Commit, triggeredEvent webhook_module.HookEventType, payload api.Payloader, evt *jobparser.Event) bool { + if !canGithubEventMatch(evt.Name, triggeredEvent) { return false } - switch triggedEvent { + switch triggeredEvent { case // events with no activity types webhook_module.HookEventCreate, webhook_module.HookEventDelete, webhook_module.HookEventFork, webhook_module.HookEventWiki: if len(evt.Acts()) != 0 { - log.Warn("Ignore unsupported %s event arguments %v", triggedEvent, evt.Acts()) + log.Warn("Ignore unsupported %s event arguments %v", triggeredEvent, evt.Acts()) } // no special filter parameters for these events, just return true if name matched return true @@ -188,7 +188,7 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType return matchPackageEvent(commit, payload.(*api.PackagePayload), evt) default: - log.Warn("unsupported event %q", triggedEvent) + log.Warn("unsupported event %q", triggeredEvent) return false } } diff --git a/modules/actions/workflows_test.go b/modules/actions/workflows_test.go index ef553c4a57267..a2b9bafc09d69 100644 --- a/modules/actions/workflows_test.go +++ b/modules/actions/workflows_test.go @@ -15,58 +15,58 @@ import ( func TestDetectMatched(t *testing.T) { testCases := []struct { - desc string - commit *git.Commit - triggedEvent webhook_module.HookEventType - payload api.Payloader - yamlOn string - expected bool + desc string + commit *git.Commit + triggeredEvent webhook_module.HookEventType + payload api.Payloader + yamlOn string + expected bool }{ { - desc: "HookEventCreate(create) matches GithubEventCreate(create)", - triggedEvent: webhook_module.HookEventCreate, - payload: nil, - yamlOn: "on: create", - expected: true, + desc: "HookEventCreate(create) matches GithubEventCreate(create)", + triggeredEvent: webhook_module.HookEventCreate, + payload: nil, + yamlOn: "on: create", + expected: true, }, { - desc: "HookEventIssues(issues) `opened` action matches GithubEventIssues(issues)", - triggedEvent: webhook_module.HookEventIssues, - payload: &api.IssuePayload{Action: api.HookIssueOpened}, - yamlOn: "on: issues", - expected: true, + desc: "HookEventIssues(issues) `opened` action matches GithubEventIssues(issues)", + triggeredEvent: webhook_module.HookEventIssues, + payload: &api.IssuePayload{Action: api.HookIssueOpened}, + yamlOn: "on: issues", + expected: true, }, { - desc: "HookEventIssues(issues) `milestoned` action matches GithubEventIssues(issues)", - triggedEvent: webhook_module.HookEventIssues, - payload: &api.IssuePayload{Action: api.HookIssueMilestoned}, - yamlOn: "on: issues", - expected: true, + desc: "HookEventIssues(issues) `milestoned` action matches GithubEventIssues(issues)", + triggeredEvent: webhook_module.HookEventIssues, + payload: &api.IssuePayload{Action: api.HookIssueMilestoned}, + yamlOn: "on: issues", + expected: true, }, { - desc: "HookEventPullRequestSync(pull_request_sync) matches GithubEventPullRequest(pull_request)", - triggedEvent: webhook_module.HookEventPullRequestSync, - payload: &api.PullRequestPayload{Action: api.HookIssueSynchronized}, - yamlOn: "on: pull_request", - expected: true, + desc: "HookEventPullRequestSync(pull_request_sync) matches GithubEventPullRequest(pull_request)", + triggeredEvent: webhook_module.HookEventPullRequestSync, + payload: &api.PullRequestPayload{Action: api.HookIssueSynchronized}, + yamlOn: "on: pull_request", + expected: true, }, { - desc: "HookEventPullRequest(pull_request) `label_updated` action doesn't match GithubEventPullRequest(pull_request) with no activity type", - triggedEvent: webhook_module.HookEventPullRequest, - payload: &api.PullRequestPayload{Action: api.HookIssueLabelUpdated}, - yamlOn: "on: pull_request", - expected: false, + desc: "HookEventPullRequest(pull_request) `label_updated` action doesn't match GithubEventPullRequest(pull_request) with no activity type", + triggeredEvent: webhook_module.HookEventPullRequest, + payload: &api.PullRequestPayload{Action: api.HookIssueLabelUpdated}, + yamlOn: "on: pull_request", + expected: false, }, { - desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with no activity type", - triggedEvent: webhook_module.HookEventPullRequest, - payload: &api.PullRequestPayload{Action: api.HookIssueClosed}, - yamlOn: "on: pull_request", - expected: false, + desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with no activity type", + triggeredEvent: webhook_module.HookEventPullRequest, + payload: &api.PullRequestPayload{Action: api.HookIssueClosed}, + yamlOn: "on: pull_request", + expected: false, }, { - desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with branches", - triggedEvent: webhook_module.HookEventPullRequest, + desc: "HookEventPullRequest(pull_request) `closed` action doesn't match GithubEventPullRequest(pull_request) with branches", + triggeredEvent: webhook_module.HookEventPullRequest, payload: &api.PullRequestPayload{ Action: api.HookIssueClosed, PullRequest: &api.PullRequest{ @@ -77,46 +77,46 @@ func TestDetectMatched(t *testing.T) { expected: false, }, { - desc: "HookEventPullRequest(pull_request) `label_updated` action matches GithubEventPullRequest(pull_request) with `label` activity type", - triggedEvent: webhook_module.HookEventPullRequest, - payload: &api.PullRequestPayload{Action: api.HookIssueLabelUpdated}, - yamlOn: "on:\n pull_request:\n types: [labeled]", - expected: true, + desc: "HookEventPullRequest(pull_request) `label_updated` action matches GithubEventPullRequest(pull_request) with `label` activity type", + triggeredEvent: webhook_module.HookEventPullRequest, + payload: &api.PullRequestPayload{Action: api.HookIssueLabelUpdated}, + yamlOn: "on:\n pull_request:\n types: [labeled]", + expected: true, }, { - desc: "HookEventPullRequestReviewComment(pull_request_review_comment) matches GithubEventPullRequestReviewComment(pull_request_review_comment)", - triggedEvent: webhook_module.HookEventPullRequestReviewComment, - payload: &api.PullRequestPayload{Action: api.HookIssueReviewed}, - yamlOn: "on:\n pull_request_review_comment:\n types: [created]", - expected: true, + desc: "HookEventPullRequestReviewComment(pull_request_review_comment) matches GithubEventPullRequestReviewComment(pull_request_review_comment)", + triggeredEvent: webhook_module.HookEventPullRequestReviewComment, + payload: &api.PullRequestPayload{Action: api.HookIssueReviewed}, + yamlOn: "on:\n pull_request_review_comment:\n types: [created]", + expected: true, }, { - desc: "HookEventPullRequestReviewRejected(pull_request_review_rejected) doesn't match GithubEventPullRequestReview(pull_request_review) with `dismissed` activity type (we don't support `dismissed` at present)", - triggedEvent: webhook_module.HookEventPullRequestReviewRejected, - payload: &api.PullRequestPayload{Action: api.HookIssueReviewed}, - yamlOn: "on:\n pull_request_review:\n types: [dismissed]", - expected: false, + desc: "HookEventPullRequestReviewRejected(pull_request_review_rejected) doesn't match GithubEventPullRequestReview(pull_request_review) with `dismissed` activity type (we don't support `dismissed` at present)", + triggeredEvent: webhook_module.HookEventPullRequestReviewRejected, + payload: &api.PullRequestPayload{Action: api.HookIssueReviewed}, + yamlOn: "on:\n pull_request_review:\n types: [dismissed]", + expected: false, }, { - desc: "HookEventRelease(release) `published` action matches GithubEventRelease(release) with `published` activity type", - triggedEvent: webhook_module.HookEventRelease, - payload: &api.ReleasePayload{Action: api.HookReleasePublished}, - yamlOn: "on:\n release:\n types: [published]", - expected: true, + desc: "HookEventRelease(release) `published` action matches GithubEventRelease(release) with `published` activity type", + triggeredEvent: webhook_module.HookEventRelease, + payload: &api.ReleasePayload{Action: api.HookReleasePublished}, + yamlOn: "on:\n release:\n types: [published]", + expected: true, }, { - desc: "HookEventPackage(package) `created` action doesn't match GithubEventRegistryPackage(registry_package) with `updated` activity type", - triggedEvent: webhook_module.HookEventPackage, - payload: &api.PackagePayload{Action: api.HookPackageCreated}, - yamlOn: "on:\n registry_package:\n types: [updated]", - expected: false, + desc: "HookEventPackage(package) `created` action doesn't match GithubEventRegistryPackage(registry_package) with `updated` activity type", + triggeredEvent: webhook_module.HookEventPackage, + payload: &api.PackagePayload{Action: api.HookPackageCreated}, + yamlOn: "on:\n registry_package:\n types: [updated]", + expected: false, }, { - desc: "HookEventWiki(wiki) matches GithubEventGollum(gollum)", - triggedEvent: webhook_module.HookEventWiki, - payload: nil, - yamlOn: "on: gollum", - expected: true, + desc: "HookEventWiki(wiki) matches GithubEventGollum(gollum)", + triggeredEvent: webhook_module.HookEventWiki, + payload: nil, + yamlOn: "on: gollum", + expected: true, }, } @@ -125,7 +125,7 @@ func TestDetectMatched(t *testing.T) { evts, err := GetEventsFromContent([]byte(tc.yamlOn)) assert.NoError(t, err) assert.Len(t, evts, 1) - assert.Equal(t, tc.expected, detectMatched(tc.commit, tc.triggedEvent, tc.payload, evts[0])) + assert.Equal(t, tc.expected, detectMatched(tc.commit, tc.triggeredEvent, tc.payload, evts[0])) }) } } diff --git a/modules/analyze/code_langauge.go b/modules/analyze/code_language.go similarity index 100% rename from modules/analyze/code_langauge.go rename to modules/analyze/code_language.go diff --git a/modules/git/diff.go b/modules/git/diff.go index 10ef3d83fba98..40b73571563d3 100644 --- a/modules/git/diff.go +++ b/modules/git/diff.go @@ -94,7 +94,7 @@ func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diff } // ParseDiffHunkString parse the diffhunk content and return -func ParseDiffHunkString(diffhunk string) (leftLine, leftHunk, rightLine, righHunk int) { +func ParseDiffHunkString(diffhunk string) (leftLine, leftHunk, rightLine, rightHunk int) { ss := strings.Split(diffhunk, "@@") ranges := strings.Split(ss[1][1:], " ") leftRange := strings.Split(ranges[0], ",") @@ -106,14 +106,14 @@ func ParseDiffHunkString(diffhunk string) (leftLine, leftHunk, rightLine, righHu rightRange := strings.Split(ranges[1], ",") rightLine, _ = strconv.Atoi(rightRange[0]) if len(rightRange) > 1 { - righHunk, _ = strconv.Atoi(rightRange[1]) + rightHunk, _ = strconv.Atoi(rightRange[1]) } } else { log.Debug("Parse line number failed: %v", diffhunk) rightLine = leftLine - righHunk = leftHunk + rightHunk = leftHunk } - return leftLine, leftHunk, rightLine, righHunk + return leftLine, leftHunk, rightLine, rightHunk } // Example: @@ -1,8 +1,9 @@ => [..., 1, 8, 1, 9] diff --git a/modules/git/diff_test.go b/modules/git/diff_test.go index 0f865c52a8c84..dae2a04a9c904 100644 --- a/modules/git/diff_test.go +++ b/modules/git/diff_test.go @@ -29,7 +29,7 @@ index d8e4c92..19dc8ad 100644 @@ -1,9 +1,10 @@ --some comment --- some comment 5 -+--some coment 2 ++--some comment 2 +-- some comment 3 create or replace procedure test(p1 varchar2) is @@ -134,7 +134,7 @@ func TestCutDiffAroundLine(t *testing.T) { @@ -1,9 +1,10 @@ --some comment --- some comment 5 -+--some coment 2` ++--some comment 2` assert.Equal(t, expected, minusDiff) // Handle minus diffs properly @@ -147,7 +147,7 @@ func TestCutDiffAroundLine(t *testing.T) { @@ -1,9 +1,10 @@ --some comment --- some comment 5 -+--some coment 2 ++--some comment 2 +-- some comment 3` assert.Equal(t, expected, minusDiff) diff --git a/modules/git/foreachref/format.go b/modules/git/foreachref/format.go index 97e8ee47247b9..75e315ad4a057 100644 --- a/modules/git/foreachref/format.go +++ b/modules/git/foreachref/format.go @@ -72,7 +72,7 @@ func (f Format) Parser(r io.Reader) *Parser { return NewParser(r, f) } -// hexEscaped produces hex-escpaed characters from a string. For example, "\n\0" +// hexEscaped produces hex-escaped characters from a string. For example, "\n\0" // would turn into "%0a%00". func (f Format) hexEscaped(delim []byte) string { escaped := "" diff --git a/modules/git/ref.go b/modules/git/ref.go index ad251515e7dbb..062cb84e6a3fd 100644 --- a/modules/git/ref.go +++ b/modules/git/ref.go @@ -184,7 +184,7 @@ func (ref RefName) RefGroup() string { } // RefType returns the simple ref type of the reference, e.g. branch, tag -// It's differrent from RefGroup, which is using the name of the directory under .git/refs +// It's different from RefGroup, which is using the name of the directory under .git/refs // Here we using branch but not heads, using tag but not tags func (ref RefName) RefType() string { var refType string diff --git a/modules/indexer/code/git.go b/modules/indexer/code/git.go index 1ba6b849d11db..92ae139826e24 100644 --- a/modules/indexer/code/git.go +++ b/modules/indexer/code/git.go @@ -113,7 +113,7 @@ func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revisio } fields := strings.Split(line, "\t") if len(fields) < 2 { - log.Warn("Unparseable output for diff --name-status: `%s`)", line) + log.Warn("Unparsable output for diff --name-status: `%s`)", line) continue } filename := fields[1] @@ -133,12 +133,12 @@ func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revisio changes.RemovedFilenames = append(changes.RemovedFilenames, filename) case 'R', 'C': if len(fields) < 3 { - log.Warn("Unparseable output for diff --name-status: `%s`)", line) + log.Warn("Unparsable output for diff --name-status: `%s`)", line) continue } dest := fields[2] if len(dest) == 0 { - log.Warn("Unparseable output for diff --name-status: `%s`)", line) + log.Warn("Unparsable output for diff --name-status: `%s`)", line) continue } if dest[0] == '"' { diff --git a/modules/lfs/transferadapter.go b/modules/lfs/transferadapter.go index 649497aabb36d..d2652b6ddf8ed 100644 --- a/modules/lfs/transferadapter.go +++ b/modules/lfs/transferadapter.go @@ -120,7 +120,7 @@ func handleErrorResponse(resp *http.Response) error { if err != nil { return fmt.Errorf("Request failed with status %s", resp.Status) } - log.Trace("ErrorRespone: %v", er) + log.Trace("ErrorResponse: %v", er) return errors.New(er.Message) } diff --git a/modules/markup/camo.go b/modules/markup/camo.go index e93797de2ba75..7e2583469d35b 100644 --- a/modules/markup/camo.go +++ b/modules/markup/camo.go @@ -38,7 +38,7 @@ func camoHandleLink(link string) string { if setting.Camo.Enabled { lnkURL, err := url.Parse(link) if err == nil && lnkURL.IsAbs() && !strings.HasPrefix(link, setting.AppURL) && - (setting.Camo.Allways || lnkURL.Scheme != "https") { + (setting.Camo.Always || lnkURL.Scheme != "https") { return CamoEncode(link) } } diff --git a/modules/markup/camo_test.go b/modules/markup/camo_test.go index ba58835221b40..3c5d40afa07b3 100644 --- a/modules/markup/camo_test.go +++ b/modules/markup/camo_test.go @@ -28,7 +28,7 @@ func TestCamoHandleLink(t *testing.T) { "https://image.proxy/eivin43gJwGVIjR9MiYYtFIk0mw/aHR0cDovL3Rlc3RpbWFnZXMub3JnL2ltZy5qcGc", camoHandleLink("http://testimages.org/img.jpg")) - setting.Camo.Allways = true + setting.Camo.Always = true assert.Equal(t, "https://gitea.com/img.jpg", camoHandleLink("https://gitea.com/img.jpg")) diff --git a/modules/markup/markdown/math/inline_parser.go b/modules/markup/markdown/math/inline_parser.go index 0ac25c2b2ac86..3a7bf3813545c 100644 --- a/modules/markup/markdown/math/inline_parser.go +++ b/modules/markup/markdown/math/inline_parser.go @@ -55,7 +55,7 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser. return nil } - precedingCharacter := block.PrecendingCharacter() + precedingCharacter := block.PrecedingCharacter() if precedingCharacter < 256 && isAlphanumeric(byte(precedingCharacter)) { // need to exclude things like `a$` from being considered a start return nil diff --git a/modules/packages/conda/metadata.go b/modules/packages/conda/metadata.go index 02dbf313ba2d8..5eb72b8e38455 100644 --- a/modules/packages/conda/metadata.go +++ b/modules/packages/conda/metadata.go @@ -27,7 +27,7 @@ const ( PropertyName = "conda.name" PropertyChannel = "conda.channel" PropertySubdir = "conda.subdir" - PropertyMetadata = "conda.metdata" + PropertyMetadata = "conda.metadata" ) // Package represents a Conda package diff --git a/modules/packages/rpm/metadata.go b/modules/packages/rpm/metadata.go index 607ea42ea0ab2..f019a8dde1aaa 100644 --- a/modules/packages/rpm/metadata.go +++ b/modules/packages/rpm/metadata.go @@ -15,7 +15,7 @@ import ( ) const ( - PropertyMetadata = "rpm.metdata" + PropertyMetadata = "rpm.metadata" SettingKeyPrivate = "rpm.key.private" SettingKeyPublic = "rpm.key.public" diff --git a/modules/process/manager.go b/modules/process/manager.go index 9c21f6215210f..bdc4931810d1c 100644 --- a/modules/process/manager.go +++ b/modules/process/manager.go @@ -134,7 +134,7 @@ func (pm *Manager) AddTypedContext(parent context.Context, description, processT // // Most processes will not need to use the cancel function but there will be cases whereby you want to cancel the process but not immediately remove it from the // process table. -func (pm *Manager) AddContextTimeout(parent context.Context, timeout time.Duration, description string) (ctx context.Context, cancel context.CancelFunc, finshed FinishedFunc) { +func (pm *Manager) AddContextTimeout(parent context.Context, timeout time.Duration, description string) (ctx context.Context, cancel context.CancelFunc, finished FinishedFunc) { if timeout <= 0 { // it's meaningless to use timeout <= 0, and it must be a bug! so we must panic here to tell developers to make the timeout correct panic("the timeout must be greater than zero, otherwise the context will be cancelled immediately") @@ -142,9 +142,9 @@ func (pm *Manager) AddContextTimeout(parent context.Context, timeout time.Durati ctx, cancel = context.WithTimeout(parent, timeout) - ctx, _, finshed = pm.Add(ctx, description, cancel, NormalProcessType, true) + ctx, _, finished = pm.Add(ctx, description, cancel, NormalProcessType, true) - return ctx, cancel, finshed + return ctx, cancel, finished } // Add create a new process diff --git a/modules/secret/secret.go b/modules/secret/secret.go index 9c2ecd181d2ca..520c573103e41 100644 --- a/modules/secret/secret.go +++ b/modules/secret/secret.go @@ -28,7 +28,7 @@ func AesEncrypt(key, text []byte) ([]byte, error) { if _, err = io.ReadFull(rand.Reader, iv); err != nil { return nil, fmt.Errorf("AesEncrypt unable to read IV: %w", err) } - cfb := cipher.NewCFBEncrypter(block, iv) + cfb := cipher.NewCFBEncryptor(block, iv) cfb.XORKeyStream(ciphertext[aes.BlockSize:], []byte(b)) return ciphertext, nil } diff --git a/modules/setting/camo.go b/modules/setting/camo.go index 366e9a116cd5b..eca4cfce2b1e6 100644 --- a/modules/setting/camo.go +++ b/modules/setting/camo.go @@ -9,7 +9,7 @@ var Camo = struct { Enabled bool ServerURL string `ini:"SERVER_URL"` HMACKey string `ini:"HMAC_KEY"` - Allways bool + Always bool }{} func loadCamoFrom(rootCfg ConfigProvider) { diff --git a/modules/structs/repo_wiki.go b/modules/structs/repo_wiki.go index 3df5a0be99144..b5d72abf80d78 100644 --- a/modules/structs/repo_wiki.go +++ b/modules/structs/repo_wiki.go @@ -7,7 +7,7 @@ package structs type WikiCommit struct { ID string `json:"sha"` Author *CommitUser `json:"author"` - Committer *CommitUser `json:"commiter"` + Committer *CommitUser `json:"committer"` Message string `json:"message"` } diff --git a/modules/templates/helper_test.go b/modules/templates/helper_test.go index ec83e9ac33138..492e07b10ab10 100644 --- a/modules/templates/helper_test.go +++ b/modules/templates/helper_test.go @@ -48,7 +48,7 @@ func TestSubjectBodySeparator(t *testing.T) { test("Multiple\n---\n-------\n---\nSeparators", "Multiple\n", "\n-------\n---\nSeparators") - test("Insuficient\n--\nSeparators", + test("Insufficient\n--\nSeparators", "", - "Insuficient\n--\nSeparators") + "Insufficient\n--\nSeparators") } diff --git a/modules/typesniffer/typesniffer_test.go b/modules/typesniffer/typesniffer_test.go index 6c6da34aa006a..6cf435a0a9fab 100644 --- a/modules/typesniffer/typesniffer_test.go +++ b/modules/typesniffer/typesniffer_test.go @@ -48,12 +48,12 @@ func TestIsSvgImage(t *testing.T) { `)).IsSvgImage()) assert.True(t, DetectContentType([]byte(` - `)).IsSvgImage()) assert.True(t, DetectContentType([]byte(` - `)).IsSvgImage()) diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index aefadaf809e82..f62bf4ef5efd7 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -308,7 +308,7 @@ func NewTeamPost(ctx *context.Context) { unitPerms := getUnitPerms(ctx.Req.Form, p) if p < perm.AccessModeAdmin { // if p is less than admin accessmode, then it should be general accessmode, - // so we should calculate the minial accessmode from units accessmodes. + // so we should calculate the minimal accessmode from units accessmodes. p = unit_model.MinUnitAccessMode(unitPerms) } @@ -459,7 +459,7 @@ func EditTeamPost(ctx *context.Context) { unitPerms := getUnitPerms(ctx.Req.Form, newAccessMode) if newAccessMode < perm.AccessModeAdmin { // if newAccessMode is less than admin accessmode, then it should be general accessmode, - // so we should calculate the minial accessmode from units accessmodes. + // so we should calculate the minimal accessmode from units accessmodes. newAccessMode = unit_model.MinUnitAccessMode(unitPerms) } isAuthChanged := false diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 2729d78a439bb..f3cc963ac8b50 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1658,7 +1658,7 @@ func ViewIssue(ctx *context.Context) { // drop error since times could be pruned from DB.. _ = comment.LoadTime() if comment.Content != "" { - // Content before v1.21 did store the formated string instead of seconds, + // Content before v1.21 did store the formatted string instead of seconds, // so "|" is used as delimiter to mark the new format if comment.Content[0] != '|' { // handle old time comments that have formatted text stored diff --git a/services/org/org.go b/services/org/org.go index a62e5b6fc8f6d..f5bde8267f7ac 100644 --- a/services/org/org.go +++ b/services/org/org.go @@ -20,11 +20,11 @@ import ( // DeleteOrganization completely and permanently deletes everything of organization. func DeleteOrganization(org *org_model.Organization) error { - ctx, commiter, err := db.TxContext(db.DefaultContext) + ctx, committer, err := db.TxContext(db.DefaultContext) if err != nil { return err } - defer commiter.Close() + defer committer.Close() // Check ownership of repository. count, err := repo_model.CountRepositories(ctx, repo_model.CountRepositoryOptions{OwnerID: org.ID}) @@ -45,7 +45,7 @@ func DeleteOrganization(org *org_model.Organization) error { return fmt.Errorf("DeleteOrganization: %w", err) } - if err := commiter.Commit(); err != nil { + if err := committer.Commit(); err != nil { return err } diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index b7620b9e763a5..9431ccdcb525a 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -21995,7 +21995,7 @@ "author": { "$ref": "#/definitions/CommitUser" }, - "commiter": { + "committer": { "$ref": "#/definitions/CommitUser" }, "message": { From 34c30bc1fb276e410375877aa4c1c77d2b274fa4 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Fri, 21 Jul 2023 00:16:04 -0500 Subject: [PATCH 4/8] More in routers --- routers/api/actions/artifacts.go | 6 +++--- routers/api/actions/runner/interceptor.go | 4 ++-- routers/web/repo/issue_dependency.go | 2 +- routers/web/repo/middlewares.go | 2 +- routers/web/shared/actions/runners.go | 2 +- templates/shared/actions/runner_list.tmpl | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/routers/api/actions/artifacts.go b/routers/api/actions/artifacts.go index 060f7bc3d4bae..26e22f0aa95b7 100644 --- a/routers/api/actions/artifacts.go +++ b/routers/api/actions/artifacts.go @@ -119,7 +119,7 @@ func ArtifactsRoutes(prefix string) *web.Route { m.Group(artifactRouteBase, func() { // retrieve, list and confirm artifacts - m.Combo("").Get(r.listArtifacts).Post(r.getUploadArtifactURL).Patch(r.comfirmUploadArtifact) + m.Combo("").Get(r.listArtifacts).Post(r.getUploadArtifactURL).Patch(r.confirmUploadArtifact) // handle container artifacts list and download m.Group("/{artifact_id}", func() { m.Put("/upload", r.uploadArtifact) @@ -348,9 +348,9 @@ func (ar artifactRoutes) uploadArtifact(ctx *ArtifactContext) { }) } -// comfirmUploadArtifact comfirm upload artifact. +// confirmUploadArtifact confirm upload artifact. // if all chunks are uploaded, merge them to one file. -func (ar artifactRoutes) comfirmUploadArtifact(ctx *ArtifactContext) { +func (ar artifactRoutes) confirmUploadArtifact(ctx *ArtifactContext) { _, runID, ok := ar.validateRunID(ctx) if !ok { return diff --git a/routers/api/actions/runner/interceptor.go b/routers/api/actions/runner/interceptor.go index ddc754dbc722b..055bba6056972 100644 --- a/routers/api/actions/runner/interceptor.go +++ b/routers/api/actions/runner/interceptor.go @@ -36,7 +36,7 @@ var withRunner = connect.WithInterceptors(connect.UnaryInterceptorFunc(func(unar uuid := request.Header().Get(uuidHeaderKey) token := request.Header().Get(tokenHeaderKey) // TODO: version will be removed from request header after Gitea 1.20 released. - // And Gitea will not try to read version from reuqest header + // And Gitea will not try to read version from request header version := request.Header().Get(versionHeaderKey) runner, err := actions_model.GetRunnerByUUID(ctx, uuid) @@ -53,7 +53,7 @@ var withRunner = connect.WithInterceptors(connect.UnaryInterceptorFunc(func(unar cols := []string{"last_online"} // TODO: version will be removed from request header after Gitea 1.20 released. - // And Gitea will not try to read version from reuqest header + // And Gitea will not try to read version from request header version, _ = util.SplitStringAtByteN(version, 64) if !util.IsEmptyString(version) && runner.Version != version { runner.Version = version diff --git a/routers/web/repo/issue_dependency.go b/routers/web/repo/issue_dependency.go index d3af319c711a6..3fe067e153d4f 100644 --- a/routers/web/repo/issue_dependency.go +++ b/routers/web/repo/issue_dependency.go @@ -120,7 +120,7 @@ func RemoveDependency(ctx *context.Context) { case "blocking": depType = issues_model.DependencyTypeBlocking default: - ctx.Error(http.StatusBadRequest, "GetDependecyType") + ctx.Error(http.StatusBadRequest, "GetDependencyType") return } diff --git a/routers/web/repo/middlewares.go b/routers/web/repo/middlewares.go index 216550ca996c6..434e4a3e80511 100644 --- a/routers/web/repo/middlewares.go +++ b/routers/web/repo/middlewares.go @@ -25,7 +25,7 @@ func SetEditorconfigIfExists(ctx *context.Context) { if err != nil && !git.IsErrNotExist(err) { description := fmt.Sprintf("Error while getting .editorconfig file: %v", err) if err := system_model.CreateRepositoryNotice(description); err != nil { - ctx.ServerError("ErrCreatingReporitoryNotice", err) + ctx.ServerError("ErrCreatingRepositoryNotice", err) } return } diff --git a/routers/web/shared/actions/runners.go b/routers/web/shared/actions/runners.go index 21e5a90d8f206..dafc5fb5ea9da 100644 --- a/routers/web/shared/actions/runners.go +++ b/routers/web/shared/actions/runners.go @@ -52,7 +52,7 @@ func RunnersList(ctx *context.Context, opts actions_model.FindRunnerOptions) { ctx.Data["Runners"] = runners ctx.Data["Total"] = count ctx.Data["RegistrationToken"] = token.Token - ctx.Data["RunnerOnwerID"] = opts.OwnerID + ctx.Data["RunnerOwnerID"] = opts.OwnerID ctx.Data["RunnerRepoID"] = opts.RepoID pager := context.NewPagination(int(count), opts.PageSize, opts.Page, 5) diff --git a/templates/shared/actions/runner_list.tmpl b/templates/shared/actions/runner_list.tmpl index 36210af6d8e8f..c4b70282aedb0 100644 --- a/templates/shared/actions/runner_list.tmpl +++ b/templates/shared/actions/runner_list.tmpl @@ -71,7 +71,7 @@ {{if .LastOnline}}{{TimeSinceUnix .LastOnline $.locale}}{{else}}{{$.locale.Tr "never"}}{{end}} - {{if .Editable $.RunnerOnwerID $.RunnerRepoID}} + {{if .Editable $.RunnerOwnerID $.RunnerRepoID}} {{svg "octicon-pencil"}} {{end}} From 325b6296f7a5b3e22f316cb53e82220574140dd1 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Fri, 21 Jul 2023 00:19:44 -0500 Subject: [PATCH 5/8] Revert some incorrect fixes --- models/auth/oauth2.go | 2 +- .../Test_UnwrapLDAPSourceCfg/login_source.yml | 14 +++++++------- models/migrations/v1_16/v189.go | 14 +++++++------- models/migrations/v1_16/v189_test.go | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go index d0173f7f3c31c..38dc3eb9247f6 100644 --- a/models/auth/oauth2.go +++ b/models/auth/oauth2.go @@ -526,7 +526,7 @@ func (err ErrOAuthApplicationNotFound) Unwrap() error { return util.ErrNotExist } -// GetActiveOAuth2ProviderSources returns all activated LoginOAuth2 sources +// GetActiveOAuth2ProviderSources returns all active LoginOAuth2 sources func GetActiveOAuth2ProviderSources() ([]*Source, error) { sources := make([]*Source, 0, 1) if err := db.GetEngine(db.DefaultContext).Where("is_active = ? and type = ?", true, OAuth2).Find(&sources); err != nil { diff --git a/models/migrations/fixtures/Test_UnwrapLDAPSourceCfg/login_source.yml b/models/migrations/fixtures/Test_UnwrapLDAPSourceCfg/login_source.yml index 31f18ec2c17ef..4b72ba145ecb8 100644 --- a/models/migrations/fixtures/Test_UnwrapLDAPSourceCfg/login_source.yml +++ b/models/migrations/fixtures/Test_UnwrapLDAPSourceCfg/login_source.yml @@ -7,42 +7,42 @@ - id: 1 type: 1 - is_activated: false + is_actived: false cfg: "{\"Source\":{\"A\":\"string\",\"B\":1}}" expected: "{\"Source\":{\"A\":\"string\",\"B\":1}}" - id: 2 type: 2 - is_activated: true + is_actived: true cfg: "{\"Source\":{\"A\":\"string2\",\"B\":2}}" expected: "{\"A\":\"string2\",\"B\":2}" - id: 3 type: 3 - is_activated: false + is_actived: false cfg: "{\"Source\":{\"A\":\"string3\",\"B\":3}}" expected: "{\"Source\":{\"A\":\"string3\",\"B\":3}}" - id: 4 type: 4 - is_activated: true + is_actived: true cfg: "{\"Source\":{\"A\":\"string4\",\"B\":4}}" expected: "{\"Source\":{\"A\":\"string4\",\"B\":4}}" - id: 5 type: 5 - is_activated: false + is_actived: false cfg: "{\"Source\":{\"A\":\"string5\",\"B\":5}}" expected: "{\"A\":\"string5\",\"B\":5}" - id: 6 type: 2 - is_activated: true + is_actived: true cfg: "{\"A\":\"string6\",\"B\":6}" expected: "{\"A\":\"string6\",\"B\":6}" - id: 7 type: 5 - is_activated: false + is_actived: false cfg: "{\"A\":\"string7\",\"B\":7}" expected: "{\"A\":\"string7\",\"B\":7}" diff --git a/models/migrations/v1_16/v189.go b/models/migrations/v1_16/v189.go index 632d7b09a7a59..79e3289ba7f51 100644 --- a/models/migrations/v1_16/v189.go +++ b/models/migrations/v1_16/v189.go @@ -43,11 +43,11 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error { // LoginSource represents an external way for authorizing users. type LoginSource struct { - ID int64 `xorm:"pk autoincr"` - Type int - IsActivated bool `xorm:"INDEX NOT NULL DEFAULT false"` - IsActive bool `xorm:"INDEX NOT NULL DEFAULT false"` - Cfg string `xorm:"TEXT"` + ID int64 `xorm:"pk autoincr"` + Type int + IsActived bool `xorm:"INDEX NOT NULL DEFAULT false"` + IsActive bool `xorm:"INDEX NOT NULL DEFAULT false"` + Cfg string `xorm:"TEXT"` } const ldapType = 2 @@ -96,14 +96,14 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error { } } - if _, err := x.SetExpr("is_active", "is_activated").Update(&LoginSource{}); err != nil { + if _, err := x.SetExpr("is_active", "is_actived").Update(&LoginSource{}); err != nil { return fmt.Errorf("SetExpr Update failed: %w", err) } if err := sess.Begin(); err != nil { return err } - if err := base.DropTableColumns(sess, "login_source", "is_activated"); err != nil { + if err := base.DropTableColumns(sess, "login_source", "is_actived"); err != nil { return err } diff --git a/models/migrations/v1_16/v189_test.go b/models/migrations/v1_16/v189_test.go index 35e1bdd589c20..32ef821d27886 100644 --- a/models/migrations/v1_16/v189_test.go +++ b/models/migrations/v1_16/v189_test.go @@ -14,11 +14,11 @@ import ( // LoginSource represents an external way for authorizing users. type LoginSourceOriginalV189 struct { - ID int64 `xorm:"pk autoincr"` - Type int - IsActivated bool `xorm:"INDEX NOT NULL DEFAULT false"` - Cfg string `xorm:"TEXT"` - Expected string `xorm:"TEXT"` + ID int64 `xorm:"pk autoincr"` + Type int + IsActived bool `xorm:"INDEX NOT NULL DEFAULT false"` + Cfg string `xorm:"TEXT"` + Expected string `xorm:"TEXT"` } func (ls *LoginSourceOriginalV189) TableName() string { From b732ec8dd641407b0952f9e1074e667406e2d93d Mon Sep 17 00:00:00 2001 From: harryzcy Date: Fri, 21 Jul 2023 00:31:47 -0500 Subject: [PATCH 6/8] `be overridden` --- docs/content/doc/administration/config-cheat-sheet.en-us.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/doc/administration/config-cheat-sheet.en-us.md b/docs/content/doc/administration/config-cheat-sheet.en-us.md index f8dee826cd547..c1834a62b1a3d 100644 --- a/docs/content/doc/administration/config-cheat-sheet.en-us.md +++ b/docs/content/doc/administration/config-cheat-sheet.en-us.md @@ -1305,7 +1305,7 @@ Defaultly every storage has their default base path like below | actions_log | actions_log/ | | actions_artifacts | actions_artifacts/ | -And bucket, basepath or `SERVE_DIRECT` could be special or overrode, if you want to use a different you can: +And bucket, basepath or `SERVE_DIRECT` could be special or overriden, if you want to use a different you can: ```ini [storage.actions_log] From d8a86408426a2cec14459308fe194b2c6abacabd Mon Sep 17 00:00:00 2001 From: harryzcy Date: Fri, 21 Jul 2023 00:34:49 -0500 Subject: [PATCH 7/8] Fix --- routers/api/actions/artifacts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/actions/artifacts.go b/routers/api/actions/artifacts.go index 1691d21c2b4d8..d81ac74352fe3 100644 --- a/routers/api/actions/artifacts.go +++ b/routers/api/actions/artifacts.go @@ -257,7 +257,7 @@ func (ar artifactRoutes) uploadArtifact(ctx *ArtifactContext) { // confirmUploadArtifact confirm upload artifact. // if all chunks are uploaded, merge them to one file. func (ar artifactRoutes) confirmUploadArtifact(ctx *ArtifactContext) { - _, runID, ok := ar.validateRunID(ctx) + _, runID, ok := validateRunID(ctx) if !ok { return } From 830cf9045656b4cea8f0e5aea824bfde333233d8 Mon Sep 17 00:00:00 2001 From: harryzcy Date: Fri, 21 Jul 2023 01:25:29 -0500 Subject: [PATCH 8/8] Fix --- modules/markup/markdown/math/inline_parser.go | 2 +- modules/secret/secret.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/markup/markdown/math/inline_parser.go b/modules/markup/markdown/math/inline_parser.go index 3a7bf3813545c..0ac25c2b2ac86 100644 --- a/modules/markup/markdown/math/inline_parser.go +++ b/modules/markup/markdown/math/inline_parser.go @@ -55,7 +55,7 @@ func (parser *inlineParser) Parse(parent ast.Node, block text.Reader, pc parser. return nil } - precedingCharacter := block.PrecedingCharacter() + precedingCharacter := block.PrecendingCharacter() if precedingCharacter < 256 && isAlphanumeric(byte(precedingCharacter)) { // need to exclude things like `a$` from being considered a start return nil diff --git a/modules/secret/secret.go b/modules/secret/secret.go index 520c573103e41..9c2ecd181d2ca 100644 --- a/modules/secret/secret.go +++ b/modules/secret/secret.go @@ -28,7 +28,7 @@ func AesEncrypt(key, text []byte) ([]byte, error) { if _, err = io.ReadFull(rand.Reader, iv); err != nil { return nil, fmt.Errorf("AesEncrypt unable to read IV: %w", err) } - cfb := cipher.NewCFBEncryptor(block, iv) + cfb := cipher.NewCFBEncrypter(block, iv) cfb.XORKeyStream(ciphertext[aes.BlockSize:], []byte(b)) return ciphertext, nil }