Merge pull request 'typos, mostly from codespell, others just by eyeballing' (#6089) from FermeLeLundi/forgejo:forgejo into forgejo
Some checks failed
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Integration tests for the release process / release-simulation (push) Has been cancelled

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6089
Reviewed-by: Otto <otto@codeberg.org>
This commit is contained in:
Gusted 2024-11-29 21:59:43 +00:00
commit ececc4fda0
15 changed files with 38 additions and 40 deletions

View file

@ -920,7 +920,7 @@ release-docs: | $(DIST_DIRS) docs
.PHONY: reproduce-build .PHONY: reproduce-build
reproduce-build: reproduce-build:
# Start building the Dockerfile with the RELEASE_VERSION tag set. GOPROXY is set # Start building the Dockerfile with the RELEASE_VERSION tag set. GOPROXY is set
# for convience, because the default of the Dockerfile is `direct` which can be # for convenience, because the default of the Dockerfile is `direct` which can be
# quite slow. # quite slow.
@docker build --build-arg="RELEASE_VERSION=$(RELEASE_VERSION)" --build-arg="GOPROXY=$(shell $(GO) env GOPROXY)" --tag "forgejo-reproducibility" . @docker build --build-arg="RELEASE_VERSION=$(RELEASE_VERSION)" --build-arg="GOPROXY=$(shell $(GO) env GOPROXY)" --tag "forgejo-reproducibility" .
@id=$$(docker create forgejo-reproducibility); \ @id=$$(docker create forgejo-reproducibility); \

View file

@ -400,14 +400,14 @@ func TestGetLatestCommitStatusForPairs(t *testing.T) {
}, pairs) }, pairs)
}) })
t.Run("Repo 62 nonexistant sha", func(t *testing.T) { t.Run("Repo 62 non-existent sha", func(t *testing.T) {
pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, []git_model.RepoSHA{{62, "774f93df12d14931ea93259ae93418da4482fcc"}}) pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, []git_model.RepoSHA{{62, "774f93df12d14931ea93259ae93418da4482fcc"}})
require.NoError(t, err) require.NoError(t, err)
assert.EqualValues(t, map[int64][]*git_model.CommitStatus{}, pairs) assert.EqualValues(t, map[int64][]*git_model.CommitStatus{}, pairs)
}) })
t.Run("SHA with non existant repo id", func(t *testing.T) { t.Run("SHA with non-existent repo id", func(t *testing.T) {
pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, []git_model.RepoSHA{{1, "774f93df12d14931ea93259ae93418da4482fcc1"}}) pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, []git_model.RepoSHA{{1, "774f93df12d14931ea93259ae93418da4482fcc1"}})
require.NoError(t, err) require.NoError(t, err)

View file

@ -23,8 +23,8 @@ func (repo *Repository) GetBranchCommitID(name string) (string, error) {
} }
// GetTagCommitID returns last commit ID string of given tag. If the tag is an // GetTagCommitID returns last commit ID string of given tag. If the tag is an
// annoted tag it will return the objectID of that tag instead of the commitID // annotated tag it will return the objectID of that tag instead of the commitID
// the tag is pointing to. `GetTagCommit` handles annoted tags correctly. // the tag is pointing to. `GetTagCommit` handles annotated tags correctly.
func (repo *Repository) GetTagCommitID(name string) (string, error) { func (repo *Repository) GetTagCommitID(name string) (string, error) {
return repo.GetRefCommitID(TagPrefix + name) return repo.GetRefCommitID(TagPrefix + name)
} }

View file

@ -202,7 +202,7 @@ func (b *Indexer) Index(ctx context.Context, repo *repo_model.Repository, sha st
func (b *Indexer) Delete(ctx context.Context, repoID int64) error { func (b *Indexer) Delete(ctx context.Context, repoID int64) error {
if err := b.doDelete(ctx, repoID); err != nil { if err := b.doDelete(ctx, repoID); err != nil {
// Maybe there is a conflict during the delete operation, so we should retry after a refresh // Maybe there is a conflict during the delete operation, so we should retry after a refresh
log.Warn("Deletion of entries of repo %v within index %v was erroneus. Trying to refresh index before trying again", repoID, b.inner.VersionedIndexName(), err) log.Warn("Deletion of entries of repo %v within index %v was erroneous. Trying to refresh index before trying again", repoID, b.inner.VersionedIndexName(), err)
if err := b.refreshIndex(ctx); err != nil { if err := b.refreshIndex(ctx); err != nil {
return err return err
} }

View file

@ -1,8 +1,8 @@
// Copyright 2024 The Forgejo Authors. All rights reserved. // Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Keying is a module that allows for subkeys to be determistically generated // Keying is a module that allows for subkeys to be deterministically generated
// from the same master key. It allows for domain seperation to take place by // from the same master key. It allows for domain separation to take place by
// using new keys for new subsystems/domains. These subkeys are provided with // using new keys for new subsystems/domains. These subkeys are provided with
// an API to encrypt and decrypt data. The module panics if a bad interaction // an API to encrypt and decrypt data. The module panics if a bad interaction
// happened, the panic should be seen as an non-recoverable error. // happened, the panic should be seen as an non-recoverable error.
@ -52,8 +52,8 @@ var (
ContextTOTP Context = "totp" ContextTOTP Context = "totp"
) )
// Derive *the* key for a given context, this is a determistic function. The // Derive *the* key for a given context, this is a deterministic function.
// same key will be provided for the same context. // The same key will be provided for the same context.
func DeriveKey(context Context) *Key { func DeriveKey(context Context) *Key {
if len(prk) == 0 { if len(prk) == 0 {
panic("keying: not initialized") panic("keying: not initialized")
@ -77,7 +77,7 @@ type Key struct {
// Encrypts the specified plaintext with some additional data that is tied to // Encrypts the specified plaintext with some additional data that is tied to
// this plaintext. The additional data can be seen as the context in which the // this plaintext. The additional data can be seen as the context in which the
// data is being encrypted for, this is different than the context for which the // data is being encrypted for, this is different than the context for which the
// key was derrived this allows for more granuality without deriving new keys. // key was derived; this allows for more granularity without deriving new keys.
// Avoid any user-generated data to be passed into the additional data. The most // Avoid any user-generated data to be passed into the additional data. The most
// common usage of this would be to encrypt a database field, in that case use // common usage of this would be to encrypt a database field, in that case use
// the ID and database column name as additional data. The additional data isn't // the ID and database column name as additional data. The additional data isn't

View file

@ -15,7 +15,7 @@ import (
) )
func TestKeying(t *testing.T) { func TestKeying(t *testing.T) {
t.Run("Not initalized", func(t *testing.T) { t.Run("Not initialized", func(t *testing.T) {
assert.Panics(t, func() { assert.Panics(t, func() {
keying.DeriveKey(keying.Context("TESTING")) keying.DeriveKey(keying.Context("TESTING"))
}) })
@ -25,7 +25,7 @@ func TestKeying(t *testing.T) {
keying.Init([]byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}) keying.Init([]byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07})
}) })
t.Run("Context seperation", func(t *testing.T) { t.Run("Context separation", func(t *testing.T) {
key1 := keying.DeriveKey(keying.Context("TESTING")) key1 := keying.DeriveKey(keying.Context("TESTING"))
key2 := keying.DeriveKey(keying.Context("TESTING2")) key2 := keying.DeriveKey(keying.Context("TESTING2"))
@ -49,20 +49,20 @@ func TestKeying(t *testing.T) {
cipherText = key.Encrypt(plainText, []byte{0x05, 0x06}) cipherText = key.Encrypt(plainText, []byte{0x05, 0x06})
cipherText2 := key.Encrypt(plainText, []byte{0x05, 0x06}) cipherText2 := key.Encrypt(plainText, []byte{0x05, 0x06})
// Ensure ciphertexts don't have an determistic output. // Ensure ciphertexts don't have an deterministic output.
assert.NotEqualValues(t, cipherText, cipherText2) assert.NotEqualValues(t, cipherText, cipherText2)
}) })
t.Run("Decrypt", func(t *testing.T) { t.Run("Decrypt", func(t *testing.T) {
key := keying.DeriveKey(context) key := keying.DeriveKey(context)
t.Run("Succesful", func(t *testing.T) { t.Run("Successful", func(t *testing.T) {
convertedPlainText, err := key.Decrypt(cipherText, []byte{0x05, 0x06}) convertedPlainText, err := key.Decrypt(cipherText, []byte{0x05, 0x06})
require.NoError(t, err) require.NoError(t, err)
assert.EqualValues(t, plainText, convertedPlainText) assert.EqualValues(t, plainText, convertedPlainText)
}) })
t.Run("Not enougn additional data", func(t *testing.T) { t.Run("Not enough additional data", func(t *testing.T) {
plainText, err := key.Decrypt(cipherText, []byte{0x05}) plainText, err := key.Decrypt(cipherText, []byte{0x05})
require.Error(t, err) require.Error(t, err)
assert.Empty(t, plainText) assert.Empty(t, plainText)

View file

@ -108,7 +108,7 @@ func DetectContentType(data []byte) SniffedType {
} }
} }
// AVIF is unsuported by http.DetectContentType // AVIF is unsupported by http.DetectContentType
// Signature taken from https://stackoverflow.com/a/68322450 // Signature taken from https://stackoverflow.com/a/68322450
if bytes.Index(data, []byte("ftypavif")) == 4 { if bytes.Index(data, []byte("ftypavif")) == 4 {
ct = AvifMimeType ct = AvifMimeType

View file

@ -4000,7 +4000,7 @@ func combineRequestReviewComments(issue *issues_model.Issue) {
} }
} }
// Propoagate creation time. // Propagate creation time.
prev.CreatedUnix = cur.CreatedUnix prev.CreatedUnix = cur.CreatedUnix
// Remove the current comment since it has been combined to prev comment // Remove the current comment since it has been combined to prev comment

View file

@ -49,7 +49,7 @@ type csrfProtector struct {
opt CsrfOptions opt CsrfOptions
// id must be unique per user. // id must be unique per user.
id string id string
// token is the valid one which wil be used by end user and passed via header, cookie, or hidden form value. // token is the valid one which will be used by end user and passed via header, cookie, or hidden form value.
token string token string
} }

View file

@ -479,7 +479,7 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R
return nil return nil
} }
// DeleteBranchAfterMerge deletes the head branch after a PR was merged assiociated with the head branch. // DeleteBranchAfterMerge deletes the head branch after a PR was merged associated with the head branch.
func DeleteBranchAfterMerge(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest, headRepo *git.Repository) error { func DeleteBranchAfterMerge(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest, headRepo *git.Repository) error {
// Don't cleanup when there are other PR's that use this branch as head branch. // Don't cleanup when there are other PR's that use this branch as head branch.
exist, err := issues_model.HasUnmergedPullRequestsByHeadInfo(ctx, pr.HeadRepoID, pr.HeadBranch) exist, err := issues_model.HasUnmergedPullRequestsByHeadInfo(ctx, pr.HeadRepoID, pr.HeadBranch)

View file

@ -120,7 +120,7 @@ because it might only look at file changes in your latest commit.
### Run e2e tests with another database ### Run e2e tests with another database
This approach is not currently used, This approach is not currently used,
neither in the CI/CD nor by core contributors on their lcoal machines. neither in the CI/CD nor by core contributors on their local machines.
It is still documented for the sake of completeness: It is still documented for the sake of completeness:
You can also perform e2e tests using MariaDB/MySQL or PostgreSQL if you want. You can also perform e2e tests using MariaDB/MySQL or PostgreSQL if you want.
@ -161,13 +161,13 @@ make test-e2e-sqlite#example
> This is not currently used by most Forgejo contributors. > This is not currently used by most Forgejo contributors.
> Your help to improve the situation and allow for visual testing is appreciated. > Your help to improve the situation and allow for visual testing is appreciated.
Although the main goal of e2e is assertion testing, we have added a framework for visual regress testing. If you are working on front-end features, please use the following: Although the main goal of e2e is assertion testing, we have added a framework for visual regression testing. If you are working on front-end features, please use the following:
- Check out `main`, `make clean frontend`, and run e2e tests with `VISUAL_TEST=1` to generate outputs. This will initially fail, as no screenshots exist. You can run the e2e tests again to assert it passes. - Check out `main`, `make clean frontend`, and run e2e tests with `VISUAL_TEST=1` to generate outputs. This will initially fail, as no screenshots exist. You can run the e2e tests again to assert that it passes.
- Check out your branch, `make clean frontend`, and run e2e tests with `VISUAL_TEST=1`. You should be able to assert you front-end changes don't break any other tests unintentionally. - Check out your branch, `make clean frontend`, and run e2e tests with `VISUAL_TEST=1`. You should be able to assert that your front-end changes don't break any other tests unintentionally.
VISUAL_TEST=1 will create screenshots in tests/e2e/test-snapshots. The test will fail the first time this is enabled (until we get visual test image persistence figured out), because it will be testing against an empty screenshot folder. `VISUAL_TEST=1` will create screenshots in tests/e2e/test-snapshots. The test will fail the first time this is enabled (until we get visual test image persistence figured out), because it will be testing against an empty screenshot folder.
ACCEPT_VISUAL=1 will overwrite the snapshot images with new images. `ACCEPT_VISUAL=1` will overwrite the snapshot images with new images.
## Tips and tricks ## Tips and tricks
@ -267,8 +267,8 @@ Run `make lint-frontend-fix`.
### Define new repos ### Define new repos
Take a look at `declare_repos_test.go` to see how to add your repositories. Take a look at `declare_repos_test.go` to see how to add your repositories.
Feel free to improve the logic used there if you need more advanced functionality Feel free to improve the logic used there if you need more advanced functionality,
(it is a simplified version of the code used in the integration tests). it is a simplified version of the code used in the integration tests.
### Accessibility testing ### Accessibility testing
@ -280,8 +280,7 @@ Take a look at `shared/forms.ts` and some other places for inspiration.
### List related files coverage ### List related files coverage
To speed up the CI pipelines and avoid running expensive tests too often, To speed up the CI pipelines and avoid running expensive tests too often,
only a selection of tests is run by default, only a selection of tests is run by default, based on the changed files.
based on the changed files.
At the top of each playwright test file, At the top of each playwright test file,
list the files or file patterns that are covered by your test. list the files or file patterns that are covered by your test.
@ -297,7 +296,7 @@ you won't detect broken visual appearance and there is little reason to watch CS
However, if your test also checks that an element is correctly positioned However, if your test also checks that an element is correctly positioned
(e.g. that it does not overflow the page), (e.g. that it does not overflow the page),
or has accessibiltiy properties (includes colour contrast), or has accessibility properties (includes colour contrast),
also list stylesheets that define the behaviour your test depends on. also list stylesheets that define the behaviour your test depends on.
Watching the place that generate the selectors you use Watching the place that generate the selectors you use
@ -305,8 +304,7 @@ Watching the place that generate the selectors you use
is a must, to ensure that someone modifying the markup notices that your selectors fail is a must, to ensure that someone modifying the markup notices that your selectors fail
(e.g. because an id or class was renamed). (e.g. because an id or class was renamed).
If you are unsure about the exact set of files, If you are unsure about the exact set of files, feel free to ask other contributors.
feel free to ask other contributors.
#### How to specify the patterns? #### How to specify the patterns?

View file

@ -10,7 +10,7 @@ export async function validate_form({page}: {page: Page}, scope: 'form' | 'field
]; ];
await accessibilityCheck({page}, [scope], excludedElements, []); await accessibilityCheck({page}, [scope], excludedElements, []);
// assert CSS properties that needed to be overriden for forms (ensure they remain active) // assert CSS properties that needed to be overridden for forms (ensure they remain active)
const boxes = page.getByRole('checkbox').or(page.getByRole('radio')); const boxes = page.getByRole('checkbox').or(page.getByRole('radio'));
for (const b of await boxes.all()) { for (const b of await boxes.all()) {
await expect(b).toHaveCSS('margin-left', '0px'); await expect(b).toHaveCSS('margin-left', '0px');
@ -25,7 +25,7 @@ export async function validate_form({page}: {page: Page}, scope: 'form' | 'field
expect(str.split('\n')[0]).not.toContain(':'); expect(str.split('\n')[0]).not.toContain(':');
} }
// check that multiple help text are correctly aligned to each other // check that multiple help texts are correctly aligned to each other
// used for example to separate read/write permissions in team permission matrix // used for example to separate read/write permissions in team permission matrix
for (const l of await page.locator('label:has(.help + .help)').all()) { for (const l of await page.locator('label:has(.help + .help)').all()) {
const helpLabels = await l.locator('.help').all(); const helpLabels = await l.locator('.help').all();

View file

@ -169,7 +169,7 @@ func TestCodeOwner(t *testing.T) {
_, err := db.GetEngine(db.DefaultContext).Cols("is_private").Update(repo) _, err := db.GetEngine(db.DefaultContext).Cols("is_private").Update(repo)
require.NoError(t, err) require.NoError(t, err)
err = os.WriteFile(path.Join(dstPath, "README.md"), []byte("## very senstive info"), 0o666) err = os.WriteFile(path.Join(dstPath, "README.md"), []byte("## very sensitive info"), 0o666)
require.NoError(t, err) require.NoError(t, err)
err = git.AddChanges(dstPath, true) err = git.AddChanges(dstPath, true)

View file

@ -140,7 +140,7 @@ func TestSyncRepoTags(t *testing.T) {
doGitClone(dstPath, u)(t) doGitClone(dstPath, u)(t)
_, _, err := git.NewCommand(git.DefaultContext, "tag", "v2", "-m", "this is an annoted tag").RunStdString(&git.RunOpts{Dir: dstPath}) _, _, err := git.NewCommand(git.DefaultContext, "tag", "v2", "-m", "this is an annotated tag").RunStdString(&git.RunOpts{Dir: dstPath})
require.NoError(t, err) require.NoError(t, err)
_, _, err = git.NewCommand(git.DefaultContext, "push", "--tags").RunStdString(&git.RunOpts{Dir: dstPath}) _, _, err = git.NewCommand(git.DefaultContext, "push", "--tags").RunStdString(&git.RunOpts{Dir: dstPath})
@ -152,10 +152,10 @@ func TestSyncRepoTags(t *testing.T) {
resp := MakeRequest(t, req, http.StatusOK) resp := MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body) htmlDoc := NewHTMLParser(t, resp.Body)
tagsTab := htmlDoc.Find(".release-list-title") tagsTab := htmlDoc.Find(".release-list-title")
assert.Contains(t, tagsTab.Text(), "this is an annoted tag") assert.Contains(t, tagsTab.Text(), "this is an annotated tag")
} }
// Make sure `SyncRepoTags` doesn't modify annoted tags. // Make sure `SyncRepoTags` doesn't modify annotated tags.
testTag(t) testTag(t)
require.NoError(t, repo_module.SyncRepoTags(git.DefaultContext, repo.ID)) require.NoError(t, repo_module.SyncRepoTags(git.DefaultContext, repo.ID))
testTag(t) testTag(t)

View file

@ -189,7 +189,7 @@ class ComboMarkdownEditor {
const newTableModal = document.querySelector(`div[data-markdown-table-modal-id="${elementId}"]`); const newTableModal = document.querySelector(`div[data-markdown-table-modal-id="${elementId}"]`);
const form = newTableModal.querySelector('div[data-selector-name="form"]'); const form = newTableModal.querySelector('div[data-selector-name="form"]');
// Vaildate input fields // Validate input fields
for (const currentInput of form.querySelectorAll('input')) { for (const currentInput of form.querySelectorAll('input')) {
if (!currentInput.checkValidity()) { if (!currentInput.checkValidity()) {
currentInput.reportValidity(); currentInput.reportValidity();