diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b7594a1ba7..91d001e078 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,10 +1,11 @@ Please check the following: 1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for backports. -2. Make sure you have read contributing guidelines: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md . -3. For documentations contribution, please go to https://gitea.com/gitea/docs -4. Describe what your pull request does and which issue you're targeting (if any). -5. It is recommended to enable "Allow edits by maintainers", so maintainers can help more easily. -6. Your input here will be included in the commit message when this PR has been merged. If you don't want some content to be included, please separate them with a line like `---`. -7. Delete all these tips before posting. +2. Use a Conventional Commits PR title, for example `fix(repo): handle empty branch names`. +3. Make sure you have read contributing guidelines: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md . +4. For documentations contribution, please go to https://gitea.com/gitea/docs +5. Describe what your pull request does and which issue you're targeting (if any). +6. It is recommended to enable "Allow edits by maintainers", so maintainers can help more easily. +7. Your input here will be included in the commit message when this PR has been merged. If you don't want some content to be included, please separate them with a line like `---`. +8. Delete all these tips before posting. diff --git a/.github/workflows/cache-seeder.yml b/.github/workflows/cache-seeder.yml index cd086fae17..b0f3ca97de 100644 --- a/.github/workflows/cache-seeder.yml +++ b/.github/workflows/cache-seeder.yml @@ -45,8 +45,7 @@ jobs: cache-name: seed - run: make deps-backend - run: TAGS="bindata" make backend - - run: TAGS="bindata sqlite sqlite_unlock_notify" make backend - - run: TAGS="bindata gogit sqlite sqlite_unlock_notify" GOEXPERIMENT="" make backend + - run: TAGS="bindata gogit" GOEXPERIMENT="" make backend lint: runs-on: ubuntu-latest @@ -54,9 +53,9 @@ jobs: fail-fast: false matrix: include: - - { job: lint-backend, tags: "bindata sqlite sqlite_unlock_notify", target: "lint-backend" } - - { job: lint-go-windows, tags: "bindata sqlite sqlite_unlock_notify", target: "lint-go-windows" } - - { job: lint-go-gogit, tags: "bindata gogit sqlite sqlite_unlock_notify", target: "lint-go" } + - { job: lint-backend, tags: "bindata", target: "lint-backend" } + - { job: lint-go-windows, tags: "bindata", target: "lint-go-windows" } + - { job: lint-go-gogit, tags: "bindata gogit", target: "lint-go" } steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 diff --git a/.github/workflows/cron-renovate.yml b/.github/workflows/cron-renovate.yml index 39bcf26ac9..9ebe1fec32 100644 --- a/.github/workflows/cron-renovate.yml +++ b/.github/workflows/cron-renovate.yml @@ -2,7 +2,7 @@ name: cron-renovate on: schedule: - - cron: "0 1 * * *" # daily at 01:00 UTC + - cron: "23 * * * *" # hourly at :23 workflow_dispatch: concurrency: @@ -21,12 +21,12 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: renovatebot/github-action@83ec54fee49ab67d9cd201084c1ff325b4b462e4 # v46.1.10 + - uses: renovatebot/github-action@f66d8679fcfcfa051abde6e7a623007173bf5164 # v46.1.12 with: renovate-version: ${{ env.RENOVATE_VERSION }} configurationFile: renovate.json5 token: ${{ secrets.RENOVATE_TOKEN }} env: RENOVATE_BINARY_SOURCE: install # auto-install go/node toolchains needed by post-upgrade tasks. - RENOVATE_ALLOWED_POST_UPGRADE_COMMANDS: '["^make (tidy|svg)$"]' + RENOVATE_ALLOWED_POST_UPGRADE_COMMANDS: '["^make (tidy|svg nolyfill)$"]' RENOVATE_REPOSITORIES: '["go-gitea/gitea"]' diff --git a/.github/workflows/pull-compliance.yml b/.github/workflows/pull-compliance.yml index dc46c9fa42..3d7e9f8be8 100644 --- a/.github/workflows/pull-compliance.yml +++ b/.github/workflows/pull-compliance.yml @@ -32,7 +32,7 @@ jobs: - run: make deps-backend deps-tools - run: make lint-backend env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata lint-on-demand: needs: files-changed @@ -82,7 +82,7 @@ jobs: - run: make deps-backend deps-tools - run: make lint-go-windows env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata GOOS: windows GOARCH: amd64 @@ -104,7 +104,7 @@ jobs: - run: make deps-backend deps-tools - run: make lint-go env: - TAGS: bindata gogit sqlite sqlite_unlock_notify + TAGS: bindata gogit checks-backend: if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' diff --git a/.github/workflows/pull-db-tests.yml b/.github/workflows/pull-db-tests.yml index c2293ac853..b750a9c264 100644 --- a/.github/workflows/pull-db-tests.yml +++ b/.github/workflows/pull-db-tests.yml @@ -34,7 +34,7 @@ jobs: minio: # as github actions doesn't support "entrypoint", we need to use a non-official image # that has a custom entrypoint set to "minio server /data" - image: bitnamilegacy/minio:2023.8.31 + image: bitnamilegacy/minio:2023.12.23 env: MINIO_ROOT_USER: 123456 MINIO_ROOT_PASSWORD: 12345678 @@ -62,6 +62,8 @@ jobs: run: GITEA_TEST_DATABASE=pgsql make test-integration timeout-minutes: 50 env: + # pgsql is chosen to be the unlucky one to run with the slow "race detector", it is about 60% slower. + GOTEST_FLAGS: -race -timeout=40m TAGS: bindata gogit TEST_LDAP: 1 @@ -82,7 +84,7 @@ jobs: - run: make deps-backend - run: make backend env: - TAGS: bindata gogit sqlite sqlite_unlock_notify + TAGS: bindata gogit GOEXPERIMENT: - name: run migration tests run: GITEA_TEST_DATABASE=sqlite make test-migration @@ -92,9 +94,10 @@ jobs: run: GITEA_TEST_DATABASE=sqlite make test-integration timeout-minutes: 50 env: + # sqlite driver can contain large amount of Golang code, so don't use race detector for it, otherwise, extremely slow + GOTEST_FLAGS: -timeout=40m TAGS: bindata gogit GOEXPERIMENT: - GOTEST_FLAGS: -race -timeout=40m test-unit: if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' @@ -124,7 +127,7 @@ jobs: ports: - 6379:6379 minio: - image: bitnamilegacy/minio:2021.3.17 + image: bitnamilegacy/minio:2021.12.29 env: MINIO_ACCESS_KEY: 123456 MINIO_SECRET_KEY: 12345678 @@ -154,15 +157,15 @@ jobs: - name: unit-tests run: make test-backend test-check env: - TAGS: bindata sqlite sqlite_unlock_notify GOTEST_FLAGS: -race -timeout=20m + TAGS: bindata GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }} - name: unit-tests-gogit run: make test-backend test-check env: - TAGS: bindata gogit sqlite sqlite_unlock_notify - GOEXPERIMENT: GOTEST_FLAGS: -race -timeout=20m + TAGS: bindata gogit + GOEXPERIMENT: GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }} test-mysql: @@ -172,7 +175,7 @@ jobs: services: mysql: # the bitnami mysql image has more options than the official one, it's easier to customize - image: bitnamilegacy/mysql:8.0 + image: bitnamilegacy/mysql:8.4 env: ALLOW_EMPTY_PASSWORD: true MYSQL_DATABASE: testgitea diff --git a/.github/workflows/pull-e2e-tests.yml b/.github/workflows/pull-e2e-tests.yml index 974d82ea5e..6743e6c37a 100644 --- a/.github/workflows/pull-e2e-tests.yml +++ b/.github/workflows/pull-e2e-tests.yml @@ -40,11 +40,11 @@ jobs: - run: make deps-backend - run: make backend env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata - run: make playwright - run: make test-e2e timeout-minutes: 10 env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata FORCE_COLOR: 1 GITEA_TEST_E2E_DEBUG: 1 diff --git a/.github/workflows/pull-pr-title.yml b/.github/workflows/pull-pr-title.yml new file mode 100644 index 0000000000..59b0e78c40 --- /dev/null +++ b/.github/workflows/pull-pr-title.yml @@ -0,0 +1,28 @@ +name: pr-title + +on: + pull_request: + types: + - opened + - edited + - reopened + - synchronize + - ready_for_review + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + lint-pr-title: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - run: make lint-pr-title + env: + PR_TITLE: ${{ github.event.pull_request.title }} diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index a5fa452ef3..ee5c4fcfb6 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -32,7 +32,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 diff --git a/.github/workflows/release-tag-rc.yml b/.github/workflows/release-tag-rc.yml index 2e0f2dd5c0..05b56b6a2b 100644 --- a/.github/workflows/release-tag-rc.yml +++ b/.github/workflows/release-tag-rc.yml @@ -33,7 +33,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 diff --git a/.github/workflows/release-tag-version.yml b/.github/workflows/release-tag-version.yml index 2e7a9f5f54..da99fb072d 100644 --- a/.github/workflows/release-tag-version.yml +++ b/.github/workflows/release-tag-version.yml @@ -36,7 +36,7 @@ jobs: # xgo build - run: make release env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: bindata - name: import gpg key id: import_gpg uses: crazy-max/ghaction-import-gpg@2dc316deee8e90f13e1a351ab510b4d5bc0c82cd # v7.0.0 diff --git a/AGENTS.md b/AGENTS.md index fd87f432b7..16770e49fc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,11 +2,12 @@ - Run `make fmt` to format `.go` files, and run `make lint-go` to lint them - Run `make lint-js` to lint `.ts` files - Run `make tidy` after any `go.mod` changes -- Run single go tests with `go test -tags 'sqlite sqlite_unlock_notify' -run '^TestName$' ./modulepath/` +- Run single go tests with `go test -run '^TestName$' ./modulepath/` - Run single js test files with `pnpm exec vitest ` - Run single playwright e2e test files with `GITEA_TEST_E2E_FLAGS='' make test-e2e` - Add the current year into the copyright header of new `.go` files - Ensure no trailing whitespace in edited files +- Use Conventional Commits format for commit messages and PR titles (e.g. `type(scope): subject`) - Never force-push, amend, or squash unless asked. Use new commits and normal push for pull request updates - Preserve existing code comments, do not remove or rewrite comments that are still relevant - In TypeScript, use `!` (non-null assertion) instead of `?.`/`??` when a value is known to always exist diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b6b94269..f807f16b3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1383,7 +1383,7 @@ been added to each release, please refer to the [blog](https://blog.gitea.com). * Fix mCaptcha bug (#33659) (#33661) * Git graph: don't show detached commits (#33645) (#33650) * Use MatchPhraseQuery for bleve code search (#33628) - * Adjust appearence of commit status webhook (#33778) #33789 + * Adjust appearance of commit status webhook (#33778) #33789 * Upgrade golang net from 0.35.0 -> 0.36.0 (#33795) #33796 ## [1.23.4](https://github.com/go-gitea/gitea/releases/tag/v1.23.4) - 2025-02-16 @@ -2114,7 +2114,7 @@ been added to each release, please refer to the [blog](https://blog.gitea.com). * Optimize repo-list layout to enhance visual experience (#31272) (#31276) * fixed the dropdown menu for the top New button to expand to the left (#31273) (#31275) * Fix Activity Page Contributors dropdown (#31264) (#31269) - * fix: allow actions artifacts storage migration to complete succesfully (#31251) (#31257) + * fix: allow actions artifacts storage migration to complete successfully (#31251) (#31257) * Make blockquote attention recognize more syntaxes (#31240) (#31250) * Remove .segment from .project-column (#31204) (#31239) * Ignore FindRecentlyPushedNewBranches err (#31164) (#31171) @@ -2298,7 +2298,7 @@ Key highlights of this release encompass significant changes categorized under ` * Performance optimization for git push and check permissions for push options (#30104) (#30354) * BUGFIXES * Fix close file in the Upload func (#30262) (#30269) - * Fix inline math blocks can't be preceeded/followed by alphanumerical characters (#30175) (#30250) + * Fix inline math blocks can't be preceded/followed by alphanumerical characters (#30175) (#30250) * Fix missing 0 prefix of GPG key id (#30245) (#30247) * Include encoding in signature payload (#30174) (#30181) * Move from `max( id )` to `max( index )` for latest commit statuses (#30076) (#30155) @@ -5590,7 +5590,7 @@ Key highlights of this release encompass significant changes categorized under ` * Fix navbar on project view (#17749) * More pleasantly handle broken or missing git repositories (#17747) * Use `*PushUpdateOptions` as receiver (#17724) - * Remove unused `user` paramater (#17723) + * Remove unused `user` parameter (#17723) * Better builtin avatar generator (#17707) * Cleanup and use global style on popups (#17674) * Move user/org deletion to services (#17673) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1871f1470..27103a991b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -189,6 +189,22 @@ In the PR title, describe the problem you are fixing, not how you are fixing it. Use the first comment as a summary of your PR. \ In the PR summary, you can describe exactly how you are fixing this problem. +PR titles must follow the [Conventional Commits](https://www.conventionalcommits.org/) format, because PRs are squash-merged and the PR title becomes the resulting commit message: + +```text +type(scope)!: subject +``` + +The allowed types are `build`, `chore`, `ci`, `docs`, `feat`, `fix`, `perf`, `refactor`, `revert`, `style`, and `test`. The generic `chore` type is intentionally not accepted; pick a more descriptive type instead. + +Examples: + +```text +fix(web): prevent avatar upload crash on empty file +feat(api): add pagination to repo hooks list +ci(workflows): lint PR titles with commitlint +``` + Keep this summary up-to-date as the PR evolves. \ If your PR changes the UI, you must add **after** screenshots in the PR summary. \ If you are not implementing a new feature, you should also post **before** screenshots for comparison. diff --git a/Dockerfile b/Dockerfile index 323f06125f..b4f3e21c64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN make frontend FROM docker.io/library/golang:1.26-alpine3.23 AS build-env ARG GITEA_VERSION -ARG TAGS="sqlite sqlite_unlock_notify" +ARG TAGS="" ENV TAGS="bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 83c69cbd51..3edf85738a 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -12,7 +12,7 @@ RUN make frontend FROM docker.io/library/golang:1.26-alpine3.23 AS build-env ARG GITEA_VERSION -ARG TAGS="sqlite sqlite_unlock_notify" +ARG TAGS="" ENV TAGS="bindata timetzdata $TAGS" ARG CGO_EXTRA_CFLAGS diff --git a/Makefile b/Makefile index ad7739c07b..a1f81738de 100644 --- a/Makefile +++ b/Makefile @@ -38,13 +38,10 @@ ifneq ($(findstring test-,$(MAKECMDGOALS)),) endif TAGS ?= -ifeq ($(GITEA_TEST_DATABASE),sqlite) - TAGS += sqlite sqlite_unlock_notify -endif TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags CGO_ENABLED ?= 0 -ifneq (,$(findstring sqlite,$(TAGS))$(findstring pam,$(TAGS))) +ifneq (,$(findstring sqlite_mattn,$(TAGS))$(findstring pam,$(TAGS))) CGO_ENABLED = 1 endif @@ -321,6 +318,10 @@ lint-md: node_modules ## lint markdown files lint-md-fix: node_modules ## lint markdown files and fix issues pnpm exec markdownlint --fix *.md +.PHONY: lint-pr-title +lint-pr-title: ## lint PR title against Conventional Commits (set PR_TITLE=...) + @node ./tools/lint-pr-title.js + .PHONY: lint-spell lint-spell: ## lint spelling @git ls-files $(SPELLCHECK_FILES) | xargs go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -error @@ -606,6 +607,11 @@ update-js: node_modules ## update js dependencies pnpm exec updates -u -f package.json rm -rf node_modules pnpm-lock.yaml pnpm install + @touch node_modules + $(MAKE) --no-print-directory nolyfill + +.PHONY: nolyfill +nolyfill: node_modules ## apply nolyfill overrides to package.json and relock pnpm exec nolyfill install pnpm install @touch node_modules diff --git a/README.md b/README.md index 7ebeac97be..4c4fedd3b8 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,6 @@ From the root of the source tree, run: TAGS="bindata" make build -or if SQLite support is required: - - TAGS="bindata sqlite sqlite_unlock_notify" make build - The `build` target is split into two sub-targets: - `make backend` which requires [Go Stable](https://go.dev/dl/), the required version is defined in [go.mod](/go.mod). diff --git a/README.zh-cn.md b/README.zh-cn.md index 8ccacc0fea..52c7781831 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -38,10 +38,6 @@ TAGS="bindata" make build -如果需要 SQLite 支持: - - TAGS="bindata sqlite sqlite_unlock_notify" make build - `build` 目标分为两个子目标: - `make backend` 需要 [Go Stable](https://go.dev/dl/),所需版本在 [go.mod](/go.mod) 中定义。 diff --git a/README.zh-tw.md b/README.zh-tw.md index 4160fd0bd9..77ad6828db 100644 --- a/README.zh-tw.md +++ b/README.zh-tw.md @@ -38,10 +38,6 @@ TAGS="bindata" make build -如果需要 SQLite 支援: - - TAGS="bindata sqlite sqlite_unlock_notify" make build - `build` 目標分為兩個子目標: - `make backend` 需要 [Go Stable](https://go.dev/dl/),所需版本在 [go.mod](/go.mod) 中定義。 diff --git a/assets/go-licenses.json b/assets/go-licenses.json index 0f2913a6ad..f6fcd2fbdf 100644 --- a/assets/go-licenses.json +++ b/assets/go-licenses.json @@ -39,6 +39,16 @@ "path": "filippo.io/edwards25519/LICENSE", "licenseText": "Copyright (c) 2009 The Go Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" }, + { + "name": "gitea.com/gitea/runner", + "path": "gitea.com/gitea/runner/LICENSE", + "licenseText": "Copyright (c) 2022 The Gitea Authors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n" + }, + { + "name": "gitea.com/gitea/runner/act", + "path": "gitea.com/gitea/runner/act/LICENSE", + "licenseText": "MIT License\n\nCopyright (c) 2022 The Gitea Authors\nCopyright (c) 2019\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" + }, { "name": "gitea.com/go-chi/binding", "path": "gitea.com/go-chi/binding/LICENSE", @@ -959,11 +969,6 @@ "path": "github.com/munnerz/goautoneg/LICENSE", "licenseText": "Copyright (c) 2011, Open Knowledge Foundation Ltd.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in\n the documentation and/or other materials provided with the\n distribution.\n\n Neither the name of the Open Knowledge Foundation Ltd. nor the\n names of its contributors may be used to endorse or promote\n products derived from this software without specific prior written\n permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nHOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" }, - { - "name": "github.com/nektos/act", - "path": "github.com/nektos/act/LICENSE", - "licenseText": "MIT License\n\nCopyright (c) 2022 The Gitea Authors\nCopyright (c) 2019\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" - }, { "name": "github.com/niklasfasching/go-org", "path": "github.com/niklasfasching/go-org/LICENSE", @@ -1079,6 +1084,11 @@ "path": "github.com/redis/go-redis/v9/LICENSE", "licenseText": "Copyright (c) 2013 The github.com/redis/go-redis Authors.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" }, + { + "name": "github.com/remyoudompheng/bigfft", + "path": "github.com/remyoudompheng/bigfft/LICENSE", + "licenseText": "Copyright (c) 2012 The Go Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + }, { "name": "github.com/rhysd/actionlint", "path": "github.com/rhysd/actionlint/LICENSE.txt", @@ -1364,6 +1374,26 @@ "path": "gopkg.in/yaml.v3/LICENSE", "licenseText": "\nThis project is covered by two different licenses: MIT and Apache.\n\n#### MIT License ####\n\nThe following files were ported to Go from C files of libyaml, and thus\nare still covered by their original MIT license, with the additional\ncopyright staring in 2011 when the project was ported over:\n\n apic.go emitterc.go parserc.go readerc.go scannerc.go\n writerc.go yamlh.go yamlprivateh.go\n\nCopyright (c) 2006-2010 Kirill Simonov\nCopyright (c) 2006-2011 Kirill Simonov\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n### Apache License ###\n\nAll the remaining project files are covered by the Apache license:\n\nCopyright (c) 2011-2019 Canonical Ltd\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n" }, + { + "name": "modernc.org/libc", + "path": "modernc.org/libc/LICENSE", + "licenseText": "Copyright (c) 2017 The Libc Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the names of the authors nor the names of the\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + }, + { + "name": "modernc.org/mathutil", + "path": "modernc.org/mathutil/LICENSE", + "licenseText": "Copyright (c) 2014 The mathutil Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the names of the authors nor the names of the\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + }, + { + "name": "modernc.org/memory", + "path": "modernc.org/memory/LICENSE", + "licenseText": "Copyright (c) 2017 The Memory Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n * Neither the names of the authors nor the names of the\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + }, + { + "name": "modernc.org/sqlite", + "path": "modernc.org/sqlite/LICENSE", + "licenseText": "Copyright (c) 2017 The Sqlite Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its contributors\nmay be used to endorse or promote products derived from this software without\nspecific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" + }, { "name": "mvdan.cc/xurls/v2", "path": "mvdan.cc/xurls/v2/LICENSE", diff --git a/contrib/ide/vscode/launch.json b/contrib/ide/vscode/launch.json index b80b826fc0..048428fc27 100644 --- a/contrib/ide/vscode/launch.json +++ b/contrib/ide/vscode/launch.json @@ -13,19 +13,6 @@ }, "args": ["web"], "showLog": true - }, - { - "name": "Launch (with SQLite3)", - "type": "go", - "request": "launch", - "mode": "debug", - "buildFlags": "-tags='sqlite sqlite_unlock_notify'", - "program": "${workspaceRoot}/main.go", - "env": { - "GITEA_WORK_DIR": "${workspaceRoot}", - }, - "args": ["web"], - "showLog": true } ] } diff --git a/contrib/ide/vscode/settings.json b/contrib/ide/vscode/settings.json index e33bccf902..d968e4daca 100644 --- a/contrib/ide/vscode/settings.json +++ b/contrib/ide/vscode/settings.json @@ -1,4 +1,4 @@ { - "go.buildTags": "'sqlite sqlite_unlock_notify'", + "go.buildTags": "", "go.testFlags": ["-v"] -} \ No newline at end of file +} diff --git a/contrib/ide/vscode/tasks.json b/contrib/ide/vscode/tasks.json index e35ae303b2..490e30338b 100644 --- a/contrib/ide/vscode/tasks.json +++ b/contrib/ide/vscode/tasks.json @@ -22,28 +22,6 @@ "args": ["build", "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""] }, "problemMatcher": ["$go"] - }, - { - "label": "Build (with SQLite3)", - "type": "shell", - "command": "go", - "group": "build", - "presentation": { - "echo": true, - "reveal": "always", - "focus": false, - "panel": "shared" - }, - "linux": { - "args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea", "${workspaceRoot}/main.go"] - }, - "osx": { - "args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea", "${workspaceRoot}/main.go"] - }, - "windows": { - "args": ["build", "-tags=\"sqlite sqlite_unlock_notify\"", "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""] - }, - "problemMatcher": ["$go"] } ] } diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index dd62cf8e83..2498050f5d 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -383,7 +383,7 @@ USER = root ;; ;DB_TYPE = sqlite3 ;PATH= ; defaults to data/gitea.db -;SQLITE_TIMEOUT = ; Query timeout defaults to: 500 +;SQLITE_TIMEOUT = ; Query timeout in milliseconds, defaults to: 20000 ;SQLITE_JOURNAL_MODE = ; defaults to sqlite database default (often DELETE), can be used to enable WAL mode. https://www.sqlite.org/pragma.html#pragma_journal_mode ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/flake.nix b/flake.nix index 7b9fbb193c..ca88b581a2 100644 --- a/flake.nix +++ b/flake.nix @@ -83,7 +83,7 @@ GO = "${go}/bin/go"; GOROOT = "${go}/share/go"; - TAGS = "sqlite sqlite_unlock_notify"; + TAGS = ""; STATIC = "true"; } // linuxOnlyEnv; diff --git a/go.mod b/go.mod index 4cd9a77a1f..bc88c0b79b 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( code.gitea.io/sdk/gitea v0.24.1 codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570 connectrpc.com/connect v1.19.2 + gitea.com/gitea/runner v1.0.0 gitea.com/go-chi/binding v0.0.0-20260414111559-654cea7ac60a gitea.com/go-chi/cache v0.2.1 gitea.com/go-chi/captcha v0.0.0-20240315150714-fb487f629098 @@ -20,8 +21,8 @@ require ( gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4 github.com/42wim/httpsig v1.2.4 github.com/42wim/sshsig v0.0.0-20260317195500-b9f38cf0d432 - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.0 - github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 + github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.3 github.com/Azure/go-ntlmssp v0.1.1 github.com/ProtonMail/go-crypto v1.4.1 github.com/PuerkitoBio/goquery v1.12.0 @@ -34,7 +35,7 @@ require ( github.com/bohde/codel v0.2.0 github.com/buildkite/terminal-to-html/v3 v3.16.8 github.com/caddyserver/certmagic v0.25.3 - github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20251013092601-6327009efd21 + github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20260309112543-12416315a635 github.com/chi-middleware/proxy v1.1.1 github.com/dimiro1/reply v0.0.0-20200315094148-d0136a4c9e21 github.com/dlclark/regexp2 v1.12.0 @@ -70,7 +71,7 @@ require ( github.com/hashicorp/go-version v1.9.0 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/huandu/xstrings v1.5.0 - github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 + github.com/jaytaylor/html2text v0.0.0-20260303211410-1a4bdc82ecec github.com/jhillyerd/enmime/v2 v2.3.0 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/klauspost/compress v1.18.6 @@ -82,10 +83,9 @@ require ( github.com/meilisearch/meilisearch-go v0.36.2 github.com/mholt/archives v0.1.5 github.com/microcosm-cc/bluemonday v1.0.27 - github.com/microsoft/go-mssqldb v1.9.6 + github.com/microsoft/go-mssqldb v1.9.7 github.com/minio/minio-go/v7 v7.1.0 github.com/msteinert/pam/v2 v2.1.0 - github.com/nektos/act v0.2.63 github.com/niklasfasching/go-org v1.9.1 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.1 @@ -102,7 +102,7 @@ require ( github.com/tstranex/u2f v1.0.0 github.com/ulikunitz/xz v0.5.15 github.com/urfave/cli-docs/v3 v3.1.0 - github.com/urfave/cli/v3 v3.4.1 + github.com/urfave/cli/v3 v3.6.1 github.com/wneessen/go-mail v0.7.2 github.com/xeipuuv/gojsonschema v1.2.0 github.com/yohcop/openid-go v1.0.1 @@ -121,6 +121,7 @@ require ( google.golang.org/protobuf v1.36.11 gopkg.in/ini.v1 v1.67.2 gopkg.in/yaml.v3 v3.0.1 + modernc.org/sqlite v1.50.0 mvdan.cc/xurls/v2 v2.6.0 strk.kbt.io/projects/go/libravatar v0.0.0-20260301104140-add494e31dab xorm.io/builder v0.3.13 @@ -238,6 +239,7 @@ require ( github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 // indirect github.com/mschoch/smat v0.2.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/ncruces/go-strftime v1.0.0 // indirect github.com/nwaples/rardecode/v2 v2.2.2 // indirect github.com/oasdiff/yaml v0.0.9 // indirect github.com/oasdiff/yaml3 v0.0.12 // indirect @@ -255,6 +257,7 @@ require ( github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.67.5 // indirect github.com/prometheus/procfs v0.20.1 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rhysd/actionlint v1.7.12 // indirect github.com/rs/xid v1.6.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect @@ -288,6 +291,9 @@ require ( golang.org/x/tools v0.44.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20260401020348-3a24fdc17823 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + modernc.org/libc v1.72.0 // indirect + modernc.org/mathutil v1.7.1 // indirect + modernc.org/memory v1.11.0 // indirect ) ignore ( @@ -301,10 +307,6 @@ ignore ( replace github.com/jaytaylor/html2text => github.com/Necoro/html2text v0.0.0-20250804200300-7bf1ce1c7347 // jaytaylor/html2text is unmaintained -replace github.com/nektos/act => gitea.com/gitea/act v0.261.10 // gitea maintains its own package - -replace github.com/urfave/cli/v3 => github.com/urfave/cli/v3 v3.4.1 // v3.6.2 breaks -c flag parsing in help commands - replace go.yaml.in/yaml/v4 => go.yaml.in/yaml/v4 v4.0.0-rc.3 // rc.4 changes block scalar serialization, wait for stable release replace github.com/Azure/azure-sdk-for-go/sdk/azcore => github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.0 // v1.21.0+ uses API version unsupported by Azurite in CI diff --git a/go.sum b/go.sum index 2574251eec..82849a19f6 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo= filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc= -gitea.com/gitea/act v0.261.10 h1:ndwbtuMXXz1dpYF2iwY1/PkgKNETo4jmPXfinTZt8cs= -gitea.com/gitea/act v0.261.10/go.mod h1:oIkqQHvU0lfuIWwcpqa4FmU+t3prA89tgkuHUTsrI2c= +gitea.com/gitea/runner v1.0.0 h1:s3AS5u8r+B5W+Gy69sYYvCVTb0f23fRM6H+CbrFrobE= +gitea.com/gitea/runner v1.0.0/go.mod h1:bn+8Qt3KyvdVQHD3OR2yRoKgEXs8dXqwBVtmfYVrNIE= gitea.com/go-chi/binding v0.0.0-20260414111559-654cea7ac60a h1:JHoBrfuTSF9Ke9aNfSYj1XRPBHjKPgCApVprnt2Am0M= gitea.com/go-chi/binding v0.0.0-20260414111559-654cea7ac60a/go.mod h1:FOsLJIMdpiHzBp3Vby6Wfkdw2ppGscrjgU1IC7E4/zQ= gitea.com/go-chi/cache v0.2.1 h1:bfAPkvXlbcZxPCpcmDVCWoHgiBSBmZN/QosnZvEC0+g= @@ -195,8 +195,8 @@ github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a h1:MISbI8sU/PSK/ github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a/go.mod h1:2GxOXOlEPAMFPfp014mK1SWq8G8BN8o7/dfYqJrVGn8= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20251013092601-6327009efd21 h1:2d64+4Jek9vjYwhY93AjbleiVH+AeWvPwPmDi1mfKFQ= -github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20251013092601-6327009efd21/go.mod h1:fNlYtCHWTRC8MofQERZkVUNUWaOvZeTBqHn/amSbKZI= +github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20260309112543-12416315a635 h1:RwCfD5XyO8jAermEy6pauh5Q5o6mCvbeNcCPOZlIA5o= +github.com/charmbracelet/git-lfs-transfer v0.1.1-0.20260309112543-12416315a635/go.mod h1:R+SetERD4+IL7QH0WHp9MLifvITvh9gL3g8vX1j2Fcs= github.com/chi-middleware/proxy v1.1.1 h1:4HaXUp8o2+bhHr1OhVy+VjN0+L7/07JDcn6v7YrTjrQ= github.com/chi-middleware/proxy v1.1.1/go.mod h1:jQwMEJct2tz9VmtCELxvnXoMfa+SOdikvbVJVHv/M+0= github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= @@ -563,8 +563,8 @@ github.com/msteinert/pam/v2 v2.1.0 h1:er5F9TKV5nGFuTt12ubtqPHEUdeBwReP7vd3wovidG github.com/msteinert/pam/v2 v2.1.0/go.mod h1:KT28NNIcDFf3PcBmNI2mIGO4zZJ+9RSs/At2PB3IDVc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= -github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= +github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/niklasfasching/go-org v1.9.1 h1:/3s4uTPOF06pImGa2Yvlp24yKXZoTYM+nsIlMzfpg/0= github.com/niklasfasching/go-org v1.9.1/go.mod h1:ZAGFFkWvUQcpazmi/8nHqwvARpr1xpb+Es67oUGX/48= github.com/nwaples/rardecode/v2 v2.2.2 h1:/5oL8dzYivRM/tqX9VcTSWfbpwcbwKG1QtSJr3b3KcU= @@ -686,8 +686,9 @@ github.com/steveyen/gtreap v0.1.0/go.mod h1:kl/5J7XbrOmlIbYIXdRHDDE5QxHqpk0cmkT7 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= +github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -719,8 +720,8 @@ github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs= github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= github.com/urfave/cli-docs/v3 v3.1.0 h1:Sa5xm19IpE5gpm6tZzXdfjdFxn67PnEsE4dpXF7vsKw= github.com/urfave/cli-docs/v3 v3.1.0/go.mod h1:59d+5Hz1h6GSGJ10cvcEkbIe3j233t4XDqI72UIx7to= -github.com/urfave/cli/v3 v3.4.1 h1:1M9UOCy5bLmGnuu1yn3t3CB4rG79Rtoxuv1sPhnm6qM= -github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo= +github.com/urfave/cli/v3 v3.6.1 h1:j8Qq8NyUawj/7rTYdBGrxcH7A/j7/G8Q5LhWEW4G3Mo= +github.com/urfave/cli/v3 v3.6.1/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/wneessen/go-mail v0.7.2 h1:xxPnhZ6IZLSgxShebmZ6DPKh1b6OJcoHfzy7UjOkzS8= github.com/wneessen/go-mail v0.7.2/go.mod h1:+TkW6QP3EVkgTEqHtVmnAE/1MRhmzb8Y9/W3pweuS+k= @@ -951,24 +952,32 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= -lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= -modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= -modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw= -modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= -modernc.org/libc v1.55.3 h1:AzcW1mhlPNrRtjS5sS+eW2ISCgSOLLNyFzRh/V3Qj/U= -modernc.org/libc v1.55.3/go.mod h1:qFXepLhz+JjFThQ4kzwzOjA/y/artDeg+pcYnY+Q83w= -modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= -modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= -modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= -modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU= -modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= -modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/sqlite v1.20.4 h1:J8+m2trkN+KKoE7jglyHYYYiaq5xmz2HoHJIiBlRzbE= -modernc.org/sqlite v1.20.4/go.mod h1:zKcGyrICaxNTMEHSr1HQ2GUraP0j+845GYw37+EyT6A= -modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= -modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= +modernc.org/cc/v4 v4.27.3 h1:uNCgn37E5U09mTv1XgskEVUJ8ADKpmFMPxzGJ0TSo+U= +modernc.org/cc/v4 v4.27.3/go.mod h1:3YjcbCqhoTTHPycJDRl2WZKKFj0nwcOIPBfEZK0Hdk8= +modernc.org/ccgo/v4 v4.32.4 h1:L5OB8rpEX4ZsXEQwGozRfJyJSFHbbNVOoQ59DU9/KuU= +modernc.org/ccgo/v4 v4.32.4/go.mod h1:lY7f+fiTDHfcv6YlRgSkxYfhs+UvOEEzj49jAn2TOx0= +modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM= +modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU= +modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= +modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/gc/v3 v3.1.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo= +modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY= +modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= +modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= +modernc.org/libc v1.72.0 h1:IEu559v9a0XWjw0DPoVKtXpO2qt5NVLAnFaBbjq+n8c= +modernc.org/libc v1.72.0/go.mod h1:tTU8DL8A+XLVkEY3x5E/tO7s2Q/q42EtnNWda/L5QhQ= +modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= +modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= +modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= +modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= +modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= +modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= +modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= +modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= +modernc.org/sqlite v1.50.0 h1:eMowQSWLK0MeiQTdmz3lqoF5dqclujdlIKeJA11+7oM= +modernc.org/sqlite v1.50.0/go.mod h1:m0w8xhwYUVY3H6pSDwc3gkJ/irZT/0YEXwBlhaxQEew= +modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= +modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= mvdan.cc/xurls/v2 v2.6.0 h1:3NTZpeTxYVWNSokW3MKeyVkz/j7uYXYiMtXRUfmjbgI= diff --git a/models/actions/artifact.go b/models/actions/artifact.go index f0effdeeca..1de83a29c5 100644 --- a/models/actions/artifact.go +++ b/models/actions/artifact.go @@ -1,7 +1,7 @@ // Copyright 2023 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT -// This artifact server is inspired by https://github.com/nektos/act/blob/master/pkg/artifacts/server.go. +// This artifact server is inspired by the Gitea runner artifact server implementation. // It updates url setting and uses ObjectStore to handle artifacts persistence. package actions diff --git a/models/db/conn.go b/models/db/conn.go index de6f3cd5ec..944b6e7b97 100644 --- a/models/db/conn.go +++ b/models/db/conn.go @@ -10,6 +10,7 @@ import ( "net/url" "os" "path/filepath" + "slices" "strings" "code.gitea.io/gitea/modules/setting" @@ -31,7 +32,9 @@ type ConnOptions struct { } type SQLiteConnStrOptions struct { - FilePath string + FilePath string + // how long a concurrent query can wait for others (milliseconds), + // if timeout is reached, the error is something like "database is locked (SQLITE_BUSY)" BusyTimeout int JournalMode string } @@ -52,10 +55,21 @@ func GlobalConnOptions() ConnOptions { } } -const sqlDriverPostgresSchema = "postgresschema" +const ( + sqlDriverPostgresSchema = "postgresschema" + sqlDriverSQLite3 = "sqlite3" // although database type also has "sqlite3", they are different, for different purposes +) var makeSQLiteConnStr = func(opts SQLiteConnStrOptions) (string, string, error) { - return "", "", errors.New(`this Gitea binary was not built with SQLite3 support, get an official release or rebuild with: -tags sqlite,sqlite_unlock_notify`) + return "", "", errors.New(`this Gitea binary was not built with SQLite3 support, get an official release or rebuild with correct "-tags"`) +} + +func registerSQLiteConnStrMaker(fn func(opts SQLiteConnStrOptions) (string, string, error)) { + if slices.Contains(setting.SupportedDatabaseTypes, setting.DatabaseTypeSQLite3) { + panic("another sqlite3 driver has been registered") + } + setting.SupportedDatabaseTypes = append(setting.SupportedDatabaseTypes, setting.DatabaseTypeSQLite3) + makeSQLiteConnStr = fn } func ConnStrDefaultDatabase(opts ConnOptions) (string, string, error) { diff --git a/models/db/driver_sqlite_mattn.go b/models/db/driver_sqlite_mattn.go index 4988a43d3f..1fe2e35cba 100644 --- a/models/db/driver_sqlite_mattn.go +++ b/models/db/driver_sqlite_mattn.go @@ -1,4 +1,4 @@ -//go:build sqlite +//go:build sqlite_mattn && sqlite_unlock_notify // Copyright 2026 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT @@ -10,14 +10,11 @@ import ( "strconv" "strings" - "code.gitea.io/gitea/modules/setting" - _ "github.com/mattn/go-sqlite3" ) func init() { - setting.SupportedDatabaseTypes = append(setting.SupportedDatabaseTypes, "sqlite3") - makeSQLiteConnStr = makeSQLiteConnStrMattnCGO + registerSQLiteConnStrMaker(makeSQLiteConnStrMattnCGO) } func makeSQLiteConnStrMattnCGO(opts SQLiteConnStrOptions) (string, string, error) { @@ -30,5 +27,5 @@ func makeSQLiteConnStrMattnCGO(opts SQLiteConnStrOptions) (string, string, error params = append(params, "_journal_mode="+opts.JournalMode) } connStr := fmt.Sprintf("file:%s?%s", opts.FilePath, strings.Join(params, "&")) - return "sqlite3", connStr, nil + return sqlDriverSQLite3, connStr, nil } diff --git a/models/db/driver_sqlite_modernc.go b/models/db/driver_sqlite_modernc.go new file mode 100644 index 0000000000..8202d5f6f4 --- /dev/null +++ b/models/db/driver_sqlite_modernc.go @@ -0,0 +1,41 @@ +//go:build !sqlite_mattn + +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +// modernc driver is chosen as the default one (compared to mattn, ncruces) +// * mattn was used as default, but it requires CGO +// * the CI times are almost the same for these three (race detector must be disabled) +// * modernc increases the binary size about 2MB, ncruces increases about 7MB +// * compiling time: modernc is slightly slower than mattn, ncruces is the slowest + +package db + +import ( + "database/sql" + "fmt" + "strings" + + "modernc.org/sqlite" +) + +func init() { + // this driver contains huge amount of Golang code, so it is much slower when "-race" check is enabled. + registerSQLiteConnStrMaker(makeSQLiteConnStrModerncCCGO) + sql.Register(sqlDriverSQLite3, &sqlite.Driver{}) +} + +func makeSQLiteConnStrModerncCCGO(opts SQLiteConnStrOptions) (string, string, error) { + var params []string + // TODO: there is a changed behavior from mattn driver: + // * mattn driver can wait for pretty long time for concurrent accesses (not limited by the busy timeout) + // * but other drivers will report something like "database is locked (5) (SQLITE_BUSY)" if the timeout is reached + // Maybe we need to relax the busy timeout to a reasonable long time in the future + params = append(params, fmt.Sprintf("_pragma=busy_timeout(%d)", opts.BusyTimeout)) + params = append(params, "_txlock=immediate") + if opts.JournalMode != "" { + params = append(params, fmt.Sprintf("_pragma=journal_mode(%s)", opts.JournalMode)) + } + connStr := fmt.Sprintf("file:%s?%s", opts.FilePath, strings.Join(params, "&")) + return sqlDriverSQLite3, connStr, nil +} diff --git a/models/git/branch.go b/models/git/branch.go index 698c43f147..db53ca0ac7 100644 --- a/models/git/branch.go +++ b/models/git/branch.go @@ -261,7 +261,7 @@ func UpdateBranch(ctx context.Context, repoID, pusherID int64, branchName string Cols("commit_id, commit_message, pusher_id, commit_time, is_deleted, updated_unix"). Update(&Branch{ CommitID: commit.ID.String(), - CommitMessage: commit.Summary(), + CommitMessage: commit.MessageTitle(), PusherID: pusherID, CommitTime: timeutil.TimeStamp(commit.Committer.When.Unix()), IsDeleted: false, diff --git a/models/git/branch_test.go b/models/git/branch_test.go index 3832df9350..be67439285 100644 --- a/models/git/branch_test.go +++ b/models/git/branch_test.go @@ -36,7 +36,7 @@ func TestAddDeletedBranch(t *testing.T) { commit := &git.Commit{ ID: git.MustIDFromString(secondBranch.CommitID), - CommitMessage: secondBranch.CommitMessage, + CommitMessage: git.CommitMessage{MessageRaw: secondBranch.CommitMessage}, Committer: &git.Signature{ When: secondBranch.CommitTime.AsLocalTime(), }, diff --git a/models/issues/issue_stats.go b/models/issues/issue_stats.go index adedaa3d3a..ddf6613870 100644 --- a/models/issues/issue_stats.go +++ b/models/issues/issue_stats.go @@ -35,12 +35,10 @@ const ( FilterModeYourRepositories ) -const ( - // MaxQueryParameters represents the max query parameters - // When queries are broken down in parts because of the number - // of parameters, attempt to break by this amount - MaxQueryParameters = 300 -) +// MaxQueryParameters represents the max query parameters +// When queries are broken down in parts because of the number +// of parameters, attempt to break by this amount +var MaxQueryParameters = 300 // CountIssuesByRepo map from repoID to number of issues matching the options func CountIssuesByRepo(ctx context.Context, opts *IssuesOptions) (map[int64]int64, error) { diff --git a/models/issues/issue_test.go b/models/issues/issue_test.go index b935c0fffd..99a09de0ec 100644 --- a/models/issues/issue_test.go +++ b/models/issues/issue_test.go @@ -17,6 +17,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/test" "github.com/stretchr/testify/assert" "xorm.io/builder" @@ -297,14 +298,11 @@ func TestIssue_ResolveMentions(t *testing.T) { func TestResourceIndex(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - var wg sync.WaitGroup - for i := range 100 { - wg.Add(1) - go func(i int) { + for i := range 25 { + wg.Go(func() { testInsertIssue(t, fmt.Sprintf("issue %d", i+1), "my issue", 0) - wg.Done() - }(i) + }) } wg.Wait() } @@ -317,18 +315,12 @@ func TestCorrectIssueStats(t *testing.T) { // maxQueryParameters + 10 issues into the testDatabase. // Each new issues will have a constant description "Bugs are nasty" // Which will be used later on. - + defer test.MockVariableValue(&issues_model.MaxQueryParameters, 25)() issueAmount := issues_model.MaxQueryParameters + 10 - var wg sync.WaitGroup for i := range issueAmount { - wg.Add(1) - go func(i int) { - testInsertIssue(t, fmt.Sprintf("Issue %d", i+1), "Bugs are nasty", 0) - wg.Done() - }(i) + testInsertIssue(t, fmt.Sprintf("Issue %d", i+1), "Bugs are nasty", 0) } - wg.Wait() // Now we will get all issueID's that match the "Bugs are nasty" query. issues, err := issues_model.Issues(t.Context(), &issues_model.IssuesOptions{ diff --git a/models/unittest/fixtures_test.go b/models/unittest/fixtures_test.go index 72944ec0db..d45ef33847 100644 --- a/models/unittest/fixtures_test.go +++ b/models/unittest/fixtures_test.go @@ -70,7 +70,7 @@ func prepareTestFixturesLoaders(t testing.TB) unittest.FixturesOptions { opts := unittest.FixturesOptions{Dir: filepath.Join(giteaRoot, "models", "fixtures"), Files: []string{ "user.yml", }} - require.NoError(t, unittest.CreateTestEngine(opts)) + require.NoError(t, unittest.CreateTestEngine(filepath.Join(t.TempDir(), "sqlite-test.db"), opts)) return opts } @@ -95,7 +95,7 @@ func TestFixturesLoader(t *testing.T) { func BenchmarkFixturesLoader(b *testing.B) { opts := prepareTestFixturesLoaders(b) - require.NoError(b, unittest.CreateTestEngine(opts)) + require.NoError(b, unittest.CreateTestEngine(filepath.Join(b.TempDir(), "sqlite-test.db"), opts)) loaderInternal, err := unittest.NewFixturesLoader(unittest.GetXORMEngine(), opts) require.NoError(b, err) loaderVendor, err := NewFixturesLoaderVendor(unittest.GetXORMEngine(), opts) diff --git a/models/unittest/testdb.go b/models/unittest/testdb.go index 116fdab496..2a87a02fcd 100644 --- a/models/unittest/testdb.go +++ b/models/unittest/testdb.go @@ -56,7 +56,7 @@ func mainTest(m *testing.M, testOptsArg ...*TestOptions) int { giteaRoot := setting.GetGiteaTestSourceRoot() fixturesOpts := FixturesOptions{Dir: filepath.Join(giteaRoot, "models", "fixtures"), Files: testOpts.FixtureFiles} - if err := CreateTestEngine(fixturesOpts); err != nil { + if err := CreateTestEngine(filepath.Join(tempWorkPath, "sqlite-test.db"), fixturesOpts); err != nil { return testlogger.MainErrorf("Error creating test database engine: %v", err) } @@ -205,9 +205,9 @@ type FixturesOptions struct { Files []string } -// CreateTestEngine creates a memory database and loads the fixture data from fixturesDir -func CreateTestEngine(opts FixturesOptions) error { - driver, connStr, err := db.ConnStr(db.ConnOptions{Type: "sqlite3", SQLitePath: ":memory:"}) +// CreateTestEngine creates a test database and loads the fixture data from fixturesDir +func CreateTestEngine(testSQLiteFile string, opts FixturesOptions) error { + driver, connStr, err := db.ConnStr(db.ConnOptions{Type: setting.DatabaseTypeSQLite3, SQLitePath: testSQLiteFile, SQLiteBusyTimeout: 5000}) if err != nil { return err } diff --git a/models/user/user.go b/models/user/user.go index 0e87d7b7b9..8a39eca634 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -1051,13 +1051,13 @@ func GetPossibleUserByIDs(ctx context.Context, ids []int64) ([]*User, error) { return users, nil } -// GetUserByName returns user by given name. -func GetUserByName(ctx context.Context, name string) (*User, error) { - if len(name) == 0 { - return nil, ErrUserNotExist{Name: name} +func getUserByNameWithTypes(ctx context.Context, name string, types ...UserType) (*User, error) { + u := &User{} + sess := db.GetEngine(ctx).Where(builder.Eq{"lower_name": strings.ToLower(name)}) + if len(types) > 0 { + sess.In("`type`", types) } - u := &User{LowerName: strings.ToLower(name), Type: UserTypeIndividual} - has, err := db.GetEngine(ctx).Get(u) + has, err := sess.Get(u) if err != nil { return nil, err } else if !has { @@ -1066,6 +1066,15 @@ func GetUserByName(ctx context.Context, name string) (*User, error) { return u, nil } +// GetUserByName returns the user object by given name, any user type. +func GetUserByName(ctx context.Context, name string) (*User, error) { + return getUserByNameWithTypes(ctx, name) +} + +func GetIndividualUserByName(ctx context.Context, name string) (*User, error) { + return getUserByNameWithTypes(ctx, name, UserTypeIndividual) +} + // GetUserEmailsByNames returns a list of e-mails corresponds to names of users // that have their email notifications set to enabled or onmention. func GetUserEmailsByNames(ctx context.Context, names []string) []string { @@ -1108,19 +1117,6 @@ func GetMailableUsersByIDs(ctx context.Context, ids []int64, isMention bool) ([] Find(&ous) } -// GetUserNameByID returns username for the id -func GetUserNameByID(ctx context.Context, id int64) (string, error) { - var name string - has, err := db.GetEngine(ctx).Table("user").Where("id = ?", id).Cols("name").Get(&name) - if err != nil { - return "", err - } - if has { - return name, nil - } - return "", nil -} - // GetUserIDsByNames returns a slice of ids corresponds to names. func GetUserIDsByNames(ctx context.Context, names []string, ignoreNonExistent bool) ([]int64, error) { ids := make([]int64, 0, len(names)) @@ -1321,13 +1317,14 @@ func GetUserByEmail(ctx context.Context, email string) (*User, error) { if id != 0 { return GetUserByID(ctx, id) } - return GetUserByName(ctx, name) + return GetIndividualUserByName(ctx, name) } return nil, ErrUserNotExist{Name: email} } func GetIndividualUser(ctx context.Context, user *User) (bool, error) { + // FIXME: the design is wrong, empty User fields won't apply, this function should be removed in the future has, err := db.GetEngine(ctx).Get(user) if has && user.Type != UserTypeIndividual { has = false @@ -1492,27 +1489,3 @@ func DisabledFeaturesWithLoginType(user *User) *container.Set[string] { } return &setting.Admin.UserDisabledFeatures } - -// GetUserOrOrgIDByName returns the id for a user or an org by name -func GetUserOrOrgIDByName(ctx context.Context, name string) (int64, error) { - var id int64 - has, err := db.GetEngine(ctx).Table("user").Where("name = ?", name).Cols("id").Get(&id) - if err != nil { - return 0, err - } else if !has { - return 0, fmt.Errorf("user or org with name %s: %w", name, util.ErrNotExist) - } - return id, nil -} - -// GetUserOrOrgByName returns the user or org by name -func GetUserOrOrgByName(ctx context.Context, name string) (*User, error) { - var u User - has, err := db.GetEngine(ctx).Where("lower_name = ?", strings.ToLower(name)).Get(&u) - if err != nil { - return nil, err - } else if !has { - return nil, ErrUserNotExist{Name: name} - } - return &u, nil -} diff --git a/modules/actions/jobparser/evaluator.go b/modules/actions/jobparser/evaluator.go index b320095071..3e314afb62 100644 --- a/modules/actions/jobparser/evaluator.go +++ b/modules/actions/jobparser/evaluator.go @@ -9,7 +9,7 @@ import ( "regexp" "strings" - "github.com/nektos/act/pkg/exprparser" + "gitea.com/gitea/runner/act/exprparser" "go.yaml.in/yaml/v4" ) diff --git a/modules/actions/jobparser/interpeter.go b/modules/actions/jobparser/interpeter.go index 512b6f02ab..37defeff7a 100644 --- a/modules/actions/jobparser/interpeter.go +++ b/modules/actions/jobparser/interpeter.go @@ -4,8 +4,8 @@ package jobparser import ( - "github.com/nektos/act/pkg/exprparser" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/exprparser" + "gitea.com/gitea/runner/act/model" "go.yaml.in/yaml/v4" ) diff --git a/modules/actions/jobparser/jobparser.go b/modules/actions/jobparser/jobparser.go index 76f229a54b..e7a2b48498 100644 --- a/modules/actions/jobparser/jobparser.go +++ b/modules/actions/jobparser/jobparser.go @@ -9,8 +9,8 @@ import ( "sort" "strings" - "github.com/nektos/act/pkg/exprparser" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/exprparser" + "gitea.com/gitea/runner/act/model" "go.yaml.in/yaml/v4" ) @@ -31,6 +31,9 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) { } results := map[string]*JobResult{} for id, job := range origin.Jobs { + if job == nil { + return nil, fmt.Errorf("needed job not found: %q", id) + } results[id] = &JobResult{ Needs: job.Needs(), Result: pc.jobResults[id], diff --git a/modules/actions/jobparser/jobparser_test.go b/modules/actions/jobparser/jobparser_test.go index 51ba70fc2a..e74f0644f8 100644 --- a/modules/actions/jobparser/jobparser_test.go +++ b/modules/actions/jobparser/jobparser_test.go @@ -59,6 +59,13 @@ func TestParse(t *testing.T) { wantErr: false, }, } + invalidFileTests := []struct { + name string + }{ + {name: "null_job_implicit"}, + {name: "null_job_explicit"}, + } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { content := ReadTestdata(t, tt.name+".in.yaml") @@ -84,4 +91,14 @@ func TestParse(t *testing.T) { assert.Equal(t, string(want), builder.String()) }) } + + for _, tt := range invalidFileTests { + t.Run(tt.name, func(t *testing.T) { + content := ReadTestdata(t, tt.name+".in.yaml") + require.NotPanics(t, func() { + _, err := Parse(content) + require.Error(t, err) + }) + }) + } } diff --git a/modules/actions/jobparser/model.go b/modules/actions/jobparser/model.go index 7132c278e9..2c4bd1f93a 100644 --- a/modules/actions/jobparser/model.go +++ b/modules/actions/jobparser/model.go @@ -8,7 +8,7 @@ import ( "errors" "fmt" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" "go.yaml.in/yaml/v4" ) diff --git a/modules/actions/jobparser/model_test.go b/modules/actions/jobparser/model_test.go index d0e8204161..bd29cb9425 100644 --- a/modules/actions/jobparser/model_test.go +++ b/modules/actions/jobparser/model_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.yaml.in/yaml/v4" diff --git a/modules/actions/jobparser/testdata/null_job_explicit.in.yaml b/modules/actions/jobparser/testdata/null_job_explicit.in.yaml new file mode 100644 index 0000000000..6731507a32 --- /dev/null +++ b/modules/actions/jobparser/testdata/null_job_explicit.in.yaml @@ -0,0 +1,9 @@ +# null_job_explicit.in.yaml +on: push +jobs: + empty: null + notempty: + needs: empty + runs-on: ubuntu-latest + steps: + - run: echo ok diff --git a/modules/actions/jobparser/testdata/null_job_implicit.in.yaml b/modules/actions/jobparser/testdata/null_job_implicit.in.yaml new file mode 100644 index 0000000000..26591aadcd --- /dev/null +++ b/modules/actions/jobparser/testdata/null_job_implicit.in.yaml @@ -0,0 +1,9 @@ +# null_job_implicit.in.yaml +on: push +jobs: + empty: + notempty: + needs: empty + runs-on: ubuntu-latest + steps: + - run: echo ok diff --git a/modules/actions/workflows.go b/modules/actions/workflows.go index ba1aee7d72..0269e8b0bb 100644 --- a/modules/actions/workflows.go +++ b/modules/actions/workflows.go @@ -17,8 +17,8 @@ import ( "code.gitea.io/gitea/modules/util" webhook_module "code.gitea.io/gitea/modules/webhook" - "github.com/nektos/act/pkg/model" - "github.com/nektos/act/pkg/workflowpattern" + "gitea.com/gitea/runner/act/model" + "gitea.com/gitea/runner/act/workflowpattern" "go.yaml.in/yaml/v4" ) diff --git a/modules/charset/charset.go b/modules/charset/charset.go index 96de1c9fcc..e5df55c9b6 100644 --- a/modules/charset/charset.go +++ b/modules/charset/charset.go @@ -89,7 +89,10 @@ func ToUTF8(content []byte, opts ConvertOpts) []byte { encoding, _ := charset.Lookup(charsetLabel) if encoding == nil { setting.PanicInDevOrTesting("unsupported detected charset %q, it shouldn't happen", charsetLabel) - return content + if opts.ErrorReturnOrigin { + return content + } + return bytes.ToValidUTF8(content, opts.ErrorReplacement) } var decoded []byte diff --git a/modules/git/commit.go b/modules/git/commit.go index c3d23d6878..b576451db8 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -11,19 +11,28 @@ import ( "os/exec" "strings" + "code.gitea.io/gitea/modules/charset" "code.gitea.io/gitea/modules/git/gitcmd" "code.gitea.io/gitea/modules/util" ) +type CommitMessage struct { + MessageRaw string + messageUTF8 *string + messageTitle *string + messageBody *string +} + // Commit represents a git commit. type Commit struct { Tree // FIXME: bad design, this field can be nil if the commit is from "last commit cache" - ID ObjectID - Author *Signature // never nil - Committer *Signature // never nil - CommitMessage string - Signature *CommitSignature + CommitMessage + + ID ObjectID + Author *Signature // never nil + Committer *Signature // never nil + Signature *CommitSignature Parents []ObjectID // ID strings submoduleCache *ObjectCache[*SubModule] @@ -35,19 +44,28 @@ type CommitSignature struct { Payload string } -// Message returns the commit message. Same as retrieving CommitMessage directly. -func (c *Commit) Message() string { - // FIXME: GIT-COMMIT-MESSAGE-ENCODING: this logic is not right - // * When need to use commit message in templates/database, it should be valid UTF-8 - // * When need to get the original commit message, it should just use "c.CommitMessage" - // It's not easy to refactor at the moment, many templates need to be updated and tested - return c.CommitMessage +func (c *CommitMessage) MessageUTF8() string { + if c.messageUTF8 == nil { + bs := charset.ToUTF8(util.UnsafeStringToBytes(c.MessageRaw), charset.ConvertOpts{ErrorReplacement: []byte{'?'}}) + c.messageUTF8 = new(util.UnsafeBytesToString(bs)) + } + return *c.messageUTF8 } -// Summary returns first line of commit message. -// The string is forced to be valid UTF8 -func (c *Commit) Summary() string { - return strings.ToValidUTF8(strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0], "?") +func (c *CommitMessage) MessageTitle() string { + if c.messageTitle == nil { + s, _, _ := strings.Cut(strings.TrimSpace(c.MessageUTF8()), "\n") + c.messageTitle = new(strings.TrimSpace(s)) + } + return *c.messageTitle +} + +func (c *CommitMessage) MessageBody() string { + if c.messageBody == nil { + _, s, _ := strings.Cut(strings.TrimSpace(c.MessageUTF8()), "\n") + c.messageBody = new(strings.TrimSpace(s)) + } + return *c.messageBody } // ParentID returns oid of n-th parent (0-based index). diff --git a/modules/git/commit_convert_gogit.go b/modules/git/commit_convert_gogit.go index d7b945ed6b..92ad1d21fd 100644 --- a/modules/git/commit_convert_gogit.go +++ b/modules/git/commit_convert_gogit.go @@ -66,7 +66,7 @@ func convertPGPSignature(c *object.Commit) *CommitSignature { func convertCommit(c *object.Commit) *Commit { return &Commit{ ID: ParseGogitHash(c.Hash), - CommitMessage: c.Message, + CommitMessage: CommitMessage{MessageRaw: c.Message}, Committer: &c.Committer, Author: &c.Author, Signature: convertPGPSignature(c), diff --git a/modules/git/commit_reader.go b/modules/git/commit_reader.go index eb8f4c6322..ce48d6f319 100644 --- a/modules/git/commit_reader.go +++ b/modules/git/commit_reader.go @@ -92,7 +92,7 @@ func CommitFromReader(gitRepo *Repository, objectID ObjectID, reader io.Reader) } } - commit.CommitMessage = messageSB.String() + commit.MessageRaw = messageSB.String() if commit.Signature != nil { commit.Signature.Payload = payloadSB.String() } diff --git a/modules/git/commit_sha256_test.go b/modules/git/commit_sha256_test.go index 0aefb30c95..9fb1539dc9 100644 --- a/modules/git/commit_sha256_test.go +++ b/modules/git/commit_sha256_test.go @@ -95,7 +95,7 @@ signed commit`, commitFromReader.Signature.Payload) commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n")) assert.NoError(t, err) - commitFromReader.CommitMessage += "\n\n" + commitFromReader.CommitMessage.MessageRaw += "\n\n" commitFromReader.Signature.Payload += "\n\n" assert.Equal(t, commitFromReader, commitFromReader2) } diff --git a/modules/git/commit_test.go b/modules/git/commit_test.go index de7b7455eb..a7668e4deb 100644 --- a/modules/git/commit_test.go +++ b/modules/git/commit_test.go @@ -91,7 +91,7 @@ empty commit`, commitFromReader.Signature.Payload) commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n")) assert.NoError(t, err) - commitFromReader.CommitMessage += "\n\n" + commitFromReader.CommitMessage.MessageRaw += "\n\n" commitFromReader.Signature.Payload += "\n\n" assert.Equal(t, commitFromReader, commitFromReader2) } @@ -154,11 +154,20 @@ ISO-8859-1`, commitFromReader.Signature.Payload) commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n")) assert.NoError(t, err) - commitFromReader.CommitMessage += "\n\n" + commitFromReader.CommitMessage.MessageRaw += "\n\n" commitFromReader.Signature.Payload += "\n\n" assert.Equal(t, commitFromReader, commitFromReader2) } +func TestCommitMessageSanitizesInvalidUTF8(t *testing.T) { + commit := &Commit{ + CommitMessage: CommitMessage{MessageRaw: "title \xff\n\n\n\nbody \xff\n\n\n"}, + } + assert.Equal(t, "title ÿ", commit.MessageTitle()) + assert.Equal(t, "body ÿ", commit.MessageBody()) + assert.Equal(t, "title ÿ\n\n\n\nbody ÿ\n\n\n", commit.MessageUTF8()) +} + func TestHasPreviousCommit(t *testing.T) { bareRepo1Path := filepath.Join(testReposDir, "repo1_bare") diff --git a/modules/git/foreachref/parser.go b/modules/git/foreachref/parser.go index 91868076b4..874b3744c3 100644 --- a/modules/git/foreachref/parser.go +++ b/modules/git/foreachref/parser.go @@ -111,8 +111,6 @@ func (p *Parser) parseRef(refBlock string) (map[string]string, error) { len(fields), len(p.format.fieldNames)) } for i, field := range fields { - field = strings.TrimSpace(field) - var fieldKey string var fieldVal string before, after, ok := strings.Cut(field, " ") diff --git a/modules/git/foreachref/parser_test.go b/modules/git/foreachref/parser_test.go index 7a37ced356..fc1c8e7cf6 100644 --- a/modules/git/foreachref/parser_test.go +++ b/modules/git/foreachref/parser_test.go @@ -116,12 +116,12 @@ func TestParser(t *testing.T) { }, { "refname:short": "v0.0.2", - "contents": "Update CI config (#651)", + "contents": "Update CI config (#651)\n\n", "author": "John Doe 1521643174 +0000", }, { "refname:short": "v0.0.3", - "contents": "Fixed code sample for bash completion (#687)", + "contents": "Fixed code sample for bash completion (#687)\n\n", "author": "Foo Baz 1524836750 +0200", }, }, diff --git a/modules/git/pipeline/lfs_nogogit.go b/modules/git/pipeline/lfs_nogogit.go index 9a49dc81a2..b4a4aff4ed 100644 --- a/modules/git/pipeline/lfs_nogogit.go +++ b/modules/git/pipeline/lfs_nogogit.go @@ -10,7 +10,6 @@ import ( "bytes" "io" "sort" - "strings" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/git/gitcmd" @@ -97,7 +96,7 @@ func findLFSFileFunc(repo *git.Repository, objectID git.ObjectID, revListReader result := LFSResult{ Name: curPath + fname, SHA: curCommit.ID.String(), - Summary: strings.Split(strings.TrimSpace(curCommit.CommitMessage), "\n")[0], + Summary: curCommit.MessageTitle(), When: curCommit.Author.When, ParentHashes: curCommit.Parents, } diff --git a/modules/git/repo_commit_test.go b/modules/git/repo_commit_test.go index 3f7883ab14..ea56a1375d 100644 --- a/modules/git/repo_commit_test.go +++ b/modules/git/repo_commit_test.go @@ -54,7 +54,7 @@ func TestGetTagCommitWithSignature(t *testing.T) { assert.NotNil(t, commit) assert.NotNil(t, commit.Signature) // test that signature is not in message - assert.Equal(t, "signed-commit\n", commit.CommitMessage) + assert.Equal(t, "signed-commit\n", commit.CommitMessage.MessageRaw) } func TestGetCommitWithBadCommitID(t *testing.T) { diff --git a/modules/git/repo_tag.go b/modules/git/repo_tag.go index 2599236ae0..862b370890 100644 --- a/modules/git/repo_tag.go +++ b/modules/git/repo_tag.go @@ -176,15 +176,14 @@ func parseTagRef(ref map[string]string) (tag *Tag, err error) { } tag.Tagger = parseSignatureFromCommitLine(ref["creator"]) - tag.Message = ref["contents"] + tag.MessageRaw = ref["contents"] // strip any signature if present in contents field - _, tag.Message, _ = parsePayloadSignature(util.UnsafeStringToBytes(tag.Message), 0) + _, tag.MessageRaw, _ = parsePayloadSignature(util.UnsafeStringToBytes(tag.MessageRaw), 0) // annotated tag with GPG signature if tag.Type == "tag" && ref["contents:signature"] != "" { - payload := fmt.Sprintf("object %s\ntype commit\ntag %s\ntagger %s\n\n%s\n", - tag.Object, tag.Name, ref["creator"], strings.TrimSpace(tag.Message)) + payload := fmt.Sprintf("object %s\ntype commit\ntag %s\ntagger %s\n\n%s", tag.Object, tag.Name, ref["creator"], tag.MessageRaw) tag.Signature = &CommitSignature{ Signature: ref["contents:signature"], Payload: payload, diff --git a/modules/git/repo_tag_gogit.go b/modules/git/repo_tag_gogit.go index 878ab55bf2..a3e25f3899 100644 --- a/modules/git/repo_tag_gogit.go +++ b/modules/git/repo_tag_gogit.go @@ -64,12 +64,12 @@ func (repo *Repository) getTag(tagID ObjectID, name string) (*Tag, error) { return nil, err } tag := &Tag{ - Name: name, - ID: tagID, - Object: commitID, - Type: tp, - Tagger: commit.Committer, - Message: commit.Message(), + Name: name, + ID: tagID, + Object: commitID, + Type: tp, + Tagger: commit.Committer, + CommitMessage: CommitMessage{MessageRaw: commit.CommitMessage.MessageRaw}, } repo.tagCache.Set(tagID.String(), tag) @@ -86,12 +86,12 @@ func (repo *Repository) getTag(tagID ObjectID, name string) (*Tag, error) { } tag := &Tag{ - Name: name, - ID: tagID, - Object: commitID.Type().MustID(gogitTag.Target[:]), - Type: tp, - Tagger: &gogitTag.Tagger, - Message: gogitTag.Message, + Name: name, + ID: tagID, + Object: commitID.Type().MustID(gogitTag.Target[:]), + Type: tp, + Tagger: &gogitTag.Tagger, + CommitMessage: CommitMessage{MessageRaw: gogitTag.Message}, } repo.tagCache.Set(tagID.String(), tag) diff --git a/modules/git/repo_tag_nogogit.go b/modules/git/repo_tag_nogogit.go index a9ac040821..053c633662 100644 --- a/modules/git/repo_tag_nogogit.go +++ b/modules/git/repo_tag_nogogit.go @@ -71,12 +71,12 @@ func (repo *Repository) getTag(tagID ObjectID, name string) (*Tag, error) { return nil, err } tag := &Tag{ - Name: name, - ID: tagID, - Object: commitID, - Type: tp, - Tagger: commit.Committer, - Message: commit.Message(), + Name: name, + ID: tagID, + Object: commitID, + Type: tp, + Tagger: commit.Committer, + CommitMessage: commit.CommitMessage, } repo.tagCache.Set(tagID.String(), tag) diff --git a/modules/git/repo_tag_test.go b/modules/git/repo_tag_test.go index e6f8e75a0e..50c6ab5036 100644 --- a/modules/git/repo_tag_test.go +++ b/modules/git/repo_tag_test.go @@ -211,13 +211,13 @@ func TestRepository_parseTagRef(t *testing.T) { }, want: &Tag{ - Name: "v1.9.1", - ID: MustIDFromString("ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889"), - Object: MustIDFromString("ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889"), - Type: "commit", - Tagger: parseSignatureFromCommitLine("Foo Bar 1565789218 +0300"), - Message: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n", - Signature: nil, + Name: "v1.9.1", + ID: MustIDFromString("ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889"), + Object: MustIDFromString("ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889"), + Type: "commit", + Tagger: parseSignatureFromCommitLine("Foo Bar 1565789218 +0300"), + CommitMessage: CommitMessage{MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n"}, + Signature: nil, }, }, @@ -240,13 +240,13 @@ func TestRepository_parseTagRef(t *testing.T) { }, want: &Tag{ - Name: "v0.0.1", - ID: MustIDFromString("8c68a1f06fc59c655b7e3905b159d761e91c53c9"), - Object: MustIDFromString("3325fd8a973321fd59455492976c042dde3fd1ca"), - Type: "tag", - Tagger: parseSignatureFromCommitLine("Foo Bar 1565789218 +0300"), - Message: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n", - Signature: nil, + Name: "v0.0.1", + ID: MustIDFromString("8c68a1f06fc59c655b7e3905b159d761e91c53c9"), + Object: MustIDFromString("3325fd8a973321fd59455492976c042dde3fd1ca"), + Type: "tag", + Tagger: parseSignatureFromCommitLine("Foo Bar 1565789218 +0300"), + CommitMessage: CommitMessage{MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n"}, + Signature: nil, }, }, @@ -263,6 +263,7 @@ func TestRepository_parseTagRef(t *testing.T) { * add changelog of v1.9.1 * Update CHANGELOG.md + -----BEGIN PGP SIGNATURE----- aBCGzBAABCgAdFiEEyWRwv/q1Q6IjSv+D4IPOwzt33PoFAmI8jbIACgkQ4IPOwzt3 @@ -298,12 +299,12 @@ qbHDASXl }, want: &Tag{ - Name: "v0.0.1", - ID: MustIDFromString("8c68a1f06fc59c655b7e3905b159d761e91c53c9"), - Object: MustIDFromString("3325fd8a973321fd59455492976c042dde3fd1ca"), - Type: "tag", - Tagger: parseSignatureFromCommitLine("Foo Bar 1565789218 +0300"), - Message: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md", + Name: "v0.0.1", + ID: MustIDFromString("8c68a1f06fc59c655b7e3905b159d761e91c53c9"), + Object: MustIDFromString("3325fd8a973321fd59455492976c042dde3fd1ca"), + Type: "tag", + Tagger: parseSignatureFromCommitLine("Foo Bar 1565789218 +0300"), + CommitMessage: CommitMessage{MessageRaw: "Add changelog of v1.9.1 (#7859)\n\n* add changelog of v1.9.1\n* Update CHANGELOG.md\n"}, Signature: &CommitSignature{ Signature: `-----BEGIN PGP SIGNATURE----- diff --git a/modules/git/tag.go b/modules/git/tag.go index 8bf3658d62..232dda7fd9 100644 --- a/modules/git/tag.go +++ b/modules/git/tag.go @@ -12,12 +12,13 @@ import ( // Tag represents a Git tag. type Tag struct { + CommitMessage + Name string ID ObjectID Object ObjectID // The id of this commit object Type string Tagger *Signature - Message string Signature *CommitSignature } @@ -87,7 +88,7 @@ func parseTagData(objectFormat ObjectFormat, data []byte) (*Tag, error) { pos += eol + 1 } payload, msg, sign := parsePayloadSignature(data, pos) - tag.Message = msg + tag.MessageRaw = msg if len(sign) > 0 { tag.Signature = &CommitSignature{Signature: sign, Payload: payload} } diff --git a/modules/git/tag_test.go b/modules/git/tag_test.go index ba02c28946..6a65e359a2 100644 --- a/modules/git/tag_test.go +++ b/modules/git/tag_test.go @@ -28,7 +28,6 @@ tagger Lucas Michot 1484491741 +0100 Object: MustIDFromString("3b114ab800c6432ad42387ccf6bc8d4388a2885a"), Type: "commit", Tagger: &Signature{Name: "Lucas Michot", Email: "lucas@semalead.com", When: time.Unix(1484491741, 0).In(time.FixedZone("", 3600))}, - Message: "", Signature: nil, }, }, @@ -43,13 +42,13 @@ o ono`, expected: Tag{ - Name: "", - ID: Sha1ObjectFormat.EmptyObjectID(), - Object: MustIDFromString("7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc"), - Type: "commit", - Tagger: &Signature{Name: "Lucas Michot", Email: "lucas@semalead.com", When: time.Unix(1484553735, 0).In(time.FixedZone("", 3600))}, - Message: "test message\no\n\nono", - Signature: nil, + Name: "", + ID: Sha1ObjectFormat.EmptyObjectID(), + Object: MustIDFromString("7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc"), + Type: "commit", + Tagger: &Signature{Name: "Lucas Michot", Email: "lucas@semalead.com", When: time.Unix(1484553735, 0).In(time.FixedZone("", 3600))}, + CommitMessage: CommitMessage{MessageRaw: "test message\no\n\nono"}, + Signature: nil, }, }, { @@ -64,12 +63,12 @@ dummy signature -----END SSH SIGNATURE----- `, expected: Tag{ - Name: "", - ID: Sha1ObjectFormat.EmptyObjectID(), - Object: MustIDFromString("7cdf42c0b1cc763ab7e4c33c47a24e27c66bfaaa"), - Type: "commit", - Tagger: &Signature{Name: "dummy user", Email: "dummy-email@example.com", When: time.Unix(1484491741, 0).In(time.FixedZone("", 3600))}, - Message: "dummy message", + Name: "", + ID: Sha1ObjectFormat.EmptyObjectID(), + Object: MustIDFromString("7cdf42c0b1cc763ab7e4c33c47a24e27c66bfaaa"), + Type: "commit", + Tagger: &Signature{Name: "dummy user", Email: "dummy-email@example.com", When: time.Unix(1484491741, 0).In(time.FixedZone("", 3600))}, + CommitMessage: CommitMessage{MessageRaw: "dummy message"}, Signature: &CommitSignature{ Signature: `-----BEGIN SSH SIGNATURE----- dummy signature @@ -93,5 +92,5 @@ dummy message`, tag, err := parseTagData(Sha1ObjectFormat, []byte("type commit\n\nfoo\n-----BEGIN SSH SIGNATURE-----\ncorrupted...")) assert.NoError(t, err) - assert.Equal(t, "foo\n-----BEGIN SSH SIGNATURE-----\ncorrupted...", tag.Message) + assert.Equal(t, "foo\n-----BEGIN SSH SIGNATURE-----\ncorrupted...", tag.CommitMessage.MessageRaw) } diff --git a/modules/httplib/serve.go b/modules/httplib/serve.go index 6c2fe9b0d6..d51c938bf0 100644 --- a/modules/httplib/serve.go +++ b/modules/httplib/serve.go @@ -87,8 +87,9 @@ func ServeSetHeaders(w http.ResponseWriter, opts ServeHeaderOptions) { if opts.ContentLength != nil { header.Set("Content-Length", strconv.FormatInt(*opts.ContentLength, 10)) } - if opts.Filename != "" && opts.ContentDisposition != "" { - header.Set("Content-Disposition", encodeContentDisposition(opts.ContentDisposition, path.Base(opts.Filename))) + if opts.Filename != "" { + contentDisposition := util.IfZero(opts.ContentDisposition, ContentDispositionAttachment) + header.Set("Content-Disposition", encodeContentDisposition(contentDisposition, path.Base(opts.Filename))) header.Set("Access-Control-Expose-Headers", "Content-Disposition") } diff --git a/modules/httplib/serve_test.go b/modules/httplib/serve_test.go index 2a245300b0..419085237c 100644 --- a/modules/httplib/serve_test.go +++ b/modules/httplib/serve_test.go @@ -133,3 +133,11 @@ func TestServeSetHeaderContentRelated(t *testing.T) { // make sure sandboxed require.Contains(t, serveHeaderCspDefault, "; sandbox") } + +func TestServeSetHeaders(t *testing.T) { + w := httptest.NewRecorder() + ServeSetHeaders(w, ServeHeaderOptions{Filename: "foo.zip"}) + assert.Equal(t, "attachment; filename=foo.zip", w.Header().Get("Content-Disposition")) + ServeSetHeaders(w, ServeHeaderOptions{Filename: "foo.zip", ContentDisposition: ContentDispositionInline}) + assert.Equal(t, "inline; filename=foo.zip", w.Header().Get("Content-Disposition")) +} diff --git a/modules/repository/branch.go b/modules/repository/branch.go index 0a8f7cc464..8dda3f82d7 100644 --- a/modules/repository/branch.go +++ b/modules/repository/branch.go @@ -97,7 +97,7 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, RepoID: repo.ID, Name: branch, CommitID: commit.ID.String(), - CommitMessage: commit.Summary(), + CommitMessage: commit.MessageTitle(), PusherID: doerID, CommitTime: timeutil.TimeStamp(commit.Committer.When.Unix()), }) @@ -112,7 +112,7 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, RepoID: repo.ID, Name: branch, CommitID: commit.ID.String(), - CommitMessage: commit.Summary(), + CommitMessage: commit.MessageTitle(), PusherID: doerID, CommitTime: timeutil.TimeStamp(commit.Committer.When.Unix()), }) diff --git a/modules/repository/commits.go b/modules/repository/commits.go index a3e253e998..32550a9f03 100644 --- a/modules/repository/commits.go +++ b/modules/repository/commits.go @@ -152,7 +152,7 @@ func (pc *PushCommits) AvatarLink(ctx context.Context, email string) string { func CommitToPushCommit(commit *git.Commit) *PushCommit { return &PushCommit{ Sha1: commit.ID.String(), - Message: commit.Message(), + Message: commit.MessageUTF8(), AuthorEmail: commit.Author.Email, AuthorName: commit.Author.Name, CommitterEmail: commit.Committer.Email, diff --git a/modules/repository/commits_test.go b/modules/repository/commits_test.go index 04c0711828..46db7b028b 100644 --- a/modules/repository/commits_test.go +++ b/modules/repository/commits_test.go @@ -145,7 +145,7 @@ func TestCommitToPushCommit(t *testing.T) { ID: sha1, Author: sig, Committer: sig, - CommitMessage: "Commit Message", + CommitMessage: git.CommitMessage{MessageRaw: "Commit Message"}, }) assert.Equal(t, hexString, pushCommit.Sha1) assert.Equal(t, "Commit Message", pushCommit.Message) @@ -176,13 +176,13 @@ func TestListToPushCommits(t *testing.T) { ID: hash1, Author: sig, Committer: sig, - CommitMessage: "Message1", + CommitMessage: git.CommitMessage{MessageRaw: "Message1"}, }, { ID: hash2, Author: sig, Committer: sig, - CommitMessage: "Message2", + CommitMessage: git.CommitMessage{MessageRaw: "Message2"}, }, } diff --git a/modules/setting/database.go b/modules/setting/database.go index 2b069a6292..a65c8e9495 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -8,11 +8,13 @@ import ( "time" ) +const defaultSQLiteBusyTimeout = 20 * 1000 + var ( - // SupportedDatabaseTypes includes all XORM supported databases type, sqlite3 maybe added by `database_sqlite3.go` + // SupportedDatabaseTypes includes all XORM supported databases type, sqlite3 maybe added by the tag-controlled drivers SupportedDatabaseTypes = []string{"mysql", "postgres", "mssql"} // DatabaseTypeNames contains the friendly names for all database types - DatabaseTypeNames = map[string]string{"mysql": "MySQL", "postgres": "PostgreSQL", "mssql": "MSSQL", "sqlite3": "SQLite3"} + DatabaseTypeNames = map[string]string{"mysql": "MySQL", "postgres": "PostgreSQL", "mssql": "MSSQL", DatabaseTypeSQLite3: "SQLite3"} // Database holds the database settings Database = struct { @@ -39,7 +41,6 @@ var ( AutoMigration bool SlowQueryThreshold time.Duration }{ - SQLiteBusyTimeout: 500, IterateBufferSize: 50, } ) @@ -63,7 +64,13 @@ func loadDBSetting(rootCfg ConfigProvider) { Database.CharsetCollation = sec.Key("CHARSET_COLLATION").String() Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "gitea.db")) - Database.SQLiteBusyTimeout = sec.Key("SQLITE_TIMEOUT").MustInt(500) + + Database.SQLiteBusyTimeout = sec.Key("SQLITE_TIMEOUT").MustInt(defaultSQLiteBusyTimeout) + // mattn driver isn't really affected by this timeout, but other drivers are affected + // the default value was 500 (0.5s), to avoid breaking existing users, make sure the timeout is long enough (at least, 5 seconds) + if Database.SQLiteBusyTimeout < 5000 { + Database.SQLiteBusyTimeout = defaultSQLiteBusyTimeout + } Database.SQLiteJournalMode = sec.Key("SQLITE_JOURNAL_MODE").MustString("") Database.MaxIdleConns = sec.Key("MAX_IDLE_CONNS").MustInt(2) @@ -85,8 +92,10 @@ func loadDBSetting(rootCfg ConfigProvider) { // DatabaseType FIXME: it is also used directly with "schemas.DBType", so the names must be consistent type DatabaseType string +const DatabaseTypeSQLite3 = "sqlite3" + func (t DatabaseType) IsSQLite3() bool { - return t == "sqlite3" + return t == DatabaseTypeSQLite3 } func (t DatabaseType) IsMySQL() bool { diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 4cd6269eaf..aebbfc7407 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -132,10 +132,9 @@ func newFuncMapWebPage() template.FuncMap { // ----------------------------------------------------------------- // misc (TODO: move them to MiscUtils to avoid bloating the main func map) - "ActionContent2Commits": ActionContent2Commits, - "IsMultilineCommitMessage": isMultilineCommitMessage, - "CommentMustAsDiff": gitdiff.CommentMustAsDiff, - "MirrorRemoteAddress": mirrorRemoteAddress, + "ActionContent2Commits": ActionContent2Commits, + "CommentMustAsDiff": gitdiff.CommentMustAsDiff, + "MirrorRemoteAddress": mirrorRemoteAddress, "FilenameIsImage": filenameIsImage, "TabSizeClass": tabSizeClass, diff --git a/modules/templates/util_misc.go b/modules/templates/util_misc.go index fb523fd53a..ac179e7178 100644 --- a/modules/templates/util_misc.go +++ b/modules/templates/util_misc.go @@ -52,11 +52,6 @@ func sortArrow(normSort, revSort, urlSort string, isDefault bool) template.HTML return "" } -// isMultilineCommitMessage checks to see if a commit message contains multiple lines. -func isMultilineCommitMessage(msg string) bool { - return strings.Count(strings.TrimSpace(msg), "\n") >= 1 -} - // Actioner describes an action type Actioner interface { GetOpType() activities_model.ActionType diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 6641ee7959..da186f87f2 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -79,20 +79,14 @@ func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, re // RenderCommitBody extracts the body of a commit message without its title. func (ut *RenderUtils) RenderCommitBody(msg string, repo *repo.Repository) template.HTML { - msgLine := strings.TrimSpace(msg) - lineEnd := strings.IndexByte(msgLine, '\n') - if lineEnd > 0 { - msgLine = msgLine[lineEnd+1:] - } else { - return "" - } - msgLine = strings.TrimLeftFunc(msgLine, unicode.IsSpace) - if len(msgLine) == 0 { + _, body, _ := strings.Cut(strings.TrimSpace(msg), "\n") + body = strings.TrimFunc(body, unicode.IsSpace) + if body == "" { return "" } rctx := renderhelper.NewRenderContextRepoComment(ut.ctx, repo) - htmlContent := template.HTML(template.HTMLEscapeString(msgLine)) + htmlContent := template.HTML(template.HTMLEscapeString(body)) renderedMessage, err := markup.PostProcessCommitMessage(rctx, htmlContent) if err != nil { log.Error("PostProcessCommitMessage: %v", err) diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index 6f3141885b..c7ec133e57 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -313,7 +313,6 @@ "install.admin_email": "Email Address", "install.install_btn_confirm": "Install Gitea", "install.test_git_failed": "Could not test 'git' command: %v", - "install.sqlite3_not_available": "This Gitea version does not support SQLite3. Please download the official binary version from %s (not the 'gobuild' version).", "install.invalid_db_setting": "The database settings are invalid: %v", "install.invalid_db_table": "The database table \"%s\" is invalid: %v", "install.invalid_repo_path": "The repository root path is invalid: %v", @@ -1306,7 +1305,7 @@ "repo.editor.upload_file_is_locked": "File \"%s\" is locked by %s.", "repo.editor.upload_files_to_dir": "Upload files to \"%s\"", "repo.editor.cannot_commit_to_protected_branch": "Cannot commit to protected branch \"%s\".", - "repo.editor.no_commit_to_branch": "Unable to commit directly to branch because:", + "repo.editor.no_commit_to_branch": "Not allowed to commit directly to branch because:", "repo.editor.user_no_push_to_branch": "User cannot push to branch", "repo.editor.require_signed_commit": "Branch requires a signed commit", "repo.editor.cherry_pick": "Cherry-pick %s onto:", diff --git a/options/locale/locale_fr-FR.json b/options/locale/locale_fr-FR.json index 870e1be56f..aa295c98a2 100644 --- a/options/locale/locale_fr-FR.json +++ b/options/locale/locale_fr-FR.json @@ -1958,7 +1958,6 @@ "repo.signing.wont_sign.headsigned": "La fusion ne sera pas signée car la dernière révision n’est pas signée.", "repo.signing.wont_sign.commitssigned": "La fusion ne sera pas signée car ses révisions ne sont pas signées.", "repo.signing.wont_sign.approved": "La fusion ne sera pas signée car la demande d'ajout n'a pas été approuvée.", - "repo.signing.wont_sign.not_signed_in": "Vous n'êtes pas connecté.", "repo.ext_wiki": "Accès au wiki externe", "repo.ext_wiki.desc": "Lier un wiki externe.", "repo.wiki": "Wiki", diff --git a/options/locale/locale_ga-IE.json b/options/locale/locale_ga-IE.json index 3584e0b597..f41aae7244 100644 --- a/options/locale/locale_ga-IE.json +++ b/options/locale/locale_ga-IE.json @@ -1958,7 +1958,6 @@ "repo.signing.wont_sign.headsigned": "Ní shínífear an cumasc toisc nach bhfuil an tiomantas ceann sínithe.", "repo.signing.wont_sign.commitssigned": "Ní shínífear an cumasc toisc nach bhfuil na tiomáintí gaolmhara go léir sínithe.", "repo.signing.wont_sign.approved": "Ní shíníofar an cumaisc toisc nach bhfuil an PR ceadaithe.", - "repo.signing.wont_sign.not_signed_in": "Níl tú sínithe isteach.", "repo.ext_wiki": "Rochtain ar Vicí Seachtrach", "repo.ext_wiki.desc": "Nasc le vicí seachtrach.", "repo.wiki": "Vicí", diff --git a/options/locale/locale_zh-CN.json b/options/locale/locale_zh-CN.json index 5960e554b7..6b9ba53878 100644 --- a/options/locale/locale_zh-CN.json +++ b/options/locale/locale_zh-CN.json @@ -313,7 +313,6 @@ "install.admin_email": "邮箱地址", "install.install_btn_confirm": "立即安装", "install.test_git_failed": "无法识别 'git' 命令:%v", - "install.sqlite3_not_available": "您所使用的发行版不支持 SQLite3,请从 %s 下载官方构建版,而不是 gobuild 版本。", "install.invalid_db_setting": "数据库设置无效: %v", "install.invalid_db_table": "数据库表「%s」无效:%v", "install.invalid_repo_path": "仓库根目录设置无效:%v", @@ -1385,6 +1384,7 @@ "repo.projects.column.delete": "删除列", "repo.projects.column.deletion_desc": "删除项目列会将所有相关工单移至默认列。是否继续?", "repo.projects.column.color": "颜色", + "repo.projects.column": "列", "repo.projects.open": "开启", "repo.projects.close": "关闭", "repo.projects.column.assigned_to": "指派给", @@ -1784,6 +1784,7 @@ "repo.pulls.review_only_possible_for_full_diff": "只有在查看全部差异时才能进行审核", "repo.pulls.filter_changes_by_commit": "按提交筛选", "repo.pulls.nothing_to_compare": "分支内容相同,无需创建合并请求。", + "repo.pulls.no_common_history": "这些分支没有共同的合并基点。请选择不同的基点或比较分支。", "repo.pulls.nothing_to_compare_have_tag": "所选分支 / Git 标签相同。", "repo.pulls.nothing_to_compare_and_allow_empty_pr": "这些分支是相等的,此合并请求将为空。", "repo.pulls.has_pull_request": "这些分支之间的合并请求已存在:%[2]s#%[3]d", @@ -1956,7 +1957,6 @@ "repo.signing.wont_sign.headsigned": "合并将不会被签名,因为最新提交没有签名。", "repo.signing.wont_sign.commitssigned": "合并将不会被签名,因为所有相关的提交都没有签名。", "repo.signing.wont_sign.approved": "合并将不会被签名,因为合并请求未被批准。", - "repo.signing.wont_sign.not_signed_in": "您还没有登录。", "repo.ext_wiki": "访问外部百科", "repo.ext_wiki.desc": "链接到外部百科。", "repo.wiki": "百科", @@ -3313,7 +3313,6 @@ "admin.config.cache_config": "缓存配置", "admin.config.cache_adapter": "缓存适配器", "admin.config.cache_interval": "缓存周期", - "admin.config.cache_conn": "缓存连接字符串", "admin.config.cache_item_ttl": "缓存项目 TTL", "admin.config.cache_test": "测试缓存", "admin.config.cache_test_failed": "缓存测试失败:%v。", @@ -3328,7 +3327,6 @@ "admin.config.instance_web_banner.message_placeholder": "横幅消息(支持 Markdown)", "admin.config.session_config": "会话配置", "admin.config.session_provider": "会话提供者", - "admin.config.provider_config": "提供者配置", "admin.config.cookie_name": "Cookie 名称", "admin.config.gc_interval_time": "GC 周期", "admin.config.session_life_time": "会话生命周期", diff --git a/renovate.json5 b/renovate.json5 index 586733b317..3362f52c23 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -71,8 +71,8 @@ "groupName": "npm dependencies", "matchManagers": ["npm"], "postUpgradeTasks": { - "commands": ["make svg"], - "fileFilters": ["public/assets/img/svg/**"], + "commands": ["make svg nolyfill"], + "fileFilters": ["package.json", "pnpm-lock.yaml", "public/assets/img/svg/**"], "executionMode": "branch", }, }, diff --git a/routers/api/v1/repo/action.go b/routers/api/v1/repo/action.go index 1d38cc2f53..09b0cc5b2d 100644 --- a/routers/api/v1/repo/action.go +++ b/routers/api/v1/repo/action.go @@ -35,7 +35,7 @@ import ( "code.gitea.io/gitea/services/convert" secret_service "code.gitea.io/gitea/services/secrets" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" ) // ListActionsSecrets list an repo's actions secrets diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 2426a6b3c2..2702f6864f 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -996,7 +996,7 @@ func MergePullRequest(ctx *context.APIContext) { return } if strings.Contains(err.Error(), "Wrong commit ID") { - ctx.JSON(http.StatusConflict, err) + ctx.APIError(http.StatusConflict, err) return } ctx.APIErrorInternal(err) diff --git a/routers/common/compare.go b/routers/common/compare.go index 7e917c4df8..8b1e1715d2 100644 --- a/routers/common/compare.go +++ b/routers/common/compare.go @@ -129,7 +129,7 @@ func GetHeadOwnerAndRepo(ctx context.Context, baseRepo *repo_model.Repository, c if compareReq.HeadOwner == baseRepo.Owner.Name { headOwner = baseRepo.Owner } else { - headOwner, err = user_model.GetUserOrOrgByName(ctx, compareReq.HeadOwner) + headOwner, err = user_model.GetUserByName(ctx, compareReq.HeadOwner) if err != nil { return nil, nil, err } diff --git a/routers/install/install.go b/routers/install/install.go index 718ede6564..3b21af6b03 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -123,7 +123,7 @@ func Install(ctx *context.Context) { func checkDatabase(ctx *context.Context, form *forms.InstallForm) bool { var err error - if (setting.Database.Type == "sqlite3") && + if (setting.Database.Type == setting.DatabaseTypeSQLite3) && len(setting.Database.Path) == 0 { ctx.Data["Err_DbPath"] = true ctx.RenderWithErrDeprecated(ctx.Tr("install.err_empty_db_path"), tplInstall, form) @@ -135,13 +135,8 @@ func checkDatabase(ctx *context.Context, form *forms.InstallForm) bool { defer db.UnsetDefaultEngine() if err = db.InitEngine(ctx); err != nil { - if strings.Contains(err.Error(), `Unknown database type: sqlite3`) { - ctx.Data["Err_DbType"] = true - ctx.RenderWithErrDeprecated(ctx.Tr("install.sqlite3_not_available", "https://docs.gitea.com/installation/install-from-binary"), tplInstall, form) - } else { - ctx.Data["Err_DbSetting"] = true - ctx.RenderWithErrDeprecated(ctx.Tr("install.invalid_db_setting", err), tplInstall, form) - } + ctx.Data["Err_DbSetting"] = true + ctx.RenderWithErrDeprecated(ctx.Tr("install.invalid_db_setting", err), tplInstall, form) return false } diff --git a/routers/web/feed/branch.go b/routers/web/feed/branch.go index eb7f6dc5bc..5818f509fe 100644 --- a/routers/web/feed/branch.go +++ b/routers/web/feed/branch.go @@ -4,7 +4,6 @@ package feed import ( - "strings" "time" "code.gitea.io/gitea/models/repo" @@ -39,14 +38,14 @@ func ShowBranchFeed(ctx *context.Context, repo *repo.Repository, formatType stri for _, commit := range commits { feed.Items = append(feed.Items, &feeds.Item{ Id: commit.ID.String(), - Title: strings.TrimSpace(strings.Split(commit.Message(), "\n")[0]), + Title: commit.MessageTitle(), Link: &feeds.Link{Href: repo.HTMLURL() + "/commit/" + commit.ID.String()}, Author: &feeds.Author{ Name: commit.Author.Name, Email: commit.Author.Email, }, - Description: commit.Message(), - Content: commit.Message(), + Description: commit.MessageUTF8(), // TODO: description can be shorten content + Content: commit.MessageUTF8(), Created: commit.Committer.When, }) } diff --git a/routers/web/feed/file.go b/routers/web/feed/file.go index 026c15c43a..2888f4e61f 100644 --- a/routers/web/feed/file.go +++ b/routers/web/feed/file.go @@ -4,7 +4,6 @@ package feed import ( - "strings" "time" "code.gitea.io/gitea/models/repo" @@ -46,14 +45,14 @@ func ShowFileFeed(ctx *context.Context, repo *repo.Repository, formatType string for _, commit := range commits { feed.Items = append(feed.Items, &feeds.Item{ Id: commit.ID.String(), - Title: strings.TrimSpace(strings.Split(commit.Message(), "\n")[0]), + Title: commit.MessageTitle(), Link: &feeds.Link{Href: repo.HTMLURL() + "/commit/" + commit.ID.String()}, Author: &feeds.Author{ Name: commit.Author.Name, Email: commit.Author.Email, }, - Description: commit.Message(), - Content: commit.Message(), + Description: commit.MessageUTF8(), // TODO: description can be shorten content + Content: commit.MessageUTF8(), Created: commit.Committer.When, }) } diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 1e9f596fc4..5c454dac24 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -28,7 +28,7 @@ import ( "code.gitea.io/gitea/services/context" "code.gitea.io/gitea/services/convert" - act_model "github.com/nektos/act/pkg/model" + act_model "gitea.com/gitea/runner/act/model" "go.yaml.in/yaml/v4" ) diff --git a/routers/web/repo/actions/actions_test.go b/routers/web/repo/actions/actions_test.go index 9e83ff0fbb..3925337844 100644 --- a/routers/web/repo/actions/actions_test.go +++ b/routers/web/repo/actions/actions_test.go @@ -11,7 +11,7 @@ import ( "code.gitea.io/gitea/models/db" unittest "code.gitea.io/gitea/models/unittest" - act_model "github.com/nektos/act/pkg/model" + act_model "gitea.com/gitea/runner/act/model" "github.com/stretchr/testify/assert" ) diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index e17d6b42d7..3ce4337fbc 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -35,7 +35,7 @@ import ( actions_service "code.gitea.io/gitea/services/actions" context_module "code.gitea.io/gitea/services/context" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" ) func findCurrentJobByPathParam(ctx *context_module.Context, jobs []*actions_model.ActionRunJob) (job *actions_model.ActionRunJob, hasPathParam bool) { @@ -1072,7 +1072,7 @@ func EnableWorkflowFile(ctx *context_module.Context) { func disableOrEnableWorkflowFile(ctx *context_module.Context, isEnable bool) { workflow := ctx.FormString("workflow") if len(workflow) == 0 { - ctx.ServerError("workflow", nil) + ctx.JSONError("workflow is required") return } diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go index 4fb61bee6d..803397f33f 100644 --- a/routers/web/repo/blame.go +++ b/routers/web/repo/blame.go @@ -231,7 +231,7 @@ func renderBlameFillFirstBlameRow(repoLink string, avatarUtils *templates.Avatar br.PreviousSha = part.PreviousSha br.PreviousShaURL = fmt.Sprintf("%s/blame/commit/%s/%s", repoLink, url.PathEscape(part.PreviousSha), util.PathEscapeSegments(part.PreviousPath)) br.CommitURL = fmt.Sprintf("%s/commit/%s", repoLink, url.PathEscape(part.Sha)) - br.CommitMessage = commit.CommitMessage + br.CommitMessage = commit.MessageUTF8() br.CommitSince = templates.TimeSince(commit.Author.When) } diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 84b51bba5f..6c973696ff 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -349,7 +349,7 @@ func Diff(ctx *context.Context) { parentCommitID = parentCommit.ID.String() } setCompareContext(ctx, parentCommit, commit, userName, repoName) - ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitID) + ctx.Data["Title"] = commit.MessageTitle() + " · " + base.ShortSha(commitID) ctx.Data["Commit"] = commit ctx.Data["Diff"] = diff ctx.Data["DiffBlobExcerptData"] = diffBlobExcerptData diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 2797b0b26d..46867e80bb 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -391,17 +391,14 @@ func prepareNewPullRequestTitleContent(ci *git_service.CompareInfo, commits []*g if useFirstCommitAsTitle { // the "commits" are from "ShowPrettyFormatLogToList", which is ordered from newest to oldest, here take the oldest one c := commits[len(commits)-1] - title = strings.TrimSpace(c.UserCommit.Summary()) + title = c.UserCommit.MessageTitle() } else { title = autoTitleFromBranchName(ci.HeadRef.ShortName()) } if len(commits) == 1 { - // FIXME: GIT-COMMIT-MESSAGE-ENCODING: try to convert the encoding for commit message explicitly, ideally it should be done by a git commit struct method c := commits[0] - _, content, _ = strings.Cut(strings.TrimSpace(c.UserCommit.CommitMessage), "\n") - content = strings.TrimSpace(content) - content = string(charset.ToUTF8([]byte(content), charset.ConvertOpts{})) + content = c.MessageBody() } var titleTrailer string diff --git a/routers/web/repo/compare_test.go b/routers/web/repo/compare_test.go index 63b0f287e5..da5b2c84b3 100644 --- a/routers/web/repo/compare_test.go +++ b/routers/web/repo/compare_test.go @@ -6,7 +6,6 @@ package repo import ( "strings" "testing" - "unicode/utf8" asymkey_model "code.gitea.io/gitea/models/asymkey" git_model "code.gitea.io/gitea/models/git" @@ -55,7 +54,7 @@ func TestNewPullRequestTitleContent(t *testing.T) { SignCommit: &asymkey_model.SignCommit{ UserCommit: &user_model.UserCommit{ Commit: &git.Commit{ - CommitMessage: msg, + CommitMessage: git.CommitMessage{MessageRaw: msg}, }, }, }, @@ -99,9 +98,9 @@ func TestNewPullRequestTitleContent(t *testing.T) { assert.Equal(t, "title-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa…", title) assert.Equal(t, "…aaaaaaaaa\n", content) - title, content = prepareNewPullRequestTitleContent(ci, []*git_model.SignCommitWithStatuses{mockCommit("a\xf0\xf0\xf0\nb\xf0\xf0\xf0")}, setting.RepoPRTitleSourceFirstCommit) - assert.Equal(t, "a?", title) // FIXME: GIT-COMMIT-MESSAGE-ENCODING: "title" doesn't use the same charset converting logic as "content" - assert.Equal(t, "b"+string(utf8.RuneError)+string(utf8.RuneError), content) + title, content = prepareNewPullRequestTitleContent(ci, []*git_model.SignCommitWithStatuses{mockCommit("title \xf0\nbody \xf0")}, setting.RepoPRTitleSourceFirstCommit) + assert.Equal(t, "title ð", title) + assert.Equal(t, "body ð", content) } func TestAutoTitleFromBranchName(t *testing.T) { diff --git a/routers/web/repo/editor_cherry_pick.go b/routers/web/repo/editor_cherry_pick.go index 605a35b100..f3cbc09827 100644 --- a/routers/web/repo/editor_cherry_pick.go +++ b/routers/web/repo/editor_cherry_pick.go @@ -6,7 +6,6 @@ package repo import ( "bytes" "net/http" - "strings" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/gitrepo" @@ -33,10 +32,10 @@ func CherryPick(ctx *context.Context) { if ctx.FormString("cherry-pick-type") == "revert" { ctx.Data["CherryPickType"] = "revert" ctx.Data["commit_summary"] = "revert " + ctx.PathParam("sha") - ctx.Data["commit_message"] = "revert " + cherryPickCommit.Message() + ctx.Data["commit_message"] = "revert " + cherryPickCommit.MessageUTF8() } else { ctx.Data["CherryPickType"] = "cherry-pick" - ctx.Data["commit_summary"], ctx.Data["commit_message"], _ = strings.Cut(cherryPickCommit.Message(), "\n") + ctx.Data["commit_summary"], ctx.Data["commit_message"] = cherryPickCommit.MessageTitle(), cherryPickCommit.MessageBody() } ctx.HTML(http.StatusOK, tplCherryPick) diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index eab4df77ad..d20bbdc36c 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -974,17 +974,15 @@ func UpdatePullRequest(ctx *context.Context) { return } - // ToDo: add check if maintainers are allowed to change branch ... (need migration & co) if (!allowedUpdateByMerge && !rebase) || (rebase && !allowedUpdateByRebase) { - ctx.Flash.Error(ctx.Tr("repo.pulls.update_not_allowed")) - ctx.Redirect(issue.Link()) + ctx.JSONError(ctx.Tr("repo.pulls.update_not_allowed")) return } // default merge commit message message := fmt.Sprintf("Merge branch '%s' into %s", issue.PullRequest.BaseBranch, issue.PullRequest.HeadBranch) - // The update process should not be cancelled by the user + // The update process should not be canceled by the user // so we set the context to be a background context if err = pull_service.Update(graceful.GetManager().ShutdownContext(), issue.PullRequest, ctx.Doer, message, rebase); err != nil { if pull_service.IsErrMergeConflicts(err) { @@ -998,8 +996,7 @@ func UpdatePullRequest(ctx *context.Context) { ctx.ServerError("UpdatePullRequest.HTMLString", err) return } - ctx.Flash.Error(flashError) - ctx.Redirect(issue.Link()) + ctx.JSONError(flashError) return } else if pull_service.IsErrRebaseConflicts(err) { conflictError := err.(pull_service.ErrRebaseConflicts) @@ -1012,19 +1009,18 @@ func UpdatePullRequest(ctx *context.Context) { ctx.ServerError("UpdatePullRequest.HTMLString", err) return } - ctx.Flash.Error(flashError) - ctx.Redirect(issue.Link()) + ctx.JSONError(flashError) return } - ctx.Flash.Error(err.Error()) - ctx.Redirect(issue.Link()) + log.Error("Update pull request failed: %v", err) + ctx.JSONError("Unable to update pull request") return } - time.Sleep(1 * time.Second) + time.Sleep(100 * time.Millisecond) // TODO: it is really questionable whether the Sleep is useful here, need to figure out ctx.Flash.Success(ctx.Tr("repo.pulls.update_branch_success")) - ctx.Redirect(issue.Link()) + ctx.JSONRedirect(issue.Link()) } // MergePullRequest response for merging pull request diff --git a/routers/web/repo/setting/actions.go b/routers/web/repo/setting/actions.go index 2237828d61..27b16b42d9 100644 --- a/routers/web/repo/setting/actions.go +++ b/routers/web/repo/setting/actions.go @@ -6,7 +6,6 @@ package setting import ( "errors" "net/http" - "strings" "code.gitea.io/gitea/models/actions" repo_model "code.gitea.io/gitea/models/repo" @@ -94,15 +93,12 @@ func ActionsUnitPost(ctx *context.Context) { } func AddCollaborativeOwner(ctx *context.Context) { - name := strings.ToLower(ctx.FormString("collaborative_owner")) - - ownerID, err := user_model.GetUserOrOrgIDByName(ctx, name) + collUser, err := user_model.GetUserByName(ctx, ctx.FormString("collaborative_owner")) if err != nil { if errors.Is(err, util.ErrNotExist) { - ctx.Flash.Error(ctx.Tr("form.user_not_exist")) - ctx.JSONErrorNotFound() + ctx.JSONError(ctx.Tr("form.user_not_exist")) } else { - ctx.ServerError("GetUserOrOrgIDByName", err) + ctx.ServerError("GetUserByName", err) } return } @@ -113,7 +109,7 @@ func AddCollaborativeOwner(ctx *context.Context) { return } actionsCfg := actionsUnit.ActionsConfig() - actionsCfg.AddCollaborativeOwner(ownerID) + actionsCfg.AddCollaborativeOwner(collUser.ID) if err := repo_model.UpdateRepoUnitConfig(ctx, actionsUnit); err != nil { ctx.ServerError("UpdateRepoUnitConfig", err) return diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index 8c57a68b25..a7c0b863cc 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -675,7 +675,7 @@ func TestWebhook(ctx *context.Context) { ID: objectFormat.EmptyObjectID(), Author: ghost.NewGitSig(), Committer: ghost.NewGitSig(), - CommitMessage: "This is a fake commit", + CommitMessage: git.CommitMessage{MessageRaw: "This is a fake commit"}, } } @@ -683,7 +683,7 @@ func TestWebhook(ctx *context.Context) { apiCommit := &api.PayloadCommit{ ID: commit.ID.String(), - Message: commit.Message(), + Message: commit.MessageUTF8(), URL: ctx.Repo.Repository.HTMLURL() + "/commit/" + url.PathEscape(commit.ID.String()), Author: &api.PayloadUser{ Name: commit.Author.Name, diff --git a/services/actions/concurrency.go b/services/actions/concurrency.go index e1ec549930..990c0e9a0b 100644 --- a/services/actions/concurrency.go +++ b/services/actions/concurrency.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/modules/json" api "code.gitea.io/gitea/modules/structs" - act_model "github.com/nektos/act/pkg/model" + act_model "gitea.com/gitea/runner/act/model" "go.yaml.in/yaml/v4" ) diff --git a/services/actions/context.go b/services/actions/context.go index 9250c40983..1d4a08459d 100644 --- a/services/actions/context.go +++ b/services/actions/context.go @@ -18,7 +18,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" ) type GiteaContext map[string]any diff --git a/services/actions/context_test.go b/services/actions/context_test.go index 22f9abcce8..d86ec47a3c 100644 --- a/services/actions/context_test.go +++ b/services/actions/context_test.go @@ -10,7 +10,7 @@ import ( actions_model "code.gitea.io/gitea/models/actions" "code.gitea.io/gitea/models/unittest" - act_model "github.com/nektos/act/pkg/model" + act_model "gitea.com/gitea/runner/act/model" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 4d2a7113b9..05f7f918df 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -28,7 +28,7 @@ import ( webhook_module "code.gitea.io/gitea/modules/webhook" "code.gitea.io/gitea/services/convert" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" ) type methodCtxKeyType struct{} @@ -256,7 +256,7 @@ func skipWorkflows(ctx context.Context, input *notifyInput, commit *git.Commit) log.Debug("repo %s: skipped run for pr %v because of %s string", input.Repo.RelativePath(), input.PullRequest.Issue.ID, s) return true } - if strings.Contains(commit.CommitMessage, s) { + if strings.Contains(commit.MessageRaw, s) { log.Debug("repo %s with commit %s: skipped run because of %s string", input.Repo.RelativePath(), commit.ID, s) return true } @@ -320,7 +320,7 @@ func handleWorkflows( for _, dwf := range detectedWorkflows { run := &actions_model.ActionRun{ - Title: strings.SplitN(commit.CommitMessage, "\n", 2)[0], + Title: commit.MessageTitle(), RepoID: input.Repo.ID, Repo: input.Repo, OwnerID: input.Repo.OwnerID, @@ -483,7 +483,7 @@ func handleSchedules( } run := &actions_model.ActionSchedule{ - Title: strings.SplitN(commit.CommitMessage, "\n", 2)[0], + Title: commit.MessageTitle(), RepoID: input.Repo.ID, Repo: input.Repo, OwnerID: input.Repo.OwnerID, diff --git a/services/actions/rerun.go b/services/actions/rerun.go index f253181a8d..d4027b7c02 100644 --- a/services/actions/rerun.go +++ b/services/actions/rerun.go @@ -17,7 +17,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" "go.yaml.in/yaml/v4" ) diff --git a/services/actions/run.go b/services/actions/run.go index 162e3678ae..ed3b3728f7 100644 --- a/services/actions/run.go +++ b/services/actions/run.go @@ -12,7 +12,7 @@ import ( "code.gitea.io/gitea/modules/actions/jobparser" "code.gitea.io/gitea/modules/util" - act_model "github.com/nektos/act/pkg/model" + act_model "gitea.com/gitea/runner/act/model" "go.yaml.in/yaml/v4" ) diff --git a/services/actions/workflow.go b/services/actions/workflow.go index b41741403f..e60ae1ec2e 100644 --- a/services/actions/workflow.go +++ b/services/actions/workflow.go @@ -5,7 +5,6 @@ package actions import ( "fmt" - "strings" actions_model "code.gitea.io/gitea/models/actions" "code.gitea.io/gitea/models/perm" @@ -22,7 +21,7 @@ import ( "code.gitea.io/gitea/services/context" "code.gitea.io/gitea/services/convert" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" "go.yaml.in/yaml/v4" ) @@ -98,7 +97,7 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re var entry *git.TreeEntry run := &actions_model.ActionRun{ - Title: strings.SplitN(runTargetCommit.CommitMessage, "\n", 2)[0], + Title: runTargetCommit.MessageTitle(), RepoID: repo.ID, Repo: repo, OwnerID: repo.OwnerID, diff --git a/services/agit/agit.go b/services/agit/agit.go index 55b98a65ae..c7c46651c0 100644 --- a/services/agit/agit.go +++ b/services/agit/agit.go @@ -150,17 +150,13 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git. if err != nil { return nil, fmt.Errorf("failed to get commit %s in repository: %s Error: %w", opts.NewCommitIDs[i], repo.FullName(), err) } - } - - // create a new pull request - if title == "" { - title = strings.Split(commit.CommitMessage, "\n")[0] - } - if description == "" { - _, description, _ = strings.Cut(commit.CommitMessage, "\n\n") - } - if description == "" { - description = title + // create a new pull request + if title == "" { + title = commit.MessageTitle() + } + if description == "" { + description = commit.MessageBody() + } } prIssue := &issues_model.Issue{ diff --git a/services/convert/convert.go b/services/convert/convert.go index a7622644d8..21fd1cadb4 100644 --- a/services/convert/convert.go +++ b/services/convert/convert.go @@ -11,7 +11,6 @@ import ( "net/url" "path" "strconv" - "strings" "time" actions_model "code.gitea.io/gitea/models/actions" @@ -38,7 +37,7 @@ import ( "code.gitea.io/gitea/services/gitdiff" runnerv1 "code.gitea.io/actions-proto-go/runner/v1" - "github.com/nektos/act/pkg/model" + "gitea.com/gitea/runner/act/model" ) // ToEmail convert models.EmailAddress to api.Email @@ -215,7 +214,7 @@ func ToTag(repo *repo_model.Repository, t *git.Tag) *api.Tag { return &api.Tag{ Name: t.Name, - Message: strings.TrimSpace(t.Message), + Message: t.MessageUTF8(), ID: t.ID.String(), Commit: ToCommitMeta(repo, t), ZipballURL: zipballURL, @@ -769,7 +768,7 @@ func ToAnnotatedTag(ctx context.Context, repo *repo_model.Repository, t *git.Tag Tag: t.Name, SHA: t.ID.String(), Object: ToAnnotatedTagObject(repo, c), - Message: t.Message, + Message: t.MessageUTF8(), URL: repo.APIURL() + "/git/tags/" + t.ID.String(), Tagger: ToCommitUser(t.Tagger), Verification: ToVerification(ctx, c), diff --git a/services/convert/git_commit.go b/services/convert/git_commit.go index d809e3778d..9daad1843e 100644 --- a/services/convert/git_commit.go +++ b/services/convert/git_commit.go @@ -56,7 +56,7 @@ func ToPayloadCommit(ctx context.Context, repo *repo_model.Repository, c *git.Co return &api.PayloadCommit{ ID: c.ID.String(), - Message: c.Message(), + Message: c.MessageUTF8(), URL: repo.HTMLURL() + "/commit/" + c.ID.String(), Author: &api.PayloadUser{ Name: c.Author.Name, @@ -171,7 +171,7 @@ func ToCommit(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Rep }, Date: commit.Committer.When.Format(time.RFC3339), }, - Message: commit.Message(), + Message: commit.MessageUTF8(), Tree: &api.CommitMeta{ URL: repo.APIURL() + "/git/trees/" + url.PathEscape(commit.ID.String()), SHA: commit.ID.String(), diff --git a/services/convert/git_commit_test.go b/services/convert/git_commit_test.go index 66a427fadf..4aa1e6cac0 100644 --- a/services/convert/git_commit_test.go +++ b/services/convert/git_commit_test.go @@ -21,12 +21,12 @@ func TestToCommitMeta(t *testing.T) { sha1 := git.Sha1ObjectFormat signature := &git.Signature{Name: "Test Signature", Email: "test@email.com", When: time.Unix(0, 0)} tag := &git.Tag{ - Name: "Test Tag", - ID: sha1.EmptyObjectID(), - Object: sha1.EmptyObjectID(), - Type: "Test Type", - Tagger: signature, - Message: "Test Message", + Name: "Test Tag", + ID: sha1.EmptyObjectID(), + Object: sha1.EmptyObjectID(), + Type: "Test Type", + Tagger: signature, + CommitMessage: git.CommitMessage{MessageRaw: "Test Message"}, } commitMeta := ToCommitMeta(headRepo, tag) diff --git a/services/convert/wiki.go b/services/convert/wiki.go index 767bfdb88d..b82b8c31e7 100644 --- a/services/convert/wiki.go +++ b/services/convert/wiki.go @@ -28,7 +28,7 @@ func ToWikiCommit(commit *git.Commit) *api.WikiCommit { }, Date: commit.Committer.When.UTC().Format(time.RFC3339), }, - Message: commit.CommitMessage, + Message: commit.MessageUTF8(), } } diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index fac382582b..e8501684d4 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -6,6 +6,7 @@ package migrations import ( "context" + "errors" "fmt" "io" "strconv" @@ -989,12 +990,15 @@ func (g *GiteaLocalUploader) remapUser(ctx context.Context, source user_model.Ex func (g *GiteaLocalUploader) remapLocalUser(ctx context.Context, source user_model.ExternalUserMigrated) (int64, error) { userid, ok := g.userMap[source.GetExternalID()] if !ok { - name, err := user_model.GetUserNameByID(ctx, source.GetExternalID()) - if err != nil { + user, err := user_model.GetUserByID(ctx, source.GetExternalID()) + if errors.Is(err, util.ErrNotExist) { + g.userMap[source.GetExternalID()] = userid + return 0, nil + } else if err != nil { return 0, err } - // let's not reuse an ID when the user was deleted or has a different user name - if name != source.GetExternalName() { + // let's not reuse an ID when the user was deleted or has a different username + if !util.AsciiEqualFold(user.Name, source.GetExternalName()) { userid = 0 } else { userid = source.GetExternalID() diff --git a/services/pull/pull.go b/services/pull/pull.go index b852dc2ed1..3524b4d9bf 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -847,7 +847,7 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ maxMsgSize := setting.Repository.PullRequest.DefaultMergeMessageSize for i := len(commits) - 1; i >= 0; i-- { commit := commits[i] - msg := strings.TrimSpace(commit.CommitMessage) + msg := strings.TrimSpace(commit.MessageUTF8()) if msg == "" { continue } @@ -1074,7 +1074,7 @@ func GetPullCommits(ctx context.Context, baseGitRepo *git.Repository, doer *user } commits = append(commits, CommitInfo{ - Summary: commit.Summary(), + Summary: commit.MessageTitle(), CommitterOrAuthorName: committerOrAuthorName, ID: commit.ID.String(), ShortSha: base.ShortSha(commit.ID.String()), diff --git a/services/repository/branch.go b/services/repository/branch.go index dc17e4f2fe..a0572f59c5 100644 --- a/services/repository/branch.go +++ b/services/repository/branch.go @@ -359,7 +359,7 @@ func SyncBranchesToDB(ctx context.Context, repoID, pusherID int64, branchNames, RepoID: repoID, Name: branchName, CommitID: commit.ID.String(), - CommitMessage: commit.Summary(), + CommitMessage: commit.MessageTitle(), PusherID: pusherID, CommitTime: timeutil.TimeStamp(commit.Committer.When.Unix()), }) diff --git a/services/repository/files/content.go b/services/repository/files/content.go index 9b042f9e67..519785ff72 100644 --- a/services/repository/files/content.go +++ b/services/repository/files/content.go @@ -179,7 +179,7 @@ func getFileContentsByEntryInternal(ctx context.Context, repo *repo_model.Reposi } } if opts.IncludeCommitMessage { - contentsResponse.LastCommitMessage = new(lastCommit.Message()) + contentsResponse.LastCommitMessage = new(lastCommit.MessageUTF8()) } } diff --git a/services/repository/files/file.go b/services/repository/files/file.go index f48e32b427..41302b2637 100644 --- a/services/repository/files/file.go +++ b/services/repository/files/file.go @@ -110,7 +110,7 @@ func GetFileCommitResponse(repo *repo_model.Repository, commit *git.Commit) (*ap }, Date: commit.Committer.When.UTC().Format(time.RFC3339), }, - Message: commit.Message(), + Message: commit.MessageUTF8(), Tree: &api.CommitMeta{ URL: commitTreeURL.String(), SHA: commit.Tree.ID.String(), diff --git a/services/repository/push.go b/services/repository/push.go index 7c68a7f176..3c9a070746 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -402,7 +402,7 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo } rel, has := relMap[lowerTag] - title, note := git.SplitCommitTitleBody(tag.Message, 255) + title, note := git.SplitCommitTitleBody(tag.MessageUTF8(), 255) if !has { rel = &repo_model.Release{ RepoID: repo.ID, diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 9cad252e67..f78fc3e5f1 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -75,7 +75,7 @@ parts: set -x sed -i 's/os.Getuid()/1/g' modules/setting/setting.go npm install -g pnpm - TAGS="bindata sqlite sqlite_unlock_notify pam cert" make build + TAGS="bindata pam cert" make build install -D gitea "${SNAPCRAFT_PART_INSTALL}/gitea" cp -r options "${SNAPCRAFT_PART_INSTALL}/" diff --git a/templates/admin/actions.tmpl b/templates/admin/actions.tmpl index 597863d73b..1bddb674c0 100644 --- a/templates/admin/actions.tmpl +++ b/templates/admin/actions.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin actions")}} +{{template "admin/layout_head" (dict "pageClass" "admin actions")}}
{{if eq .PageType "runners"}} {{template "shared/actions/runner_list" .}} diff --git a/templates/admin/applications/list.tmpl b/templates/admin/applications/list.tmpl index cbb66b1605..efc4e6e0df 100644 --- a/templates/admin/applications/list.tmpl +++ b/templates/admin/applications/list.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin config")}} +{{template "admin/layout_head" (dict "pageClass" "admin config")}}

