Skip to content

codespell: add config and action to codespell the code to avoid known typos #26194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Codespell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to configure exceptions? Otherwise this job will always fail because it detects false positives.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Codespell
uses: codespell-project/actions-codespell@v2
144 changes: 72 additions & 72 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ Gitea or set your environment appropriately.`, "")
type pktLineType int64

const (
// UnKnow type
// unknown type
pktLineTypeUnknow pktLineType = 0
// flush-pkt "0000"
pktLineTypeFlush pktLineType = iota
Expand Down
2 changes: 1 addition & 1 deletion contrib/backport/README
Original file line number Diff line number Diff line change
Expand Up @@ -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 overridden using `--upstream`, and fetching can be avoided using
`--no-fetch`.

By default the branch created will be called `backport-$PR-$VERSION`. You
Expand Down
8 changes: 4 additions & 4 deletions docs/content/administration/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ Default templates for project boards:
- `ResponseWriter`: the responseWriter from the request.
- `RequestID`: the value matching REQUEST_ID_HEADERS(default: `-`, if not matched).
- You must be very careful to ensure that this template does not throw errors or panics as this template runs outside the panic/recovery script.
- `REQUEST_ID_HEADERS`: **_empty_**: You can configure multiple values that are splited by comma here. It will match in the order of configuration, and the first match will be finally printed in the access log.
- `REQUEST_ID_HEADERS`: **_empty_**: You can configure multiple values that are split by comma here. It will match in the order of configuration, and the first match will be finally printed in the access log.
- e.g.
- In the Request Header: X-Request-ID: **test-id-123**
- Configuration in app.ini: REQUEST_ID_HEADERS = X-Request-ID
Expand Down Expand Up @@ -1268,7 +1268,7 @@ Default storage configuration for attachments, lfs, avatars, repo-avatars, repo-
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`

The recommanded storage configuration for minio like below:
The recommended storage configuration for minio like below:

```ini
[storage]
Expand Down Expand Up @@ -1303,7 +1303,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 overridden, if you want to use a different you can:

```ini
[storage.actions_log]
Expand Down Expand Up @@ -1388,7 +1388,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`.
Expand Down
2 changes: 1 addition & 1 deletion docs/content/administration/config-cheat-sheet.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ Attachments, lfs, avatars, repo-avatars, repo-archive, packages, actions_log, ac
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket,仅当 `STORAGE_TYPE` 是 `minio` 时有效。
- `MINIO_USE_SSL`: **false**: Minio enabled ssl,仅当 `STORAGE_TYPE` 是 `minio` 时有效。

以下为推荐的 recommanded storage configuration for minio like below:
以下为推荐的 recommended storage configuration for minio like below:

```ini
[storage]
Expand Down
2 changes: 1 addition & 1 deletion docs/content/usage/packages/storage.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This document describes the storage of the package registry and how it can be ma

## Deduplication

The package registry has a build-in deduplication of uploaded blobs.
The package registry has a built-in deduplication of uploaded blobs.
If two identical files are uploaded only one blob is saved on the filesystem.
This ensures no space is wasted for duplicated files.

Expand Down
2 changes: 1 addition & 1 deletion models/actions/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,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()
}
Expand Down
2 changes: 1 addition & 1 deletion models/actions/tasks_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

// ActionTasksVersion
// If both ownerID and repoID is zero, its scope is global.
// If ownerID is not zero and repoID is zero, its scope is org (there is no user-level runner currrently).
// If ownerID is not zero and repoID is zero, its scope is org (there is no user-level runner currently).
// If ownerID is zero and repoID is not zero, its scope is repo.
type ActionTasksVersion struct {
ID int64 `xorm:"pk autoincr"`
Expand Down
2 changes: 1 addition & 1 deletion models/auth/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion models/auth/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(":"))
}

Expand Down
12 changes: 6 additions & 6 deletions models/fixtures/pull_request.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion models/git/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func DeleteBranches(ctx context.Context, repoID, doerID int64, branchIDs []int64
}

