diff --git a/.air.toml b/.air.toml index d13f8c4f99..de97bd8b29 100644 --- a/.air.toml +++ b/.air.toml @@ -8,6 +8,15 @@ delay = 1000 include_ext = ["go", "tmpl"] include_file = ["main.go"] include_dir = ["cmd", "models", "modules", "options", "routers", "services"] -exclude_dir = ["modules/git/tests", "services/gitdiff/testdata", "modules/avatar/testdata", "models/fixtures", "models/migrations/fixtures", "modules/migration/file_format_testdata", "modules/avatar/identicon/testdata"] +exclude_dir = [ + "models/fixtures", + "models/migrations/fixtures", + "modules/avatar/identicon/testdata", + "modules/avatar/testdata", + "modules/git/tests", + "modules/migration/file_format_testdata", + "routers/private/tests", + "services/gitdiff/testdata", +] exclude_regex = ["_test.go$", "_gen.go$"] stop_on_error = true diff --git a/.deadcode-out b/.deadcode-out index 39b2a5d2d6..0cdbd1ae6f 100644 --- a/.deadcode-out +++ b/.deadcode-out @@ -22,7 +22,6 @@ package "code.gitea.io/gitea/models/actions" func (ScheduleList).GetRepoIDs func (ScheduleList).LoadTriggerUser func (ScheduleList).LoadRepos - func GetVariableByID package "code.gitea.io/gitea/models/asymkey" func (ErrGPGKeyAccessDenied).Error @@ -92,7 +91,6 @@ package "code.gitea.io/gitea/models/repo" func (*releaseSorter).Swap func SortReleases func FindReposMapByIDs - func RepositoryListOfMap func (SearchOrderBy).String func IsErrTopicNotExist func (ErrTopicNotExist).Error @@ -163,9 +161,6 @@ package "code.gitea.io/gitea/modules/cache" package "code.gitea.io/gitea/modules/charset" func (*BreakWriter).Write -package "code.gitea.io/gitea/modules/context" - func GetPrivateContext - package "code.gitea.io/gitea/modules/emoji" func ReplaceCodes @@ -182,6 +177,7 @@ package "code.gitea.io/gitea/modules/git" func (ErrExecTimeout).Error func (ErrUnsupportedVersion).Error func SetUpdateHook + func GetObjectFormatOfRepo func openRepositoryWithDefaultContext func IsTagExist func ToEntryMode @@ -193,6 +189,7 @@ package "code.gitea.io/gitea/modules/gitgraph" package "code.gitea.io/gitea/modules/gitrepo" func GetBranchCommitID + func GetWikiDefaultBranch package "code.gitea.io/gitea/modules/graceful" func (*Manager).TerminateContext @@ -225,7 +222,6 @@ package "code.gitea.io/gitea/modules/markup/markdown" func IsSummary func IsTaskCheckBoxListItem func IsIcon - func IsColorPreview func RenderRawString package "code.gitea.io/gitea/modules/markup/markdown/math" @@ -275,13 +271,19 @@ package "code.gitea.io/gitea/modules/sync" package "code.gitea.io/gitea/modules/testlogger" func (*testLoggerWriterCloser).pushT - func (*testLoggerWriterCloser).Write + func (*testLoggerWriterCloser).Log + func (*testLoggerWriterCloser).recordError + func (*testLoggerWriterCloser).printMsg func (*testLoggerWriterCloser).popT - func (*testLoggerWriterCloser).Close func (*testLoggerWriterCloser).Reset func PrintCurrentTest func Printf func NewTestLoggerWriter + func (*TestLogEventWriter).Base + func (*TestLogEventWriter).GetLevel + func (*TestLogEventWriter).GetWriterName + func (*TestLogEventWriter).GetWriterType + func (*TestLogEventWriter).Run package "code.gitea.io/gitea/modules/timeutil" func GetExecutableModTime @@ -293,12 +295,9 @@ package "code.gitea.io/gitea/modules/translation" func (MockLocale).TrString func (MockLocale).Tr func (MockLocale).TrN + func (MockLocale).TrSize func (MockLocale).PrettyNumber -package "code.gitea.io/gitea/modules/util" - func UnsafeStringToBytes - func OptionalBoolFromGeneric - package "code.gitea.io/gitea/modules/util/filebuffer" func CreateFromReader @@ -324,6 +323,9 @@ package "code.gitea.io/gitea/routers/web/org" func getActionIssues func UpdateIssueProject +package "code.gitea.io/gitea/services/context" + func GetPrivateContext + package "code.gitea.io/gitea/services/convert" func ToSecret @@ -335,7 +337,6 @@ package "code.gitea.io/gitea/services/pull" package "code.gitea.io/gitea/services/repository" func IsErrForkAlreadyExist - func UpdateRepositoryUnits package "code.gitea.io/gitea/services/repository/archiver" func ArchiveRepository diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9e290fb6a5..1b1b66c7dd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,11 +4,13 @@ "features": { // installs nodejs into container "ghcr.io/devcontainers/features/node:1": { - "version":"20" + "version": "20" }, "ghcr.io/devcontainers/features/git-lfs:1.1.0": {}, "ghcr.io/devcontainers-contrib/features/poetry:2": {}, - "ghcr.io/devcontainers/features/python:1": {} + "ghcr.io/devcontainers/features/python:1": { + "version": "3.12" + } }, "customizations": { "vscode": { @@ -22,7 +24,7 @@ "DavidAnson.vscode-markdownlint", "Vue.volar", "ms-azuretools.vscode-docker", - "zixuanchen.vitest-explorer", + "vitest.explorer", "qwtel.sqlite-viewer", "GitHub.vscode-pull-request-github" ] diff --git a/.dockerignore b/.dockerignore index d1a08977a5..86cc8f6087 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,7 +14,7 @@ _test # MS VSCode .vscode -__debug_bin +__debug_bin* # Architecture specific extensions/prefixes *.[568vq] @@ -62,7 +62,6 @@ cpu.out /data /indexers /log -/public/img/avatar /tests/integration/gitea-integration-* /tests/integration/indexers-* /tests/e2e/gitea-e2e-* @@ -77,7 +76,7 @@ cpu.out /public/assets/js /public/assets/css /public/assets/fonts -/public/assets/img/webpack +/public/assets/img/avatar /vendor /web_src/fomantic/node_modules /web_src/fomantic/build/* diff --git a/.eslintrc.yaml b/.eslintrc.yaml index e9991c02ba..5fd0a245f2 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -3,6 +3,7 @@ reportUnusedDisableDirectives: true ignorePatterns: - /web_src/js/vendor + - /web_src/fomantic parserOptions: sourceType: module @@ -42,10 +43,6 @@ overrides: worker: true rules: no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, status, statusbar, stop, toolbar, top] - - files: ["build/generate-images.js"] - rules: - i/no-unresolved: [0] - i/no-extraneous-dependencies: [0] - files: ["*.config.*"] rules: i/no-unused-modules: [0] @@ -123,7 +120,7 @@ rules: "@stylistic/js/arrow-spacing": [2, {before: true, after: true}] "@stylistic/js/block-spacing": [0] "@stylistic/js/brace-style": [2, 1tbs, {allowSingleLine: true}] - "@stylistic/js/comma-dangle": [2, only-multiline] + "@stylistic/js/comma-dangle": [2, always-multiline] "@stylistic/js/comma-spacing": [2, {before: false, after: true}] "@stylistic/js/comma-style": [2, last] "@stylistic/js/computed-property-spacing": [2, never] @@ -171,7 +168,7 @@ rules: "@stylistic/js/semi-spacing": [2, {before: false, after: true}] "@stylistic/js/semi-style": [2, last] "@stylistic/js/space-before-blocks": [2, always] - "@stylistic/js/space-before-function-paren": [0] + "@stylistic/js/space-before-function-paren": [2, {anonymous: ignore, named: never, asyncArrow: always}] "@stylistic/js/space-in-parens": [2, never] "@stylistic/js/space-infix-ops": [2] "@stylistic/js/space-unary-ops": [2] @@ -283,14 +280,14 @@ rules: i/unambiguous: [0] init-declarations: [0] jquery/no-ajax-events: [2] - jquery/no-ajax: [0] + jquery/no-ajax: [2] jquery/no-animate: [2] - jquery/no-attr: [0] + jquery/no-attr: [2] jquery/no-bind: [2] jquery/no-class: [0] jquery/no-clone: [2] jquery/no-closest: [0] - jquery/no-css: [0] + jquery/no-css: [2] jquery/no-data: [0] jquery/no-deferred: [2] jquery/no-delegate: [2] @@ -307,7 +304,7 @@ rules: jquery/no-in-array: [2] jquery/no-is-array: [2] jquery/no-is-function: [2] - jquery/no-is: [0] + jquery/no-is: [2] jquery/no-load: [2] jquery/no-map: [2] jquery/no-merge: [2] @@ -315,7 +312,7 @@ rules: jquery/no-parent: [0] jquery/no-parents: [0] jquery/no-parse-html: [2] - jquery/no-prop: [0] + jquery/no-prop: [2] jquery/no-proxy: [2] jquery/no-ready: [2] jquery/no-serialize: [2] @@ -396,12 +393,12 @@ rules: no-irregular-whitespace: [2] no-iterator: [2] no-jquery/no-ajax-events: [2] - no-jquery/no-ajax: [0] + no-jquery/no-ajax: [2] no-jquery/no-and-self: [2] no-jquery/no-animate-toggle: [2] no-jquery/no-animate: [2] - no-jquery/no-append-html: [0] - no-jquery/no-attr: [0] + no-jquery/no-append-html: [2] + no-jquery/no-attr: [2] no-jquery/no-bind: [2] no-jquery/no-box-model: [2] no-jquery/no-browser: [2] @@ -413,7 +410,7 @@ rules: no-jquery/no-constructor-attributes: [2] no-jquery/no-contains: [2] no-jquery/no-context-prop: [2] - no-jquery/no-css: [0] + no-jquery/no-css: [2] no-jquery/no-data: [0] no-jquery/no-deferred: [2] no-jquery/no-delegate: [2] @@ -444,7 +441,7 @@ rules: no-jquery/no-is-numeric: [2] no-jquery/no-is-plain-object: [2] no-jquery/no-is-window: [2] - no-jquery/no-is: [0] + no-jquery/no-is: [2] no-jquery/no-jquery-constructor: [0] no-jquery/no-live: [2] no-jquery/no-load-shorthand: [2] @@ -466,7 +463,7 @@ rules: no-jquery/no-parse-html: [2] no-jquery/no-parse-json: [2] no-jquery/no-parse-xml: [2] - no-jquery/no-prop: [0] + no-jquery/no-prop: [2] no-jquery/no-proxy: [2] no-jquery/no-ready-shorthand: [2] no-jquery/no-ready: [2] @@ -487,7 +484,7 @@ rules: no-jquery/no-visibility: [2] no-jquery/no-when: [2] no-jquery/no-wrap: [2] - no-jquery/variable-pattern: [0] + no-jquery/variable-pattern: [2] no-label-var: [2] no-labels: [0] # handled by no-restricted-syntax no-lone-blocks: [2] @@ -540,7 +537,7 @@ rules: no-underscore-dangle: [0] no-unexpected-multiline: [2] no-unmodified-loop-condition: [2] - no-unneeded-ternary: [0] + no-unneeded-ternary: [2] no-unreachable-loop: [2] no-unreachable: [2] no-unsafe-finally: [2] @@ -719,12 +716,14 @@ rules: unicorn/import-style: [0] unicorn/new-for-builtins: [2] unicorn/no-abusive-eslint-disable: [0] + unicorn/no-anonymous-default-export: [0] unicorn/no-array-callback-reference: [0] unicorn/no-array-for-each: [2] unicorn/no-array-method-this-argument: [2] unicorn/no-array-push-push: [2] unicorn/no-array-reduce: [2] unicorn/no-await-expression-member: [0] + unicorn/no-await-in-promise-methods: [2] unicorn/no-console-spaces: [0] unicorn/no-document-cookie: [2] unicorn/no-empty-file: [2] @@ -741,6 +740,7 @@ rules: unicorn/no-null: [0] unicorn/no-object-as-default-parameter: [0] unicorn/no-process-exit: [0] + unicorn/no-single-promise-in-promise-methods: [2] unicorn/no-static-only-class: [2] unicorn/no-thenable: [2] unicorn/no-this-assignment: [2] diff --git a/.forgejo/cascading-pr-end-to-end b/.forgejo/cascading-pr-end-to-end index 975888b245..d7a6b46b48 100755 --- a/.forgejo/cascading-pr-end-to-end +++ b/.forgejo/cascading-pr-end-to-end @@ -5,17 +5,29 @@ set -ex end_to_end=$1 end_to_end_pr=$2 forgejo=$3 -forgejo_pr=$4 +forgejo_pr_or_ref=$4 + +cd $forgejo +full_version=$(make show-version-full) +minor_version=$(make show-version-minor) -head_url=$(jq --raw-output .head.repo.html_url < $forgejo_pr) -test "$head_url" != null -branch=$(jq --raw-output .head.ref < $forgejo_pr) -test "$branch" != null cd $end_to_end -echo $head_url $branch 7.0.0+0-gitea-1.22.0 > forgejo/sources/1.22 + +if ! test -f forgejo/sources/$minor_version ; then + echo "FAIL: forgejo/sources/$minor_version does not exist in the end-to-end repository" + false +fi + date > last-upgrade -base_url=$(jq --raw-output .base.repo.html_url < $forgejo_pr) -test "$base_url" != null -test "$GITHUB_RUN_NUMBER" -echo $base_url/actions/runs/$GITHUB_RUN_NUMBER/artifacts/forgejo > forgejo/binary-url +if test -f "$forgejo_pr_or_ref" ; then + forgejo_pr=$forgejo_pr_or_ref + head_url=$(jq --raw-output .head.repo.html_url < $forgejo_pr) + test "$head_url" != null + branch=$(jq --raw-output .head.ref < $forgejo_pr) + test "$branch" != null + echo $head_url $branch $full_version > forgejo/sources/$minor_version +else + forgejo_ref=$forgejo_pr_or_ref + echo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY ${forgejo_ref#refs/heads/} $full_version > forgejo/sources/$minor_version +fi diff --git a/.forgejo/cascading-release-end-to-end b/.forgejo/cascading-release-end-to-end index 7b43c89ed8..08ad8a4431 100755 --- a/.forgejo/cascading-release-end-to-end +++ b/.forgejo/cascading-release-end-to-end @@ -9,4 +9,14 @@ forgejo_ref=$4 cd $end_to_end date > last-upgrade -echo $FORGEJO_BINARY > forgejo/binary-url +organizations=lib/ORGANIZATIONS +if ! test -f $organizations ; then + echo "$organizations file not found" + false +fi +# +# do not include forgejo-experimental so that 7.0-test is found +# in forgejo-integration where it was just built instead of +# forgejo-experimental which was published by the previous build +# +echo forgejo forgejo-integration > $organizations diff --git a/.forgejo/workflows/backport.yml b/.forgejo/workflows/backport.yml new file mode 100644 index 0000000000..da064feff3 --- /dev/null +++ b/.forgejo/workflows/backport.yml @@ -0,0 +1,83 @@ +# Copyright 2024 The Forgejo Authors +# SPDX-License-Identifier: MIT +# +# To modify this workflow: +# +# - change pull_request_target: to pull_request: +# so that it runs from a pull request instead of the default branch +# +# - push it to the wip-ci-backport branch on the forgejo repository +# otherwise it will not have access to the secrets required to push +# the PR +# +# - open a pull request targetting wip-ci-backport that includes a change +# that can be backported without conflict in v1.21 and set the +# `backport/v1.21` label. +# +# - once it works, open a pull request for the sake of keeping track +# of the change even if the PR won't run it because it will use +# whatever is in the default branch instead +# +# - after it is merged, double check it works by setting a +# `backport/v1.21` label on a merged pull request that can be backported +# without conflict. +# +on: + pull_request_target: + types: + - closed + - labeled + +jobs: + backporting: + if: > + !startsWith(vars.ROLE, 'forgejo-') && ( + github.event.pull_request.merged + && + contains(toJSON(github.event.pull_request.labels), 'backport/v') + ) + runs-on: docker + container: + image: 'docker.io/node:20-bookworm' + steps: + - name: event info + run: | + cat <<'EOF' + ${{ toJSON(github) }} + EOF + - name: Fetch labels + id: fetch-labels + shell: bash + run: | + set -x + echo "Labels retrieved below" + export DEBIAN_FRONTEND=noninteractive + apt-get update -qq + apt-get -q install -qq -y jq + filtered_labels=$(echo "$LABELS" | jq -c 'map(select(.name | startswith("backport/v")))') + echo "FILTERED_LABELS=${filtered_labels}" >> $GITHUB_ENV + env: + LABELS: ${{ toJSON(github.event.pull_request.labels) }} + - name: Extract targets + id: extract-targets + shell: bash + run: | + set -x + targets="$(echo $FILTERED_LABELS | jq -c '[.[] | .name | sub("backport/"; "")]')" + echo "targets=$(echo $targets)" >> $GITHUB_OUTPUT + + - name: Printing info + shell: bash + run: | + echo "targets: ${{ steps.extract-targets.outputs.targets }}" + echo "target-branch: ${{ fromJSON(steps.extract-targets.outputs.targets)[0] }}" + echo "pull-request: ${{ github.event.pull_request.url }}" + + - uses: https://code.forgejo.org/forgejo/git-backporting@b2554a678d5ea2814f0df3abad2ac4fcdee2d81f + with: + target-branch: ${{ fromJSON(steps.extract-targets.outputs.targets)[0] }}/forgejo + strategy: ort + strategy-option: find-renames + cherry-pick-options: -x + auth: ${{ secrets.BACKPORT_TOKEN }} + pull-request: ${{ github.event.pull_request.url }} diff --git a/.forgejo/workflows/build-release-integration.yml b/.forgejo/workflows/build-release-integration.yml index e066f0af5e..610b8f0520 100644 --- a/.forgejo/workflows/build-release-integration.yml +++ b/.forgejo/workflows/build-release-integration.yml @@ -9,6 +9,8 @@ on: - docker/** - .forgejo/workflows/build-release.yml - .forgejo/workflows/build-release-integration.yml + branches-ignore: + - renovate/** pull_request: paths: - Makefile diff --git a/.forgejo/workflows/build-release.yml b/.forgejo/workflows/build-release.yml index c012991b3a..f8cd69850c 100644 --- a/.forgejo/workflows/build-release.yml +++ b/.forgejo/workflows/build-release.yml @@ -43,7 +43,7 @@ jobs: - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" check-latest: true - name: version from ref @@ -203,11 +203,9 @@ jobs: destination-url: https://code.forgejo.org destination-fork-repo: ${{ vars.CASCADE_DESTINATION_DOER }}/end-to-end destination-repo: forgejo/end-to-end - destination-branch: forgejo-pr + destination-branch: main destination-token: ${{ secrets.CASCADE_DESTINATION_TOKEN }} update: .forgejo/cascading-release-end-to-end - env: - FORGEJO_BINARY: "${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/releases/download/v${{ steps.release-info.outputs.version }}/forgejo-${{ steps.release-info.outputs.version }}-linux-amd64" - name: copy to experimental if: vars.ROLE == 'forgejo-integration' && secrets.TOKEN != '' diff --git a/.forgejo/workflows/cascade-setup-end-to-end.yml b/.forgejo/workflows/cascade-setup-end-to-end.yml index 235211f18a..dcca2404d9 100644 --- a/.forgejo/workflows/cascade-setup-end-to-end.yml +++ b/.forgejo/workflows/cascade-setup-end-to-end.yml @@ -1,5 +1,23 @@ +# Copyright 2024 The Forgejo Authors # SPDX-License-Identifier: MIT +# +# To modify this workflow: +# +# - push it to the wip-ci-end-to-end branch on the forgejo repository +# otherwise it will not have access to the secrets required to push +# the cascading PR +# +# - once it works, open a pull request for the sake of keeping track +# of the change even if the PR won't run it because it will use +# whatever is in the default branch instead +# +# - after it is merged, double check it works by setting the +# run-end-to-end-test on a pull request (any pull request will doe +# on: + push: + branches: + - 'wip-ci-end-to-end' pull_request_target: types: - labeled @@ -20,58 +38,37 @@ jobs: cat <<'EOF' ${{ toJSON(github.event.pull_request.labels.*.name) }} EOF - - build: - if: ${{ !startsWith(vars.ROLE, 'forgejo-') && github.event.action == 'label_updated' && contains(github.event.pull_request.labels.*.name, 'run-end-to-end-tests') }} - runs-on: docker - container: - image: 'docker.io/node:20-bookworm' - steps: - - uses: https://code.forgejo.org/actions/checkout@v3 - with: - fetch-depth: '0' - show-progress: 'false' - - name: adduser forgejo - run: | - git config --add safe.directory '*' - git config user.email "you@example.com" - git config user.name "Your Name" - adduser --quiet --comment forgejo --disabled-password forgejo - chown -R forgejo:forgejo . - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version: "1.21" - - name: make deps-backend - run: | - su forgejo -c 'make deps-backend' - - name: make forgejo - run: | - su forgejo -c 'make generate-backend static-executable && ln gitea forgejo' - env: - TAGS: bindata sqlite sqlite_unlock_notify - - uses: actions/upload-artifact@v3 - with: - name: forgejo - path: forgejo + cat <<'EOF' + ${{ toJSON(github.event) }} + EOF cascade: - if: ${{ !startsWith(vars.ROLE, 'forgejo-') && github.event.action == 'label_updated' && contains(github.event.pull_request.labels.*.name, 'run-end-to-end-tests') }} - needs: [build] + if: > + !startsWith(vars.ROLE, 'forgejo-') && ( + github.event_name == 'push' || + ( + github.event.action == 'label_updated' && contains(github.event.pull_request.labels.*.name, 'run-end-to-end-tests') + ) + ) runs-on: docker container: image: node:20-bookworm steps: - uses: actions/checkout@v4 - - uses: actions/cascading-pr@v1 + with: + fetch-depth: '0' + show-progress: 'false' + - uses: actions/cascading-pr@v2 with: origin-url: ${{ env.GITHUB_SERVER_URL }} origin-repo: ${{ github.repository }} origin-token: ${{ secrets.END_TO_END_CASCADING_PR_ORIGIN }} origin-pr: ${{ github.event.pull_request.number }} + origin-ref: ${{ github.event_name == 'push' && github.event.ref || '' }} destination-url: https://code.forgejo.org destination-fork-repo: cascading-pr/end-to-end destination-repo: forgejo/end-to-end - destination-branch: forgejo-pr + destination-branch: main destination-token: ${{ secrets.END_TO_END_CASCADING_PR_DESTINATION }} close-merge: true update: .forgejo/cascading-pr-end-to-end diff --git a/.forgejo/workflows/e2e.yml b/.forgejo/workflows/e2e.yml index 2104f6a067..c1321b0a8e 100644 --- a/.forgejo/workflows/e2e.yml +++ b/.forgejo/workflows/e2e.yml @@ -17,7 +17,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "~1.21" + go-version: "1.22" check-latest: true - run: | apt-get -qq update diff --git a/.forgejo/workflows/publish-release.yml b/.forgejo/workflows/publish-release.yml index eaa14c3693..674c1c2704 100644 --- a/.forgejo/workflows/publish-release.yml +++ b/.forgejo/workflows/publish-release.yml @@ -64,7 +64,7 @@ jobs: if: vars.ROLE == 'forgejo-experimental' && secrets.OVH_APP_KEY != '' uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" check-latest: true - name: update the _release.experimental DNS record if: vars.ROLE == 'forgejo-experimental' && secrets.OVH_APP_KEY != '' diff --git a/.forgejo/workflows/renovate.yml b/.forgejo/workflows/renovate.yml new file mode 100644 index 0000000000..457d5b5d56 --- /dev/null +++ b/.forgejo/workflows/renovate.yml @@ -0,0 +1,58 @@ +# +# Runs every 2 hours, but Renovate is limited to create new PR before 4am. +# See renovate.json for more settings. +# Automerge is enabled for Renovate PR's but need to be approved before. +# +name: renovate + +on: + push: + branches: + - 'renovate/**' # self-test updates + schedule: + - cron: '0 0/2 * * *' + +env: + RENOVATE_DRY_RUN: ${{ (github.event_name != 'schedule' && github.ref_name != github.event.repository.default_branch) && 'full' || '' }} + RENOVATE_REPOSITORIES: ${{ github.repository }} + +jobs: + renovate: + if: ${{ secrets.RENOVATE_TOKEN != '' }} + + runs-on: docker + container: + image: ghcr.io/visualon/renovate:37.280.0 + + steps: + - uses: https://code.forgejo.org/actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: | + .tmp/cache/renovate/repository + key: repo-cache-${{ github.run_id }} + restore-keys: | + repo-cache- + + - run: renovate + env: + GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_COM_TOKEN }} + LOG_LEVEL: debug + RENOVATE_BASE_DIR: ${{ github.workspace }}/.tmp + RENOVATE_ENDPOINT: ${{ github.server_url }} + RENOVATE_PLATFORM: gitea + RENOVATE_REPOSITORY_CACHE: 'enabled' + RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }} + RENOVATE_GIT_AUTHOR: 'Renovate Bot ' + + GIT_AUTHOR_NAME: 'Renovate Bot' + GIT_AUTHOR_EMAIL: 'forgejo-renovate-action@forgejo.org' + GIT_COMMITTER_NAME: 'Renovate Bot' + GIT_COMMITTER_EMAIL: 'forgejo-renovate-action@forgejo.org' + + - name: Save renovate repo cache + if: always() && env.RENOVATE_DRY_RUN != 'full' + uses: https://code.forgejo.org/actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + with: + path: | + .tmp/cache/renovate/repository + key: repo-cache-${{ github.run_id }} diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 80fd87152e..be0689006c 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -14,15 +14,18 @@ jobs: container: image: 'docker.io/node:20-bookworm' steps: + - name: event info + run: | + cat <<'EOF' + ${{ toJSON(github) }} + EOF - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" check-latest: true - run: make deps-backend deps-tools - run: make --always-make -j$(nproc) lint-backend checks-backend # ensure the "go-licenses" make target runs - env: - TAGS: bindata sqlite sqlite_unlock_notify frontend-checks: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} runs-on: docker @@ -43,15 +46,18 @@ jobs: image: 'docker.io/node:20-bookworm' services: minio: - image: 'docker.io/bitnami/minio:2023.8.31' + image: bitnami/minio:2024.3.30 + options: >- + --hostname gitea.minio env: + MINIO_DOMAIN: minio MINIO_ROOT_USER: 123456 MINIO_ROOT_PASSWORD: 12345678 steps: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - run: | git config --add safe.directory '*' adduser --quiet --comment forgejo --disabled-password forgejo @@ -96,7 +102,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -130,10 +136,10 @@ jobs: image: 'docker.io/node:20-bookworm' services: minio: - image: bitnami/minio:2021.3.17 + image: bitnami/minio:2024.3.30 env: - MINIO_ACCESS_KEY: 123456 - MINIO_SECRET_KEY: 12345678 + MINIO_ROOT_USER: 123456 + MINIO_ROOT_PASSWORD: 12345678 pgsql: image: 'docker.io/postgres:15' env: @@ -143,7 +149,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -180,7 +186,7 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: https://code.forgejo.org/actions/setup-go@v4 with: - go-version: "1.21" + go-version: "1.22" - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive diff --git a/.gitea/issue_template/bug-report-ui.yaml b/.gitea/issue_template/bug-report-ui.yaml index 4d80198399..09513d08e7 100644 --- a/.gitea/issue_template/bug-report-ui.yaml +++ b/.gitea/issue_template/bug-report-ui.yaml @@ -1,7 +1,7 @@ name: 🦋 Bug Report (web interface / frontend) description: Something doesn't look quite as it should? Report it here! title: "[BUG] " -labels: ["bug", "forgejo/ui"] +labels: ["bug/new-report", "forgejo/ui"] body: - type: markdown attributes: diff --git a/.gitea/issue_template/bug-report.yaml b/.gitea/issue_template/bug-report.yaml index ce67378175..6fab61fcdc 100644 --- a/.gitea/issue_template/bug-report.yaml +++ b/.gitea/issue_template/bug-report.yaml @@ -1,7 +1,7 @@ name: 🐛 Bug Report (server / backend) description: Found something you weren't expecting? Report it here! title: "[BUG] " -labels: bug +labels: bug/new-report body: - type: markdown attributes: @@ -87,4 +87,3 @@ body: - SQLite - PostgreSQL - MySQL - - MSSQL diff --git a/.gitea/pull_request_template.md b/.gitea/pull_request_template.md index 385300ddf8..00b874fd5b 100644 --- a/.gitea/pull_request_template.md +++ b/.gitea/pull_request_template.md @@ -1,3 +1,12 @@ +--- + +name: "Pull Request Template" +about: "Template for all Pull Requests" +labels: + +- test/needed + +--- Alice: Authentication Response - -Alice -> Bob: Another authentication Request -Alice <-- Bob: Another authentication Response -``` - -The script will detect tags with `class="language-plantuml"`, but you can change this by providing a second argument to `parsePlantumlCodeBlocks`. - -### Example: STL Preview - -You can display STL file directly in Gitea by adding: - -```html - -``` - -to the file `templates/custom/footer.tmpl` - -You also need to download the content of the library [Madeleine.js](https://github.com/beige90/Madeleine.js) and place it under `$GITEA_CUSTOM/public/assets/` folder. - -You should end-up with a folder structure similar to: - -``` -$GITEA_CUSTOM/templates --- custom - `-- footer.tmpl - -$GITEA_CUSTOM/public/assets/ --- Madeleine.js - |-- LICENSE - |-- README.md - |-- css - | |-- pygment_trac.css - | `-- stylesheet.css - |-- examples - | |-- ajax.html - | |-- index.html - | `-- upload.html - |-- images - | |-- bg_hr.png - | |-- blacktocat.png - | |-- icon_download.png - | `-- sprite_download.png - |-- models - | |-- dino2.stl - | |-- ducati.stl - | |-- gallardo.stl - | |-- lamp.stl - | |-- octocat.stl - | |-- skull.stl - | `-- treefrog.stl - `-- src - |-- Madeleine.js - |-- css - | `-- Madeleine.css - |-- icons - | |-- logo.png - | |-- madeleine.eot - | |-- madeleine.svg - | |-- madeleine.ttf - | `-- madeleine.woff - `-- lib - |-- MadeleineConverter.js - |-- MadeleineLoader.js - |-- detector.js - |-- stats.js - `-- three.min.js -``` - -Then restart Gitea and open a STL file on your Gitea instance. - -## Customizing Gitea mails - -The `$GITEA_CUSTOM/templates/mail` folder allows changing the body of every mail of Gitea. -Templates to override can be found in the -[`templates/mail`](https://github.com/go-gitea/gitea/tree/main/templates/mail) -directory of Gitea source. -Override by making a copy of the file under `$GITEA_CUSTOM/templates/mail` using a -full path structure matching source. - -Any statement contained inside `{{` and `}}` are Gitea's template -syntax and shouldn't be touched without fully understanding these components. - -## Adding Analytics to Gitea - -Google Analytics, Matomo (previously Piwik), and other analytics services can be added to Gitea. To add the tracking code, refer to the `Other additions to the page` section of this document, and add the JavaScript to the `$GITEA_CUSTOM/templates/custom/header.tmpl` file. - -## Customizing gitignores, labels, licenses, locales, and readmes. - -Place custom files in corresponding sub-folder under `custom/options`. - -**NOTE:** The files should not have a file extension, e.g. `Labels` rather than `Labels.txt` - -### gitignores - -To add custom .gitignore, add a file with existing [.gitignore rules](https://git-scm.com/docs/gitignore) in it to `$GITEA_CUSTOM/options/gitignore` - -## Customizing the git configuration - -Starting with Gitea 1.20, you can customize the git configuration via the `git.config` section. - -### Enabling signed git pushes - -To enable signed git pushes, set these two options: - -```ini -[git.config] -receive.advertisePushOptions = true -receive.certNonceSeed = -``` - -`certNonceSeed` should be set to a random string and be kept secret. - -### Labels - -Starting with Gitea 1.19, you can add a file that follows the [YAML label format](https://github.com/go-gitea/gitea/blob/main/options/label/Advanced.yaml) to `$GITEA_CUSTOM/options/label`: - -```yaml -labels: - - name: "foo/bar" # name of the label that will appear in the dropdown - exclusive: true # whether to use the exclusive namespace for scoped labels. scoped delimiter is / - color: aabbcc # hex colour coding - description: Some label # long description of label intent - ``` - -The [legacy file format](https://github.com/go-gitea/gitea/blob/main/options/label/Default) can still be used following the format below, however we strongly recommend using the newer YAML format instead. - -`#hex-color label name ; label description` - -For more information, see the [labels documentation](usage/labels.md). - -### Licenses - -To add a custom license, add a file with the license text to `$GITEA_CUSTOM/options/license` - -### Locales - -Locales are managed via our [Crowdin](https://crowdin.com/project/gitea). -You can override a locale by placing an altered locale file in `$GITEA_CUSTOM/options/locale`. -Gitea's default locale files can be found in the [`options/locale`](https://github.com/go-gitea/gitea/tree/main/options/locale) source folder and these should be used as examples for your changes. - -To add a completely new locale, as well as placing the file in the above location, you will need to add the new lang and name to the `[i18n]` section in your `app.ini`. Keep in mind that Gitea will use those settings as **overrides**, so if you want to keep the other languages as well you will need to copy/paste the default values and add your own to them. - -``` -[i18n] -LANGS = en-US,foo-BAR -NAMES = English,FooBar -``` - -The first locale will be used as the default if user browser's language doesn't match any locale in the list. - -Locales may change between versions, so keeping track of your customized locales is highly encouraged. - -### Readmes - -To add a custom Readme, add a markdown formatted file (without an `.md` extension) to `$GITEA_CUSTOM/options/readme` - -**NOTE:** readme templates support **variable expansion**. -currently there are `{Name}` (name of repository), `{Description}`, `{CloneURL.SSH}`, `{CloneURL.HTTPS}` and `{OwnerName}` - -### Reactions - -To change reaction emoji's you can set allowed reactions at app.ini - -``` -[ui] -REACTIONS = +1, -1, laugh, confused, heart, hooray, eyes -``` - -A full list of supported emoji's is at [emoji list](https://gitea.com/gitea/gitea.com/issues/8) - -## Customizing the look of Gitea - -The built-in themes are `gitea-light`, `gitea-dark`, and `gitea-auto` (which automatically adapts to OS settings). - -The default theme can be changed via `DEFAULT_THEME` in the [ui](administration/config-cheat-sheet.md#ui-ui) section of `app.ini`. - -Gitea also has support for user themes, which means every user can select which theme should be used. -The list of themes a user can choose from can be configured with the `THEMES` value in the [ui](administration/config-cheat-sheet.md#ui-ui) section of `app.ini`. - -To make a custom theme available to all users: - -1. Add a CSS file to `$GITEA_CUSTOM/public/assets/css/theme-.css`. - The value of `$GITEA_CUSTOM` of your instance can be queried by calling `gitea help` and looking up the value of "CustomPath". -2. Add `` to the comma-separated list of setting `THEMES` in `app.ini` - -Community themes are listed in [gitea/awesome-gitea#themes](https://gitea.com/gitea/awesome-gitea#themes). - -The default theme sources can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/css/themes). - -If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`. -This allows Gitea to adjust the Monaco code editor's theme accordingly. - -## Customizing fonts - -Fonts can be customized using CSS variables: - -```css -:root { - --fonts-proportional: /* custom proportional fonts */ !important; - --fonts-monospace: /* custom monospace fonts */ !important; - --fonts-emoji: /* custom emoji fonts */ !important; -} -``` diff --git a/docs/content/administration/customizing-gitea.zh-cn.md b/docs/content/administration/customizing-gitea.zh-cn.md deleted file mode 100644 index f41533c69c..0000000000 --- a/docs/content/administration/customizing-gitea.zh-cn.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -date: "2017-04-15T14:56:00+02:00" -title: "自定义 Gitea 配置" -slug: "customizing-gitea" -sidebar_position: 100 -toc: false -draft: false -aliases: - - /zh-cn/customizing-gitea -menu: - sidebar: - parent: "administration" - name: "自定义 Gitea 配置" - sidebar_position: 100 - identifier: "customizing-gitea" ---- - -# 自定义 Gitea 配置 - -Gitea 引用 `custom` 目录中的自定义配置文件来覆盖配置、模板等默认配置。 - -如果从二进制部署 Gitea ,则所有默认路径都将相对于该 gitea 二进制文件;如果从发行版安装,则可能会将这些路径修改为Linux文件系统标准。Gitea -将会自动创建包括 `custom/` 在内的必要应用目录,应用本身的配置存放在 -`custom/conf/app.ini` 当中。在发行版中可能会以 `/etc/gitea/` 的形式为 `custom` 设置一个符号链接,查看配置详情请移步: - -- [快速备忘单](administration/config-cheat-sheet.md) -- [完整配置清单](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) - -如果您在 binary 同目录下无法找到 `custom` 文件夹,请检查您的 `GITEA_CUSTOM` -环境变量配置, 因为它可能被配置到了其他地方(可能被一些启动脚本设置指定了目录)。 - -- [环境变量清单](administration/environment-variables.md) - -**注:** 必须完全重启 Gitea 以使配置生效。 - -## 使用自定义 /robots.txt - -将 [想要展示的内容](http://www.robotstxt.org/) 存放在 `custom` 目录中的 -`robots.txt` 文件来让 Gitea 使用自定义的`/robots.txt` (默认:空 404)。 - -## 使用自定义的公共文件 - -将自定义的公共文件(比如页面和图片)作为 webroot 放在 `custom/public/` 中来让 Gitea 提供这些自定义内容(符号链接将被追踪)。 - -举例说明:`image.png` 存放在 `custom/public/assets/`中,那么它可以通过链接 http://gitea.domain.tld/assets/image.png 访问。 - -## 修改默认头像 - -替换以下目录中的 png 图片: `custom/public/assets/img/avatar\_default.png` - -## 自定义 Gitea 页面 - -您可以改变 Gitea `custom/templates` 的每个单页面。您可以在 Gitea 源码的 `templates` 目录中找到用于覆盖的模板文件,应用将根据 -`custom/templates` 目录下的路径结构进行匹配和覆盖。 - -包含在 `{{` 和 `}}` 中的任何语句都是 Gitea 的模板语法,如果您不完全理解这些组件,不建议您对它们进行修改。 - -### 添加链接和页签 - -如果您只是想添加额外的链接到顶部导航栏或额外的选项卡到存储库视图,您可以将它们放在您 `custom/templates/custom/` 目录下的 `extra_links.tmpl` 和 `extra_tabs.tmpl` 文件中。 - -举例说明:假设您需要在网站放置一个静态的“关于”页面,您只需将该页面放在您的 -"custom/public/"目录下(比如 `custom/public/impressum.html`)并且将它与 `custom/templates/custom/extra_links.tmpl` 链接起来即可。 - -这个链接应当使用一个名为“item”的 class 来匹配当前样式,您可以使用 `{{AppSubUrl}}` 来获取 base URL: -`Impressum` - -同理,您可以将页签添加到 `extra_tabs.tmpl` 中,使用同样的方式来添加页签。它的具体样式需要与 -`templates/repo/header.tmpl` 中已有的其他选项卡的样式匹配 -([source in GitHub](https://github.com/go-gitea/gitea/blob/main/templates/repo/header.tmpl)) - -### 页面的其他新增内容 - -除了 `extra_links.tmpl` 和 `extra_tabs.tmpl`,您可以在您的 `custom/templates/custom/` 目录中存放一些其他有用的模板,例如: - -- `header.tmpl`,在 `` 标记结束之前的模板,例如添加自定义CSS文件 -- `body_outer_pre.tmpl`,在 `` 标记开始处的模板 -- `body_inner_pre.tmpl`,在顶部导航栏之前,但在主 container 内部的模板,例如添加一个 `
` -- `body_inner_post.tmpl`,在主 container 结束处的模板 -- `body_outer_post.tmpl`,在底部 `