{{ctx.Locale.Tr "settings.applications"}} diff --git a/templates/admin/applications/oauth2_edit.tmpl b/templates/admin/applications/oauth2_edit.tmpl index 668bfe0633..34ae0bf4bf 100644 --- a/templates/admin/applications/oauth2_edit.tmpl +++ b/templates/admin/applications/oauth2_edit.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin config")}} +{{template "admin/layout_head" (dict "pageClass" "admin config")}}
{{template "user/settings/applications_oauth2_edit_form" .}} diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 60480ce82f..40f19667b3 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin edit authentication")}} +{{template "admin/layout_head" (dict "pageClass" "admin edit authentication")}}

{{ctx.Locale.Tr "admin.auths.edit"}} diff --git a/templates/admin/auth/list.tmpl b/templates/admin/auth/list.tmpl index 7296e95558..17795880ea 100644 --- a/templates/admin/auth/list.tmpl +++ b/templates/admin/auth/list.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin authentication")}} +{{template "admin/layout_head" (dict "pageClass" "admin authentication")}}

{{ctx.Locale.Tr "admin.auths.auth_manage_panel"}} ({{ctx.Locale.Tr "admin.total" .Total}}) diff --git a/templates/admin/auth/new.tmpl b/templates/admin/auth/new.tmpl index 256f648c6a..6bc273c80d 100644 --- a/templates/admin/auth/new.tmpl +++ b/templates/admin/auth/new.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin new authentication")}} +{{template "admin/layout_head" (dict "pageClass" "admin new authentication")}}