// UpdateBranch updates the branch information in the database. If the branch exist, it will update latest commit of this branch information
// If it doest not exist, insert a new record into database
// If it does not exist, insert a new record into database
func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string, commit *git.Commit) error {
cnt, err := db.GetEngine(ctx).Where("repo_id=? AND name=?", repoID, branchName).
Cols("commit_id, commit_message, pusher_id, commit_time, is_deleted, updated_unix").
Expand Down
2 changes: 1 addition & 1 deletion models/git/branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestFindRenamedBranch(t *testing.T) {
assert.True(t, exist)
assert.Equal(t, "master", branch.To)

_, exist, err = git_model.FindRenamedBranch(db.DefaultContext, 1, "unknow")
_, exist, err = git_model.FindRenamedBranch(db.DefaultContext, 1, "unknown")
assert.NoError(t, err)
assert.False(t, exist)
}
Expand Down
2 changes: 1 addition & 1 deletion models/issues/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func TestGetLabelsByIssueID(t *testing.T) {
func TestUpdateLabel(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
// make sure update wont overwrite it
// make sure update won't overwrite it
update := &issues_model.Label{
ID: label.ID,
Color: "#ffff00",
Expand Down
2 changes: 1 addition & 1 deletion models/issues/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,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.
Expand Down
12 changes: 6 additions & 6 deletions models/issues/tracked_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ func AddTime(ctx context.Context, user *user_model.User, issue *Issue, amount in
Issue: issue,
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
// 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,
TimeID: t.ID,
Expand Down Expand Up @@ -253,8 +253,8 @@ 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,
// so use "|" as delimeter to mark the new format
// 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,
}); err != nil {
Expand Down Expand Up @@ -284,8 +284,8 @@ 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,
// so use "|" as delimeter to mark the new format
// 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,
}); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion models/migrations/v1_17/v216.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion models/user/setting_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion modules/avatar/identicon/identicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (i *Identicon) render(c, b1, b2, b1Angle, b2Angle, foreColor int) image.Ima
/*
# Algorithm

Origin: An image is splitted into 9 areas
Origin: An image is split into 9 areas

```
-------------
Expand Down
2 changes: 1 addition & 1 deletion modules/context/csrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func PrepareCSRFProtector(opt CsrfOptions, ctx *Context) CSRFProtector {
if uidChanged {
_ = ctx.Session.Set(opt.oldSessionKey, x.ID)
} else if cookieToken != "" {
// If cookie token presents, re-use existing unexpired token, else generate a new one.
// If cookie token presents, reuse existing unexpired token, else generate a new one.
if issueTime, ok := ParseCsrfToken(cookieToken); ok {
dur := time.Since(issueTime) // issueTime is not a monotonic-clock, the server time may change a lot to an early time.
if dur >= -CsrfTokenRegenerationInterval && dur <= CsrfTokenRegenerationInterval {
Expand Down
2 changes: 1 addition & 1 deletion modules/doctor/dbconsistency.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func genericOrphanCheck(name, subject, refobject, joincond string) consistencyCh
}

func checkDBConsistency(ctx context.Context, logger log.Logger, autofix bool) error {
// make sure DB version is uptodate
// make sure DB version is up-to-date
if err := db.InitEngineWithMigration(ctx, migrations.EnsureUpToDate); err != nil {
logger.Critical("Model version on the database does not match the current Gitea version. Model consistency will not be checked until the database is upgraded")
return err
Expand Down
2 changes: 1 addition & 1 deletion modules/git/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions modules/gitgraph/graph_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (flow *Flow) AddGlyph(row, column int, glyph byte) {
})
}

// Glyph represents a co-ordinate and glyph
// Glyph represents a coordinate and glyph
type Glyph struct {
Row int
Column int
Expand Down Expand Up @@ -234,7 +234,7 @@ func newRefsFromRefNames(refNames []byte) []git.Reference {
return refs
}

// Commit represents a commit at co-ordinate X, Y with the data
// Commit represents a commit at coordinate X, Y with the data
type Commit struct {
Commit *git.Commit
User *user_model.User
Expand Down
6 changes: 3 additions & 3 deletions modules/indexer/code/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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] == '"' {
Expand Down
2 changes: 1 addition & 1 deletion modules/log/event_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func EventFormatTextMessage(mode *WriterMode, event *Event, msgFormat string, ms
msg = []byte(fmt.Sprintf(msgFormat, msgArgs...))
}
}
// try to re-use the pre-formatted simple text message
// try to reuse the pre-formatted simple text message
if len(msg) == 0 {
msg = []byte(event.MsgSimpleText)
}
Expand Down
6 changes: 3 additions & 3 deletions modules/process/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ 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")
}

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
Expand Down
4 changes: 2 additions & 2 deletions modules/setting/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ func getStorage(rootCfg ConfigProvider, name, typ string, sec ConfigSection) (*S
targetType := targetSec.Key("STORAGE_TYPE").String()
if targetType == "" {
if !IsValidStorageType(StorageType(typ)) {
return nil, fmt.Errorf("unknow storage type %q", typ)
return nil, fmt.Errorf("unknown storage type %q", typ)
}
targetSec.Key("STORAGE_TYPE").SetValue(typ)
} else if !IsValidStorageType(StorageType(targetType)) {
return nil, fmt.Errorf("unknow storage type %q for section storage.%v", targetType, typ)
return nil, fmt.Errorf("unknown storage type %q for section storage.%v", targetType, typ)
}
}
}
Expand Down
Loading