{{ctx.Locale.Tr "admin.auths.new"}} diff --git a/templates/admin/badge/edit.tmpl b/templates/admin/badge/edit.tmpl index f2cdc4ad44..582ba60cd6 100644 --- a/templates/admin/badge/edit.tmpl +++ b/templates/admin/badge/edit.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin edit badge")}} +{{template "admin/layout_head" (dict "pageClass" "admin edit badge")}}

{{ctx.Locale.Tr "admin.badges.edit_badge"}} diff --git a/templates/admin/badge/list.tmpl b/templates/admin/badge/list.tmpl index 3020b7b25a..691bc44811 100644 --- a/templates/admin/badge/list.tmpl +++ b/templates/admin/badge/list.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin badge")}} +{{template "admin/layout_head" (dict "pageClass" "admin badge")}}

{{ctx.Locale.Tr "admin.badges.badges_manage_panel"}} ({{ctx.Locale.Tr "admin.total" .Total}}) diff --git a/templates/admin/badge/new.tmpl b/templates/admin/badge/new.tmpl index 5b67bed314..0c64c39608 100644 --- a/templates/admin/badge/new.tmpl +++ b/templates/admin/badge/new.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin new badge")}} +{{template "admin/layout_head" (dict "pageClass" "admin new badge")}}

{{ctx.Locale.Tr "admin.badges.new_badge"}} diff --git a/templates/admin/badge/users.tmpl b/templates/admin/badge/users.tmpl index 326fea8b11..051de1b466 100644 --- a/templates/admin/badge/users.tmpl +++ b/templates/admin/badge/users.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin badge")}} +{{template "admin/layout_head" (dict "pageClass" "admin badge")}}

{{.Title}} diff --git a/templates/admin/badge/view.tmpl b/templates/admin/badge/view.tmpl index cbe5c7b710..26d3d8dbe6 100644 --- a/templates/admin/badge/view.tmpl +++ b/templates/admin/badge/view.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" .)}} +{{template "admin/layout_head" (dict)}}
diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index c381c5bf1d..ae37950fb5 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin config")}} +{{template "admin/layout_head" (dict "pageClass" "admin config")}}

{{ctx.Locale.Tr "admin.config.server_config"}} diff --git a/templates/admin/config_settings/config_settings.tmpl b/templates/admin/config_settings/config_settings.tmpl index 6d1db4f89f..b12c2dc395 100644 --- a/templates/admin/config_settings/config_settings.tmpl +++ b/templates/admin/config_settings/config_settings.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin config" "dataGlobalInit" "initAdminConfigSettings")}} +{{template "admin/layout_head" (dict "pageClass" "admin config" "dataGlobalInit" "initAdminConfigSettings")}} {{template "admin/config_settings/avatars" .}} {{template "admin/config_settings/repository" .}} diff --git a/templates/admin/cron.tmpl b/templates/admin/cron.tmpl index 8e44614d97..457cdd5212 100644 --- a/templates/admin/cron.tmpl +++ b/templates/admin/cron.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin monitor")}} +{{template "admin/layout_head" (dict "pageClass" "admin monitor")}}

{{ctx.Locale.Tr "admin.monitor.cron"}} diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index f44dc24362..059ddd3c7e 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin dashboard")}} +{{template "admin/layout_head" (dict "pageClass" "admin dashboard")}}
{{if .NeedUpdate}}
diff --git a/templates/admin/emails/list.tmpl b/templates/admin/emails/list.tmpl index d597a2753f..135b4da3a0 100644 --- a/templates/admin/emails/list.tmpl +++ b/templates/admin/emails/list.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin user")}} +{{template "admin/layout_head" (dict "pageClass" "admin user")}}

{{ctx.Locale.Tr "admin.emails.email_manage_panel"}} ({{ctx.Locale.Tr "admin.total" .Total}}) diff --git a/templates/admin/hook_new.tmpl b/templates/admin/hook_new.tmpl index 37dcc49d53..d8df205449 100644 --- a/templates/admin/hook_new.tmpl +++ b/templates/admin/hook_new.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin settings new webhook")}} +{{template "admin/layout_head" (dict "pageClass" "admin settings new webhook")}}
{{$CustomHeaderTitle := ctx.Locale.Tr "admin.defaulthooks.update_webhook"}} {{if .PageIsAdminDefaultHooksNew}} @@ -8,6 +8,6 @@ {{else if .Webhook.IsSystemWebhook}} {{$CustomHeaderTitle = ctx.Locale.Tr "admin.systemhooks.update_webhook"}} {{end}} - {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}} + {{template "webhook/new" (dict "CustomHeaderTitle" $CustomHeaderTitle)}}
{{template "admin/layout_footer" .}} diff --git a/templates/admin/hooks.tmpl b/templates/admin/hooks.tmpl index d5fdef6850..c36a9b10eb 100644 --- a/templates/admin/hooks.tmpl +++ b/templates/admin/hooks.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin hooks")}} +{{template "admin/layout_head" (dict "pageClass" "admin hooks")}}
{{template "repo/settings/webhook/base_list" .SystemWebhooks}} {{template "repo/settings/webhook/base_list" .DefaultWebhooks}} diff --git a/templates/admin/layout_head.tmpl b/templates/admin/layout_head.tmpl index 397516da5d..ce989c40c8 100644 --- a/templates/admin/layout_head.tmpl +++ b/templates/admin/layout_head.tmpl @@ -1,9 +1,9 @@ -{{template "base/head" .ctxData}} -
+{{template "base/head" ctx.RootData}} +
- {{template "admin/navbar" .ctxData}} + {{template "admin/navbar" ctx.RootData}}
- {{template "base/alert" .ctxData}} + {{template "base/alert" ctx.RootData}} {{/* block: admin-setting-content */}} {{if false}}{{/* to make html structure "likely" complete to prevent IDE warnings */}} diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index 55ee9da852..c4c29fc830 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin notice")}} +{{template "admin/layout_head" (dict "pageClass" "admin notice")}}

{{ctx.Locale.Tr "admin.notices.system_notice_list"}} ({{ctx.Locale.Tr "admin.total" .Total}}) diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index e6de93c5f8..ad2bb46167 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin user")}} +{{template "admin/layout_head" (dict "pageClass" "admin user")}}

{{ctx.Locale.Tr "admin.orgs.org_manage_panel"}} ({{ctx.Locale.Tr "admin.total" .Total}}) diff --git a/templates/admin/packages/list.tmpl b/templates/admin/packages/list.tmpl index 8701cb0d57..800f8dac5b 100644 --- a/templates/admin/packages/list.tmpl +++ b/templates/admin/packages/list.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin user")}} +{{template "admin/layout_head" (dict "pageClass" "admin user")}}

{{ctx.Locale.Tr "admin.packages.package_manage_panel"}} ({{ctx.Locale.Tr "admin.total" .TotalCount}}, diff --git a/templates/admin/perftrace.tmpl b/templates/admin/perftrace.tmpl index 2e09f14e46..6b302f2996 100644 --- a/templates/admin/perftrace.tmpl +++ b/templates/admin/perftrace.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin monitor")}} +{{template "admin/layout_head" (dict "pageClass" "admin monitor")}}
{{template "admin/trace_tabs" .}} diff --git a/templates/admin/queue.tmpl b/templates/admin/queue.tmpl index e6abd1e794..b3804980ce 100644 --- a/templates/admin/queue.tmpl +++ b/templates/admin/queue.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin monitor")}} +{{template "admin/layout_head" (dict "pageClass" "admin monitor")}}

{{ctx.Locale.Tr "admin.monitor.queues"}} diff --git a/templates/admin/queue_manage.tmpl b/templates/admin/queue_manage.tmpl index 73da9164cc..a57273f055 100644 --- a/templates/admin/queue_manage.tmpl +++ b/templates/admin/queue_manage.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin monitor")}} +{{template "admin/layout_head" (dict "pageClass" "admin monitor")}}

{{ctx.Locale.Tr "admin.monitor.queue" .Queue.GetName}} diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index c72daba322..d366b8cb2d 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin")}} +{{template "admin/layout_head" (dict "pageClass" "admin")}}

{{ctx.Locale.Tr "admin.repos.repo_manage_panel"}} ({{ctx.Locale.Tr "admin.total" .Total}}) diff --git a/templates/admin/repo/unadopted.tmpl b/templates/admin/repo/unadopted.tmpl index e66add6ce8..db27b11ac5 100644 --- a/templates/admin/repo/unadopted.tmpl +++ b/templates/admin/repo/unadopted.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin")}} +{{template "admin/layout_head" (dict "pageClass" "admin")}}

{{ctx.Locale.Tr "admin.repos.unadopted"}} diff --git a/templates/admin/runners/edit.tmpl b/templates/admin/runners/edit.tmpl index 1165c84b79..7d7fee1505 100644 --- a/templates/admin/runners/edit.tmpl +++ b/templates/admin/runners/edit.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin runners")}} +{{template "admin/layout_head" (dict "pageClass" "admin runners")}}
{{template "shared/actions/runner_edit" .}}
diff --git a/templates/admin/self_check.tmpl b/templates/admin/self_check.tmpl index a7f43f4e12..31d6a5d516 100644 --- a/templates/admin/self_check.tmpl +++ b/templates/admin/self_check.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin")}} +{{template "admin/layout_head" (dict "pageClass" "admin")}}

diff --git a/templates/admin/stacktrace.tmpl b/templates/admin/stacktrace.tmpl index c5dde6b30c..a74a3d3e41 100644 --- a/templates/admin/stacktrace.tmpl +++ b/templates/admin/stacktrace.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin monitor")}} +{{template "admin/layout_head" (dict "pageClass" "admin monitor")}}
{{template "admin/trace_tabs" .}} diff --git a/templates/admin/stats.tmpl b/templates/admin/stats.tmpl index bb6a86ac30..610c2860a3 100644 --- a/templates/admin/stats.tmpl +++ b/templates/admin/stats.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin monitor")}} +{{template "admin/layout_head" (dict "pageClass" "admin monitor")}}

{{ctx.Locale.Tr "admin.dashboard.statistic"}} diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 83eac64fa0..0563cf63b4 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin edit user")}} +{{template "admin/layout_head" (dict "pageClass" "admin edit user")}}

{{ctx.Locale.Tr "admin.users.edit_account"}} diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index 168603354d..db7cb4874f 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin user")}} +{{template "admin/layout_head" (dict "pageClass" "admin user")}}

{{ctx.Locale.Tr "admin.users.user_manage_panel"}} ({{ctx.Locale.Tr "admin.total" .Total}}) diff --git a/templates/admin/user/new.tmpl b/templates/admin/user/new.tmpl index 8af7f116a1..8fe91bd343 100644 --- a/templates/admin/user/new.tmpl +++ b/templates/admin/user/new.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin new user")}} +{{template "admin/layout_head" (dict "pageClass" "admin new user")}}

{{ctx.Locale.Tr "admin.users.new_account"}} diff --git a/templates/admin/user/view.tmpl b/templates/admin/user/view.tmpl index 67f9148e64..bb1b4991d8 100644 --- a/templates/admin/user/view.tmpl +++ b/templates/admin/user/view.tmpl @@ -1,4 +1,4 @@ -{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin view user")}} +{{template "admin/layout_head" (dict "pageClass" "admin view user")}}
diff --git a/templates/base/head_opengraph.tmpl b/templates/base/head_opengraph.tmpl index 93624ea4b0..3de262f59f 100644 --- a/templates/base/head_opengraph.tmpl +++ b/templates/base/head_opengraph.tmpl @@ -18,8 +18,7 @@ {{if and .PageIsDiff .Commit}} - {{- $commitMessageParts := StringUtils.Cut .Commit.Message "\n" -}} - {{- $commitMessageBody := index $commitMessageParts 1 -}} + {{- $commitMessageBody := .Commit.MessageBody -}} {{- if $commitMessageBody -}} {{- end -}} diff --git a/templates/mail/repo/issue/default.tmpl b/templates/mail/repo/issue/default.tmpl index 6e70cb83cd..44cdc563ad 100644 --- a/templates/mail/repo/issue/default.tmpl +++ b/templates/mail/repo/issue/default.tmpl @@ -65,11 +65,12 @@ {{end -}} {{if eq .ActionName "push"}} diff --git a/templates/org/settings/actions.tmpl b/templates/org/settings/actions.tmpl index abb9c98435..1abf895627 100644 --- a/templates/org/settings/actions.tmpl +++ b/templates/org/settings/actions.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings actions")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings actions")}}
{{if eq .PageType "runners"}} {{template "shared/actions/runner_list" .}} diff --git a/templates/org/settings/actions_general.tmpl b/templates/org/settings/actions_general.tmpl index ebf9482f61..2d2c4a4ca0 100644 --- a/templates/org/settings/actions_general.tmpl +++ b/templates/org/settings/actions_general.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" .)}} +{{template "org/settings/layout_head" (dict)}}
{{template "shared/actions/owner_general_settings" .}}
diff --git a/templates/org/settings/applications.tmpl b/templates/org/settings/applications.tmpl index df5f4e9dbc..eb12d3fa2a 100644 --- a/templates/org/settings/applications.tmpl +++ b/templates/org/settings/applications.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings options")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings options")}}

{{ctx.Locale.Tr "settings.applications"}} diff --git a/templates/org/settings/applications_oauth2_edit.tmpl b/templates/org/settings/applications_oauth2_edit.tmpl index 987803ac26..7fdbc94058 100644 --- a/templates/org/settings/applications_oauth2_edit.tmpl +++ b/templates/org/settings/applications_oauth2_edit.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings options")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings options")}}
{{template "user/settings/applications_oauth2_edit_form" .}}
diff --git a/templates/org/settings/blocked_users.tmpl b/templates/org/settings/blocked_users.tmpl index eab5ec0007..4444048f7a 100644 --- a/templates/org/settings/blocked_users.tmpl +++ b/templates/org/settings/blocked_users.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings blocked_users")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings blocked_users")}}
{{template "shared/user/blocked_users" .}}
diff --git a/templates/org/settings/hook_new.tmpl b/templates/org/settings/hook_new.tmpl index f89ee5f2b8..11f71d9059 100644 --- a/templates/org/settings/hook_new.tmpl +++ b/templates/org/settings/hook_new.tmpl @@ -1,7 +1,7 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings new webhook")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings new webhook")}}
{{$CustomHeaderTitle := ctx.Locale.Tr "repo.settings.update_webhook"}} {{if .PageIsSettingsHooksNew}}{{$CustomHeaderTitle = ctx.Locale.Tr "repo.settings.add_webhook"}}{{end}} - {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}} + {{template "webhook/new" (dict "CustomHeaderTitle" $CustomHeaderTitle)}}
{{template "org/settings/layout_footer" .}} diff --git a/templates/org/settings/hooks.tmpl b/templates/org/settings/hooks.tmpl index b05e22fe20..dbb1721fff 100644 --- a/templates/org/settings/hooks.tmpl +++ b/templates/org/settings/hooks.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings webhooks")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings webhooks")}}
{{template "repo/settings/webhook/base_list" .}}
diff --git a/templates/org/settings/labels.tmpl b/templates/org/settings/labels.tmpl index 283b2199cb..4246c7305e 100644 --- a/templates/org/settings/labels.tmpl +++ b/templates/org/settings/labels.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings labels")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings labels")}}
diff --git a/templates/org/settings/layout_head.tmpl b/templates/org/settings/layout_head.tmpl index 31dad2c141..97515d89ef 100644 --- a/templates/org/settings/layout_head.tmpl +++ b/templates/org/settings/layout_head.tmpl @@ -1,10 +1,10 @@ -{{template "base/head" .ctxData}} -
- {{template "org/header" .ctxData}} +{{template "base/head" ctx.RootData}} +
+ {{template "org/header" ctx.RootData}}
- {{template "org/settings/navbar" .ctxData}} + {{template "org/settings/navbar" ctx.RootData}}
- {{template "base/alert" .ctxData}} + {{template "base/alert" ctx.RootData}} {{/* block: org-setting-content */}} {{if false}}{{/* to make html structure "likely" complete to prevent IDE warnings */}} diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 2c17e13937..614e861b09 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings options")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings options")}}

diff --git a/templates/org/settings/packages.tmpl b/templates/org/settings/packages.tmpl index 91106c3f15..a73ab97a37 100644 --- a/templates/org/settings/packages.tmpl +++ b/templates/org/settings/packages.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings packages")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings packages")}}
{{template "package/shared/cleanup_rules/list" .}} {{template "package/shared/cargo" .}} diff --git a/templates/org/settings/packages_cleanup_rules_edit.tmpl b/templates/org/settings/packages_cleanup_rules_edit.tmpl index ff4c2dd651..a6359416c0 100644 --- a/templates/org/settings/packages_cleanup_rules_edit.tmpl +++ b/templates/org/settings/packages_cleanup_rules_edit.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings packages")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings packages")}}
{{template "package/shared/cleanup_rules/edit" .}}
diff --git a/templates/org/settings/packages_cleanup_rules_preview.tmpl b/templates/org/settings/packages_cleanup_rules_preview.tmpl index 5a2f061225..973413c440 100644 --- a/templates/org/settings/packages_cleanup_rules_preview.tmpl +++ b/templates/org/settings/packages_cleanup_rules_preview.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings packages")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings packages")}}
{{template "package/shared/cleanup_rules/preview" .}}
diff --git a/templates/org/settings/runners_edit.tmpl b/templates/org/settings/runners_edit.tmpl index acd67a4d7b..b87c6c1091 100644 --- a/templates/org/settings/runners_edit.tmpl +++ b/templates/org/settings/runners_edit.tmpl @@ -1,4 +1,4 @@ -{{template "org/settings/layout_head" (dict "ctxData" . "pageClass" "organization settings runners")}} +{{template "org/settings/layout_head" (dict "pageClass" "organization settings runners")}}
{{template "shared/actions/runner_edit" .}}
diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 8451a6f3cf..975cd303ec 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -5,7 +5,7 @@
-

{{ctx.RenderUtils.RenderCommitMessage .Commit.Message $.Repository}}{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "AdditionalClasses" "tw-inline"}}

+

{{ctx.RenderUtils.RenderCommitMessage .Commit.MessageUTF8 $.Repository}}{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "AdditionalClasses" "tw-inline"}}

{{if not $.PageIsWiki}} {{end}}
- {{if IsMultilineCommitMessage .Commit.Message}} -
{{ctx.RenderUtils.RenderCommitBody .Commit.Message $.Repository}}
+ {{if .Commit.MessageBody}} +
{{ctx.RenderUtils.RenderCommitBody .Commit.MessageUTF8 $.Repository}}
{{end}} {{template "repo/commit_load_branches_and_tags" .}}
diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index d520c0fbcf..e79d189b8d 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -11,7 +11,7 @@ {{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}} - {{range .Commits}} + {{range $commit := .Commits}} @@ -38,18 +38,22 @@ {{if $.PageIsWiki}} - {{.Summary | ctx.RenderUtils.RenderEmoji}} + + {{$commit.MessageTitle | ctx.RenderUtils.RenderEmoji}} + {{else}} - {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} - {{ctx.RenderUtils.RenderCommitMessageLinkSubject .Message $commitLink $.Repository}} + {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape $commit.ID.String)}} + + {{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.MessageUTF8 $commitLink $.Repository}} + {{end}} - {{if IsMultilineCommitMessage .Message}} + {{if $commit.MessageBody}} {{end}} {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} - {{if IsMultilineCommitMessage .Message}} -
{{ctx.RenderUtils.RenderCommitBody .Message $.Repository}}
+ {{if $commit.MessageBody}} +
{{ctx.RenderUtils.RenderCommitBody $commit.MessageUTF8 $.Repository}}
{{end}} {{if $.CommitsTagsMap}} {{range (index $.CommitsTagsMap .ID.String)}} diff --git a/templates/repo/commits_list_small.tmpl b/templates/repo/commits_list_small.tmpl index 0470d1e9f5..c5f0d5b590 100644 --- a/templates/repo/commits_list_small.tmpl +++ b/templates/repo/commits_list_small.tmpl @@ -1,6 +1,6 @@ {{$index := 0}}
-{{range .comment.Commits}} +{{range $commit := .comment.Commits}} {{$tag := printf "%s-%d" $.comment.HashTag $index}} {{$index = Eval $index "+" 1}}
{{/*singular-commit*/}} @@ -14,11 +14,11 @@ {{$commitBaseLink := printf "%s/commit" $.comment.Issue.PullRequest.BaseRepo.Link}} {{$commitLink:= printf "%s/%s" $commitBaseLink (PathEscape .ID.String)}} - - {{- ctx.RenderUtils.RenderCommitMessageLinkSubject .Message $commitLink $.comment.Issue.PullRequest.BaseRepo -}} + + {{- ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.MessageUTF8 $commitLink $.comment.Issue.PullRequest.BaseRepo -}} - {{if IsMultilineCommitMessage .Message}} + {{if $commit.MessageBody}} {{end}} @@ -27,9 +27,9 @@ {{template "repo/commit_sign_badge" dict "Commit" . "CommitBaseLink" $commitBaseLink "CommitSignVerification" .Verification}}
- {{if IsMultilineCommitMessage .Message}} + {{if $commit.MessageBody}}
-		{{- ctx.RenderUtils.RenderCommitBody .Message $.comment.Issue.PullRequest.BaseRepo -}}
+		{{- ctx.RenderUtils.RenderCommitBody $commit.MessageUTF8 $.comment.Issue.PullRequest.BaseRepo -}}
 	
{{end}} {{end}} diff --git a/templates/repo/editor/commit_form.tmpl b/templates/repo/editor/commit_form.tmpl index 7fdd36b3bd..d0c47e9bdd 100644 --- a/templates/repo/editor/commit_form.tmpl +++ b/templates/repo/editor/commit_form.tmpl @@ -22,7 +22,7 @@
-
+
@@ -30,9 +30,9 @@ {{svg "octicon-git-commit"}} {{ctx.Locale.Tr "repo.editor.commit_directly_to_this_branch" .BranchName}} {{if not .CommitFormOptions.CanCommitToBranch}} -
+
{{ctx.Locale.Tr "repo.editor.no_commit_to_branch"}} -
    +
      {{if not .CommitFormOptions.UserCanPush}}
    • {{ctx.Locale.Tr "repo.editor.user_no_push_to_branch"}}
    • {{end}} {{if and .CommitFormOptions.RequireSigned (not .CommitFormOptions.WillSign)}}
    • {{ctx.Locale.Tr "repo.editor.require_signed_commit"}}
    • {{end}}
    diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 275dd47a76..d1b327434b 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -1,8 +1,8 @@
    {{$createdStr:= DateUtils.TimeSince .Issue.CreatedUnix}} -
    -
    -
    +
    +
    +
    {{if .Issue.OriginalAuthor}} {{ctx.AvatarUtils.Avatar nil 40}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 6a67ef754d..d5c0b5d7df 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -86,7 +86,7 @@ {{template "shared/user/avatarlink" dict "user" .Poster}} {{end}} - {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{template "repo/issue/view_content/comments_authorlink" dict "comment" .}} {{if .Issue.IsPull}} {{ctx.Locale.Tr "repo.pulls.reopened_at" .EventTag $createdStr}} {{else}} @@ -101,7 +101,7 @@ {{template "shared/user/avatarlink" dict "user" .Poster}} {{end}} - {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{template "repo/issue/view_content/comments_authorlink" dict "comment" .}} {{if .Issue.IsPull}} {{ctx.Locale.Tr "repo.pulls.closed_at" .EventTag $createdStr}} {{else}} @@ -116,7 +116,7 @@ {{template "shared/user/avatarlink" dict "user" .Poster}} {{end}} - {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{template "repo/issue/view_content/comments_authorlink" dict "comment" .}} {{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}} {{if eq $.Issue.PullRequest.Status 3}} {{ctx.Locale.Tr "repo.issues.comment_manually_pull_merged_at" (HTMLFormat `%[2]s` $link (ShortSha $.Issue.PullRequest.MergedCommitID)) (HTMLFormat "%[1]s" $.BaseTarget) $createdStr}} @@ -256,7 +256,7 @@ {{if not $timeStr}}{{$timeStr = .Content|Sec2Hour}}{{end}} {{ctx.Locale.Tr "repo.issues.stop_tracking_history" $timeStr $createdStr}} - {{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}} + {{template "repo/issue/view_content/comments_delete_time" dict "comment" .}}
    {{else if eq .Type 14}}
    @@ -268,7 +268,7 @@ {{if not $timeStr}}{{$timeStr = .Content|Sec2Hour}}{{end}} {{ctx.Locale.Tr "repo.issues.add_time_history" $timeStr $createdStr}} - {{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}} + {{template "repo/issue/view_content/comments_delete_time" dict "comment" .}}
    {{else if eq .Type 15}}
    @@ -362,7 +362,7 @@ {{else if eq .Type 22}}
    @@ -663,7 +665,7 @@
    {{svg "octicon-git-merge" 16}} - {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{template "repo/issue/view_content/comments_authorlink" dict "comment" .}} {{if eq .Type 34}}{{ctx.Locale.Tr "repo.pulls.auto_merge_newly_scheduled_comment" $createdStr}} {{else}}{{ctx.Locale.Tr "repo.pulls.auto_merge_canceled_schedule_comment" $createdStr}}{{end}} diff --git a/templates/repo/issue/view_content/comments_authorlink.tmpl b/templates/repo/issue/view_content/comments_authorlink.tmpl index fd07bd2b1c..8e0645c983 100644 --- a/templates/repo/issue/view_content/comments_authorlink.tmpl +++ b/templates/repo/issue/view_content/comments_authorlink.tmpl @@ -1,10 +1,10 @@ {{if .comment.OriginalAuthor}} - {{svg (MigrationIcon .ctxData.Repository.GetOriginalURLHostname)}} + {{svg (MigrationIcon ctx.RootData.Repository.GetOriginalURLHostname)}} {{.comment.OriginalAuthor}} - {{if .ctxData.Repository.OriginalURL}} - ({{ctx.Locale.Tr "repo.migrated_from" .ctxData.Repository.OriginalURL .ctxData.Repository.GetOriginalURLHostname}}) + {{if ctx.RootData.Repository.OriginalURL}} + ({{ctx.Locale.Tr "repo.migrated_from" ctx.RootData.Repository.OriginalURL ctx.RootData.Repository.GetOriginalURLHostname}}) {{end}} {{else}} {{template "shared/user/authorlink" .comment.Poster}} diff --git a/templates/repo/issue/view_content/comments_delete_time.tmpl b/templates/repo/issue/view_content/comments_delete_time.tmpl index 219d5fc203..dfbbd5fd7a 100644 --- a/templates/repo/issue/view_content/comments_delete_time.tmpl +++ b/templates/repo/issue/view_content/comments_delete_time.tmpl @@ -1,9 +1,9 @@ -{{if and .comment.Time (.ctxData.Repository.IsTimetrackerEnabled ctx)}} {{/* compatibility with time comments made before v1.14 */}} +{{if and .comment.Time (ctx.RootData.Repository.IsTimetrackerEnabled ctx)}} {{/* compatibility with time comments made before v1.14 */}} {{if (not .comment.Time.Deleted)}} - {{if (or .ctxData.IsAdmin (and .ctxData.IsSigned (eq .ctxData.SignedUserID .comment.PosterID)))}} + {{if (or ctx.RootData.IsAdmin (and ctx.RootData.IsSigned (eq ctx.RootData.SignedUserID .comment.PosterID)))}} - + {{if $data.UpdateAllowed}} +
    + + {{if $data.UpdateByRebaseAllowed}} + {{end}}
    + {{end}}
    diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl index c8f1ad5492..c0518189b8 100644 --- a/templates/repo/latest_commit.tmpl +++ b/templates/repo/latest_commit.tmpl @@ -17,10 +17,11 @@ {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} {{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}} - {{ctx.RenderUtils.RenderCommitMessageLinkSubject .LatestCommit.Message $commitLink $.Repository}} - {{if IsMultilineCommitMessage .LatestCommit.Message}} + + {{ctx.RenderUtils.RenderCommitMessageLinkSubject .LatestCommit.MessageUTF8 $commitLink $.Repository}} + {{if .LatestCommit.MessageBody}} -
    {{ctx.RenderUtils.RenderCommitBody .LatestCommit.Message $.Repository}}
    +
    {{ctx.RenderUtils.RenderCommitBody .LatestCommit.MessageUTF8 $.Repository}}
    {{end}}
    {{end}} diff --git a/templates/repo/settings/actions.tmpl b/templates/repo/settings/actions.tmpl index 5388de35af..5754ce388d 100644 --- a/templates/repo/settings/actions.tmpl +++ b/templates/repo/settings/actions.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings actions")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings actions")}}
    {{if eq .PageType "runners"}} {{template "shared/actions/runner_list" .}} diff --git a/templates/repo/settings/branches.tmpl b/templates/repo/settings/branches.tmpl index d3f6f38e13..6ec80c057f 100644 --- a/templates/repo/settings/branches.tmpl +++ b/templates/repo/settings/branches.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings edit")}}
    {{if .Repository.IsArchived}}
    diff --git a/templates/repo/settings/collaboration.tmpl b/templates/repo/settings/collaboration.tmpl index d9e52d9568..48e3f3287e 100644 --- a/templates/repo/settings/collaboration.tmpl +++ b/templates/repo/settings/collaboration.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings collaboration")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings collaboration")}}

    {{ctx.Locale.Tr "repo.settings.collaboration"}} diff --git a/templates/repo/settings/deploy_keys.tmpl b/templates/repo/settings/deploy_keys.tmpl index c4bffbbf08..89a9df3667 100644 --- a/templates/repo/settings/deploy_keys.tmpl +++ b/templates/repo/settings/deploy_keys.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings")}}

    {{ctx.Locale.Tr "repo.settings.deploy_keys"}} diff --git a/templates/repo/settings/githook_edit.tmpl b/templates/repo/settings/githook_edit.tmpl index b537403298..07ea7fb4fd 100644 --- a/templates/repo/settings/githook_edit.tmpl +++ b/templates/repo/settings/githook_edit.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit githook")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings edit githook")}}

    diff --git a/templates/repo/settings/githooks.tmpl b/templates/repo/settings/githooks.tmpl index cd4fd6f31f..77aa503a6b 100644 --- a/templates/repo/settings/githooks.tmpl +++ b/templates/repo/settings/githooks.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings githooks")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings githooks")}}

    {{ctx.Locale.Tr "repo.settings.githooks"}} diff --git a/templates/repo/settings/layout_head.tmpl b/templates/repo/settings/layout_head.tmpl index efec9bf874..5f975b879e 100644 --- a/templates/repo/settings/layout_head.tmpl +++ b/templates/repo/settings/layout_head.tmpl @@ -1,10 +1,10 @@ -{{template "base/head" .ctxData}} -
    - {{template "repo/header" .ctxData}} +{{template "base/head" ctx.RootData}} +
    + {{template "repo/header" ctx.RootData}}
    - {{template "repo/settings/navbar" .ctxData}} + {{template "repo/settings/navbar" ctx.RootData}}
    - {{template "base/alert" .ctxData}} + {{template "base/alert" ctx.RootData}} {{/* block: repo-setting-content */}} {{if false}}{{/* to make html structure "likely" complete to prevent IDE warnings */}} diff --git a/templates/repo/settings/lfs.tmpl b/templates/repo/settings/lfs.tmpl index a3957ffd53..0b9f4aac22 100644 --- a/templates/repo/settings/lfs.tmpl +++ b/templates/repo/settings/lfs.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings lfs")}}

    {{ctx.Locale.Tr "repo.settings.lfs_filelist"}} ({{ctx.Locale.Tr "admin.total" .Total}}) diff --git a/templates/repo/settings/lfs_file.tmpl b/templates/repo/settings/lfs_file.tmpl index e9f4afda26..b04dc16cdf 100644 --- a/templates/repo/settings/lfs_file.tmpl +++ b/templates/repo/settings/lfs_file.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings lfs")}}

    diff --git a/templates/repo/settings/lfs_file_find.tmpl b/templates/repo/settings/lfs_file_find.tmpl index c19bd56e87..ddf98783db 100644 --- a/templates/repo/settings/lfs_file_find.tmpl +++ b/templates/repo/settings/lfs_file_find.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings lfs")}}

    @@ -6,7 +6,7 @@

    - {{range .Results}} + {{range $lfsItem := .Results}} diff --git a/templates/repo/settings/lfs_locks.tmpl b/templates/repo/settings/lfs_locks.tmpl index 55bb2ce1d3..f91ad46afb 100644 --- a/templates/repo/settings/lfs_locks.tmpl +++ b/templates/repo/settings/lfs_locks.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings lfs")}}

    diff --git a/templates/repo/settings/lfs_pointers.tmpl b/templates/repo/settings/lfs_pointers.tmpl index 2138aadc53..9e558c9af5 100644 --- a/templates/repo/settings/lfs_pointers.tmpl +++ b/templates/repo/settings/lfs_pointers.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings lfs")}}

    {{ctx.Locale.Tr "repo.settings.lfs_pointers.found" .NumPointers .NumAssociated .NumNotAssociated .NumNoExist}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 352469234b..2494251725 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings options")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings options")}}

    {{ctx.Locale.Tr "repo.settings.basic_settings"}} diff --git a/templates/repo/settings/protected_branch.tmpl b/templates/repo/settings/protected_branch.tmpl index daa1d5f3f9..fc26c3b517 100644 --- a/templates/repo/settings/protected_branch.tmpl +++ b/templates/repo/settings/protected_branch.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings branches")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings branches")}}

    diff --git a/templates/repo/settings/public_access.tmpl b/templates/repo/settings/public_access.tmpl index cfd9bf5cb1..de3fe0d9f0 100644 --- a/templates/repo/settings/public_access.tmpl +++ b/templates/repo/settings/public_access.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings")}}

    {{ctx.Locale.Tr "repo.settings.public_access"}} diff --git a/templates/repo/settings/runner_edit.tmpl b/templates/repo/settings/runner_edit.tmpl index 8b76aead57..726f608d34 100644 --- a/templates/repo/settings/runner_edit.tmpl +++ b/templates/repo/settings/runner_edit.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings runners")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings runners")}}
    {{template "shared/actions/runner_edit" .}}
    diff --git a/templates/repo/settings/secrets.tmpl b/templates/repo/settings/secrets.tmpl index 0b89639e79..30d374685a 100644 --- a/templates/repo/settings/secrets.tmpl +++ b/templates/repo/settings/secrets.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings")}}
    {{template "shared/secrets/add_list" .}}
    diff --git a/templates/repo/settings/tags.tmpl b/templates/repo/settings/tags.tmpl index af03b3598f..5abac11ebb 100644 --- a/templates/repo/settings/tags.tmpl +++ b/templates/repo/settings/tags.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings edit")}}
    {{if .Repository.IsArchived}}
    diff --git a/templates/repo/settings/webhook/base.tmpl b/templates/repo/settings/webhook/base.tmpl index 39bb7a9fe0..2a75edc328 100644 --- a/templates/repo/settings/webhook/base.tmpl +++ b/templates/repo/settings/webhook/base.tmpl @@ -1,4 +1,4 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings webhooks")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings webhooks")}}
    {{template "repo/settings/webhook/base_list" .}}
    diff --git a/templates/repo/settings/webhook/new.tmpl b/templates/repo/settings/webhook/new.tmpl index b04a44213a..45db5fa082 100644 --- a/templates/repo/settings/webhook/new.tmpl +++ b/templates/repo/settings/webhook/new.tmpl @@ -1,7 +1,7 @@ -{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings new webhook")}} +{{template "repo/settings/layout_head" (dict "pageClass" "repository settings new webhook")}}
    {{$CustomHeaderTitle := ctx.Locale.Tr "repo.settings.update_webhook"}} {{if .PageIsSettingsHooksNew}}{{$CustomHeaderTitle = ctx.Locale.Tr "repo.settings.add_webhook"}}{{end}} - {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}} + {{template "webhook/new" (dict "CustomHeaderTitle" $CustomHeaderTitle)}}
    {{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 317c67611e..e79eac1dd1 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -56,7 +56,7 @@
    {{if $commit}} {{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}} - {{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.Message $commitLink $.Repository}} + {{ctx.RenderUtils.RenderCommitMessageLinkSubject $commit.MessageUTF8 $commitLink $.Repository}} {{else}} … {{/* will be loaded again by LastCommitLoaderURL */}} {{end}} diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 03f03b176d..baf077863c 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -88,13 +88,13 @@ {{$repoLink := (.GetRepoLink ctx)}} {{$repo := .Repo}}
    - {{range $push.Commits}} + {{range $pushCommit := $push.Commits}} {{$commitLink := printf "%s/commit/%s" $repoLink .Sha1}}
    {{ShortSha .Sha1}} - {{ctx.RenderUtils.RenderCommitMessage .Message $repo}} + {{ctx.RenderUtils.RenderCommitMessage $pushCommit.Message $repo}}
    {{end}} diff --git a/templates/user/settings/account.tmpl b/templates/user/settings/account.tmpl index aabdbbb8cb..1b58f711ec 100644 --- a/templates/user/settings/account.tmpl +++ b/templates/user/settings/account.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings account")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings account")}}

    {{ctx.Locale.Tr "settings.password"}} diff --git a/templates/user/settings/actions.tmpl b/templates/user/settings/actions.tmpl index abc5443383..5ba550abf0 100644 --- a/templates/user/settings/actions.tmpl +++ b/templates/user/settings/actions.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings actions")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings actions")}}
    {{if eq .PageType "secrets"}} {{template "shared/secrets/add_list" .}} diff --git a/templates/user/settings/actions_general.tmpl b/templates/user/settings/actions_general.tmpl index 86ad0d1dd3..03bd449f85 100644 --- a/templates/user/settings/actions_general.tmpl +++ b/templates/user/settings/actions_general.tmpl @@ -1,3 +1,3 @@ -{{template "user/settings/layout_head" (dict "ctxData" .)}} +{{template "user/settings/layout_head" (dict)}} {{template "shared/actions/owner_general_settings" .}} {{template "user/settings/layout_footer" .}} diff --git a/templates/user/settings/appearance.tmpl b/templates/user/settings/appearance.tmpl index 139ddab943..ecce437af7 100644 --- a/templates/user/settings/appearance.tmpl +++ b/templates/user/settings/appearance.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings")}}
    diff --git a/templates/user/settings/applications.tmpl b/templates/user/settings/applications.tmpl index 4f1c1bbd82..195a2c3a57 100644 --- a/templates/user/settings/applications.tmpl +++ b/templates/user/settings/applications.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings applications")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings applications")}}

    {{ctx.Locale.Tr "settings.manage_access_token"}} diff --git a/templates/user/settings/applications_oauth2_edit.tmpl b/templates/user/settings/applications_oauth2_edit.tmpl index 2858ecd0ee..05ed2a5766 100644 --- a/templates/user/settings/applications_oauth2_edit.tmpl +++ b/templates/user/settings/applications_oauth2_edit.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings applications")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings applications")}}
    {{template "user/settings/applications_oauth2_edit_form" .}} diff --git a/templates/user/settings/blocked_users.tmpl b/templates/user/settings/blocked_users.tmpl index e495b85f58..0d77968a42 100644 --- a/templates/user/settings/blocked_users.tmpl +++ b/templates/user/settings/blocked_users.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings blocked_users")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings blocked_users")}}
    {{template "shared/user/blocked_users" .}}
    diff --git a/templates/user/settings/hook_new.tmpl b/templates/user/settings/hook_new.tmpl index be21f59b9c..b093a39cd1 100644 --- a/templates/user/settings/hook_new.tmpl +++ b/templates/user/settings/hook_new.tmpl @@ -1,7 +1,7 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings new webhook")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings new webhook")}}
    {{$CustomHeaderTitle := ctx.Locale.Tr "repo.settings.update_webhook"}} {{if .PageIsSettingsHooksNew}}{{$CustomHeaderTitle = ctx.Locale.Tr "repo.settings.add_webhook"}}{{end}} - {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}} + {{template "webhook/new" (dict "CustomHeaderTitle" $CustomHeaderTitle)}}
    {{template "user/settings/layout_footer" .}} diff --git a/templates/user/settings/hooks.tmpl b/templates/user/settings/hooks.tmpl index e2d18001f2..a31aba7ac6 100644 --- a/templates/user/settings/hooks.tmpl +++ b/templates/user/settings/hooks.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings webhooks")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings webhooks")}}
    {{template "repo/settings/webhook/base_list" .}}
    diff --git a/templates/user/settings/keys.tmpl b/templates/user/settings/keys.tmpl index e0f5e426ae..c9678850d2 100644 --- a/templates/user/settings/keys.tmpl +++ b/templates/user/settings/keys.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings sshkeys")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings sshkeys")}}
    {{if not ($.UserDisabledFeatures.Contains "manage_ssh_keys")}} {{template "user/settings/keys_ssh" .}} diff --git a/templates/user/settings/layout_head.tmpl b/templates/user/settings/layout_head.tmpl index dce496e7fa..48b90782d7 100644 --- a/templates/user/settings/layout_head.tmpl +++ b/templates/user/settings/layout_head.tmpl @@ -1,9 +1,9 @@ -{{template "base/head" .ctxData}} -
    +{{template "base/head" ctx.RootData}} +
    - {{template "user/settings/navbar" .ctxData}} + {{template "user/settings/navbar" ctx.RootData}}
    - {{template "base/alert" .ctxData}} + {{template "base/alert" ctx.RootData}} {{/* block: user-setting-content */}} {{if false}}{{/* to make html structure "likely" complete to prevent IDE warnings */}} diff --git a/templates/user/settings/notifications.tmpl b/templates/user/settings/notifications.tmpl index b57b63ac42..421bc3f0de 100644 --- a/templates/user/settings/notifications.tmpl +++ b/templates/user/settings/notifications.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings")}}

    {{ctx.Locale.Tr "notifications"}} diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl index 0b1873bda0..166f34f54a 100644 --- a/templates/user/settings/organization.tmpl +++ b/templates/user/settings/organization.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings organization")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings organization")}}

    {{ctx.Locale.Tr "settings.orgs"}} diff --git a/templates/user/settings/packages.tmpl b/templates/user/settings/packages.tmpl index ef4a7c8be2..1773ebbcfc 100644 --- a/templates/user/settings/packages.tmpl +++ b/templates/user/settings/packages.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings packages")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings packages")}}
    {{template "package/shared/cleanup_rules/list" .}} {{template "package/shared/cargo" .}} diff --git a/templates/user/settings/packages_cleanup_rules_edit.tmpl b/templates/user/settings/packages_cleanup_rules_edit.tmpl index 522b524882..40e1a2c588 100644 --- a/templates/user/settings/packages_cleanup_rules_edit.tmpl +++ b/templates/user/settings/packages_cleanup_rules_edit.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings packages")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings packages")}}
    {{template "package/shared/cleanup_rules/edit" .}}
    diff --git a/templates/user/settings/packages_cleanup_rules_preview.tmpl b/templates/user/settings/packages_cleanup_rules_preview.tmpl index d99aee4b9a..3f3a1f07f8 100644 --- a/templates/user/settings/packages_cleanup_rules_preview.tmpl +++ b/templates/user/settings/packages_cleanup_rules_preview.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user packages admin")}} +{{template "user/settings/layout_head" (dict "pageClass" "user packages admin")}}
    {{template "package/shared/cleanup_rules/preview" .}}
    diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 0f88f71275..bd39e0a1b4 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings profile")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings profile")}}

    {{ctx.Locale.Tr "settings.public_profile"}} diff --git a/templates/user/settings/repos.tmpl b/templates/user/settings/repos.tmpl index e6b7d99bd7..ae1f53b6a4 100644 --- a/templates/user/settings/repos.tmpl +++ b/templates/user/settings/repos.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings repos")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings repos")}}

    {{ctx.Locale.Tr "settings.repos"}} diff --git a/templates/user/settings/runner_edit.tmpl b/templates/user/settings/runner_edit.tmpl index 90c58c16da..03e6cb4c04 100644 --- a/templates/user/settings/runner_edit.tmpl +++ b/templates/user/settings/runner_edit.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings runners")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings runners")}}
    {{template "shared/actions/runner_edit" .}}
    diff --git a/templates/user/settings/security/security.tmpl b/templates/user/settings/security/security.tmpl index d9403cfc26..90e44ba941 100644 --- a/templates/user/settings/security/security.tmpl +++ b/templates/user/settings/security/security.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings security")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings security")}} {{if not ($.UserDisabledFeatures.Contains "manage_mfa" "manage_credentials")}}
    {{if not ($.UserDisabledFeatures.Contains "manage_mfa")}} diff --git a/templates/user/settings/security/twofa_enroll.tmpl b/templates/user/settings/security/twofa_enroll.tmpl index 6232bd7827..76d1cfdc99 100644 --- a/templates/user/settings/security/twofa_enroll.tmpl +++ b/templates/user/settings/security/twofa_enroll.tmpl @@ -1,4 +1,4 @@ -{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings twofa")}} +{{template "user/settings/layout_head" (dict "pageClass" "user settings twofa")}}

    {{ctx.Locale.Tr "settings.twofa_enroll"}} diff --git a/templates/webhook/new.tmpl b/templates/webhook/new.tmpl index b83499aa9c..2cded88365 100644 --- a/templates/webhook/new.tmpl +++ b/templates/webhook/new.tmpl @@ -2,24 +2,24 @@ {{.CustomHeaderTitle}}

    - {{template "repo/settings/webhook/gitea" .ctxData}} - {{template "repo/settings/webhook/gogs" .ctxData}} - {{template "repo/settings/webhook/slack" .ctxData}} - {{template "repo/settings/webhook/discord" .ctxData}} - {{template "repo/settings/webhook/dingtalk" .ctxData}} - {{template "repo/settings/webhook/telegram" .ctxData}} - {{template "repo/settings/webhook/msteams" .ctxData}} - {{template "repo/settings/webhook/feishu" .ctxData}} - {{template "repo/settings/webhook/matrix" .ctxData}} - {{template "repo/settings/webhook/wechatwork" .ctxData}} - {{template "repo/settings/webhook/packagist" .ctxData}} + {{template "repo/settings/webhook/gitea" ctx.RootData}} + {{template "repo/settings/webhook/gogs" ctx.RootData}} + {{template "repo/settings/webhook/slack" ctx.RootData}} + {{template "repo/settings/webhook/discord" ctx.RootData}} + {{template "repo/settings/webhook/dingtalk" ctx.RootData}} + {{template "repo/settings/webhook/telegram" ctx.RootData}} + {{template "repo/settings/webhook/msteams" ctx.RootData}} + {{template "repo/settings/webhook/feishu" ctx.RootData}} + {{template "repo/settings/webhook/matrix" ctx.RootData}} + {{template "repo/settings/webhook/wechatwork" ctx.RootData}} + {{template "repo/settings/webhook/packagist" ctx.RootData}}
    -{{template "repo/settings/webhook/history" .ctxData}} +{{template "repo/settings/webhook/history" ctx.RootData}} diff --git a/tests/e2e/reactions.test.ts b/tests/e2e/reactions.test.ts index 603cae8298..2048b938cf 100644 --- a/tests/e2e/reactions.test.ts +++ b/tests/e2e/reactions.test.ts @@ -12,7 +12,7 @@ test('toggle issue reactions', async ({page, request}) => { ]); await page.goto(`/${owner}/${repoName}/issues/1`); - const issueComment = page.locator('.timeline-item.comment.first'); + const issueComment = page.locator('.timeline-item.comment.issue-content-comment'); const reactionPicker = issueComment.locator('.select-reaction'); await reactionPicker.click(); diff --git a/tests/integration/actions_trigger_test.go b/tests/integration/actions_trigger_test.go index 4d88d42f36..e7a3cd7b4f 100644 --- a/tests/integration/actions_trigger_test.go +++ b/tests/integration/actions_trigger_test.go @@ -1801,7 +1801,7 @@ jobs: testEditFile(t, session, "user2", repoName, repo.DefaultBranch, "dir1/dir1.txt", "11") // update by rebase req := NewRequest(t, "POST", fmt.Sprintf("/%s/%s/pulls/%d/update?style=rebase", "user2", repoName, apiPull.Index)) - session.MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusOK) runner.fetchNoTask(t) }) } diff --git a/tests/integration/api_issue_test.go b/tests/integration/api_issue_test.go index f8b6ab4dd9..e1708e90aa 100644 --- a/tests/integration/api_issue_test.go +++ b/tests/integration/api_issue_test.go @@ -149,16 +149,16 @@ func testAPICreateIssue(t *testing.T) { } func testAPICreateIssueParallel(t *testing.T) { - // FIXME: There seems to be a bug in github.com/mattn/go-sqlite3 with sqlite_unlock_notify, when doing concurrent writes to the same database, + // HINT: There seems to be a bug in github.com/mattn/go-sqlite3 with sqlite_unlock_notify, when doing concurrent writes to the same database, // some requests may get stuck in "go-sqlite3.(*SQLiteRows).Next", "go-sqlite3.(*SQLiteStmt).exec" and "go-sqlite3.unlock_notify_wait", - // because the "unlock_notify_wait" never returns and the internal lock never gets releases. + // because the "unlock_notify_wait" never returns and the internal lock never gets released. // // The trigger is: a previous test created issues and made the real issue indexer queue start processing, then this test does concurrent writing. // Adding this "Sleep" makes go-sqlite3 "finish" some internal operations before concurrent writes and then won't get stuck. // To reproduce: make a new test run these 2 tests enough times: // > func testBug() { for i := 0; i < 100; i++ { testAPICreateIssue(t); testAPICreateIssueParallel(t) } } // Usually the test gets stuck in fewer than 10 iterations without this "sleep". - time.Sleep(time.Second) + time.Sleep(100 * time.Millisecond) const body, title = "apiTestBody", "apiTestTitle" diff --git a/tests/integration/api_repo_tags_test.go b/tests/integration/api_repo_tags_test.go index 03dafafb2d..13718040ce 100644 --- a/tests/integration/api_repo_tags_test.go +++ b/tests/integration/api_repo_tags_test.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/tests" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestAPIRepoTags(t *testing.T) { @@ -35,24 +36,22 @@ func TestAPIRepoTags(t *testing.T) { assert.Len(t, tags, 1) assert.Equal(t, "v1.1", tags[0].Name) - assert.Equal(t, "Initial commit", tags[0].Message) + assert.Equal(t, "Initial commit\n", tags[0].Message) assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", tags[0].Commit.SHA) assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/git/commits/65f1bf27bc3bf70f64657658635e66094edbcb4d", tags[0].Commit.URL) assert.Equal(t, setting.AppURL+"user2/repo1/archive/v1.1.zip", tags[0].ZipballURL) assert.Equal(t, setting.AppURL+"user2/repo1/archive/v1.1.tar.gz", tags[0].TarballURL) newTag := createNewTagUsingAPI(t, token, user.Name, repoName, "gitea/22", "", "nice!\nand some text") + assert.Equal(t, "nice!\nand some text\n", newTag.Message) // git message standard: there will always be a newline at the end of the message + resp = MakeRequest(t, req, http.StatusOK) tags = DecodeJSON(t, resp, []*api.Tag{}) - assert.Len(t, tags, 2) - for _, tag := range tags { - if tag.Name != "v1.1" { - assert.Equal(t, newTag.Name, tag.Name) - assert.Equal(t, newTag.Message, tag.Message) - assert.Equal(t, "nice!\nand some text", tag.Message) - assert.Equal(t, newTag.Commit.SHA, tag.Commit.SHA) - } - } + require.Len(t, tags, 2) + respTag := tags[0] + assert.Equal(t, newTag.Name, respTag.Name) + assert.Equal(t, newTag.Message, respTag.Message) + assert.Equal(t, newTag.Commit.SHA, respTag.Commit.SHA) // get created tag req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/tags/%s", user.Name, repoName, newTag.Name). diff --git a/tests/integration/issue_test.go b/tests/integration/issue_test.go index 09475bad20..ba15f8962e 100644 --- a/tests/integration/issue_test.go +++ b/tests/integration/issue_test.go @@ -692,9 +692,9 @@ func TestIssueReferenceURL(t *testing.T) { htmlDoc := NewHTMLParser(t, resp.Body) // the "reference" uses relative URLs, then JS code will convert them to absolute URLs for current origin, in case users are using multiple domains - ref, _ := htmlDoc.Find(`.timeline-item.comment.first .reference-issue`).Attr("data-reference") + ref, _ := htmlDoc.Find(`.timeline-item.comment.issue-content-comment .reference-issue`).Attr("data-reference") assert.Equal(t, "/user2/repo1/issues/1#issue-1", ref) - ref, _ = htmlDoc.Find(`.timeline-item.comment:not(.first) .reference-issue`).Attr("data-reference") + ref, _ = htmlDoc.Find(`.timeline-item.comment:not(.issue-content-comment) .reference-issue`).Attr("data-reference") assert.Equal(t, "/user2/repo1/issues/1#issuecomment-2", ref) } diff --git a/tools/lint-pr-title.js b/tools/lint-pr-title.js new file mode 100644 index 0000000000..7caeb78085 --- /dev/null +++ b/tools/lint-pr-title.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node +import {env, exit} from 'node:process'; + +const allowedTypes = 'build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test'; +const title = env.PR_TITLE; + +if (!title) { + console.error('Missing PR_TITLE'); + exit(1); +} + +const validTitlePattern = new RegExp(`^(${allowedTypes.replaceAll(', ', '|')})(\\([\\w.-]+\\))?(!)?: .+$`); + +if (!validTitlePattern.test(title)) { + console.error(`Invalid PR title: ${title}`); + console.error('Expected format: type(scope): subject'); + console.error(`Allowed types: ${allowedTypes}`); + exit(1); +} diff --git a/web_src/css/modules/checkbox.css b/web_src/css/modules/checkbox.css index f24b91df07..a6caf3324f 100644 --- a/web_src/css/modules/checkbox.css +++ b/web_src/css/modules/checkbox.css @@ -105,6 +105,7 @@ input[type="checkbox"]:indeterminate::before { vertical-align: middle; } +.ui.disabled.checkbox input, .ui.disabled.checkbox label, .ui.checkbox input[disabled] ~ label { cursor: default !important; diff --git a/web_src/css/repo.css b/web_src/css/repo.css index fb85dc8e9f..3eb016650f 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -1,9 +1,9 @@ .repo-header { - margin: 1em 0 0.5em; + padding: 1em 0 0.25em; } -.repo-header .secondary-info { - margin-top: 0.5rem; +.secondary-nav .secondary-info { + margin-top: 0.25em; font-size: 12px; } @@ -423,28 +423,14 @@ td .commit-summary { margin-right: 5px; } -.repository.view.issue .comment-list:not(.prevent-before-timeline)::before { - display: block; - content: ""; - position: absolute; - margin-top: 12px; - margin-bottom: 14px; - top: 0; - bottom: 0; - left: 96px; - width: 2px; - background-color: var(--color-timeline); - z-index: -1; -} - -.repository.view.issue .comment-list .timeline { +.repository.view.issue .comment-list { position: relative; display: block; margin-left: 40px; padding-left: 16px; } -.repository.view.issue .comment-list .timeline::before { /* ciara */ +.repository.view.issue .comment-list::before { display: block; content: ""; position: absolute; @@ -1318,6 +1304,7 @@ td .commit-summary { display: flex; align-items: center; gap: 6px; + flex-wrap: wrap; } .comment-header-right { @@ -1844,26 +1831,23 @@ tbody.commit-list { } @media (max-width: 767.98px) { - .repository.view.issue .comment-list .timeline, + .repository.view.issue .comment-list, .repository.view.issue .comment-list .timeline-item { margin-left: 0; } - .repository.view.issue .comment-list .timeline::before { + .repository.view.issue .comment-list::before { left: 14px; } - .repository.view.issue .comment-list .timeline .inline-timeline-avatar { + .repository.view.issue .comment-list .inline-timeline-avatar { display: flex; margin-bottom: auto; margin-left: 6px; margin-right: 2px; } - .repository.view.issue .comment-list .timeline .comment-header { - padding-left: 4px; - } /* Don't show the general avatar, we show the inline avatar on mobile. * And don't show the role labels, there's no place for that. */ - .repository.view.issue .comment-list .timeline .timeline-avatar, - .repository.view.issue .comment-list .timeline .comment-header-right .role-label { + .repository.view.issue .comment-list .timeline-avatar, + .repository.view.issue .comment-list .comment-header-right .role-label { display: none; } .commit-header h3 { diff --git a/web_src/js/features/repo-issue-content.ts b/web_src/js/features/repo-issue-content.ts index 865d4305e4..e385d5b1e8 100644 --- a/web_src/js/features/repo-issue-content.ts +++ b/web_src/js/features/repo-issue-content.ts @@ -94,7 +94,7 @@ function showContentHistoryDetail(issueBaseUrl: string, commentId: string, histo function showContentHistoryMenu(issueBaseUrl: string, elCommentItem: Element, commentId: string) { const elHeaderLeft = elCommentItem.querySelector('.comment-header-left')!; const menuHtml = ` -

    {{svg "octicon-file"}} @@ -14,8 +14,8 @@ - - {{.Summary | ctx.RenderUtils.RenderEmoji}} + + {{$lfsItem.Summary | ctx.RenderUtils.RenderEmoji}}