diff --git a/.gitea/issue_template.md b/.gitea/issue_template.md deleted file mode 100644 index cf173a67cae..00000000000 --- a/.gitea/issue_template.md +++ /dev/null @@ -1,42 +0,0 @@ - - - - -- Gitea version (or commit ref): -- Git version: -- Operating system: - - - -- Database (use `[x]`): - - [ ] PostgreSQL - - [ ] MySQL - - [ ] MSSQL - - [ ] SQLite -- Can you reproduce the bug at https://demo.gitea.com: - - [ ] Yes (provide example URL) - - [ ] No -- Log gist: - - - - -## Description - - -... - - -## Screenshots - - diff --git a/.github/ISSUE_TEMPLATE/bug-report.yaml b/.github/ISSUE_TEMPLATE/bug-report.yaml index 4dbe1a4c56d..e793e068bb8 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yaml +++ b/.github/ISSUE_TEMPLATE/bug-report.yaml @@ -1,91 +1,28 @@ name: Bug Report -description: Found something you weren't expecting? Report it here! +description: Something isn't working as expected. labels: ["type/bug"] body: - type: markdown attributes: value: | - NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue. - - type: markdown - attributes: - value: | - 1. Please speak English, this is the language all maintainers can speak and write. - 2. Please ask questions or configuration/deploy problems on our Discord - server (https://discord.gg/gitea) or forum (https://forum.gitea.com). - 3. Make sure you are using the latest release and - take a moment to check that your issue hasn't been reported before. - 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.com/help/faq) - 5. It's really important to provide pertinent details and logs (https://docs.gitea.com/help/support), - incomplete details will be handled as an invalid report. - - type: textarea - id: description - attributes: - label: Description - description: | - Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below) - If you are using a proxy or a CDN (e.g. Cloudflare) in front of Gitea, please disable the proxy/CDN fully and access Gitea directly to confirm the issue still persists without those services. + - **Security issue?** Email security@gitea.io instead of opening a public issue. + - **Need help** with setup or configuration? Ask on [Discord](https://discord.gg/Gitea) or the [forum](https://forum.gitea.com). + - Search [existing issues](https://github.com/go-gitea/gitea/issues?q=is%3Aissue) first. - type: input id: gitea-ver attributes: label: Gitea Version - description: Gitea version (or commit reference) of your instance validations: required: true - - type: dropdown - id: can-reproduce + - type: textarea + id: description attributes: - label: Can you reproduce the bug on the Gitea demo site? - description: | - If so, please provide a URL in the Description field - URL of Gitea demo: https://demo.gitea.com - options: - - "Yes" - - "No" + label: What happened? + description: What you did, what you expected to happen, and what happened instead. Include logs if relevant. validations: required: true - - type: markdown - attributes: - value: | - It's really important to provide pertinent logs - Please read https://docs.gitea.com/administration/logging-config#collecting-logs-for-help - In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini - - type: input - id: logs - attributes: - label: Log Gist - description: Please provide a gist URL of your logs, with any sensitive information (e.g. API keys) removed/hidden - type: textarea - id: screenshots - attributes: - label: Screenshots - description: If this issue involves the Web Interface, please provide one or more screenshots - - type: input - id: git-ver - attributes: - label: Git Version - description: The version of git running on the server - - type: input - id: os-ver - attributes: - label: Operating System - description: The operating system you are using to run Gitea - - type: textarea - id: run-info + id: environment attributes: label: How are you running Gitea? - description: | - Please include information on whether you built Gitea yourself, used one of our downloads, are using https://demo.gitea.com or are using some other package - Please also tell us how you are running Gitea, e.g. if it is being run from docker, a command-line, systemd etc. - If you are using a package or systemd tell us what distribution you are using - validations: - required: true - - type: dropdown - id: database - attributes: - label: Database - description: What database system are you running? - options: - - PostgreSQL - - MySQL/MariaDB - - MSSQL - - SQLite + description: Install method (binary, Docker, package), operating system, and database. diff --git a/.github/ISSUE_TEMPLATE/feature-request.yaml b/.github/ISSUE_TEMPLATE/feature-request.yaml index d5c480d2023..3ad0fb9e643 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yaml +++ b/.github/ISSUE_TEMPLATE/feature-request.yaml @@ -1,24 +1,20 @@ name: Feature Request -description: Got an idea for a feature that Gitea doesn't have currently? Submit your idea here! +description: Suggest an idea for Gitea. labels: ["type/proposal"] body: - type: markdown attributes: value: | - 1. Please speak English, this is the language all maintainers can speak and write. - 2. Please ask questions or configuration/deploy problems on our Discord - server (https://discord.gg/gitea) or forum (https://forum.gitea.com). - 3. Please take a moment to check that your feature hasn't already been suggested. + Search [existing issues](https://github.com/go-gitea/gitea/issues?q=is%3Aissue) first. - type: textarea - id: description + id: problem attributes: - label: Feature Description - placeholder: | - I think it would be great if Gitea had... + label: What problem would this solve? validations: required: true - type: textarea - id: screenshots + id: proposal attributes: - label: Screenshots - description: If you can, provide screenshots of an implementation on another site e.g. GitHub + label: What do you propose? + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/ui.bug-report.yaml b/.github/ISSUE_TEMPLATE/ui.bug-report.yaml deleted file mode 100644 index 3ad5dbaf54e..00000000000 --- a/.github/ISSUE_TEMPLATE/ui.bug-report.yaml +++ /dev/null @@ -1,66 +0,0 @@ -name: Web Interface Bug Report -description: Something doesn't look quite as it should? Report it here! -labels: ["type/bug", "topic/ui"] -body: - - type: markdown - attributes: - value: | - NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue. - - type: markdown - attributes: - value: | - 1. Please speak English, this is the language all maintainers can speak and write. - 2. Please ask questions or configuration/deploy problems on our Discord - server (https://discord.gg/gitea) or forum (https://forum.gitea.com). - 3. Please take a moment to check that your issue doesn't already exist. - 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.com/help/faq) - 5. Please give all relevant information below for bug reports, because - incomplete details will be handled as an invalid report. - 6. In particular it's really important to provide pertinent logs. If you are certain that this is a javascript - error, show us the javascript console. If the error appears to relate to Gitea the server you must also give us - DEBUG level logs. (See https://docs.gitea.com/administration/logging-config#collecting-logs-for-help) - - type: textarea - id: description - attributes: - label: Description - description: | - Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below) - If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services. - - type: textarea - id: screenshots - attributes: - label: Screenshots - description: Please provide at least 1 screenshot showing the issue. - validations: - required: true - - type: input - id: gitea-ver - attributes: - label: Gitea Version - description: Gitea version (or commit reference) your instance is running - validations: - required: true - - type: dropdown - id: can-reproduce - attributes: - label: Can you reproduce the bug on the Gitea demo site? - description: | - If so, please provide a URL in the Description field - URL of Gitea demo: https://demo.gitea.com - options: - - "Yes" - - "No" - validations: - required: true - - type: input - id: os-ver - attributes: - label: Operating System - description: The operating system you are using to access Gitea - - type: input - id: browser-ver - attributes: - label: Browser Version - description: The browser and version that you are using to access Gitea - validations: - required: true diff --git a/.github/actions/go-cache/action.yml b/.github/actions/go-cache/action.yml index 04d4bac3673..7096fa3952c 100644 --- a/.github/actions/go-cache/action.yml +++ b/.github/actions/go-cache/action.yml @@ -1,47 +1,51 @@ name: go-caches -description: Restore and save go module, build, and golangci-lint caches +description: Restore the go module, build, and golangci-lint caches. Save only on the cache-seeder workflow. + +# Only the cache-seeder workflow saves; rename requires updating cache-seeder.yml. +# The lint job restores but does not save the gobuild cache, so only one writer +# (the gobuild job) populates it and there is no contention on the cache key. inputs: - cache-name: - description: Short identifier used in the per-caller build cache key - required: true - build-cache: - description: Whether to include ~/.cache/go-build - default: "true" - build-cache-rotate: - description: Whether to rotate the build cache key per run so Go's test result cache can accumulate across runs - default: "false" lint-cache: - description: Whether to include ~/.cache/golangci-lint + description: Restore (and save in cache-seeder) ~/.cache/golangci-lint default: "false" runs: using: composite steps: - - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + - if: ${{ github.workflow == 'cache-seeder' }} + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ~/go/pkg/mod key: gomod-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum') }} restore-keys: gomod-${{ runner.os }}-${{ runner.arch }} - - if: ${{ inputs.build-cache == 'true' && inputs.build-cache-rotate == 'true' }} - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + - if: ${{ github.workflow != 'cache-seeder' }} + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: - path: ~/.cache/go-build - key: gobuild-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }}-${{ hashFiles('go.sum') }}-${{ github.run_id }} - restore-keys: | - gobuild-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }}-${{ hashFiles('go.sum') }} - gobuild-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }} - gobuild-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum') }} - gobuild-${{ runner.os }}-${{ runner.arch }} - - if: ${{ inputs.build-cache == 'true' && inputs.build-cache-rotate != 'true' }} + path: ~/go/pkg/mod + key: gomod-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum') }} + restore-keys: gomod-${{ runner.os }}-${{ runner.arch }} + - if: ${{ github.workflow == 'cache-seeder' && inputs.lint-cache != 'true' }} uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ~/.cache/go-build key: gobuild-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum') }} restore-keys: gobuild-${{ runner.os }}-${{ runner.arch }} - - if: ${{ inputs.lint-cache == 'true' }} + - if: ${{ github.workflow != 'cache-seeder' || inputs.lint-cache == 'true' }} + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: ~/.cache/go-build + key: gobuild-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum') }} + restore-keys: gobuild-${{ runner.os }}-${{ runner.arch }} + - if: ${{ inputs.lint-cache == 'true' && github.workflow == 'cache-seeder' }} uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ~/.cache/golangci-lint - key: golangci-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }}-${{ hashFiles('go.sum', '.golangci.yml') }} - restore-keys: golangci-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cache-name }} + key: golint-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum', '.golangci.yml') }} + restore-keys: golint-${{ runner.os }}-${{ runner.arch }} + - if: ${{ inputs.lint-cache == 'true' && github.workflow != 'cache-seeder' }} + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: ~/.cache/golangci-lint + key: golint-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('go.sum', '.golangci.yml') }} + restore-keys: golint-${{ runner.os }}-${{ runner.arch }} diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index b7594a1ba7f..6ae22da7be2 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,10 +1,9 @@ - -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. - + diff --git a/.github/workflows/cache-seeder.yml b/.github/workflows/cache-seeder.yml index cd086fae17f..91109b1c06d 100644 --- a/.github/workflows/cache-seeder.yml +++ b/.github/workflows/cache-seeder.yml @@ -1,15 +1,9 @@ -# Populates the go module, build, and golangci-lint caches under the default -# branch's cache scope so that PR runs have a warm fallback to restore from. +# Populates main's cache scope so PR runs warm-start from it. Saves the go +# module, go build (incl. test compile), and golangci-lint caches. # -# GitHub Actions caches are scoped per ref: a PR run can only write to its own -# branch's scope, but can read from the base branch's scope as a fallback. -# PRs therefore cannot seed main's scope themselves. Running the same cache -# steps on push-to-main is the only opportunity to populate that fallback -# scope so fresh PR branches start with a useful cache on first run. - -# A PR job's exact key lives in its own PR-scope (empty on first run, filled -# by later runs of the same PR); on miss, actions/cache's restore-keys fall -# back to prefix matches against entries this seeder saves in main's scope. +# Caches are ref-scoped: PR runs read their own scope then fall back to the +# base branch. Per .github/actions/go-cache/action.yml, PRs are restore-only, +# so push-to-main is the only opportunity to populate the fallback scope. name: cache-seeder @@ -41,12 +35,25 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: seed - - run: make deps-backend + - run: make deps-backend deps-tools - 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 + - name: warm test compile cache (bindata) + env: + TAGS: bindata + GOTEST_FLAGS: -race -list=^$$ -count=1 + run: make test-backend + - name: warm test compile cache (bindata gogit) + env: + TAGS: bindata gogit + GOEXPERIMENT: + GOTEST_FLAGS: -race -list=^$$ -count=1 + run: make test-backend + - name: warm integration compile cache + run: | + TAGS="bindata" make test-integration-compile + TAGS="bindata gogit" GOEXPERIMENT="" make test-integration-compile + TAGS="bindata gogit" GOTEST_FLAGS="-race" make test-integration-compile lint: runs-on: ubuntu-latest @@ -54,9 +61,7 @@ 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" } + - { tags: "bindata", target: "lint-backend" } steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 @@ -66,9 +71,11 @@ jobs: cache: false - uses: ./.github/actions/go-cache with: - cache-name: ${{ matrix.job }} lint-cache: "true" - run: make deps-backend deps-tools + - run: make generate-go + env: + TAGS: ${{ matrix.tags }} - run: make ${{ matrix.target }} env: TAGS: ${{ matrix.tags }} diff --git a/.github/workflows/cron-renovate.yml b/.github/workflows/cron-renovate.yml index c4906552d5f..2c6cc8aedcd 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@f66d8679fcfcfa051abde6e7a623007173bf5164 # v46.1.12 + - uses: renovatebot/github-action@693b9ef15eec82123529a37c782242f091365961 # v46.1.14 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/files-changed.yml b/.github/workflows/files-changed.yml index 78915d81ea4..ac2bd1a5ba5 100644 --- a/.github/workflows/files-changed.yml +++ b/.github/workflows/files-changed.yml @@ -63,23 +63,21 @@ jobs: - "options/locale/locale_en-US.json" frontend: - - "*.js" - "*.ts" - "web_src/**" - - "tools/*.js" - - "tools/*.ts" + - "tools/generate-svg.ts" - "assets/emoji.json" - "package.json" - "pnpm-lock.yaml" + - "pnpm-workspace.yaml" - "Makefile" - - ".eslintrc.cjs" - - ".npmrc" docs: - "**/*.md" - ".markdownlint.yaml" - "package.json" - "pnpm-lock.yaml" + - "pnpm-workspace.yaml" actions: - ".github/workflows/*" @@ -99,8 +97,8 @@ jobs: - "Makefile" dockerfile: - - "Dockerfile" - - "Dockerfile.rootless" + - "Dockerfile" + - "Dockerfile.rootless" swagger: - "templates/swagger/v1_json.tmpl" @@ -108,6 +106,7 @@ jobs: - "Makefile" - "package.json" - "pnpm-lock.yaml" + - "pnpm-workspace.yaml" - ".spectral.yaml" yaml: @@ -118,6 +117,7 @@ jobs: json: - "**/*.json" + - "**/*.json5" e2e: - "tests/e2e/**" diff --git a/.github/workflows/giteabot-backport.yml b/.github/workflows/giteabot-backport.yml new file mode 100644 index 00000000000..9a9c244b0c8 --- /dev/null +++ b/.github/workflows/giteabot-backport.yml @@ -0,0 +1,26 @@ +name: giteabot backport + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +jobs: + giteabot: + if: github.repository == 'go-gitea/gitea' + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: go-gitea/giteabot@d4f19d5b4a88059d8c3ca78d660631506fc0c286 # add retry logic to giteabot + with: + github_token: ${{ secrets.GITEABOT_TOKEN }} + gitea_fork: giteabot/gitea + checks: backport diff --git a/.github/workflows/giteabot.yml b/.github/workflows/giteabot.yml new file mode 100644 index 00000000000..91043988898 --- /dev/null +++ b/.github/workflows/giteabot.yml @@ -0,0 +1,51 @@ +name: giteabot + +on: + # pull_request_target gives this workflow access to GITEABOT_TOKEN on PRs from + # forks, which the bot needs to write labels, statuses and comments. Safe here + # because the job only runs a pinned action and never checks out PR HEAD. + pull_request_target: # zizmor: ignore[dangerous-triggers] + types: + - opened + - synchronize + - labeled + - unlabeled + - closed + - review_requested + - review_request_removed + pull_request_review: + types: + - submitted + - edited + - dismissed + schedule: + - cron: "15 3 * * *" + workflow_dispatch: + inputs: + checks: + description: Comma-separated list of non-backport checks to run + required: false + default: labels,merge_queue,lock,feedback,last_call,milestones,lgtm,translation_comment,pr_actions + +permissions: + contents: read + issues: write + pull-requests: write + statuses: write + +concurrency: + group: ${{ format('{0}-{1}', github.workflow, (github.event_name == 'pull_request_target' || github.event_name == 'pull_request_review') && format('pr-{0}', github.event.pull_request.number) || 'maintenance') }} + cancel-in-progress: false + +jobs: + giteabot: + if: github.repository == 'go-gitea/gitea' + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + # pull_request_review runs without repository secrets on fork PRs, so fall + # back to the workflow token for the non-backport checks handled here. + - uses: go-gitea/giteabot@d4f19d5b4a88059d8c3ca78d660631506fc0c286 # add retry logic to giteabot + with: + github_token: ${{ secrets.GITEABOT_TOKEN || github.token }} + checks: ${{ github.event.inputs.checks || 'labels,merge_queue,lock,feedback,last_call,milestones,lgtm,translation_comment,pr_actions' }} diff --git a/.github/workflows/pull-compliance.yml b/.github/workflows/pull-compliance.yml index dc46c9fa42e..ada537a188c 100644 --- a/.github/workflows/pull-compliance.yml +++ b/.github/workflows/pull-compliance.yml @@ -27,12 +27,10 @@ jobs: cache: false - uses: ./.github/actions/go-cache with: - cache-name: lint-backend lint-cache: "true" - run: make deps-backend deps-tools + - run: TAGS="bindata" make generate-go # lint-go also lints with "bindata" tags which requires "_bindata.go" - run: make lint-backend - env: - TAGS: bindata sqlite sqlite_unlock_notify lint-on-demand: needs: files-changed @@ -44,19 +42,19 @@ jobs: go-version-file: go.mod check-latest: true cache: false - - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24 - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - run: make lint-spell - - if: needs.files-changed.outputs.templates == 'true' || needs.files-changed.outputs.yaml == 'true' + - if: needs.files-changed.outputs.templates == 'true' || needs.files-changed.outputs.yaml == 'true' || needs.files-changed.outputs.actions == 'true' uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + python-version: 3.14 - if: needs.files-changed.outputs.templates == 'true' || needs.files-changed.outputs.yaml == 'true' - run: uv python install 3.14 && make deps-py lint-templates lint-yaml + run: make deps-py lint-templates lint-yaml - if: needs.files-changed.outputs.docs == 'true' || needs.files-changed.outputs.swagger == 'true' || needs.files-changed.outputs.json == 'true' run: make deps-frontend lint-md lint-swagger lint-json @@ -64,48 +62,6 @@ jobs: - if: needs.files-changed.outputs.actions == 'true' run: make lint-actions - lint-go-windows: - if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' - needs: files-changed - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 - with: - go-version-file: go.mod - check-latest: true - cache: false - - uses: ./.github/actions/go-cache - with: - cache-name: lint-go-windows - lint-cache: "true" - - run: make deps-backend deps-tools - - run: make lint-go-windows - env: - TAGS: bindata sqlite sqlite_unlock_notify - GOOS: windows - GOARCH: amd64 - - lint-go-gogit: - if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' - needs: files-changed - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 - with: - go-version-file: go.mod - check-latest: true - cache: false - - uses: ./.github/actions/go-cache - with: - cache-name: lint-go-gogit - lint-cache: "true" - - run: make deps-backend deps-tools - - run: make lint-go - env: - TAGS: bindata gogit sqlite sqlite_unlock_notify - checks-backend: if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' needs: files-changed @@ -118,9 +74,6 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: checks-backend - build-cache: "false" - run: make deps-backend deps-tools - run: make --always-make checks-backend # ensure the "go-licenses" make target runs @@ -130,7 +83,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24 @@ -154,8 +107,6 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: compliance-backend - run: make deps-backend generate-go # no frontend build here as backend should be able to build, even without any frontend files # CGO is not used when cross-compile, so these steps also test if the code is compatible with CGO disabled diff --git a/.github/workflows/pull-db-tests.yml b/.github/workflows/pull-db-tests.yml index 944a117e15d..bc73d6391ca 100644 --- a/.github/workflows/pull-db-tests.yml +++ b/.github/workflows/pull-db-tests.yml @@ -14,10 +14,14 @@ jobs: files-changed: uses: ./.github/workflows/files-changed.yml - test-pgsql: + test-pgsql-shards: if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' needs: files-changed runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + shard: [1, 2] services: pgsql: image: postgres:14 @@ -27,14 +31,14 @@ jobs: ports: - "5432:5432" ldap: - image: gitea/test-openldap:latest + image: gitea/test-openldap:latest@sha256:4ac633b01d684e6b2a458cc0c8530c92f9b3702f6e040ce5f365607df34fbda0 ports: - "389:389" - "636:636" 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.12.23 + image: bitnamilegacy/minio:2025.7.23 env: MINIO_ROOT_USER: 123456 MINIO_ROOT_PASSWORD: 12345678 @@ -48,8 +52,6 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: pgsql - name: Add hosts to /etc/hosts run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 pgsql ldap minio" | sudo tee -a /etc/hosts' - run: make deps-backend @@ -57,13 +59,18 @@ jobs: env: TAGS: bindata - name: run migration tests + if: matrix.shard == 1 run: GITEA_TEST_DATABASE=pgsql make test-migration - name: run tests 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 + TEST_SHARD: ${{ matrix.shard }} + TEST_TOTAL_SHARDS: ${{ strategy.job-total }} test-sqlite: if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' @@ -77,24 +84,22 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: sqlite - 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 + - run: GITEA_TEST_DATABASE=sqlite make test-migration env: TAGS: bindata gogit - name: run tests 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' @@ -102,7 +107,7 @@ jobs: runs-on: ubuntu-latest services: elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:8.19.14 + image: docker.elastic.co/elasticsearch/elasticsearch:8.19.15 env: discovery.type: single-node xpack.security.enabled: false @@ -115,7 +120,7 @@ jobs: ports: - "7700:7700" redis: - image: redis + image: redis:latest@sha256:94ea4f5ccdaa6b154df99a792986ecb3ffbb3fe7722a197220477f1f3e65f9fe options: >- # wait until redis has started --health-cmd "redis-cli ping" --health-interval 5s @@ -124,14 +129,14 @@ jobs: ports: - 6379:6379 minio: - image: bitnamilegacy/minio:2021.12.29 + image: bitnamilegacy/minio:2025.7.23 env: - MINIO_ACCESS_KEY: 123456 - MINIO_SECRET_KEY: 12345678 + MINIO_ROOT_USER: 123456 + MINIO_ROOT_PASSWORD: 12345678 ports: - "9000:9000" devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583 - image: mcr.microsoft.com/azure-storage/azurite:latest + image: mcr.microsoft.com/azure-storage/azurite:latest@sha256:dae2a5f96553962901304b94e72ef87e299d0825e4b679673bcc527a25076fe4 ports: - 10000:10000 steps: @@ -142,28 +147,27 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: unit - build-cache-rotate: "true" - name: Add hosts to /etc/hosts run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 minio devstoreaccount1.azurite.local mysql elasticsearch meilisearch smtpimap" | sudo tee -a /etc/hosts' - run: make deps-backend - - run: make backend + - run: make generate-go env: TAGS: bindata - name: unit-tests - run: make test-backend test-check + run: make test-backend 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 + run: make test-backend 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 }} + GITEA_TEST_CI_SKIP_EXTERNAL: true + - run: make test-check test-mysql: if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true' @@ -181,14 +185,14 @@ jobs: options: >- --mount type=tmpfs,destination=/bitnami/mysql/data elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:8.19.14 + image: docker.elastic.co/elasticsearch/elasticsearch:8.19.15 env: discovery.type: single-node xpack.security.enabled: false ports: - "9200:9200" smtpimap: - image: tabascoterrier/docker-imap-devel:latest + image: tabascoterrier/docker-imap-devel:latest@sha256:3fb7cf50b47693e7b80f6f74abea2def4d7386016931d61359864de8a0aba551 ports: - "25:25" - "143:143" @@ -202,16 +206,13 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: mysql - name: Add hosts to /etc/hosts run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts' - run: make deps-backend - run: make backend env: TAGS: bindata - - name: run migration tests - run: GITEA_TEST_DATABASE=mysql make test-migration + - run: GITEA_TEST_DATABASE=mysql make test-migration - name: run tests run: GITEA_TEST_DATABASE=mysql make test-integration env: @@ -232,7 +233,7 @@ jobs: ports: - "1433:1433" devstoreaccount1.azurite.local: # https://github.com/Azure/Azurite/issues/1583 - image: mcr.microsoft.com/azure-storage/azurite:latest + image: mcr.microsoft.com/azure-storage/azurite:latest@sha256:dae2a5f96553962901304b94e72ef87e299d0825e4b679673bcc527a25076fe4 ports: - 10000:10000 steps: @@ -243,8 +244,6 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: mssql - name: Add hosts to /etc/hosts run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql devstoreaccount1.azurite.local" | sudo tee -a /etc/hosts' - run: make deps-backend diff --git a/.github/workflows/pull-e2e-tests.yml b/.github/workflows/pull-e2e-tests.yml index 974d82ea5e9..7bf73d4a0f9 100644 --- a/.github/workflows/pull-e2e-tests.yml +++ b/.github/workflows/pull-e2e-tests.yml @@ -26,10 +26,7 @@ jobs: check-latest: true cache: false - uses: ./.github/actions/go-cache - with: - cache-name: e2e - build-cache: "false" - - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24 @@ -40,11 +37,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-labeler.yml b/.github/workflows/pull-labeler.yml index f9e2e5e07b7..b27fc32cdb3 100644 --- a/.github/workflows/pull-labeler.yml +++ b/.github/workflows/pull-labeler.yml @@ -15,6 +15,6 @@ jobs: contents: read pull-requests: write steps: - - uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1 + - uses: actions/labeler@f27b608878404679385c85cfa523b85ccb86e213 # v6.1.0 with: sync-labels: true diff --git a/.github/workflows/pull-pr-title.yml b/.github/workflows/pull-pr-title.yml new file mode 100644 index 00000000000..6dadcb70589 --- /dev/null +++ b/.github/workflows/pull-pr-title.yml @@ -0,0 +1,31 @@ +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 + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version: 24 + - 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 a5fa452ef36..82ebf79a61e 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -22,7 +22,7 @@ jobs: with: go-version-file: go.mod check-latest: true - - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24 @@ -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 @@ -40,26 +40,34 @@ jobs: gpg_private_key: ${{ secrets.GPGSIGN_KEY }} passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }} - name: sign binaries + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GPG_PASSPHRASE: ${{ secrets.GPGSIGN_PASSPHRASE }} run: | for f in dist/release/*; do - echo '${{ secrets.GPGSIGN_PASSPHRASE }}' | gpg --pinentry-mode loopback --passphrase-fd 0 --batch --yes --detach-sign -u ${{ steps.import_gpg.outputs.fingerprint }} --output "$f.asc" "$f" + echo "$GPG_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --batch --yes --detach-sign -u "$GPG_FINGERPRINT" --output "$f.asc" "$f" done # clean branch name to get the folder name in S3 - name: Get cleaned branch name id: clean_name + env: + REF: ${{ github.ref }} run: | - REF_NAME=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\///' -e 's/release\/v//') + REF_NAME=$(echo "$REF" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\///' -e 's/release\/v//') echo "Cleaned name is ${REF_NAME}" echo "branch=${REF_NAME}-nightly" >> "$GITHUB_OUTPUT" - name: configure aws - uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0 + uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 with: aws-region: ${{ secrets.AWS_REGION }} aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - name: upload binaries to s3 + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + BRANCH: ${{ steps.clean_name.outputs.branch }} run: | - aws s3 sync dist/release s3://${{ secrets.AWS_S3_BUCKET }}/gitea/${{ steps.clean_name.outputs.branch }} --no-progress + aws s3 sync dist/release "s3://$AWS_S3_BUCKET/gitea/$BRANCH" --no-progress nightly-container: runs-on: namespace-profile-gitea-release-docker @@ -75,8 +83,10 @@ jobs: - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 - name: Get cleaned branch name id: clean_name + env: + REF: ${{ github.ref }} run: | - REF_NAME=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\///' -e 's/release\/v//') + REF_NAME=$(echo "$REF" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\///' -e 's/release\/v//') echo "branch=${REF_NAME}-nightly" >> "$GITHUB_OUTPUT" - uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 id: meta diff --git a/.github/workflows/release-tag-rc.yml b/.github/workflows/release-tag-rc.yml index 2e0f2dd5c0b..b246d87b9ad 100644 --- a/.github/workflows/release-tag-rc.yml +++ b/.github/workflows/release-tag-rc.yml @@ -23,7 +23,7 @@ jobs: with: go-version-file: go.mod check-latest: true - - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24 @@ -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 @@ -41,35 +41,44 @@ jobs: gpg_private_key: ${{ secrets.GPGSIGN_KEY }} passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }} - name: sign binaries + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GPG_PASSPHRASE: ${{ secrets.GPGSIGN_PASSPHRASE }} run: | for f in dist/release/*; do - echo '${{ secrets.GPGSIGN_PASSPHRASE }}' | gpg --pinentry-mode loopback --passphrase-fd 0 --batch --yes --detach-sign -u ${{ steps.import_gpg.outputs.fingerprint }} --output "$f.asc" "$f" + echo "$GPG_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --batch --yes --detach-sign -u "$GPG_FINGERPRINT" --output "$f.asc" "$f" done # clean branch name to get the folder name in S3 - name: Get cleaned branch name id: clean_name + env: + REF: ${{ github.ref }} run: | - REF_NAME=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\/v//' -e 's/release\/v//') + REF_NAME=$(echo "$REF" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\/v//' -e 's/release\/v//') echo "Cleaned name is ${REF_NAME}" echo "branch=${REF_NAME}" >> "$GITHUB_OUTPUT" - name: configure aws - uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0 + uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 with: aws-region: ${{ secrets.AWS_REGION }} aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - name: upload binaries to s3 + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + BRANCH: ${{ steps.clean_name.outputs.branch }} run: | - aws s3 sync dist/release s3://${{ secrets.AWS_S3_BUCKET }}/gitea/${{ steps.clean_name.outputs.branch }} --no-progress + aws s3 sync dist/release "s3://$AWS_S3_BUCKET/gitea/$BRANCH" --no-progress - name: Install GH CLI uses: dev-hanz-ops/install-gh-cli-action@af38ce09b1ec248aeb08eea2b16bbecea9e059f8 # v0.2.1 with: gh-cli-version: 2.39.1 - name: create github release - run: | - gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --draft --notes-from-tag dist/release/* env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + TAG: ${{ github.ref_name }} + run: | + gh release create "$TAG" --title "$TAG" --draft --notes-from-tag dist/release/* container: runs-on: namespace-profile-gitea-release-docker diff --git a/.github/workflows/release-tag-version.yml b/.github/workflows/release-tag-version.yml index 2e7a9f5f54c..9eb910c8e36 100644 --- a/.github/workflows/release-tag-version.yml +++ b/.github/workflows/release-tag-version.yml @@ -26,7 +26,7 @@ jobs: with: go-version-file: go.mod check-latest: true - - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0 + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: 24 @@ -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 @@ -44,35 +44,44 @@ jobs: gpg_private_key: ${{ secrets.GPGSIGN_KEY }} passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }} - name: sign binaries + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GPG_PASSPHRASE: ${{ secrets.GPGSIGN_PASSPHRASE }} run: | for f in dist/release/*; do - echo '${{ secrets.GPGSIGN_PASSPHRASE }}' | gpg --pinentry-mode loopback --passphrase-fd 0 --batch --yes --detach-sign -u ${{ steps.import_gpg.outputs.fingerprint }} --output "$f.asc" "$f" + echo "$GPG_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --batch --yes --detach-sign -u "$GPG_FINGERPRINT" --output "$f.asc" "$f" done # clean branch name to get the folder name in S3 - name: Get cleaned branch name id: clean_name + env: + REF: ${{ github.ref }} run: | - REF_NAME=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\/v//' -e 's/release\/v//') + REF_NAME=$(echo "$REF" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\/v//' -e 's/release\/v//') echo "Cleaned name is ${REF_NAME}" echo "branch=${REF_NAME}" >> "$GITHUB_OUTPUT" - name: configure aws - uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0 + uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 with: aws-region: ${{ secrets.AWS_REGION }} aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - name: upload binaries to s3 + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + BRANCH: ${{ steps.clean_name.outputs.branch }} run: | - aws s3 sync dist/release s3://${{ secrets.AWS_S3_BUCKET }}/gitea/${{ steps.clean_name.outputs.branch }} --no-progress + aws s3 sync dist/release "s3://$AWS_S3_BUCKET/gitea/$BRANCH" --no-progress - name: Install GH CLI uses: dev-hanz-ops/install-gh-cli-action@af38ce09b1ec248aeb08eea2b16bbecea9e059f8 # v0.2.1 with: gh-cli-version: 2.39.1 - name: create github release - run: | - gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --notes-from-tag dist/release/* env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} + TAG: ${{ github.ref_name }} + run: | + gh release create "$TAG" --title "$TAG" --notes-from-tag dist/release/* container: runs-on: namespace-profile-gitea-release-docker diff --git a/.golangci.yml b/.golangci.yml index 570942bdd32..056a6c2a08f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,7 +13,6 @@ linters: - forbidigo - gocheckcompilerdirectives - gocritic - - goheader - govet - ineffassign - mirror @@ -118,11 +117,6 @@ linters: enable: - nilness - unusedwrite - goheader: - values: - regexp: - HEADER: '((Copyright [^\n]+|All rights reserved\.)\n)*Copyright \d{4} (The (Gogs|Gitea) Authors|Gitea Authors|Gitea)\.( All rights reserved\.)?(\n(Copyright [^\n]+|All rights reserved\.))*\nSPDX-License-Identifier: [\w.-]+' - template: '{{ HEADER }}' exclusions: generated: lax presets: diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 790a49a6eb9..00000000000 --- a/.npmrc +++ /dev/null @@ -1,7 +0,0 @@ -audit=false -fund=false -update-notifier=false -save-exact=true -auto-install-peers=true -dedupe-peer-dependents=false -enable-pre-post-scripts=true diff --git a/AGENTS.md b/AGENTS.md index fd87f432b71..2331da486aa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,13 +2,17 @@ - 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 (for example `type(scope): subject`; place `!` immediately before the colon when the change is breaking) - 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 +- Keep comments short, prefer same-line, explain why, never narrate code +- Prefer unit tests over integration tests when logic is testable in isolation +- Aim for sub-2s local runtime for integration and e2e tests - In TypeScript, use `!` (non-null assertion) instead of `?.`/`??` when a value is known to always exist - For CSS layout, prefer `flex-*` helpers over per-child `tw-ml-*` / `tw-mr-*` margins; fall back to `tw-*` utilities when specificity requires `!important` - Include authorship attribution in issue and pull request comments diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b6b94269b..691e6eaed14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,68 @@ This changelog goes through the changes that have been made in each release without substantial changes to our git log; to see the highlights of what has been added to each release, please refer to the [blog](https://blog.gitea.com). +## [1.26.2](https://github.com/go-gitea/gitea/releases/tag/1.26.2) - 2026-05-20 + +* SECURITY + * fix(permissions): Fix reading permission (#37769) + * fix(actions): make artifact signature payloads unambiguous (#37707) + * fix: Unify public-only token filtering in API queries and repo access checks (#37118) + * fix: Add missed token scope checking (#37735) + * fix(oauth): bind token exchanges to the original client request (#37704) + * fix(oauth): strengthen PKCE validation and refresh token replay protection (#37706) + * fix(web): enforce token scopes on raw, media, and attachment downloads (#37698) + * fix(security): enforce wiki git writes and LFS token access at request time (#37695) + * feat(api): encrypt AWS creds (#37679) + * fix(deps): update dependency mermaid to v11.15.0 [security], add e2e test + * fix(packages): Add label for private and internal package and fix composor package source permission check (#37610) + * fix(git): Fix smart http request scope bug (#37583) + * Fix basic auth bug (#37503) + * Fix allow maintainer edit permission check (#37479) (#37484) + * Fix URL sanitization to handle schemeless credentials (#37440) (#37471) + * Fix attachment Content-Security-Policy (#37455) (#37464) + * chore(deps): bump go-git/go-git/v5 to 5.19.0 (#37608) + +* BUGFIXES + * fix(pull): handle empty pull request files view to allow reviews (#37783) + * fix(markup): make RenderString never fail (#37779) + * fix: add natural sort to sortTreeViewNodes (#37772) + * fix: package creation unique conflict (#37774) + * fix!: add DEFAULT_TITLE_SOURCE setting for pull request title default behavior (#37465) + * fix: Allow direct commits for unprotected files with push restrictions (#37657) + * fix(actions): wrong assumption that run id always >= job id (#37737) + * fix(auth): set User-Agent on avatar fetch and sync avatar on link-account register (#37564) (#37588) + * fix(actions): deadlock between PrepareRunAndInsert and UpdateTaskByState (#37692) + * fix(repo): /generate must sync the branch table for the new repo (#37693) + * build: Fix snap build (1.26) + * fix(actions): run TransferLogs on UpdateLog{Rows:[], NoMore:true} (#37631) + * fix show correct mergebase + * fix: make clone URL respect public URL detection setting (#37615) + * fix: "run as root" check (#37622) + * chore(deps): update dependency go to v1.26.3 (#37601) + * Compare dropdown fails when selecting branch with no common merge-base (#37470) + * fix: treat email addresses case-insensitively (#37600) + * fix(actions): fix blank lines after ::endgroup:: (#37597) + * fix(actions): report individual step status in workflow job API response (#37592) + * fix: Invalid UTF-8 commit messages in JSON API responses (#37542) + * fix: use consistent GetUser family functions (#37553) + * fix(api): return 409 message instead of empty JSON for wrong commit id (#37572) + * fix(actions): prevent panic when workflow contains null jobs (#37570) + * Make ServeSetHeaders default to download attachment if filename exists (#37552) (#37555) + * Fix(actions): validate workflow param to prevent 500 error (#37546) (#37554) + * Don't unblock run-level-concurrency-blocked runs in the resolver (#37461) (#37538) + * Fix(packages): use file names for generic web downloads (#37514) (#37520) + * Fix merge autodetect can't close other PRs but only the last one when multiple PRs are pushed at once (#37512) (#37516) + * Fix update branch protection order (#37508) (#37513) + * Fix mCaptcha broken after Vite migration (#37492) (#37509) + * Fix review submission from single-commit PR view (#37475) (#37485) + * Fix scheduled action panic with null event payload (#37459) (#37466) + * Make GetPossibleUserByID can handle deleted user (#37430) (#37431) + * Remove excessive quote from terraform instructions (#37424) (#37426) + * Fix color regressions, add `priority` color (#37417) (#37421) + +* MISC + * Add CurrentURL template variable back (#37444) (#37449) + ## [1.26.1](https://github.com/go-gitea/gitea/releases/tag/v1.26.1) - 2026-04-21 * BUGFIXES @@ -1383,7 +1445,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 +2176,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 +2360,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 +5652,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 f1871f14701..6888b4ad653 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -189,6 +189,38 @@ 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 scope in parentheses is optional. A `!` immediately before the colon marks a [breaking change](https://www.conventionalcommits.org/en/v1.0.0/#summary): either `type!:` or `type(scope)!:` (not `type!(scope):`). + +Use one of these types: + +- `build`: Changes affecting the build system, packaging, or external dependencies +- `ci`: Changes to CI/CD configuration files and scripts +- `chore`: Maintenance changes that do not affect production code or should not appear in the changelog +- `docs`: Documentation-only changes +- `feat`: A larger user-facing feature, improvement, or new functionality +- `enhance`: Small or trivial user-facing improvements or UX polish (for example wording changes, color adjustments, spacing or padding tweaks, placeholders, small UI behavior improvements) +- `fix`: A bug fix, UX correction, or security-related dependency update +- `perf`: Performance improvements (speed, memory, scalability) +- `refactor`: A code change that neither fixes a bug nor adds a feature +- `revert`: Reverts a previous change +- `style`: Formatting or style-only changes that do not affect code behavior (for example lint-driven edits) +- `test`: Adding or correcting tests + +Examples: + +```text +fix(web): prevent avatar upload crash on empty file +feat(api): add pagination to repo hooks list +enhance(repo): improve diff toolbar spacing +ci(workflows): lint PR titles in CI +``` + 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. @@ -201,6 +233,10 @@ Another requirement for merging PRs is that the PR is labeled correctly.\ However, this is not your job as a contributor, but the job of the person merging your PR.\ If you think that your PR was labeled incorrectly, or notice that it was merged without labels, please let us know. +For pull requests that use a valid Conventional Commits title, CI automatically applies a matching `type/…` label when the title prefix is `feat`, `enhance`, `fix`, `docs`, or `test` (for example `enhance(web): …` receives `type/enhancement`).\ +That label is kept in sync with the PR title when the title is edited.\ +Other title prefixes do not get an automatic `type/…` label; the merger still assigns the correct labels (including `type/…` when needed) for changelog and backport decisions. + If your PR closes some issues, you must note that in a way that both GitHub and Gitea understand, i.e. by appending a paragraph like ```text diff --git a/Dockerfile b/Dockerfile index 323f06125fe..c69b5a65d1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.26-alpine3.23 AS frontend-build RUN apk --no-cache add build-base git nodejs pnpm WORKDIR /src -COPY package.json pnpm-lock.yaml .npmrc ./ +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile COPY --exclude=.git/ . . RUN make frontend @@ -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 83c69cbd513..6f029067ded 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -3,7 +3,7 @@ FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.26-alpine3.23 AS frontend-build RUN apk --no-cache add build-base git nodejs pnpm WORKDIR /src -COPY package.json pnpm-lock.yaml .npmrc ./ +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile COPY --exclude=.git/ . . RUN make frontend @@ -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 2466435b17f..94f07a44125 100644 --- a/Makefile +++ b/Makefile @@ -11,15 +11,15 @@ COMMA := , XGO_VERSION := go-1.26.x -AIR_PACKAGE ?= github.com/air-verse/air@v1 # renovate: datasource=go -EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3 # renovate: datasource=go -GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4 # renovate: datasource=go +AIR_PACKAGE ?= github.com/air-verse/air@v1.65.1 # renovate: datasource=go +EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.6.1 # renovate: datasource=go +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 # renovate: datasource=go GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15 # renovate: datasource=go MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.8.0 # renovate: datasource=go -SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1 # renovate: datasource=go -XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest -GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1 # renovate: datasource=go -ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.7.11 # renovate: datasource=go +SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.2 # renovate: datasource=go +XGO_PACKAGE ?= src.techknowlogick.com/xgo@v1.9.0 # renovate: datasource=go +GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1.3.0 # renovate: datasource=go +ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 # renovate: datasource=go HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes) ifeq ($(HAS_GO), yes) @@ -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.ts + .PHONY: lint-spell lint-spell: ## lint spelling @git ls-files $(SPELLCHECK_FILES) | xargs go run $(MISSPELL_PACKAGE) -dict assets/misspellings.csv -error @@ -331,18 +332,11 @@ lint-spell-fix: ## lint spelling and fix issues .PHONY: lint-go lint-go: ## lint go files - $(GO) run $(GOLANGCI_LINT_PACKAGE) run + GO=$(GO) GOLANGCI_LINT_PACKAGE=$(GOLANGCI_LINT_PACKAGE) $(GO) run ./tools/lint-go-all.go .PHONY: lint-go-fix lint-go-fix: ## lint go files and fix issues - $(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix - -# workaround step for the lint-go-windows CI task because 'go run' can not -# have distinct GOOS/GOARCH for its build and run steps -.PHONY: lint-go-windows -lint-go-windows: - @GOOS= GOARCH= $(GO) install $(GOLANGCI_LINT_PACKAGE) - golangci-lint run + GO=$(GO) GOLANGCI_LINT_PACKAGE=$(GOLANGCI_LINT_PACKAGE) $(GO) run ./tools/lint-go-all.go --fix .PHONY: lint-editorconfig lint-editorconfig: @@ -350,8 +344,9 @@ lint-editorconfig: @$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES) .PHONY: lint-actions -lint-actions: ## lint action workflow files - $(GO) run $(ACTIONLINT_PACKAGE) +lint-actions: .venv ## lint action workflow files + @$(GO) run $(ACTIONLINT_PACKAGE) + @uv run --frozen zizmor --quiet --min-confidence=medium .github .PHONY: lint-templates lint-templates: .venv node_modules ## lint template files @@ -450,7 +445,11 @@ test-integration: @# would flood output per passing test. testcache can't help these tests anyway — @# they mutate the work directory, so cache inputs change between runs. $(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -c code.gitea.io/gitea/tests/integration -o ./test-integration-$(GITEA_TEST_DATABASE).test - ./test-integration-$(GITEA_TEST_DATABASE).test + ./tools/test-integration.sh ./test-integration-$(GITEA_TEST_DATABASE).test + +.PHONY: test-integration-compile +test-integration-compile: + $(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -c -o /dev/null code.gitea.io/gitea/tests/integration .PHONY: test-integration\#% test-integration\#%: @@ -474,12 +473,11 @@ migrations.individual.test\#%: .PHONY: playwright playwright: deps-frontend - @# on GitHub Actions VMs, playwright's system deps are pre-installed - @pnpm exec playwright install $(if $(GITHUB_ACTIONS),,--with-deps) chromium firefox $(PLAYWRIGHT_FLAGS) + @./tools/test-e2e.sh install .PHONY: test-e2e test-e2e: playwright frontend backend - @EXECUTABLE=$(EXECUTABLE) ./tools/test-e2e.sh $(GITEA_TEST_E2E_FLAGS) + @EXECUTABLE=$(EXECUTABLE) ./tools/test-e2e.sh run $(GITEA_TEST_E2E_FLAGS) .PHONY: build build: frontend backend ## build everything @@ -612,6 +610,7 @@ update-js: node_modules ## update js dependencies .PHONY: nolyfill nolyfill: node_modules ## apply nolyfill overrides to package.json and relock pnpm exec nolyfill install + node tools/migrate-nolyfills.ts pnpm install @touch node_modules @@ -666,6 +665,10 @@ generate-gitignore: ## update gitignore files generate-images: | node_modules ## generate images cd tools && node generate-images.ts $(TAGS) +.PHONY: generate-codemirror-languages +generate-codemirror-languages: | node_modules ## generate codemirror languages + node tools/generate-codemirror-languages.ts + .PHONY: generate-manpage generate-manpage: ## generate manpage @[ -f gitea ] || make backend diff --git a/README.md b/README.md index 7ebeac97be0..4c4fedd3b8e 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 8ccacc0fea4..52c77818311 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 4160fd0bd91..77ad6828db2 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/codemirror-languages.json b/assets/codemirror-languages.json new file mode 100644 index 00000000000..573e7c493b3 --- /dev/null +++ b/assets/codemirror-languages.json @@ -0,0 +1,1277 @@ +[ + { + "name": "APL", + "extensions": [ + "apl", + "dyalog" + ], + "filenames": [] + }, + { + "name": "ASN.1", + "extensions": [ + "asn", + "asn1" + ], + "filenames": [] + }, + { + "name": "Brainfuck", + "extensions": [ + "b", + "bf" + ], + "filenames": [] + }, + { + "name": "C", + "extensions": [ + "c", + "cats", + "h", + "idc" + ], + "filenames": [] + }, + { + "name": "C#", + "extensions": [ + "cs", + "cake", + "csx", + "linq" + ], + "filenames": [] + }, + { + "name": "C++", + "extensions": [ + "cpp", + "c++", + "cc", + "cp", + "cppm", + "cxx", + "h++", + "hh", + "hpp", + "hxx", + "inl", + "ipp", + "ixx", + "re", + "tcc", + "tpp", + "txx" + ], + "filenames": [] + }, + { + "name": "Clojure", + "extensions": [ + "clj", + "bb", + "boot", + "cl2", + "cljc", + "cljscm", + "cljx", + "hic" + ], + "filenames": [ + "riemann.config" + ] + }, + { + "name": "CMake", + "extensions": [ + "cmake" + ], + "filenames": [ + "CMakeLists.txt" + ] + }, + { + "name": "Cobol", + "extensions": [ + "cob", + "cbl", + "ccp", + "cobol", + "cpy" + ], + "filenames": [] + }, + { + "name": "CoffeeScript", + "extensions": [ + "coffee", + "_coffee", + "cake", + "cjsx", + "iced" + ], + "filenames": [ + "Cakefile" + ] + }, + { + "name": "Common Lisp", + "extensions": [ + "lisp", + "asd", + "cl", + "l", + "lsp", + "ny", + "podsl", + "sexp" + ], + "filenames": [] + }, + { + "name": "CQL", + "extensions": [ + "cql" + ], + "filenames": [] + }, + { + "name": "Crystal", + "extensions": [ + "cr" + ], + "filenames": [] + }, + { + "name": "CSS", + "extensions": [ + "css" + ], + "filenames": [] + }, + { + "name": "Cypher", + "extensions": [ + "cyp", + "cypher" + ], + "filenames": [] + }, + { + "name": "Cython", + "extensions": [ + "pyx", + "pxd", + "pxi" + ], + "filenames": [] + }, + { + "name": "D", + "extensions": [ + "d", + "di" + ], + "filenames": [] + }, + { + "name": "Dart", + "extensions": [ + "dart" + ], + "filenames": [] + }, + { + "name": "diff", + "extensions": [ + "diff", + "patch" + ], + "filenames": [] + }, + { + "name": "Dylan", + "extensions": [ + "dylan", + "dyl", + "intr", + "lid" + ], + "filenames": [] + }, + { + "name": "EBNF", + "extensions": [ + "ebnf" + ], + "filenames": [] + }, + { + "name": "ECL", + "extensions": [ + "ecl", + "eclxml" + ], + "filenames": [] + }, + { + "name": "edn", + "extensions": [ + "edn" + ], + "filenames": [] + }, + { + "name": "Eiffel", + "extensions": [ + "e" + ], + "filenames": [] + }, + { + "name": "Elm", + "extensions": [ + "elm" + ], + "filenames": [] + }, + { + "name": "Erlang", + "extensions": [ + "erl", + "app", + "es", + "escript", + "hrl", + "xrl", + "yrl" + ], + "filenames": [ + "Emakefile", + "rebar.config", + "rebar.config.lock", + "rebar.lock" + ] + }, + { + "name": "F#", + "extensions": [ + "fs", + "fsi", + "fsx" + ], + "filenames": [] + }, + { + "name": "Factor", + "extensions": [ + "factor" + ], + "filenames": [ + ".factor-boot-rc", + ".factor-rc" + ] + }, + { + "name": "Forth", + "extensions": [ + "fth", + "4th", + "forth", + "fr", + "frt" + ], + "filenames": [] + }, + { + "name": "Fortran", + "extensions": [ + "f", + "f77", + "for", + "fpp" + ], + "filenames": [] + }, + { + "name": "Gherkin", + "extensions": [ + "feature", + "story" + ], + "filenames": [] + }, + { + "name": "Go", + "extensions": [ + "go" + ], + "filenames": [] + }, + { + "name": "Groovy", + "extensions": [ + "groovy", + "grt", + "gtpl", + "gvy" + ], + "filenames": [ + "Jenkinsfile" + ] + }, + { + "name": "Haskell", + "extensions": [ + "hs", + "hs-boot", + "hsc" + ], + "filenames": [] + }, + { + "name": "Haxe", + "extensions": [ + "hx", + "hxsl" + ], + "filenames": [] + }, + { + "name": "HTML", + "extensions": [ + "html", + "hta", + "htm", + "xht", + "xhtml" + ], + "filenames": [] + }, + { + "name": "HTTP", + "extensions": [ + "http" + ], + "filenames": [] + }, + { + "name": "HXML", + "extensions": [ + "hxml" + ], + "filenames": [] + }, + { + "name": "IDL", + "extensions": [ + "pro", + "dlm" + ], + "filenames": [] + }, + { + "name": "Java", + "extensions": [ + "java", + "jav", + "jsh" + ], + "filenames": [] + }, + { + "name": "JavaScript", + "extensions": [ + "js", + "_js", + "bones", + "cjs", + "es", + "es6", + "frag", + "gs", + "jake", + "javascript", + "jsb", + "jscad", + "jsfl", + "jslib", + "jsm", + "jspre", + "jss", + "mjs", + "njs", + "pac", + "sjs", + "ssjs", + "xsjs", + "xsjslib" + ], + "filenames": [ + "Jakefile" + ] + }, + { + "name": "Jinja", + "extensions": [ + "jinja", + "j2", + "jinja2" + ], + "filenames": [] + }, + { + "name": "JSON", + "extensions": [ + "json", + "4DForm", + "4DProject", + "avsc", + "geojson", + "gltf", + "har", + "ice", + "JSON-tmLanguage", + "jsonl", + "mcmeta", + "sarif", + "tact", + "tfstate", + "topojson", + "webapp", + "webmanifest", + "yy", + "yyp" + ], + "filenames": [ + ".all-contributorsrc", + ".arcconfig", + ".auto-changelog", + ".c8rc", + ".htmlhintrc", + ".imgbotconfig", + ".nycrc", + ".tern-config", + ".tern-project", + ".watchmanconfig", + "MODULE.bazel.lock", + "Package.resolved", + "Pipfile.lock", + "bun.lock", + "composer.lock", + "deno.lock", + "flake.lock", + "mcmod.info" + ] + }, + { + "name": "JSON-LD", + "extensions": [ + "jsonld" + ], + "filenames": [] + }, + { + "name": "Julia", + "extensions": [ + "jl" + ], + "filenames": [] + }, + { + "name": "Kotlin", + "extensions": [ + "kt", + "ktm", + "kts" + ], + "filenames": [] + }, + { + "name": "LaTeX", + "extensions": [ + "tex", + "aux", + "bbx", + "cbx", + "cls", + "dtx", + "ins", + "lbx", + "ltx", + "mkii", + "mkiv", + "mkvi", + "sty", + "toc" + ], + "filenames": [] + }, + { + "name": "LESS", + "extensions": [ + "less" + ], + "filenames": [] + }, + { + "name": "Liquid", + "extensions": [ + "liquid" + ], + "filenames": [] + }, + { + "name": "LiveScript", + "extensions": [ + "ls", + "_ls" + ], + "filenames": [ + "Slakefile" + ] + }, + { + "name": "Lua", + "extensions": [ + "lua", + "nse", + "p8", + "pd_lua", + "rbxs", + "rockspec", + "wlua" + ], + "filenames": [ + ".luacheckrc" + ] + }, + { + "name": "Modelica", + "extensions": [ + "mo" + ], + "filenames": [] + }, + { + "name": "Nginx", + "extensions": [ + "nginx", + "nginxconf", + "vhost" + ], + "filenames": [ + "nginx.conf" + ] + }, + { + "name": "NSIS", + "extensions": [ + "nsi", + "nsh" + ], + "filenames": [] + }, + { + "name": "Objective-C", + "extensions": [], + "filenames": [] + }, + { + "name": "Objective-C++", + "extensions": [ + "mm" + ], + "filenames": [] + }, + { + "name": "OCaml", + "extensions": [ + "ml", + "eliom", + "eliomi", + "ml4", + "mli", + "mll", + "mly" + ], + "filenames": [] + }, + { + "name": "Oz", + "extensions": [ + "oz" + ], + "filenames": [] + }, + { + "name": "Pascal", + "extensions": [ + "pas", + "dfm", + "dpr", + "lpr", + "pascal" + ], + "filenames": [] + }, + { + "name": "Perl", + "extensions": [ + "pl", + "al", + "perl", + "ph", + "plx", + "pm", + "psgi", + "t" + ], + "filenames": [ + ".latexmkrc", + "Makefile.PL", + "Rexfile", + "ack", + "cpanfile", + "latexmkrc" + ] + }, + { + "name": "PHP", + "extensions": [ + "php", + "aw", + "ctp", + "php3", + "php4", + "php5", + "phps", + "phpt" + ], + "filenames": [ + ".php", + ".php_cs", + ".php_cs.dist", + "Phakefile" + ] + }, + { + "name": "PLSQL", + "extensions": [ + "pls", + "bdy", + "ddl", + "fnc", + "pck", + "pkb", + "pks", + "plb", + "plsql", + "prc", + "spc", + "tpb", + "tps", + "trg", + "vw" + ], + "filenames": [] + }, + { + "name": "PowerShell", + "extensions": [ + "ps1", + "psd1", + "psm1" + ], + "filenames": [] + }, + { + "name": "Properties files", + "extensions": [ + "ini", + "cnf", + "dof", + "lektorproject", + "prefs", + "properties", + "url", + "conf" + ], + "filenames": [ + ".buckconfig", + ".coveragerc", + ".flake8", + ".pylintrc", + "HOSTS", + "buildozer.spec", + "hosts", + "pylintrc", + "vlcrc", + ".editorconfig", + ".gitconfig", + ".npmrc" + ] + }, + { + "name": "ProtoBuf", + "extensions": [ + "proto" + ], + "filenames": [] + }, + { + "name": "Pug", + "extensions": [ + "jade", + "pug" + ], + "filenames": [] + }, + { + "name": "Puppet", + "extensions": [ + "pp" + ], + "filenames": [ + "Modulefile" + ] + }, + { + "name": "Python", + "extensions": [ + "py", + "gyp", + "gypi", + "lmi", + "py3", + "pyde", + "pyi", + "pyp", + "pyt", + "pyw", + "rpy", + "tac", + "wsgi", + "xpy" + ], + "filenames": [ + ".gclient", + "DEPS", + "SConscript", + "SConstruct", + "wscript", + "Snakefile" + ] + }, + { + "name": "Q", + "extensions": [ + "q" + ], + "filenames": [] + }, + { + "name": "R", + "extensions": [ + "r", + "rd", + "rsx" + ], + "filenames": [ + ".Rprofile", + "expr-dist" + ] + }, + { + "name": "RPM Spec", + "extensions": [ + "spec" + ], + "filenames": [] + }, + { + "name": "Ruby", + "extensions": [ + "rb", + "builder", + "eye", + "gemspec", + "god", + "jbuilder", + "mspec", + "pluginspec", + "podspec", + "prawn", + "rabl", + "rake", + "rbi", + "rbuild", + "rbw", + "rbx", + "ru", + "ruby", + "thor", + "watchr" + ], + "filenames": [ + ".irbrc", + ".pryrc", + ".simplecov", + "Appraisals", + "Berksfile", + "Brewfile", + "Buildfile", + "Capfile", + "Dangerfile", + "Deliverfile", + "Fastfile", + "Gemfile", + "Guardfile", + "Jarfile", + "Mavenfile", + "Podfile", + "Puppetfile", + "Rakefile", + "Snapfile", + "Steepfile", + "Thorfile", + "Vagrantfile", + "buildfile" + ] + }, + { + "name": "Rust", + "extensions": [ + "rs" + ], + "filenames": [] + }, + { + "name": "SAS", + "extensions": [ + "sas" + ], + "filenames": [] + }, + { + "name": "Sass", + "extensions": [ + "sass" + ], + "filenames": [] + }, + { + "name": "Scala", + "extensions": [ + "scala", + "kojo", + "sbt", + "sc" + ], + "filenames": [] + }, + { + "name": "Scheme", + "extensions": [ + "scm", + "sch", + "sld", + "sls", + "sps", + "ss" + ], + "filenames": [] + }, + { + "name": "SCSS", + "extensions": [ + "scss" + ], + "filenames": [] + }, + { + "name": "Shell", + "extensions": [ + "sh", + "bash", + "bats", + "command", + "ksh", + "sbatch", + "slurm", + "tmux", + "tool", + "trigger", + "zsh", + "zsh-theme" + ], + "filenames": [ + ".bash_aliases", + ".bash_functions", + ".bash_history", + ".bash_logout", + ".bash_profile", + ".bashrc", + ".cshrc", + ".envrc", + ".flaskenv", + ".kshrc", + ".login", + ".profile", + ".tmux.conf", + ".xinitrc", + ".xsession", + ".zlogin", + ".zlogout", + ".zprofile", + ".zshenv", + ".zshrc", + "9fs", + "PKGBUILD", + "bash_aliases", + "bash_logout", + "bash_profile", + "bashrc", + "cshrc", + "gradlew", + "kshrc", + "login", + "man", + "mvnw", + "profile", + "tmux.conf", + "xinitrc", + "xsession", + "zlogin", + "zlogout", + "zprofile", + "zshenv", + "zshrc" + ] + }, + { + "name": "Sieve", + "extensions": [ + "sieve" + ], + "filenames": [] + }, + { + "name": "Smalltalk", + "extensions": [ + "st" + ], + "filenames": [] + }, + { + "name": "SPARQL", + "extensions": [ + "sparql", + "rq" + ], + "filenames": [] + }, + { + "name": "SQL", + "extensions": [ + "sql", + "ddl", + "mysql", + "prc", + "tab", + "udf", + "viw" + ], + "filenames": [] + }, + { + "name": "Squirrel", + "extensions": [ + "nut" + ], + "filenames": [] + }, + { + "name": "Stylus", + "extensions": [ + "styl" + ], + "filenames": [] + }, + { + "name": "Swift", + "extensions": [ + "swift" + ], + "filenames": [] + }, + { + "name": "SystemVerilog", + "extensions": [ + "sv", + "svh", + "vh" + ], + "filenames": [] + }, + { + "name": "Tcl", + "extensions": [ + "tcl", + "adp", + "sdc", + "tm", + "xdc" + ], + "filenames": [ + "owh", + "starfield" + ] + }, + { + "name": "Textile", + "extensions": [ + "textile" + ], + "filenames": [] + }, + { + "name": "TOML", + "extensions": [ + "toml" + ], + "filenames": [ + "Cargo.lock", + "Cargo.toml.orig", + "Gopkg.lock", + "Pipfile", + "mise.local.lock", + "mise.lock", + "pdm.lock", + "poetry.lock", + "uv.lock" + ] + }, + { + "name": "TSX", + "extensions": [ + "tsx" + ], + "filenames": [] + }, + { + "name": "Turtle", + "extensions": [ + "ttl" + ], + "filenames": [] + }, + { + "name": "TypeScript", + "extensions": [ + "ts", + "cts", + "mts" + ], + "filenames": [] + }, + { + "name": "VBScript", + "extensions": [ + "vbs" + ], + "filenames": [] + }, + { + "name": "Verilog", + "extensions": [ + "veo" + ], + "filenames": [] + }, + { + "name": "VHDL", + "extensions": [ + "vhdl", + "vhd", + "vhf", + "vhi", + "vho", + "vhs", + "vht", + "vhw" + ], + "filenames": [] + }, + { + "name": "Vue", + "extensions": [ + "vue" + ], + "filenames": [] + }, + { + "name": "WebAssembly", + "extensions": [ + "wast", + "wat" + ], + "filenames": [] + }, + { + "name": "XML", + "extensions": [ + "xml", + "adml", + "admx", + "ant", + "axaml", + "axml", + "builds", + "ccproj", + "ccxml", + "clixml", + "cproject", + "cscfg", + "csdef", + "csl", + "csproj", + "ct", + "depproj", + "dita", + "ditamap", + "ditaval", + "dotsettings", + "filters", + "fsproj", + "fxml", + "glade", + "gml", + "gmx", + "gpx", + "grxml", + "gst", + "hzp", + "icls", + "iml", + "ivy", + "jelly", + "jsproj", + "kml", + "launch", + "mdpolicy", + "mjml", + "mod", + "mojo", + "mxml", + "natvis", + "ncl", + "ndproj", + "nproj", + "nuspec", + "odd", + "osm", + "pkgproj", + "pluginspec", + "proj", + "props", + "ps1xml", + "psc1", + "pt", + "pubxml", + "qhelp", + "rdf", + "res", + "resx", + "rss", + "sch", + "scxml", + "sfproj", + "shproj", + "slnx", + "srdf", + "storyboard", + "sublime-snippet", + "sw", + "targets", + "tml", + "typ", + "ui", + "urdf", + "ux", + "vbproj", + "vcxproj", + "vsixmanifest", + "vssettings", + "vstemplate", + "vxml", + "wixproj", + "workflow", + "wsdl", + "wsf", + "wxi", + "wxl", + "wxs", + "x3d", + "xacro", + "xaml", + "xib", + "xlf", + "xliff", + "xmi", + "xmp", + "xproj", + "xsd", + "xspec", + "xul", + "zcml" + ], + "filenames": [ + ".classpath", + ".cproject", + ".project", + "App.config", + "NuGet.config", + "Settings.StyleCop", + "Web.Debug.config", + "Web.Release.config", + "Web.config", + "packages.config" + ] + }, + { + "name": "XQuery", + "extensions": [ + "xquery", + "xq", + "xql", + "xqm", + "xqy" + ], + "filenames": [] + }, + { + "name": "YAML", + "extensions": [ + "yml", + "mir", + "reek", + "rviz", + "sublime-syntax", + "syntax", + "yaml", + "yaml-tmlanguage" + ], + "filenames": [ + ".clang-format", + ".clang-tidy", + ".clangd", + ".gemrc", + "CITATION.cff", + "glide.lock", + "pixi.lock", + "yarn.lock" + ] + } +] diff --git a/assets/go-licenses.json b/assets/go-licenses.json index 0f2913a6ada..3566fc2f6e2 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", @@ -650,8 +660,8 @@ "licenseText": "\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n" }, { - "name": "github.com/google/go-github/v84", - "path": "github.com/google/go-github/v84/LICENSE", + "name": "github.com/google/go-github/v86", + "path": "github.com/google/go-github/v86/LICENSE", "licenseText": "Copyright (c) 2013 The go-github 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" }, { @@ -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", @@ -1240,8 +1250,8 @@ "licenseText": "BSD 2-Clause License\n\nCopyright (c) 2012-2014, Yann Collet\nCopyright (c) 2019, Jeff Wendling\nAll rights reserved.\n\nxxHash Library\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this\n list of conditions and the following disclaimer in the documentation and/or\n other materials provided with the distribution.\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 FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" }, { - "name": "gitlab.com/gitlab-org/api/client-go", - "path": "gitlab.com/gitlab-org/api/client-go/LICENSE", + "name": "gitlab.com/gitlab-org/api/client-go/v2", + "path": "gitlab.com/gitlab-org/api/client-go/v2/LICENSE", "licenseText": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"{}\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright {yyyy} {name of copyright owner}\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n" }, { @@ -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/build/generate-gitignores.go b/build/generate-gitignores.go index 1e09c83a6a7..7a498f548e0 100644 --- a/build/generate-gitignores.go +++ b/build/generate-gitignores.go @@ -1,3 +1,6 @@ +// Copyright 2020 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + //go:build ignore package main diff --git a/build/test-env-check.sh b/build/test-env-check.sh deleted file mode 100755 index 38e5a288231..00000000000 --- a/build/test-env-check.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -set -e - -if [ ! -f ./build/test-env-check.sh ]; then - echo "${0} can only be executed in gitea source root directory" - exit 1 -fi - - -echo "check uid ..." - -# the uid of gitea defined in "https://gitea.com/gitea/test-env" is 1000 -gitea_uid=$(id -u gitea) -if [ "$gitea_uid" != "1000" ]; then - echo "The uid of linux user 'gitea' is expected to be 1000, but it is $gitea_uid" - exit 1 -fi - -cur_uid=$(id -u) -if [ "$cur_uid" != "0" -a "$cur_uid" != "$gitea_uid" ]; then - echo "The uid of current linux user is expected to be 0 or $gitea_uid, but it is $cur_uid" - exit 1 -fi diff --git a/build/test-env-prepare.sh b/build/test-env-prepare.sh deleted file mode 100755 index 0c5bc25f116..00000000000 --- a/build/test-env-prepare.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -e - -if [ ! -f ./build/test-env-prepare.sh ]; then - echo "${0} can only be executed in gitea source root directory" - exit 1 -fi - -echo "change the owner of files to gitea ..." -chown -R gitea:gitea . diff --git a/cmd/doctor.go b/cmd/doctor.go index 188740dbcea..3593670047b 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -21,7 +21,6 @@ import ( "code.gitea.io/gitea/services/doctor" "github.com/urfave/cli/v3" - "xorm.io/xorm" ) func newDoctorCommand() *cli.Command { @@ -132,7 +131,7 @@ func runRecreateTable(ctx context.Context, cmd *cli.Command) error { } recreateTables := migrate_base.RecreateTables(beans...) - return db.InitEngineWithMigration(context.Background(), func(ctx context.Context, x *xorm.Engine) error { + return db.InitEngineWithMigration(context.Background(), func(ctx context.Context, x db.EngineMigration) error { if err := migrations.EnsureUpToDate(ctx, x); err != nil { return err } diff --git a/cmd/web.go b/cmd/web.go index 994c481fc08..19ced5a3364 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -150,7 +150,7 @@ func serveInstall(cmd *cli.Command) error { c := install.Routes() err := listen(c, false) if err != nil { - log.Critical("Unable to open listener for installer. Is Gitea already running?") + log.Error("Unable to open listener for installer. Is Gitea already running?") graceful.GetManager().DoGracefulShutdown() } select { @@ -375,7 +375,7 @@ func listen(m http.Handler, handleRedirector bool) error { log.Fatal("Invalid protocol: %s", setting.Protocol) } if err != nil { - log.Critical("Failed to start server: %v", err) + log.Error("Failed to start server: %v", err) } log.Info("HTTP Listener: %s Closed", listenAddr) return err diff --git a/contrib/backport/README b/contrib/backport/README deleted file mode 100644 index 466b79c6d49..00000000000 --- a/contrib/backport/README +++ /dev/null @@ -1,41 +0,0 @@ -`backport` -========== - -`backport` is a command to help create backports of PRs. It backports a -provided PR from main on to a released version. - -It will create a backport branch, cherry-pick the PR's merge commit, adjust -the commit message and then push this back up to your fork's remote. - -The default version will read from `docs/config.yml`. You can override this -using the option `--version`. - -The upstream branches will be fetched, using the remote `origin`. This can -be overridden using `--upstream`, and fetching can be avoided using -`--no-fetch`. - -By default the branch created will be called `backport-$PR-$VERSION`. You -can override this using the option `--backport-branch`. This branch will -be created from `--release-branch` which is `release/$(VERSION)` -by default and will be pulled from `$(UPSTREAM)`. - -The merge-commit as determined by the github API will be used as the SHA to -cherry-pick. You can override this using `--cherry-pick`. - -The commit message will be amended to add the `Backport` header. -`--no-amend-message` can be set to stop this from happening. - -If cherry-pick is successful the backported branch will be pushed up to your -fork using your remote. These will be determined using `git remote -v`. You -can set your fork name using `--fork-user` and your remote name using -`--remote`. You can avoid pushing using `--no-push`. - -If the push is successful, `xdg-open` will be called to open a backport url. -You can stop this using `--no-xdg-open`. - -Installation -============ - -```bash -go install contrib/backport/backport.go -``` diff --git a/contrib/ide/README.md b/contrib/development/README.md similarity index 100% rename from contrib/ide/README.md rename to contrib/development/README.md diff --git a/contrib/ide/vscode/launch.json b/contrib/development/vscode/launch.json similarity index 50% rename from contrib/ide/vscode/launch.json rename to contrib/development/vscode/launch.json index b80b826fc0b..048428fc27f 100644 --- a/contrib/ide/vscode/launch.json +++ b/contrib/development/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/development/vscode/settings.json b/contrib/development/vscode/settings.json new file mode 100644 index 00000000000..d968e4daca4 --- /dev/null +++ b/contrib/development/vscode/settings.json @@ -0,0 +1,4 @@ +{ + "go.buildTags": "", + "go.testFlags": ["-v"] +} diff --git a/contrib/development/vscode/tasks.json b/contrib/development/vscode/tasks.json new file mode 100644 index 00000000000..490e30338b1 --- /dev/null +++ b/contrib/development/vscode/tasks.json @@ -0,0 +1,27 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build", + "type": "shell", + "command": "go", + "group": "build", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared" + }, + "linux": { + "args": ["build", "-o", "gitea", "${workspaceRoot}/main.go" ] + }, + "osx": { + "args": ["build", "-o", "gitea", "${workspaceRoot}/main.go" ] + }, + "windows": { + "args": ["build", "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""] + }, + "problemMatcher": ["$go"] + } + ] +} diff --git a/contrib/gitea-monitoring-mixin/.gitignore b/contrib/grafana-monitoring-mixin/.gitignore similarity index 100% rename from contrib/gitea-monitoring-mixin/.gitignore rename to contrib/grafana-monitoring-mixin/.gitignore diff --git a/contrib/gitea-monitoring-mixin/Makefile b/contrib/grafana-monitoring-mixin/Makefile similarity index 100% rename from contrib/gitea-monitoring-mixin/Makefile rename to contrib/grafana-monitoring-mixin/Makefile diff --git a/contrib/gitea-monitoring-mixin/README.md b/contrib/grafana-monitoring-mixin/README.md similarity index 100% rename from contrib/gitea-monitoring-mixin/README.md rename to contrib/grafana-monitoring-mixin/README.md diff --git a/contrib/gitea-monitoring-mixin/config.libsonnet b/contrib/grafana-monitoring-mixin/config.libsonnet similarity index 100% rename from contrib/gitea-monitoring-mixin/config.libsonnet rename to contrib/grafana-monitoring-mixin/config.libsonnet diff --git a/contrib/gitea-monitoring-mixin/dashboards/dashboards.libsonnet b/contrib/grafana-monitoring-mixin/dashboards/dashboards.libsonnet similarity index 100% rename from contrib/gitea-monitoring-mixin/dashboards/dashboards.libsonnet rename to contrib/grafana-monitoring-mixin/dashboards/dashboards.libsonnet diff --git a/contrib/gitea-monitoring-mixin/dashboards/overview.libsonnet b/contrib/grafana-monitoring-mixin/dashboards/overview.libsonnet similarity index 100% rename from contrib/gitea-monitoring-mixin/dashboards/overview.libsonnet rename to contrib/grafana-monitoring-mixin/dashboards/overview.libsonnet diff --git a/contrib/gitea-monitoring-mixin/jsonnetfile.json b/contrib/grafana-monitoring-mixin/jsonnetfile.json similarity index 100% rename from contrib/gitea-monitoring-mixin/jsonnetfile.json rename to contrib/grafana-monitoring-mixin/jsonnetfile.json diff --git a/contrib/gitea-monitoring-mixin/jsonnetfile.lock.json b/contrib/grafana-monitoring-mixin/jsonnetfile.lock.json similarity index 100% rename from contrib/gitea-monitoring-mixin/jsonnetfile.lock.json rename to contrib/grafana-monitoring-mixin/jsonnetfile.lock.json diff --git a/contrib/gitea-monitoring-mixin/lib/alerts.jsonnet b/contrib/grafana-monitoring-mixin/lib/alerts.jsonnet similarity index 100% rename from contrib/gitea-monitoring-mixin/lib/alerts.jsonnet rename to contrib/grafana-monitoring-mixin/lib/alerts.jsonnet diff --git a/contrib/gitea-monitoring-mixin/lib/dashboards.jsonnet b/contrib/grafana-monitoring-mixin/lib/dashboards.jsonnet similarity index 100% rename from contrib/gitea-monitoring-mixin/lib/dashboards.jsonnet rename to contrib/grafana-monitoring-mixin/lib/dashboards.jsonnet diff --git a/contrib/gitea-monitoring-mixin/lib/rules.jsonnet b/contrib/grafana-monitoring-mixin/lib/rules.jsonnet similarity index 100% rename from contrib/gitea-monitoring-mixin/lib/rules.jsonnet rename to contrib/grafana-monitoring-mixin/lib/rules.jsonnet diff --git a/contrib/gitea-monitoring-mixin/mixin.libsonnet b/contrib/grafana-monitoring-mixin/mixin.libsonnet similarity index 100% rename from contrib/gitea-monitoring-mixin/mixin.libsonnet rename to contrib/grafana-monitoring-mixin/mixin.libsonnet diff --git a/contrib/ide/vscode/settings.json b/contrib/ide/vscode/settings.json deleted file mode 100644 index e33bccf9028..00000000000 --- a/contrib/ide/vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "go.buildTags": "'sqlite sqlite_unlock_notify'", - "go.testFlags": ["-v"] -} \ No newline at end of file diff --git a/contrib/ide/vscode/tasks.json b/contrib/ide/vscode/tasks.json deleted file mode 100644 index e35ae303b27..00000000000 --- a/contrib/ide/vscode/tasks.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Build", - "type": "shell", - "command": "go", - "group": "build", - "presentation": { - "echo": true, - "reveal": "always", - "focus": false, - "panel": "shared" - }, - "linux": { - "args": ["build", "-o", "gitea", "${workspaceRoot}/main.go" ] - }, - "osx": { - "args": ["build", "-o", "gitea", "${workspaceRoot}/main.go" ] - }, - "windows": { - "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/contrib/init/centos/gitea b/contrib/init/centos/gitea deleted file mode 100644 index 4f0d0d99b26..00000000000 --- a/contrib/init/centos/gitea +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh -# -# /etc/rc.d/init.d/gitea -# -# Runs the Gitea Git with a cup of tea. -# -# -# chkconfig: - 85 15 -# - -### BEGIN INIT INFO -# Provides: gitea -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start gitea at boot time. -# Description: Control gitea. -### END INIT INFO - -# Source function library. -. /etc/init.d/functions - -# Default values - -NAME=gitea -GITEA_HOME=/var/lib/${NAME} -GITEA_PATH=/usr/local/bin/${NAME} -GITEA_USER=git -SERVICENAME="Gitea - Git with a cup of tea" -LOCKFILE=/var/lock/subsys/gitea -LOGPATH=${GITEA_HOME}/log -LOGFILE=${LOGPATH}/gitea.log -RETVAL=0 - -# Read configuration from /etc/sysconfig/gitea to override defaults -[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME - -# Don't do anything if nothing is installed -[ -x ${GITEA_PATH} ] || exit 0 -# exit if logpath dir is not created. -[ -x ${LOGPATH} ] || exit 0 - -DAEMON_OPTS="--check $NAME" - -# Set additional options, if any -[ ! -z "$GITEA_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GITEA_USER}" - -start() { - cd ${GITEA_HOME} - echo -n "Starting ${SERVICENAME}: " - daemon $DAEMON_OPTS "${GITEA_PATH} web -c /etc/${NAME}/app.ini > ${LOGFILE} 2>&1 &" - RETVAL=$? - echo - [ $RETVAL = 0 ] && touch ${LOCKFILE} - - return $RETVAL -} - -stop() { - cd ${GITEA_HOME} - echo -n "Shutting down ${SERVICENAME}: " - killproc ${NAME} - RETVAL=$? - echo - [ $RETVAL = 0 ] && rm -f ${LOCKFILE} -} - -case "$1" in - start) - status ${NAME} > /dev/null 2>&1 && exit 0 - start - ;; - stop) - stop - ;; - status) - status ${NAME} - ;; - restart) - stop - start - ;; - reload) - stop - start - ;; - *) - echo "Usage: ${NAME} {start|stop|status|restart}" - exit 1 - ;; -esac -exit $RETVAL diff --git a/contrib/init/debian/gitea b/contrib/init/debian/gitea deleted file mode 100644 index 22463094407..00000000000 --- a/contrib/init/debian/gitea +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: gitea -# Required-Start: $syslog $network -# Required-Stop: $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: A self-hosted Git service written in Go. -# Description: A self-hosted Git service written in Go. -### END INIT INFO - -# Author: Danny Boisvert - -# Do NOT "set -e" - -# PATH should only include /usr/* if it runs after the mountnfs.sh script -PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin -DESC="Gitea - Git with a cup of tea" -NAME=gitea -SERVICEVERBOSE=yes -PIDFILE=/run/$NAME.pid -SCRIPTNAME=/etc/init.d/$NAME -WORKINGDIR=/var/lib/$NAME -DAEMON=/usr/local/bin/$NAME -DAEMON_ARGS="web -c /etc/$NAME/app.ini" -USER=git -USERBIND="" -# If you want to bind Gitea to a port below 1024 uncomment -# the line below -#USERBIND="setcap cap_net_bind_service=+ep" -STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}" - -# Read configuration variable file if it is present -[ -r /etc/default/$NAME ] && . /etc/default/$NAME - -# Exit if the package is not installed -[ -x "$DAEMON" ] || exit 0 - -do_start() -{ - $USERBIND $DAEMON - sh -c "USER=$USER HOME=/home/$USER GITEA_WORK_DIR=$WORKINGDIR start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\ - --background --chdir $WORKINGDIR --chuid $USER \\ - --exec $DAEMON -- $DAEMON_ARGS" -} - -do_stop() -{ - start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PIDFILE --name $NAME --oknodo - rm -f $PIDFILE -} - -do_status() -{ - if [ -f $PIDFILE ]; then - if kill -0 $(cat "$PIDFILE"); then - echo "$NAME is running, PID is $(cat $PIDFILE)" - else - echo "$NAME process is dead, but pidfile exists" - fi - else - echo "$NAME is not running" - fi -} - -case "$1" in - start) - echo "Starting $DESC" "$NAME" - do_start - ;; - stop) - echo "Stopping $DESC" "$NAME" - do_stop - ;; - status) - do_status - ;; - restart) - echo "Restarting $DESC" "$NAME" - do_stop - do_start - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2 - exit 2 - ;; -esac - -exit 0 diff --git a/contrib/init/suse/gitea b/contrib/init/suse/gitea deleted file mode 100644 index 6391bedaf83..00000000000 --- a/contrib/init/suse/gitea +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/sh -# -# /etc/init.d/gitea -# -# Runs the Gitea Git with a cup of tea. -# - -### BEGIN INIT INFO -# Provides: gitea -# Required-Start: $remote_fs -# Required-Stop: $remote_fs -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start gitea at boot time. -# Description: Control gitea. -### END INIT INFO - -# Default values - -NAME=gitea -GITEA_HOME=/var/lib/$NAME -GITEA_PATH=/usr/local/bin/$NAME -GITEA_USER=git -SERVICENAME="Gitea - Git with a cup of tea" -LOCKFILE=/var/lock/subsys/gitea -LOGPATH=${GITEA_HOME}/log -LOGFILE=${LOGPATH}/error.log -# gitea creates its own gitea.log from stdout -RETVAL=0 - -# Read configuration from /etc/sysconfig/gitea to override defaults -[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME - -# Don't do anything if nothing is installed -test -x ${GITEA_PATH} || { echo "$NAME not installed"; - if [ "$1" = "stop" ]; then exit 0; - else exit 5; fi; } - -# exit if logpath dir is not created. -test -r ${LOGPATH} || { echo "$LOGPATH not existing"; - if [ "$1" = "stop" ]; then exit 0; - else exit 6; fi; } - -# Source function library. -. /etc/rc.status - -# Reset status of this service -rc_reset - - -case "$1" in - start) - echo -n "Starting ${SERVICENAME} " - - # As we can't use startproc, we have to check ourselves if the service is already running - /sbin/checkproc ${GITEA_PATH} - if [ $? -eq 0 ]; then - # return skipped as service is already running - (exit 5) - else - su - ${GITEA_USER} -c "USER=${GITEA_USER} GITEA_WORK_DIR=${GITEA_HOME} ${GITEA_PATH} web -c /etc/${NAME}/app.ini 2>&1 >>${LOGFILE} &" - fi - - # Remember status and be verbose - rc_status -v - ;; - - stop) - echo -n "Shutting down ${SERVICENAME} " - - ## Stop daemon with killproc(8) and if this fails - ## killproc sets the return value according to LSB. - /sbin/killproc ${GITEA_PATH} - - # Remember status and be verbose - rc_status -v - ;; - - restart) - ## Stop the service and regardless of whether it was - ## running or not, start it again. - $0 stop - $0 start - - # Remember status and be quiet - rc_status - ;; - - status) - echo -n "Checking for ${SERVICENAME} " - ## Check status with checkproc(8), if process is running - ## checkproc will return with exit status 0. - - # Return value is slightly different for the status command: - # 0 - service up and running - # 1 - service dead, but /run/ pid file exists - # 2 - service dead, but /var/lock/ lock file exists - # 3 - service not running (unused) - # 4 - service status unknown :-( - # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) - - # NOTE: checkproc returns LSB compliant status values. - /sbin/checkproc ${GITEA_PATH} - # NOTE: rc_status knows that we called this init script with - # "status" option and adapts its messages accordingly. - rc_status -v - ;; - - *) - echo "Usage: $0 {start|stop|status|restart}" - exit 1 - ;; - -esac -rc_exit diff --git a/contrib/legal/privacy.html.sample b/contrib/sample-page/privacy.html.sample similarity index 100% rename from contrib/legal/privacy.html.sample rename to contrib/sample-page/privacy.html.sample diff --git a/contrib/legal/tos.html.sample b/contrib/sample-page/tos.html.sample similarity index 100% rename from contrib/legal/tos.html.sample rename to contrib/sample-page/tos.html.sample diff --git a/contrib/init/freebsd/gitea b/contrib/service/freebsd/gitea similarity index 100% rename from contrib/init/freebsd/gitea rename to contrib/service/freebsd/gitea diff --git a/contrib/init/gentoo/gitea b/contrib/service/gentoo/gitea similarity index 100% rename from contrib/init/gentoo/gitea rename to contrib/service/gentoo/gitea diff --git a/contrib/launchd/io.gitea.web.plist b/contrib/service/launchd/io.gitea.web.plist similarity index 100% rename from contrib/launchd/io.gitea.web.plist rename to contrib/service/launchd/io.gitea.web.plist diff --git a/contrib/init/openbsd/gitea b/contrib/service/openbsd/gitea similarity index 100% rename from contrib/init/openbsd/gitea rename to contrib/service/openbsd/gitea diff --git a/contrib/init/openwrt/gitea b/contrib/service/openwrt/gitea similarity index 100% rename from contrib/init/openwrt/gitea rename to contrib/service/openwrt/gitea diff --git a/contrib/init/sunos/gitea.xml b/contrib/service/sunos/gitea.xml similarity index 100% rename from contrib/init/sunos/gitea.xml rename to contrib/service/sunos/gitea.xml diff --git a/contrib/supervisor/gitea b/contrib/service/supervisor/gitea similarity index 100% rename from contrib/supervisor/gitea rename to contrib/service/supervisor/gitea diff --git a/contrib/systemd/gitea.service b/contrib/service/systemd/gitea.service similarity index 100% rename from contrib/systemd/gitea.service rename to contrib/service/systemd/gitea.service diff --git a/contrib/init/ubuntu/gitea b/contrib/service/sysvinit/gitea similarity index 90% rename from contrib/init/ubuntu/gitea rename to contrib/service/sysvinit/gitea index da56b6e4a97..1508da7f843 100644 --- a/contrib/init/ubuntu/gitea +++ b/contrib/service/sysvinit/gitea @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ### BEGIN INIT INFO # Provides: gitea # Required-Start: $syslog $network @@ -9,6 +9,8 @@ # Description: A self-hosted Git service written in Go. ### END INIT INFO +# This is a System V Init (init.d) startup script for legacy Linux distributions + # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script @@ -24,6 +26,9 @@ DAEMON_ARGS="web -c /etc/$NAME/app.ini" USER=git STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}" +# If you want to bind Gitea to a port below 1024, apply "setcap" to the gitea binary +#setcap cap_net_bind_service=+ep $DAEMON" + # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME diff --git a/contrib/update_dependencies.sh b/contrib/update_dependencies.sh deleted file mode 100755 index 5700a198974..00000000000 --- a/contrib/update_dependencies.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -grep 'git' go.mod | grep '\.com' | grep -v indirect | grep -v replace | cut -f 2 | cut -d ' ' -f 1 | while read line; do - go get -u "$line" - make vendor - git add . - git commit -m "update $line" -done diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index dd62cf8e830..3dab03d7883 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 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1172,7 +1172,7 @@ LEVEL = Info ;; Default source for the pull request title when opening a new PR. ;; "first-commit" uses the oldest commit's summary. ;; "auto" uses commit's summary if the PR only has one commit, normalizes the branch name if multiple commits. -;DEFAULT_TITLE_SOURCE = first-commit +;DEFAULT_TITLE_SOURCE = auto ;; ;; Delay mergeable check until page view or API access, for pull requests that have not been updated in the specified days when their base branches get updated. ;; Use "-1" to always check all pull requests (old behavior). Use "0" to always delay the checks. diff --git a/docs/community-governance.md b/docs/community-governance.md index dbf24813295..e37e9def64e 100644 --- a/docs/community-governance.md +++ b/docs/community-governance.md @@ -48,7 +48,7 @@ If a PR has `lgtm/done`, no open discussions, and no merge conflicts, any mainta -Gitea uses its own tool, , to automate parts of the review process. The backporter: +Gitea uses its own tool, , to automate parts of the review process. The backporter: - Creates a backport PR when needed after the initial PR merges. - Removes the PR from the merge queue after it merges. diff --git a/eslint.config.ts b/eslint.config.ts index 29016ed808b..91adc06e193 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -570,8 +570,6 @@ export default defineConfig([ 'no-redeclare': [0], // must be disabled for typescript overloads 'no-regex-spaces': [2], 'no-restricted-exports': [0], - 'no-restricted-globals': [2, ...restrictedGlobals], - 'no-restricted-properties': [2, ...restrictedProperties], 'no-restricted-imports': [2, {paths: [ {name: 'jquery', message: 'Use the global $ instead', allowTypeImports: true}, ]}], @@ -1022,5 +1020,9 @@ export default defineConfig([ { files: ['web_src/**/*'], languageOptions: {globals: {...globals.browser, ...globals.jquery}}, + rules: { + 'no-restricted-globals': [2, ...restrictedGlobals], + 'no-restricted-properties': [2, ...restrictedProperties], + }, }, ]); diff --git a/eslint.json.config.ts b/eslint.json.config.ts index 45696fb79cb..aa6ed0e4c62 100644 --- a/eslint.json.config.ts +++ b/eslint.json.config.ts @@ -13,12 +13,18 @@ export default defineConfig([ language: 'json/json', extends: ['json/recommended'], }, + { + files: ['**/*.json5'], + plugins: {json}, + language: 'json/json5', + extends: ['json/recommended'], + }, { files: [ 'tsconfig.json', '.devcontainer/*.json', '.vscode/*.json', - 'contrib/ide/vscode/*.json', + 'contrib/development/vscode/*.json', ], plugins: {json}, language: 'json/jsonc', diff --git a/flake.nix b/flake.nix index 7b9fbb193c3..ca88b581a22 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 61de57c2a17..c87c07c5327 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module code.gitea.io/gitea -go 1.26.2 +go 1.26.3 // rfc5280 said: "The serial number is an integer assigned by the CA to each certificate." // But some CAs use negative serial number, just relax the check. related: @@ -9,9 +9,10 @@ godebug x509negativeserial=1 require ( code.gitea.io/actions-proto-go v0.4.1 - code.gitea.io/sdk/gitea v0.24.1 + code.gitea.io/sdk/gitea v0.25.1 codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570 connectrpc.com/connect v1.19.2 + gitea.com/gitea/runner v1.0.3 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 @@ -46,31 +47,32 @@ require ( github.com/ethantkoenig/rupture v1.0.1 github.com/felixge/fgprof v0.9.5 github.com/fsnotify/fsnotify v1.10.1 - github.com/getkin/kin-openapi v0.137.0 + github.com/getkin/kin-openapi v0.138.0 github.com/gliderlabs/ssh v0.3.8 github.com/go-chi/chi/v5 v5.2.5 github.com/go-chi/cors v1.2.2 - github.com/go-co-op/gocron/v2 v2.21.1 + github.com/go-co-op/gocron/v2 v2.21.2 github.com/go-enry/go-enry/v2 v2.9.6 - github.com/go-git/go-billy/v5 v5.8.0 - github.com/go-git/go-git/v5 v5.18.0 + github.com/go-git/go-billy/v5 v5.9.0 + github.com/go-git/go-git/v5 v5.19.1 github.com/go-ldap/ldap/v3 v3.4.13 github.com/go-redsync/redsync/v4 v4.16.0 github.com/go-sql-driver/mysql v1.10.0 - github.com/go-webauthn/webauthn v0.17.2 + github.com/go-webauthn/webauthn v0.17.3 github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85 github.com/golang-jwt/jwt/v5 v5.3.1 github.com/google/go-github/v84 v84.0.0 + github.com/google/go-github/v86 v86.0.0 github.com/google/licenseclassifier/v2 v2.0.0 - github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 + github.com/google/pprof v0.0.0-20260507013755-92041b743c96 github.com/google/uuid v1.6.0 github.com/gorilla/feeds v1.2.0 github.com/gorilla/sessions v1.4.0 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 +84,10 @@ 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/nektos/act v0.0.0-00010101000000-000000000000 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,24 +104,24 @@ 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/wneessen/go-mail v0.7.2 - github.com/xeipuuv/gojsonschema v1.2.0 + github.com/urfave/cli/v3 v3.6.1 + github.com/wneessen/go-mail v0.7.3 github.com/yohcop/openid-go v1.0.1 github.com/yuin/goldmark v1.8.2 github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc - gitlab.com/gitlab-org/api/client-go v1.46.0 + gitlab.com/gitlab-org/api/client-go/v2 v2.26.0 go.yaml.in/yaml/v4 v4.0.0-rc.3 - golang.org/x/crypto v0.50.0 - golang.org/x/image v0.39.0 - golang.org/x/net v0.53.0 + golang.org/x/crypto v0.51.0 + golang.org/x/image v0.40.0 + golang.org/x/net v0.54.0 golang.org/x/oauth2 v0.36.0 golang.org/x/sync v0.20.0 - golang.org/x/sys v0.43.0 - golang.org/x/text v0.36.0 - google.golang.org/grpc v1.81.0 + golang.org/x/sys v0.44.0 + golang.org/x/text v0.37.0 + google.golang.org/grpc v1.81.1 google.golang.org/protobuf v1.36.11 gopkg.in/ini.v1 v1.67.2 + modernc.org/sqlite v1.50.1 mvdan.cc/xurls/v2 v2.6.0 strk.kbt.io/projects/go/libravatar v0.0.0-20260301104140-add494e31dab xorm.io/builder v0.3.13 @@ -185,7 +187,7 @@ require ( github.com/davidmz/go-pageant v1.0.2 // indirect github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 // indirect github.com/fatih/color v1.19.0 // indirect - github.com/fxamacker/cbor/v2 v2.9.1 // indirect + github.com/fxamacker/cbor/v2 v2.9.2 // indirect github.com/git-lfs/pktline v0.0.0-20230103162542-ca444d533ef1 // indirect github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 // indirect github.com/go-enry/go-oniguruma v1.2.1 // indirect @@ -195,7 +197,7 @@ require ( github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect - github.com/go-webauthn/x v0.2.3 // indirect + github.com/go-webauthn/x v0.2.5 // indirect github.com/goccy/go-json v0.10.6 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect @@ -238,6 +240,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 @@ -249,12 +252,13 @@ require ( github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/philhofer/fwd v1.2.0 // indirect github.com/pierrec/lz4/v4 v4.1.26 // indirect - github.com/pjbgf/sha1cd v0.5.0 // indirect + github.com/pjbgf/sha1cd v0.6.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect 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 @@ -269,8 +273,6 @@ require ( github.com/woodsbury/decimal128 v1.3.0 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect - github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/zeebo/blake3 v0.2.4 // indirect github.com/zeebo/xxh3 v1.1.0 // indirect @@ -282,13 +284,15 @@ require ( go.yaml.in/yaml/v2 v2.4.4 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect go4.org v0.0.0-20260112195520-a5071408f32f // indirect - golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect golang.org/x/mod v0.35.0 // indirect golang.org/x/time v0.15.0 // indirect 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 gopkg.in/yaml.v3 v3.0.1 // indirect + modernc.org/libc v1.72.3 // indirect + modernc.org/mathutil v1.7.1 // indirect + modernc.org/memory v1.11.0 // indirect ) ignore ( diff --git a/go.sum b/go.sum index 262a04fb319..2743910da16 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ code.gitea.io/actions-proto-go v0.4.1 h1:l0EYhjsgpUe/1VABo2eK7zcoNX2W44WOnb0MSLr code.gitea.io/actions-proto-go v0.4.1/go.mod h1:mn7Wkqz6JbnTOHQpot3yDeHx+O5C9EGhMEE+htvHBas= code.gitea.io/gitea-vet v0.2.3 h1:gdFmm6WOTM65rE8FUBTRzeQZYzXePKSSB1+r574hWwI= code.gitea.io/gitea-vet v0.2.3/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE= -code.gitea.io/sdk/gitea v0.24.1 h1:hpaqcdGcBmfMpV7JSbBJVwE99qo+WqGreJYKrDKEyW8= -code.gitea.io/sdk/gitea v0.24.1/go.mod h1:5/77BL3sHneCMEiZaMT9lfTvnnibsYxyO48mceCF3qA= +code.gitea.io/sdk/gitea v0.25.1 h1:yywxWwoV+SdjHtbC6unBiXojWdZOtoHuGhEazEXeWuE= +code.gitea.io/sdk/gitea v0.25.1/go.mod h1:uDFWYBU8dgZsgOHwe6C/6olxvf8FHguNB3wW1i83fgg= code.pfad.fr/check v1.1.0 h1:GWvjdzhSEgHvEHe2uJujDcpmZoySKuHQNrZMfzfO0bE= code.pfad.fr/check v1.1.0/go.mod h1:NiUH13DtYsb7xp5wll0U4SXx7KhXQVCtRgdC96IPfoM= codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570 h1:TXbikPqa7YRtfU9vS6QJBg77pUvbEb6StRdZO8t1bEY= @@ -18,6 +18,8 @@ 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.262.0 h1:R0U+VeFvhJSYACSCR9fEV8a3ZXlGlBE1X5YjaFzwv4c= gitea.com/gitea/act v0.262.0/go.mod h1:oIkqQHvU0lfuIWwcpqa4FmU+t3prA89tgkuHUTsrI2c= +gitea.com/gitea/runner v1.0.3 h1:jwwXPj2UKSrbFCfyAcqoiXcbaTNQTWlozRb1kikiquw= +gitea.com/gitea/runner v1.0.3/go.mod h1:0xR69LP2GwVJT9QnbLHok/87YIFDmpKnJVLkRKKJbSM= 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= @@ -197,8 +199,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= @@ -275,10 +277,10 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho= github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo= -github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ= -github.com/fxamacker/cbor/v2 v2.9.1/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= -github.com/getkin/kin-openapi v0.137.0 h1:Q3HhawNQV0GfvO2mIYMUBUSEFrDsVlzcYz4VydL9YEo= -github.com/getkin/kin-openapi v0.137.0/go.mod h1:vUYWaKyMqj7PfTybelXtLuLN9tReS12vxnzMRK+z2GY= +github.com/fxamacker/cbor/v2 v2.9.2 h1:X4Ksno9+x3cz0TZv69ec1hxP/+tymuR8PXQJyDwfh78= +github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/getkin/kin-openapi v0.138.0 h1:ebfE0JAmF6AqHrNBy1KO3Fs68K9tPs48HalvLPo7Rv4= +github.com/getkin/kin-openapi v0.138.0/go.mod h1:vUYWaKyMqj7PfTybelXtLuLN9tReS12vxnzMRK+z2GY= github.com/git-lfs/pktline v0.0.0-20230103162542-ca444d533ef1 h1:mtDjlmloH7ytdblogrMz1/8Hqua1y8B4ID+bh3rvod0= github.com/git-lfs/pktline v0.0.0-20230103162542-ca444d533ef1/go.mod h1:fenKRzpXDjNpsIBhuhUzvjCKlDjKam0boRAenTE0Q6A= github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= @@ -292,8 +294,8 @@ github.com/go-chi/chi/v5 v5.2.5 h1:Eg4myHZBjyvJmAFjFvWgrqDTXFyOzjj7YIm3L3mu6Ug= github.com/go-chi/chi/v5 v5.2.5/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0= github.com/go-chi/cors v1.2.2 h1:Jmey33TE+b+rB7fT8MUy1u0I4L+NARQlK6LhzKPSyQE= github.com/go-chi/cors v1.2.2/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= -github.com/go-co-op/gocron/v2 v2.21.1 h1:QYOK6iOQVCut+jDcs4zRdWRTBHRxRCEeeFi1TnAmgbU= -github.com/go-co-op/gocron/v2 v2.21.1/go.mod h1:5lEiCKk1oVJV39Zg7/YG10OnaVrDAV5GGR6O0663k6U= +github.com/go-co-op/gocron/v2 v2.21.2 h1:bD8/YwkojYHgXFr3iEulL148KBdTbKVxUZzFKpXcdbY= +github.com/go-co-op/gocron/v2 v2.21.2/go.mod h1:5lEiCKk1oVJV39Zg7/YG10OnaVrDAV5GGR6O0663k6U= github.com/go-enry/go-enry/v2 v2.9.6 h1:np63eOtMV56zfYDHnFVgpEVOk8fr2kmylcMnAZUDbSs= github.com/go-enry/go-enry/v2 v2.9.6/go.mod h1:9yrj4ES1YrbNb1Wb7/PWYr2bpaCXUGRt0uafN0ISyG8= github.com/go-enry/go-oniguruma v1.2.1 h1:k8aAMuJfMrqm/56SG2lV9Cfti6tC4x8673aHCcBk+eo= @@ -302,12 +304,12 @@ github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e h1:oRq/fiirun5Hql github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.8.0 h1:I8hjc3LbBlXTtVuFNJuwYuMiHvQJDq1AT6u4DwDzZG0= -github.com/go-git/go-billy/v5 v5.8.0/go.mod h1:RpvI/rw4Vr5QA+Z60c6d6LXH0rYJo0uD5SqfmrrheCY= +github.com/go-git/go-billy/v5 v5.9.0 h1:jItGXszUDRtR/AlferWPTMN4j38BQ88XnXKbilmmBPA= +github.com/go-git/go-billy/v5 v5.9.0/go.mod h1:jCnQMLj9eUgGU7+ludSTYoZL/GGmii14RxKFj7ROgHw= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.18.0 h1:O831KI+0PR51hM2kep6T8k+w0/LIAD490gvqMCvL5hM= -github.com/go-git/go-git/v5 v5.18.0/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo= +github.com/go-git/go-git/v5 v5.19.1 h1:nX27AnaU43/K5bKktKwgBmR9lawoYVe1Ckg0rgzzN00= +github.com/go-git/go-git/v5 v5.19.1/go.mod h1:Pb1v0c7/g8aGQJwx9Us09W85yGoyvSwuhEGMH7zjDKQ= github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA= @@ -333,10 +335,10 @@ github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U= github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= -github.com/go-webauthn/webauthn v0.17.2 h1:e9YtSZTVnxnMWFezXi6JvnqOSxmH4Er8QDHK2a/mM40= -github.com/go-webauthn/webauthn v0.17.2/go.mod h1:mQC6L0lZ5Kiu35G70zeB2WnrW4+vbHjR8Koq4HdVaMg= -github.com/go-webauthn/x v0.2.3 h1:8oArS+Rc1SWFLXhE17KZNx258Z4kUSyaDgsSncCO5RA= -github.com/go-webauthn/x v0.2.3/go.mod h1:tM04GF3V6VYq79AZMl7vbj4q6pz9r7L2criWRzbWhPk= +github.com/go-webauthn/webauthn v0.17.3 h1:XHZ0TXV7k8vChcE4TFgPitOPJ5cb7h1dpAeFDS0cjCo= +github.com/go-webauthn/webauthn v0.17.3/go.mod h1:PlkMgmuL9McCT7dvgBj/Sz/fgs3V6ZID6/KnFkEcPvQ= +github.com/go-webauthn/x v0.2.5 h1:wEVTfU04XFyPTXGQbKOQwMKhcDWfDAkdsDDBsDaG9yY= +github.com/go-webauthn/x v0.2.5/go.mod h1:Qna/yJz9rV6lRzwl5BfYbmTJpVGxcBIds3gJtw2tlGg= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY= @@ -385,6 +387,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/go-github/v84 v84.0.0 h1:I/0Xn5IuChMe8TdmI2bbim5nyhaRFJ7DEdzmD2w+yVA= github.com/google/go-github/v84 v84.0.0/go.mod h1:WwYL1z1ajRdlaPszjVu/47x1L0PXukJBn73xsiYrRRQ= +github.com/google/go-github/v86 v86.0.0 h1:S/6aANJhwRm8EQmGKVML3j41yq0h2BsTP8FnDkO7kcA= +github.com/google/go-github/v86 v86.0.0/go.mod h1:zKv1l4SwDXNFMGByi2FWkq71KwSXqj/eQRZuqtmcot8= github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0= github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU= github.com/google/go-tpm v0.9.8 h1:slArAR9Ft+1ybZu0lBwpSmpwhRXaa85hWtMinMyRAWo= @@ -397,8 +401,8 @@ github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/licenseclassifier/v2 v2.0.0 h1:1Y57HHILNf4m0ABuMVb6xk4vAJYEUO0gDxNpog0pyeA= github.com/google/licenseclassifier/v2 v2.0.0/go.mod h1:cOjbdH0kyC9R22sdQbYsFkto4NGCAc+ZSwbeThazEtM= github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= -github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 h1:EwtI+Al+DeppwYX2oXJCETMO23COyaKGP6fHVpkpWpg= -github.com/google/pprof v0.0.0-20260402051712-545e8a4df936/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= +github.com/google/pprof v0.0.0-20260507013755-92041b743c96 h1:YDDnaZ9afWajDboPMt9Vikqca/yWAX7KAxVzb4lJU1M= +github.com/google/pprof v0.0.0-20260507013755-92041b743c96/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -565,8 +569,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= @@ -609,8 +613,8 @@ github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pierrec/lz4/v4 v4.1.26 h1:GrpZw1gZttORinvzBdXPUXATeqlJjqUG/D87TKMnhjY= github.com/pierrec/lz4/v4 v4.1.26/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4= -github.com/pjbgf/sha1cd v0.5.0 h1:a+UkboSi1znleCDUNT3M5YxjOnN1fz2FhN48FlwCxs0= -github.com/pjbgf/sha1cd v0.5.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM= +github.com/pjbgf/sha1cd v0.6.0 h1:3WJ8Wz8gvDz29quX1OcEmkAlUg9diU4GxJHqs0/XiwU= +github.com/pjbgf/sha1cd v0.6.0/go.mod h1:lhpGlyHLpQZoxMv8HcgXvZEhcGs0PG/vsZnEJ7H0iCM= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -688,8 +692,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= @@ -724,21 +729,14 @@ github.com/urfave/cli-docs/v3 v3.1.0/go.mod h1:59d+5Hz1h6GSGJ10cvcEkbIe3j233t4XD 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/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= +github.com/wneessen/go-mail v0.7.3 h1:g3DravXC5SMlVdboFrQA8Jx95A8sOzoBeS5F+vzNRK0= +github.com/wneessen/go-mail v0.7.3/go.mod h1:QGhBX0yNbc1J+Mkjcu7z2rpj4B4l+BmDY8gYznPC9sk= github.com/woodsbury/decimal128 v1.3.0 h1:8pffMNWIlC0O5vbyHWFZAt5yWvWcrHA+3ovIIjVWss0= github.com/woodsbury/decimal128 v1.3.0/go.mod h1:C5UTmyTjW3JftjUFzOVhC20BEQa2a4ZKOB5I6Zjb+ds= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= @@ -762,8 +760,8 @@ github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs= github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s= -gitlab.com/gitlab-org/api/client-go v1.46.0 h1:YxBWFZIFYKcGESCb9fpkwzouo+apyB9pr/XTWzNoL24= -gitlab.com/gitlab-org/api/client-go v1.46.0/go.mod h1:FtgyU6g2HS5+fMhw6nLK96GBEEBx5MzntOiJWfIaiN8= +gitlab.com/gitlab-org/api/client-go/v2 v2.26.0 h1:1E35d1GRLb22Yq7Jr4gWptjW1+Vg7ZDGogK/SZ6ijV8= +gitlab.com/gitlab-org/api/client-go/v2 v2.26.0/go.mod h1:wx4w52UDENs3jolsL9cYT4byPNN9Pc6UpfGtCcHEIWY= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.4.3 h1:dEadXpI6G79deX5prL3QRNP6JB8UxVkqo4UPnHaNXJo= go.etcd.io/bbolt v1.4.3/go.mod h1:tKQlpPaYCVFctUIgFKFnAlvbmB3tpy1vkTnDWohtc0E= @@ -799,12 +797,12 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= -golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI= -golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/image v0.39.0 h1:skVYidAEVKgn8lZ602XO75asgXBgLj9G/FE3RbuPFww= -golang.org/x/image v0.39.0/go.mod h1:sIbmppfU+xFLPIG0FoVUTvyBMmgng1/XAMhQ2ft0hpA= +golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI= +golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8= +golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= +golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= +golang.org/x/image v0.40.0 h1:Tw4GyDXMo+daZN1znreBRC3VayR1aLFUyUEOLUdW1a8= +golang.org/x/image v0.40.0/go.mod h1:uIc348UZMSvS5Z65CVZ7iDPaNobNFEPeJ4kbqTOszmA= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -833,8 +831,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA= -golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs= +golang.org/x/net v0.54.0 h1:2zJIZAxAHV/OHCDTCOHAYehQzLfSXuf/5SoL/Dv6w/w= +golang.org/x/net v0.54.0/go.mod h1:Sj4oj8jK6XmHpBZU/zWHw3BV3abl4Kvi+Ut7cQcY+cQ= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -882,8 +880,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= -golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ= +golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -894,8 +892,8 @@ golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= -golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY= -golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY= +golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4= +golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -906,8 +904,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= -golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= +golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= +golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -928,8 +926,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20260401020348-3a24fdc17823 h1:YedBIttDguBl/zy2wJauEUm+DZZg4UXseWj0g/3N+yo= google.golang.org/genproto/googleapis/rpc v0.0.0-20260401020348-3a24fdc17823/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/grpc v1.81.0 h1:W3G9N3KQf3BU+YuCtGKJk0CmxQNbAISICD/9AORxLIw= -google.golang.org/grpc v1.81.0/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I= +google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ= +google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -958,24 +956,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.28.2 h1:3tQ0lf2ADtoby2EtSP+J7IE2SHwEJdP8ioR59wx7XpY= +modernc.org/cc/v4 v4.28.2/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI= +modernc.org/ccgo/v4 v4.34.0 h1:yRLPFZieg532OT4rp4JFNIVcquwalMX26G95WQDqwCQ= +modernc.org/ccgo/v4 v4.34.0/go.mod h1:AS5WYMyBakQ+fhsHhtP8mWB82KTGPkNNJDGfGQCe0/A= +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.3 h1:ZnDF4tXn4NBXFutMMQC4vtbTFSXhhKzR73fv0beZEAU= +modernc.org/libc v1.72.3/go.mod h1:dn0dZNnnn1clLyvRxLxYExxiKRZIRENOfqQ8XEeg4Qs= +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.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg= +modernc.org/opt v0.2.0/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.1 h1:l+cQvn0sd0zJJtfygGHuQJ5AjlrwXmWPw4KP3ZMwr9w= +modernc.org/sqlite v1.50.1/go.mod h1:tcNzv5p84E0skkmJn038y+hWJbLQXQqEnQfeh5r2JLM= +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 f0effdeecaf..1de83a29c58 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/actions/main_test.go b/models/actions/main_test.go index 4af483813ab..3c878c68444 100644 --- a/models/actions/main_test.go +++ b/models/actions/main_test.go @@ -15,6 +15,7 @@ func TestMain(m *testing.M) { "action_runner_token.yml", "action_run.yml", "repository.yml", + "user.yml", }, }) } diff --git a/models/actions/run.go b/models/actions/run.go index a44b0ff343e..61cc4599b6e 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -7,7 +7,6 @@ import ( "context" "errors" "fmt" - "slices" "strings" "time" @@ -224,30 +223,34 @@ func (run *ActionRun) IsSchedule() bool { } // UpdateRepoRunsNumbers updates the number of runs and closed runs of a repository. -func UpdateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error { - _, err := db.GetEngine(ctx).ID(repo.ID). - NoAutoTime(). - Cols("num_action_runs", "num_closed_action_runs"). - SetExpr("num_action_runs", - builder.Select("count(*)").From("action_run"). - Where(builder.Eq{"repo_id": repo.ID}), - ). - SetExpr("num_closed_action_runs", - builder.Select("count(*)").From("action_run"). - Where(builder.Eq{ - "repo_id": repo.ID, - }.And( - builder.In("status", - StatusSuccess, - StatusFailure, - StatusCancelled, - StatusSkipped, - ), - ), - ), - ). - Update(repo) - return err +// Callers MUST invoke this from outside any transaction that has X-locked action_run rows for the same repo, otherwise, transaction deadlock +func UpdateRepoRunsNumbers(ctx context.Context, repoID int64) { + if db.InTransaction(ctx) { + setting.PanicInDevOrTesting("UpdateRepoRunsNumbers must not be called inside a transaction") + } + + e := db.GetEngine(ctx) + + numActionRuns, err := e.Where("repo_id = ?", repoID).Count(new(ActionRun)) + if err != nil { + log.Error("UpdateRepoRunsNumbers count num_action_runs for repo %d: %v", repoID, err) + return + } + + numClosedActionRuns, err := e.Where("repo_id = ?", repoID). + In("status", StatusSuccess, StatusFailure, StatusCancelled, StatusSkipped). + Count(new(ActionRun)) + if err != nil { + log.Error("UpdateRepoRunsNumbers count num_closed_action_runs for repo %d: %v", repoID, err) + return + } + + if _, err := e.ID(repoID).Cols("num_action_runs", "num_closed_action_runs").NoAutoTime().Update(&repo_model.Repository{ + NumActionRuns: int(numActionRuns), + NumClosedActionRuns: int(numClosedActionRuns), + }); err != nil { + log.Error("UpdateRepoRunsNumbers update repo %d: %v", repoID, err) + } } // CancelPreviousJobs cancels all previous jobs of the same repository, reference, workflow, and event. @@ -259,7 +262,7 @@ func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID strin Ref: ref, WorkflowID: workflowID, TriggerEvent: event, - Status: []Status{StatusRunning, StatusWaiting, StatusBlocked}, + Status: []Status{StatusRunning, StatusWaiting, StatusBlocked, StatusCancelling}, }) if err != nil { return nil, err @@ -326,7 +329,7 @@ func CancelJobs(ctx context.Context, jobs []*ActionRunJob) ([]*ActionRunJob, err } // If the job has an associated task, try to stop the task, effectively cancelling the job. - if err := StopTask(ctx, job.TaskID, StatusCancelled); err != nil { + if err := StopTask(ctx, job.TaskID, StatusCancelling); err != nil { return cancelledJobs, err } updatedJob, err := GetRunJobByRunAndID(ctx, job.RunID, job.ID) @@ -415,18 +418,6 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error { // It's impossible that the run is not found, since Gitea never deletes runs. } - if run.Status != 0 || slices.Contains(cols, "status") { - if run.RepoID == 0 { - setting.PanicInDevOrTesting("RepoID should not be 0") - } - if err = run.LoadRepo(ctx); err != nil { - return err - } - if err := UpdateRepoRunsNumbers(ctx, run.Repo); err != nil { - return err - } - } - return nil } @@ -461,6 +452,7 @@ func CancelPreviousJobsByRunConcurrency(ctx context.Context, attempt *ActionRunA statusFindOption := []Status{StatusWaiting, StatusBlocked} if attempt.ConcurrencyCancel { statusFindOption = append(statusFindOption, StatusRunning) + statusFindOption = append(statusFindOption, StatusCancelling) } attempts, jobs, err := GetConcurrentRunAttemptsAndJobs(ctx, attempt.RepoID, attempt.ConcurrencyGroup, statusFindOption) if err != nil { diff --git a/models/actions/run_job.go b/models/actions/run_job.go index 82ca4ba3116..8722de35254 100644 --- a/models/actions/run_job.go +++ b/models/actions/run_job.go @@ -242,7 +242,10 @@ func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, col return 0, err } - if affected == 0 || (!slices.Contains(cols, "status") && job.Status == 0) { + // xorm's Update writes only non-zero fields when cols is empty, so a zero job.Status + // with empty cols means status isn't actually being persisted — skip aggregation. + statusUpdated := slices.Contains(cols, "status") || (len(cols) == 0 && job.Status != 0) + if affected == 0 || !statusUpdated { return affected, nil } @@ -315,12 +318,13 @@ func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, col func AggregateJobStatus(jobs []*ActionRunJob) Status { allSuccessOrSkipped := len(jobs) != 0 allSkipped := len(jobs) != 0 - var hasFailure, hasCancelled, hasWaiting, hasRunning, hasBlocked bool + var hasFailure, hasCancelled, hasCancelling, hasWaiting, hasRunning, hasBlocked bool for _, job := range jobs { allSuccessOrSkipped = allSuccessOrSkipped && (job.Status == StatusSuccess || job.Status == StatusSkipped) allSkipped = allSkipped && job.Status == StatusSkipped hasFailure = hasFailure || job.Status == StatusFailure hasCancelled = hasCancelled || job.Status == StatusCancelled + hasCancelling = hasCancelling || job.Status == StatusCancelling hasWaiting = hasWaiting || job.Status == StatusWaiting hasRunning = hasRunning || job.Status == StatusRunning hasBlocked = hasBlocked || job.Status == StatusBlocked @@ -330,16 +334,20 @@ func AggregateJobStatus(jobs []*ActionRunJob) Status { return StatusSkipped case allSuccessOrSkipped: return StatusSuccess - case hasCancelled: - return StatusCancelled + case hasCancelling: + return StatusCancelling case hasRunning: return StatusRunning case hasWaiting: return StatusWaiting + case hasBlocked: + // Blocked is still a pending state, so it should outrank terminal + // statuses like cancelled/failure when no job is waiting or running. + return StatusBlocked + case hasCancelled: + return StatusCancelled case hasFailure: return StatusFailure - case hasBlocked: - return StatusBlocked default: return StatusUnknown // it shouldn't happen } @@ -359,6 +367,7 @@ func CancelPreviousJobsByJobConcurrency(ctx context.Context, job *ActionRunJob) statusFindOption := []Status{StatusWaiting, StatusBlocked} if job.ConcurrencyCancel { statusFindOption = append(statusFindOption, StatusRunning) + statusFindOption = append(statusFindOption, StatusCancelling) } attempts, jobs, err := GetConcurrentRunAttemptsAndJobs(ctx, job.RepoID, job.ConcurrencyGroup, statusFindOption) if err != nil { diff --git a/models/actions/run_job_list.go b/models/actions/run_job_list.go index db7554593dd..5f4e4827209 100644 --- a/models/actions/run_job_list.go +++ b/models/actions/run_job_list.go @@ -5,9 +5,11 @@ package actions import ( "context" + "slices" "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" + "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/optional" "code.gitea.io/gitea/modules/timeutil" @@ -23,6 +25,22 @@ func (jobs ActionJobList) GetRunIDs() []int64 { }) } +// SortMatrixGroupsByName natural-sorts each contiguous run of jobs that share a JobID +// so matrix expansions (e.g. "test (1)", "test (2)", "test (10)") appear in human order. +// Input is expected to be in DB id order so JobID groups are contiguous; cross-group order is preserved. +func (jobs ActionJobList) SortMatrixGroupsByName() { + for i := 0; i < len(jobs); { + j := i + 1 + for j < len(jobs) && jobs[j].JobID == jobs[i].JobID { + j++ + } + slices.SortFunc(jobs[i:j], func(a, b *ActionRunJob) int { + return base.NaturalSortCompare(a.Name, b.Name) + }) + i = j + } +} + func (jobs ActionJobList) LoadRepos(ctx context.Context) error { repoIDs := container.FilterSlice(jobs, func(j *ActionRunJob) (int64, bool) { return j.RepoID, j.RepoID != 0 && j.Repo == nil @@ -80,6 +98,12 @@ type FindRunJobOptions struct { Statuses []Status UpdatedBefore timeutil.TimeStamp ConcurrencyGroup string + OrderBy db.SearchOrderBy +} + +var JobOrderByMap = map[string]map[string]db.SearchOrderBy{ + "asc": {"id": "`action_run_job`.id ASC"}, + "desc": {"id": "`action_run_job`.id DESC"}, } func (opts FindRunJobOptions) ToConds() builder.Cond { @@ -122,3 +146,9 @@ func (opts FindRunJobOptions) ToJoins() []db.JoinFunc { } return nil } + +func (opts FindRunJobOptions) ToOrders() string { + return string(opts.OrderBy) +} + +var _ db.FindOptionsOrder = FindRunJobOptions{} diff --git a/models/actions/run_job_list_test.go b/models/actions/run_job_list_test.go new file mode 100644 index 00000000000..271031b4cdd --- /dev/null +++ b/models/actions/run_job_list_test.go @@ -0,0 +1,61 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package actions + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestActionJobList_SortMatrixGroupsByName(t *testing.T) { + mk := func(jobID, name string) *ActionRunJob { + return &ActionRunJob{JobID: jobID, Name: name} + } + names := func(jobs ActionJobList) []string { + out := make([]string, len(jobs)) + for i, j := range jobs { + out[i] = j.Name + } + return out + } + + t.Run("matrix group sorted naturally", func(t *testing.T) { + jobs := ActionJobList{ + mk("build", "build"), + mk("test", "test (10)"), + mk("test", "test (2)"), + mk("test", "test (1)"), + mk("deploy", "deploy"), + } + jobs.SortMatrixGroupsByName() + assert.Equal(t, []string{"build", "test (1)", "test (2)", "test (10)", "deploy"}, names(jobs)) + }) + + t.Run("non-adjacent same JobID stays in input order", func(t *testing.T) { + jobs := ActionJobList{ + mk("test", "test (10)"), + mk("build", "build"), + mk("test", "test (1)"), + } + jobs.SortMatrixGroupsByName() + assert.Equal(t, []string{"test (10)", "build", "test (1)"}, names(jobs)) + }) + + t.Run("groups stay in input order", func(t *testing.T) { + jobs := ActionJobList{ + mk("z", "z"), + mk("a", "a"), + } + jobs.SortMatrixGroupsByName() + assert.Equal(t, []string{"z", "a"}, names(jobs)) + }) + + t.Run("empty and singleton", func(t *testing.T) { + ActionJobList(nil).SortMatrixGroupsByName() + jobs := ActionJobList{mk("only", "only")} + jobs.SortMatrixGroupsByName() + assert.Equal(t, []string{"only"}, names(jobs)) + }) +} diff --git a/models/actions/run_job_status_test.go b/models/actions/run_job_status_test.go index b9ae9f34bfd..c1a44cc6d36 100644 --- a/models/actions/run_job_status_test.go +++ b/models/actions/run_job_status_test.go @@ -36,6 +36,7 @@ func TestAggregateJobStatus(t *testing.T) { {[]Status{StatusUnknown, StatusSkipped}, StatusUnknown}, {[]Status{StatusUnknown, StatusFailure}, StatusFailure}, {[]Status{StatusUnknown, StatusCancelled}, StatusCancelled}, + {[]Status{StatusUnknown, StatusCancelling}, StatusCancelling}, {[]Status{StatusUnknown, StatusWaiting}, StatusWaiting}, {[]Status{StatusUnknown, StatusRunning}, StatusRunning}, {[]Status{StatusUnknown, StatusBlocked}, StatusBlocked}, @@ -45,6 +46,7 @@ func TestAggregateJobStatus(t *testing.T) { {[]Status{StatusSuccess, StatusSkipped}, StatusSuccess}, // skipped doesn't affect success {[]Status{StatusSuccess, StatusFailure}, StatusFailure}, {[]Status{StatusSuccess, StatusCancelled}, StatusCancelled}, + {[]Status{StatusSuccess, StatusCancelling}, StatusCancelling}, {[]Status{StatusSuccess, StatusWaiting}, StatusWaiting}, {[]Status{StatusSuccess, StatusRunning}, StatusRunning}, {[]Status{StatusSuccess, StatusBlocked}, StatusBlocked}, @@ -54,9 +56,16 @@ func TestAggregateJobStatus(t *testing.T) { {[]Status{StatusCancelled, StatusSuccess}, StatusCancelled}, {[]Status{StatusCancelled, StatusSkipped}, StatusCancelled}, {[]Status{StatusCancelled, StatusFailure}, StatusCancelled}, - {[]Status{StatusCancelled, StatusWaiting}, StatusCancelled}, - {[]Status{StatusCancelled, StatusRunning}, StatusCancelled}, - {[]Status{StatusCancelled, StatusBlocked}, StatusCancelled}, + {[]Status{StatusCancelled, StatusCancelling}, StatusCancelling}, + {[]Status{StatusCancelled, StatusWaiting}, StatusWaiting}, + {[]Status{StatusCancelled, StatusRunning}, StatusRunning}, + {[]Status{StatusCancelled, StatusBlocked}, StatusBlocked}, + + {[]Status{StatusCancelling}, StatusCancelling}, + {[]Status{StatusCancelling, StatusRunning}, StatusCancelling}, + {[]Status{StatusCancelling, StatusWaiting}, StatusCancelling}, + {[]Status{StatusCancelling, StatusFailure}, StatusCancelling}, + {[]Status{StatusCancelling, StatusSkipped}, StatusCancelling}, // failure with other status, usually fail fast, but "running" wins to match GitHub's behavior // another reason that we can't make "failure" wins over "running": it would cause a weird behavior that user cannot cancel a workflow or get current running workflows correctly by filter after a job fail. @@ -64,9 +73,10 @@ func TestAggregateJobStatus(t *testing.T) { {[]Status{StatusFailure, StatusSuccess}, StatusFailure}, {[]Status{StatusFailure, StatusSkipped}, StatusFailure}, {[]Status{StatusFailure, StatusCancelled}, StatusCancelled}, + {[]Status{StatusFailure, StatusCancelling}, StatusCancelling}, {[]Status{StatusFailure, StatusWaiting}, StatusWaiting}, {[]Status{StatusFailure, StatusRunning}, StatusRunning}, - {[]Status{StatusFailure, StatusBlocked}, StatusFailure}, + {[]Status{StatusFailure, StatusBlocked}, StatusBlocked}, // skipped with other status // "all skipped" is also considered as "mergeable" by "services/actions.toCommitStatus", the same as GitHub @@ -74,6 +84,7 @@ func TestAggregateJobStatus(t *testing.T) { {[]Status{StatusSkipped, StatusSuccess}, StatusSuccess}, {[]Status{StatusSkipped, StatusFailure}, StatusFailure}, {[]Status{StatusSkipped, StatusCancelled}, StatusCancelled}, + {[]Status{StatusSkipped, StatusCancelling}, StatusCancelling}, {[]Status{StatusSkipped, StatusWaiting}, StatusWaiting}, {[]Status{StatusSkipped, StatusRunning}, StatusRunning}, {[]Status{StatusSkipped, StatusBlocked}, StatusBlocked}, diff --git a/models/actions/run_list.go b/models/actions/run_list.go index 0a0840648da..bfa9bbfb169 100644 --- a/models/actions/run_list.go +++ b/models/actions/run_list.go @@ -121,8 +121,8 @@ type StatusInfo struct { // GetStatusInfoList returns a slice of StatusInfo func GetStatusInfoList(ctx context.Context, lang translation.Locale) []StatusInfo { // same as those in aggregateJobStatus - allStatus := []Status{StatusSuccess, StatusFailure, StatusWaiting, StatusRunning} - statusInfoList := make([]StatusInfo, 0, 4) + allStatus := []Status{StatusSuccess, StatusFailure, StatusWaiting, StatusRunning, StatusCancelling} + statusInfoList := make([]StatusInfo, 0, len(allStatus)) for _, s := range allStatus { statusInfoList = append(statusInfoList, StatusInfo{ Status: int(s), diff --git a/models/actions/run_test.go b/models/actions/run_test.go index e82cbe84b51..6c8160beae5 100644 --- a/models/actions/run_test.go +++ b/models/actions/run_test.go @@ -29,8 +29,7 @@ func TestUpdateRepoRunsNumbers(t *testing.T) { assert.Equal(t, 2, repo.NumClosedActionRuns) // now update will correct them, only num_actionr_runs and num_closed_action_runs should be updated - err = UpdateRepoRunsNumbers(t.Context(), repo) - assert.NoError(t, err) + UpdateRepoRunsNumbers(t.Context(), repo.ID) repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4}) assert.Equal(t, 4, repo.NumActionRuns) assert.Equal(t, 3, repo.NumClosedActionRuns) diff --git a/models/actions/runner.go b/models/actions/runner.go index f0088491bb5..27b7509ac4e 100644 --- a/models/actions/runner.go +++ b/models/actions/runner.go @@ -64,6 +64,8 @@ type ActionRunner struct { Ephemeral bool `xorm:"ephemeral NOT NULL DEFAULT false"` // Store if this runner is disabled and should not pick up new jobs IsDisabled bool `xorm:"is_disabled NOT NULL DEFAULT false"` + // Store if this runner supports the StatusCancelling flow + HasCancellingSupport bool `xorm:"has_cancelling_support NOT NULL DEFAULT false"` Created timeutil.TimeStamp `xorm:"created"` Updated timeutil.TimeStamp `xorm:"updated"` diff --git a/models/actions/status.go b/models/actions/status.go index 2b1d70613c7..f0701ad3b6f 100644 --- a/models/actions/status.go +++ b/models/actions/status.go @@ -15,25 +15,27 @@ import ( type Status int const ( - StatusUnknown Status = iota // 0, consistent with runnerv1.Result_RESULT_UNSPECIFIED - StatusSuccess // 1, consistent with runnerv1.Result_RESULT_SUCCESS - StatusFailure // 2, consistent with runnerv1.Result_RESULT_FAILURE - StatusCancelled // 3, consistent with runnerv1.Result_RESULT_CANCELLED - StatusSkipped // 4, consistent with runnerv1.Result_RESULT_SKIPPED - StatusWaiting // 5, isn't a runnerv1.Result - StatusRunning // 6, isn't a runnerv1.Result - StatusBlocked // 7, isn't a runnerv1.Result + StatusUnknown Status = iota // 0, consistent with runnerv1.Result_RESULT_UNSPECIFIED + StatusSuccess // 1, consistent with runnerv1.Result_RESULT_SUCCESS + StatusFailure // 2, consistent with runnerv1.Result_RESULT_FAILURE + StatusCancelled // 3, consistent with runnerv1.Result_RESULT_CANCELLED + StatusSkipped // 4, consistent with runnerv1.Result_RESULT_SKIPPED + StatusWaiting // 5, isn't a runnerv1.Result + StatusRunning // 6, isn't a runnerv1.Result + StatusBlocked // 7, isn't a runnerv1.Result + StatusCancelling // 8, isn't a runnerv1.Result ) var statusNames = map[Status]string{ - StatusUnknown: "unknown", - StatusWaiting: "waiting", - StatusRunning: "running", - StatusSuccess: "success", - StatusFailure: "failure", - StatusCancelled: "cancelled", - StatusSkipped: "skipped", - StatusBlocked: "blocked", + StatusUnknown: "unknown", + StatusWaiting: "waiting", + StatusRunning: "running", + StatusSuccess: "success", + StatusFailure: "failure", + StatusCancelled: "cancelled", + StatusCancelling: "cancelling", + StatusSkipped: "skipped", + StatusBlocked: "blocked", } // String returns the string name of the Status @@ -88,14 +90,41 @@ func (s Status) IsBlocked() bool { return s == StatusBlocked } +func (s Status) IsCancelling() bool { + return s == StatusCancelling +} + // In returns whether s is one of the given statuses func (s Status) In(statuses ...Status) bool { return slices.Contains(statuses, s) } func (s Status) AsResult() runnerv1.Result { - if s.IsDone() { - return runnerv1.Result(s) + switch s { + case StatusSuccess: + return runnerv1.Result_RESULT_SUCCESS + case StatusFailure: + return runnerv1.Result_RESULT_FAILURE + case StatusCancelled, StatusCancelling: + return runnerv1.Result_RESULT_CANCELLED + case StatusSkipped: + return runnerv1.Result_RESULT_SKIPPED + default: + return runnerv1.Result_RESULT_UNSPECIFIED + } +} + +func StatusFromResult(r runnerv1.Result) Status { + switch r { + case runnerv1.Result_RESULT_SUCCESS: + return StatusSuccess + case runnerv1.Result_RESULT_FAILURE: + return StatusFailure + case runnerv1.Result_RESULT_CANCELLED: + return StatusCancelled + case runnerv1.Result_RESULT_SKIPPED: + return StatusSkipped + default: + return StatusUnknown } - return runnerv1.Result_RESULT_UNSPECIFIED } diff --git a/models/actions/status_test.go b/models/actions/status_test.go new file mode 100644 index 00000000000..2363101c5d5 --- /dev/null +++ b/models/actions/status_test.go @@ -0,0 +1,49 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package actions + +import ( + "testing" + + runnerv1 "code.gitea.io/actions-proto-go/runner/v1" + "github.com/stretchr/testify/assert" +) + +func TestStatusAsResult(t *testing.T) { + cases := []struct { + status Status + want runnerv1.Result + }{ + {StatusUnknown, runnerv1.Result_RESULT_UNSPECIFIED}, + {StatusWaiting, runnerv1.Result_RESULT_UNSPECIFIED}, + {StatusRunning, runnerv1.Result_RESULT_UNSPECIFIED}, + {StatusBlocked, runnerv1.Result_RESULT_UNSPECIFIED}, + {StatusSuccess, runnerv1.Result_RESULT_SUCCESS}, + {StatusFailure, runnerv1.Result_RESULT_FAILURE}, + {StatusCancelled, runnerv1.Result_RESULT_CANCELLED}, + {StatusCancelling, runnerv1.Result_RESULT_CANCELLED}, + {StatusSkipped, runnerv1.Result_RESULT_SKIPPED}, + } + + for _, tt := range cases { + assert.Equal(t, tt.want, tt.status.AsResult(), "status=%s", tt.status) + } +} + +func TestStatusFromResult(t *testing.T) { + cases := []struct { + result runnerv1.Result + want Status + }{ + {runnerv1.Result_RESULT_UNSPECIFIED, StatusUnknown}, + {runnerv1.Result_RESULT_SUCCESS, StatusSuccess}, + {runnerv1.Result_RESULT_FAILURE, StatusFailure}, + {runnerv1.Result_RESULT_CANCELLED, StatusCancelled}, + {runnerv1.Result_RESULT_SKIPPED, StatusSkipped}, + } + + for _, tt := range cases { + assert.Equal(t, tt.want, StatusFromResult(tt.result), "result=%s", tt.result) + } +} diff --git a/models/actions/task.go b/models/actions/task.go index 7a97eadc798..38a92714b00 100644 --- a/models/actions/task.go +++ b/models/actions/task.go @@ -193,7 +193,8 @@ func GetRunningTaskByToken(ctx context.Context, token string) (*ActionTask, erro } var tasks []*ActionTask - err := db.GetEngine(ctx).Where("token_last_eight = ? AND status = ?", lastEight, StatusRunning).Find(&tasks) + // Cancelling tasks are still authenticating — post-run cleanup steps need API access (artifact uploads, cache saves, etc.) before the runner finalizes the task. + err := db.GetEngine(ctx).Where("token_last_eight = ? AND status IN (?, ?)", lastEight, StatusRunning, StatusCancelling).Find(&tasks) if err != nil { return nil, err } else if len(tasks) == 0 { @@ -374,7 +375,12 @@ func UpdateTaskByState(ctx context.Context, runnerID int64, state *runnerv1.Task // state.Result is not unspecified means the task is finished if state.Result != runnerv1.Result_RESULT_UNSPECIFIED { - task.Status = Status(state.Result) + if task.Status == StatusCancelling { + // The runner may report SUCCESS/FAILURE for the cleanup phase; preserve user intent. + task.Status = StatusCancelled + } else { + task.Status = StatusFromResult(state.Result) + } task.Stopped = timeutil.TimeStamp(state.StoppedAt.AsTime().Unix()) if err := UpdateTask(ctx, task, "status", "stopped"); err != nil { return nil, err @@ -409,7 +415,7 @@ func UpdateTaskByState(ctx context.Context, runnerID int64, state *runnerv1.Task step.Stopped = convertTimestamp(v.StoppedAt) } if result != runnerv1.Result_RESULT_UNSPECIFIED { - step.Status = Status(result) + step.Status = StatusFromResult(result) } else if step.Started != 0 { step.Status = StatusRunning } @@ -423,7 +429,7 @@ func UpdateTaskByState(ctx context.Context, runnerID int64, state *runnerv1.Task } func StopTask(ctx context.Context, taskID int64, status Status) error { - if !status.IsDone() { + if !status.IsDone() && status != StatusCancelling { return fmt.Errorf("cannot stop task with status %v", status) } e := db.GetEngine(ctx) @@ -439,6 +445,32 @@ func StopTask(ctx context.Context, taskID int64, status Status) error { } now := timeutil.TimeStampNow() + if status == StatusCancelling { + runner, err := GetRunnerByID(ctx, task.RunnerID) + if err != nil { + if !errors.Is(err, util.ErrNotExist) { + return err + } + status = StatusCancelled + } else if !runner.HasCancellingSupport { + status = StatusCancelled + } + } + + if status == StatusCancelling { + task.Status = StatusCancelling + + if _, err := UpdateRunJob(ctx, &ActionRunJob{ + ID: task.JobID, + RepoID: task.RepoID, + Status: StatusCancelling, + }, nil, "status"); err != nil { + return err + } + + return UpdateTask(ctx, task, "status") + } + task.Status = status task.Stopped = now if _, err := UpdateRunJob(ctx, &ActionRunJob{ diff --git a/models/actions/task_test.go b/models/actions/task_test.go index cbfc6f7636b..9d719d3c3a7 100644 --- a/models/actions/task_test.go +++ b/models/actions/task_test.go @@ -7,9 +7,15 @@ import ( "strings" "testing" + "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/actions/jobparser" + "code.gitea.io/gitea/modules/timeutil" + runnerv1 "code.gitea.io/actions-proto-go/runner/v1" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/types/known/timestamppb" ) func TestMakeTaskStepDisplayName(t *testing.T) { @@ -75,3 +81,228 @@ func TestMakeTaskStepDisplayName(t *testing.T) { }) } } + +func TestTaskCancellingFinalizesToCancelled(t *testing.T) { + newRunningTask := func(t *testing.T) (*ActionTask, *ActionRunJob) { + t.Helper() + + run := &ActionRun{ + Title: "cancelling-test-run", + RepoID: 1, + OwnerID: 2, + WorkflowID: "test.yaml", + Index: 999, + TriggerUserID: 2, + Ref: "refs/heads/master", + CommitSHA: "c2d72f548424103f01ee1dc02889c1e2bff816b0", + Event: "push", + TriggerEvent: "push", + Status: StatusRunning, + Started: timeutil.TimeStampNow(), + } + require.NoError(t, db.Insert(t.Context(), run)) + + job := &ActionRunJob{ + RunID: run.ID, + RepoID: run.RepoID, + OwnerID: run.OwnerID, + CommitSHA: run.CommitSHA, + Name: "cancelling-finalization-job", + Attempt: 1, + JobID: "cancelling-finalization-job", + Status: StatusRunning, + } + require.NoError(t, db.Insert(t.Context(), job)) + + runner := &ActionRunner{ + UUID: "runner-cancelling-supported", + Name: "runner-cancelling-supported", + HasCancellingSupport: true, + } + require.NoError(t, db.Insert(t.Context(), runner)) + + task := &ActionTask{ + JobID: job.ID, + Attempt: 1, + RunnerID: runner.ID, + Status: StatusRunning, + Started: timeutil.TimeStampNow(), + RepoID: run.RepoID, + OwnerID: run.OwnerID, + CommitSHA: run.CommitSHA, + } + require.NoError(t, db.Insert(t.Context(), task)) + + job.TaskID = task.ID + _, err := UpdateRunJob(t.Context(), job, nil, "task_id") + require.NoError(t, err) + + return task, job + } + + testResult := func(t *testing.T, result runnerv1.Result) { + t.Helper() + require.NoError(t, unittest.PrepareTestDatabase()) + + task, job := newRunningTask(t) + require.NoError(t, StopTask(t.Context(), task.ID, StatusCancelling)) + + taskAfterStop := unittest.AssertExistsAndLoadBean(t, &ActionTask{ID: task.ID}) + assert.Equal(t, StatusCancelling, taskAfterStop.Status) + + updatedTask, err := UpdateTaskByState(t.Context(), task.RunnerID, &runnerv1.TaskState{ + Id: task.ID, + Result: result, + StoppedAt: timestamppb.Now(), + }) + require.NoError(t, err) + assert.Equal(t, StatusCancelled, updatedTask.Status) + + taskAfterUpdate := unittest.AssertExistsAndLoadBean(t, &ActionTask{ID: task.ID}) + assert.Equal(t, StatusCancelled, taskAfterUpdate.Status) + + jobAfterUpdate := unittest.AssertExistsAndLoadBean(t, &ActionRunJob{ID: job.ID}) + assert.Equal(t, StatusCancelled, jobAfterUpdate.Status) + } + + t.Run("runner reports success", func(t *testing.T) { + testResult(t, runnerv1.Result_RESULT_SUCCESS) + }) + + t.Run("runner reports failure", func(t *testing.T) { + testResult(t, runnerv1.Result_RESULT_FAILURE) + }) +} + +func TestStopTaskCancellingFallsBackForLegacyRunner(t *testing.T) { + require.NoError(t, unittest.PrepareTestDatabase()) + + run := &ActionRun{ + Title: "cancelling-test-run", + RepoID: 1, + OwnerID: 2, + WorkflowID: "test.yaml", + Index: 999, + TriggerUserID: 2, + Ref: "refs/heads/master", + CommitSHA: "c2d72f548424103f01ee1dc02889c1e2bff816b0", + Event: "push", + TriggerEvent: "push", + Status: StatusRunning, + Started: timeutil.TimeStampNow(), + } + require.NoError(t, db.Insert(t.Context(), run)) + + job := &ActionRunJob{ + RunID: run.ID, + RepoID: run.RepoID, + OwnerID: run.OwnerID, + CommitSHA: run.CommitSHA, + Name: "legacy-cancelling-job", + Attempt: 1, + JobID: "legacy-cancelling-job", + Status: StatusRunning, + } + require.NoError(t, db.Insert(t.Context(), job)) + + runner := &ActionRunner{ + UUID: "runner-legacy-no-cancelling", + Name: "runner-legacy-no-cancelling", + HasCancellingSupport: false, + } + require.NoError(t, db.Insert(t.Context(), runner)) + + task := &ActionTask{ + JobID: job.ID, + Attempt: 1, + RunnerID: runner.ID, + Status: StatusRunning, + Started: timeutil.TimeStampNow(), + RepoID: run.RepoID, + OwnerID: run.OwnerID, + CommitSHA: run.CommitSHA, + } + require.NoError(t, db.Insert(t.Context(), task)) + + job.TaskID = task.ID + _, err := UpdateRunJob(t.Context(), job, nil, "task_id") + require.NoError(t, err) + + require.NoError(t, StopTask(t.Context(), task.ID, StatusCancelling)) + + taskAfterStop := unittest.AssertExistsAndLoadBean(t, &ActionTask{ID: task.ID}) + assert.Equal(t, StatusCancelled, taskAfterStop.Status) + assert.NotZero(t, taskAfterStop.Stopped) + + jobAfterStop := unittest.AssertExistsAndLoadBean(t, &ActionRunJob{ID: job.ID}) + assert.Equal(t, StatusCancelled, jobAfterStop.Status) + assert.NotZero(t, jobAfterStop.Stopped) +} + +func TestStopTaskCancellingFallsBackForMissingRunner(t *testing.T) { + require.NoError(t, unittest.PrepareTestDatabase()) + + run := &ActionRun{ + Title: "cancelling-test-run", + RepoID: 1, + OwnerID: 2, + WorkflowID: "test.yaml", + Index: 999, + TriggerUserID: 2, + Ref: "refs/heads/master", + CommitSHA: "c2d72f548424103f01ee1dc02889c1e2bff816b0", + Event: "push", + TriggerEvent: "push", + Status: StatusRunning, + Started: timeutil.TimeStampNow(), + } + require.NoError(t, db.Insert(t.Context(), run)) + + job := &ActionRunJob{ + RunID: run.ID, + RepoID: run.RepoID, + OwnerID: run.OwnerID, + CommitSHA: run.CommitSHA, + Name: "missing-runner-cancelling-job", + Attempt: 1, + JobID: "missing-runner-cancelling-job", + Status: StatusRunning, + } + require.NoError(t, db.Insert(t.Context(), job)) + + runner := &ActionRunner{ + UUID: "runner-cleaned-up-before-cancel", + Name: "runner-cleaned-up-before-cancel", + HasCancellingSupport: true, + } + require.NoError(t, db.Insert(t.Context(), runner)) + + task := &ActionTask{ + JobID: job.ID, + Attempt: 1, + RunnerID: runner.ID, + Status: StatusRunning, + Started: timeutil.TimeStampNow(), + RepoID: run.RepoID, + OwnerID: run.OwnerID, + CommitSHA: run.CommitSHA, + } + require.NoError(t, db.Insert(t.Context(), task)) + + job.TaskID = task.ID + _, err := UpdateRunJob(t.Context(), job, nil, "task_id") + require.NoError(t, err) + + _, err = db.DeleteByID[ActionRunner](t.Context(), runner.ID) + require.NoError(t, err) + + require.NoError(t, StopTask(t.Context(), task.ID, StatusCancelling)) + + taskAfterStop := unittest.AssertExistsAndLoadBean(t, &ActionTask{ID: task.ID}) + assert.Equal(t, StatusCancelled, taskAfterStop.Status) + assert.NotZero(t, taskAfterStop.Stopped) + + jobAfterStop := unittest.AssertExistsAndLoadBean(t, &ActionRunJob{ID: job.ID}) + assert.Equal(t, StatusCancelled, jobAfterStop.Status) + assert.NotZero(t, jobAfterStop.Stopped) +} diff --git a/models/activities/action.go b/models/activities/action.go index 4ffdca842a4..97388402d49 100644 --- a/models/activities/action.go +++ b/models/activities/action.go @@ -436,6 +436,12 @@ type GetFeedsOptions struct { DontCount bool // do counting in GetFeeds } +func (opts *GetFeedsOptions) ApplyPublicOnly(publicOnly bool) { + if publicOnly { + opts.IncludePrivate = false + } +} + // ActivityReadable return whether doer can read activities of user func ActivityReadable(user, doer *user_model.User) bool { return !user.KeepActivityPrivate || diff --git a/models/activities/action_list.go b/models/activities/action_list.go index 5b07a8e080a..e9e3873f9a1 100644 --- a/models/activities/action_list.go +++ b/models/activities/action_list.go @@ -242,7 +242,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err if opts.Page < 10 { // TODO: why it's 10 but other values? It's an experience value. sess := db.GetEngine(ctx).Where(cond) - sess = db.SetSessionPagination(sess, &opts) + db.SetSessionPagination(sess, &opts) if opts.DontCount { err = sess.Desc("`action`.created_unix").Find(&actions) @@ -255,7 +255,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err } else { // First, only query which IDs are necessary, and only then query all actions to speed up the overall query sess := db.GetEngine(ctx).Where(cond).Select("`action`.id") - sess = db.SetSessionPagination(sess, &opts) + db.SetSessionPagination(sess, &opts) actionIDs := make([]int64, 0, opts.PageSize) if err := sess.Table("action").Desc("`action`.created_unix").Find(&actionIDs); err != nil { diff --git a/models/activities/repo_activity.go b/models/activities/repo_activity.go index aeaa452c9e9..54ea6be7735 100644 --- a/models/activities/repo_activity.go +++ b/models/activities/repo_activity.go @@ -17,7 +17,6 @@ import ( "code.gitea.io/gitea/modules/gitrepo" "xorm.io/builder" - "xorm.io/xorm" ) // ActivityAuthorData represents statistical git commit count data @@ -248,7 +247,7 @@ func (stats *ActivityStats) FillPullRequests(ctx context.Context, repoID int64, return nil } -func pullRequestsForActivityStatement(ctx context.Context, repoID int64, fromTime time.Time, merged bool) *xorm.Session { +func pullRequestsForActivityStatement(ctx context.Context, repoID int64, fromTime time.Time, merged bool) db.Session { sess := db.GetEngine(ctx).Where("pull_request.base_repo_id=?", repoID). Join("INNER", "issue", "pull_request.issue_id = issue.id") @@ -324,7 +323,7 @@ func (stats *ActivityStats) FillUnresolvedIssues(ctx context.Context, repoID int return sess.Find(&stats.UnresolvedIssues) } -func newlyCreatedIssues(ctx context.Context, repoID int64, fromTime time.Time) *xorm.Session { +func newlyCreatedIssues(ctx context.Context, repoID int64, fromTime time.Time) db.Session { sess := db.GetEngine(ctx).Where("issue.repo_id = ?", repoID). And("issue.is_pull = ?", false). // Retain the is_pull check to exclude pull requests And("issue.created_unix >= ?", fromTime.Unix()) // Include all issues created after fromTime @@ -332,7 +331,7 @@ func newlyCreatedIssues(ctx context.Context, repoID int64, fromTime time.Time) * return sess } -func activeIssues(ctx context.Context, repoID int64, fromTime time.Time) *xorm.Session { +func activeIssues(ctx context.Context, repoID int64, fromTime time.Time) db.Session { sess := db.GetEngine(ctx).Where("issue.repo_id = ?", repoID). And("issue.is_pull = ?", false). And(builder.Or( @@ -343,7 +342,7 @@ func activeIssues(ctx context.Context, repoID int64, fromTime time.Time) *xorm.S return sess } -func issuesForActivityStatement(ctx context.Context, repoID int64, fromTime time.Time, closed, unresolved bool) *xorm.Session { +func issuesForActivityStatement(ctx context.Context, repoID int64, fromTime time.Time, closed, unresolved bool) db.Session { sess := db.GetEngine(ctx).Where("issue.repo_id = ?", repoID). And("issue.is_closed = ?", closed) @@ -385,7 +384,7 @@ func (stats *ActivityStats) FillReleases(ctx context.Context, repoID int64, from return nil } -func releasesForActivityStatement(ctx context.Context, repoID int64, fromTime time.Time) *xorm.Session { +func releasesForActivityStatement(ctx context.Context, repoID int64, fromTime time.Time) db.Session { return db.GetEngine(ctx).Where("`release`.repo_id = ?", repoID). And("`release`.is_draft = ?", false). And("`release`.created_unix >= ?", fromTime.Unix()) diff --git a/models/admin/task.go b/models/admin/task.go index 5d2b9bbff6f..7056a8359ec 100644 --- a/models/admin/task.go +++ b/models/admin/task.go @@ -137,6 +137,11 @@ func (task *Task) MigrateConfig() (*migration.MigrateOptions, error) { log.Error("Unable to decrypt AuthToken, maybe SECRET_KEY is wrong: %v", err) } } + if opts.AWSSecretAccessKeyEncrypted != "" { + if opts.AWSSecretAccessKey, err = secret.DecryptSecret(setting.SecretKey, opts.AWSSecretAccessKeyEncrypted); err != nil { + log.Error("Unable to decrypt AWSSecretAccessKey, maybe SECRET_KEY is wrong: %v", err) + } + } return &opts, nil } @@ -201,6 +206,8 @@ func FinishMigrateTask(ctx context.Context, task *Task) error { conf.AuthPasswordEncrypted = "" conf.AuthTokenEncrypted = "" conf.CloneAddrEncrypted = "" + conf.AWSSecretAccessKey = "" + conf.AWSSecretAccessKeyEncrypted = "" confBytes, err := json.Marshal(conf) if err != nil { return err diff --git a/models/asymkey/ssh_key_principals.go b/models/asymkey/ssh_key_principals.go index e8b97d306e6..2d4c74740d6 100644 --- a/models/asymkey/ssh_key_principals.go +++ b/models/asymkey/ssh_key_principals.go @@ -40,7 +40,7 @@ func CheckPrincipalKeyString(ctx context.Context, user *user_model.User, content if !email.IsActivated { continue } - if content == email.Email { + if strings.EqualFold(content, email.LowerEmail) { return content, nil } } diff --git a/models/auth/oauth2.go b/models/auth/oauth2.go index d5a5e2af8e8..104a7ba9f46 100644 --- a/models/auth/oauth2.go +++ b/models/auth/oauth2.go @@ -5,9 +5,8 @@ package auth import ( "context" - "crypto/sha256" + "crypto/subtle" "encoding/base32" - "encoding/base64" "errors" "fmt" "net" @@ -24,6 +23,7 @@ import ( uuid "github.com/google/uuid" "golang.org/x/crypto/bcrypt" + "golang.org/x/oauth2" "xorm.io/builder" "xorm.io/xorm" ) @@ -31,7 +31,10 @@ import ( // Authorization codes should expire within 10 minutes per https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2 const oauth2AuthorizationCodeValidity = 10 * time.Minute -var ErrOAuth2AuthorizationCodeInvalidated = errors.New("oauth2 authorization code already invalidated") +var ( + ErrOAuth2AuthorizationCodeInvalidated = errors.New("oauth2 authorization code already invalidated") + ErrOAuth2GrantStaleCounter = errors.New("oauth2 grant state changed during token refresh") +) // OAuth2Application represents an OAuth2 client (RFC 6749) type OAuth2Application struct { @@ -151,30 +154,40 @@ func (app *OAuth2Application) ContainsRedirectURI(redirectURI string) bool { // https://www.rfc-editor.org/rfc/rfc6819#section-5.2.3.3 // https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest // https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics-12#section-3.1 - contains := func(s string) bool { - s = strings.TrimSuffix(strings.ToLower(s), "/") - for _, u := range app.RedirectURIs { - if strings.TrimSuffix(strings.ToLower(u), "/") == s { + redirectCandidates := []string{redirectURI} + if !app.ConfidentialClient { + loopbackRedirect, ok := normalizePublicClientRedirectURI(redirectURI) + if ok { + redirectCandidates = append(redirectCandidates, loopbackRedirect) + } + } + + for _, candidate := range redirectCandidates { + normalizedCandidate := normalizeRedirectURIForComparison(candidate) + for _, registeredURI := range app.RedirectURIs { + if normalizeRedirectURIForComparison(registeredURI) == normalizedCandidate { return true } } - return false } - if !app.ConfidentialClient { - uri, err := url.Parse(redirectURI) - // ignore port for http loopback uris following https://datatracker.ietf.org/doc/html/rfc8252#section-7.3 - if err == nil && uri.Scheme == "http" && uri.Port() != "" { - ip := net.ParseIP(uri.Hostname()) - if ip != nil && ip.IsLoopback() { - // strip port - uri.Host = uri.Hostname() - if contains(uri.String()) { - return true - } - } - } + + return false +} + +func normalizeRedirectURIForComparison(redirectURI string) string { + return strings.TrimSuffix(util.ToLowerASCII(redirectURI), "/") +} + +func normalizePublicClientRedirectURI(redirectURI string) (string, bool) { + parsedURI, err := url.Parse(redirectURI) + if err != nil || parsedURI.Scheme != "http" || parsedURI.Port() == "" { + return "", false } - return contains(redirectURI) + if ip := net.ParseIP(parsedURI.Hostname()); ip == nil || !ip.IsLoopback() { + return "", false + } + parsedURI.Host = parsedURI.Hostname() + return parsedURI.String(), true } // Base32 characters, but lowercased. @@ -424,22 +437,34 @@ func (code *OAuth2AuthorizationCode) Invalidate(ctx context.Context) error { return nil } +func (code *OAuth2AuthorizationCode) requiresCodeVerifier() bool { + return code.CodeChallengeMethod != "" || code.CodeChallenge != "" +} + +func deriveCodeChallenge(method, verifier string) (string, bool) { + switch method { + case "S256": + return oauth2.S256ChallengeFromVerifier(verifier), true + case "plain": + return verifier, true + default: + return "", false + } +} + // ValidateCodeChallenge validates the given verifier against the saved code challenge. This is part of the PKCE implementation. func (code *OAuth2AuthorizationCode) ValidateCodeChallenge(verifier string) bool { - switch code.CodeChallengeMethod { - case "S256": - // base64url(SHA256(verifier)) see https://tools.ietf.org/html/rfc7636#section-4.6 - h := sha256.Sum256([]byte(verifier)) - hashedVerifier := base64.RawURLEncoding.EncodeToString(h[:]) - return hashedVerifier == code.CodeChallenge - case "plain": - return verifier == code.CodeChallenge - case "": + if !code.requiresCodeVerifier() { return true - default: - // unsupported method -> return false + } + if verifier == "" || code.CodeChallengeMethod == "" { return false } + expectedChallenge, ok := deriveCodeChallenge(code.CodeChallengeMethod, verifier) + if !ok { + return false + } + return subtle.ConstantTimeCompare([]byte(expectedChallenge), []byte(code.CodeChallenge)) == 1 } // GetOAuth2AuthorizationByCode returns an authorization by its code @@ -504,15 +529,18 @@ func (grant *OAuth2Grant) GenerateNewAuthorizationCode(ctx context.Context, redi // IncreaseCounter increases the counter and updates the grant func (grant *OAuth2Grant) IncreaseCounter(ctx context.Context) error { - _, err := db.GetEngine(ctx).ID(grant.ID).Incr("counter").Update(new(OAuth2Grant)) + affected, err := db.GetEngine(ctx). + Where("id = ?", grant.ID). + And("counter = ?", grant.Counter). + Incr("counter"). + Update(new(OAuth2Grant)) if err != nil { return err } - updatedGrant, err := GetOAuth2GrantByID(ctx, grant.ID) - if err != nil { - return err + if affected == 0 { + return ErrOAuth2GrantStaleCounter } - grant.Counter = updatedGrant.Counter + grant.Counter++ return nil } diff --git a/models/auth/oauth2_test.go b/models/auth/oauth2_test.go index d72e1cb1d52..465dfb14f2c 100644 --- a/models/auth/oauth2_test.go +++ b/models/auth/oauth2_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "golang.org/x/oauth2" ) func TestOAuth2AuthorizationCode(t *testing.T) { @@ -116,6 +117,47 @@ func TestOAuth2Application_ContainsRedirect_Slash(t *testing.T) { assert.False(t, app.ContainsRedirectURI("http://127.0.0.1/other")) } +func TestOAuth2Application_ContainsRedirectURI_ASCIIOnlyNormalization(t *testing.T) { + testCases := []struct { + name string + registered []string + redirectURI string + allowed bool + }{ + { + name: "exact-match", + registered: []string{"https://signin.example.test/callback"}, + redirectURI: "https://signin.example.test/callback", + allowed: true, + }, + { + name: "ascii-case-insensitive", + registered: []string{"https://signin.example.test/callback"}, + redirectURI: "https://signIN.example.test/callback", + allowed: true, + }, + { + name: "non-ascii-not-folded", + registered: []string{"https://signin.example.test/callback"}, + redirectURI: "https://signİn.example.test/callback", + allowed: false, + }, + { + name: "loopback-strips-port", + registered: []string{"http://127.0.0.1/callback"}, + redirectURI: "http://127.0.0.1:12345/callback", + allowed: true, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + app := &auth_model.OAuth2Application{RedirectURIs: tc.registered} + assert.Equal(t, tc.allowed, app.ContainsRedirectURI(tc.redirectURI)) + }) + } +} + func TestOAuth2Application_ValidateClientSecret(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1}) @@ -193,6 +235,16 @@ func TestOAuth2Grant_IncreaseCounter(t *testing.T) { unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Grant{ID: 1, Counter: 2}) } +func TestOAuth2Grant_IncreaseCounterRejectsStaleCounter(t *testing.T) { + assert.NoError(t, unittest.PrepareTestDatabase()) + grant := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Grant{ID: 1, Counter: 1}) + stale := *grant + + assert.NoError(t, grant.IncreaseCounter(t.Context())) + err := stale.IncreaseCounter(t.Context()) + assert.ErrorIs(t, err, auth_model.ErrOAuth2GrantStaleCounter) +} + func TestOAuth2Grant_ScopeContains(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) grant := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Grant{ID: 1, Scope: "openid profile"}) @@ -237,35 +289,38 @@ func TestRevokeOAuth2Grant(t *testing.T) { //////////////////// Authorization Code func TestOAuth2AuthorizationCode_ValidateCodeChallenge(t *testing.T) { - // test plain - code := &auth_model.OAuth2AuthorizationCode{ - CodeChallengeMethod: "plain", - CodeChallenge: "test123", - } - assert.True(t, code.ValidateCodeChallenge("test123")) - assert.False(t, code.ValidateCodeChallenge("ierwgjoergjio")) + s256Verifier := "s256-verifier" + s256Challenge := oauth2.S256ChallengeFromVerifier(s256Verifier) + missingVerifierChallenge := oauth2.S256ChallengeFromVerifier("verifier-not-supplied") - // test S256 - code = &auth_model.OAuth2AuthorizationCode{ - CodeChallengeMethod: "S256", - CodeChallenge: "CjvyTLSdR47G5zYenDA-eDWW4lRrO8yvjcWwbD_deOg", + testCases := []struct { + name string + method string + challenge string + verifier string + valid bool + }{ + {"plain-success", "plain", "plain-secret", "plain-secret", true}, + {"plain-failure", "plain", "plain-secret", "ierwgjoergjio", false}, + {"s256-success", "S256", s256Challenge, s256Verifier, true}, + {"s256-failure", "S256", s256Challenge, "wiogjerogorewngoenrgoiuenorg", false}, + {"unsupported-method", "monkey", "foiwgjioriogeiogjerger", "foiwgjioriogeiogjerger", false}, + {"no-pkce-configured", "", "", "", true}, + {"s256-missing-verifier", "S256", missingVerifierChallenge, "", false}, + {"plain-missing-verifier", "plain", "plain-secret", "", false}, + {"missing-method-with-challenge", "", "foierjiogerogerg", "", false}, + {"missing-method-rejects-even-matching-verifier", "", "foierjiogerogerg", "foierjiogerogerg", false}, } - assert.True(t, code.ValidateCodeChallenge("N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt")) - assert.False(t, code.ValidateCodeChallenge("wiogjerogorewngoenrgoiuenorg")) - // test unknown - code = &auth_model.OAuth2AuthorizationCode{ - CodeChallengeMethod: "monkey", - CodeChallenge: "foiwgjioriogeiogjerger", + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + code := &auth_model.OAuth2AuthorizationCode{ + CodeChallengeMethod: tc.method, + CodeChallenge: tc.challenge, + } + assert.Equal(t, tc.valid, code.ValidateCodeChallenge(tc.verifier)) + }) } - assert.False(t, code.ValidateCodeChallenge("foiwgjioriogeiogjerger")) - - // test no code challenge - code = &auth_model.OAuth2AuthorizationCode{ - CodeChallengeMethod: "", - CodeChallenge: "foierjiogerogerg", - } - assert.True(t, code.ValidateCodeChallenge("")) } func TestOAuth2AuthorizationCode_GenerateRedirectURI(t *testing.T) { diff --git a/models/auth/source.go b/models/auth/source.go index 7a008f08a8b..16f36eb0c24 100644 --- a/models/auth/source.go +++ b/models/auth/source.go @@ -100,7 +100,7 @@ var registeredConfigs = map[Type]func() Config{} // RegisterTypeConfig register a config for a provided type func RegisterTypeConfig(typ Type, exemplar Config) { - if reflect.TypeOf(exemplar).Kind() == reflect.Ptr { + if reflect.TypeOf(exemplar).Kind() == reflect.Pointer { // Pointer: registeredConfigs[typ] = func() Config { return reflect.New(reflect.ValueOf(exemplar).Elem().Type()).Interface().(Config) diff --git a/models/db/collation.go b/models/db/collation.go index 203f7cbfe47..56173ad97dd 100644 --- a/models/db/collation.go +++ b/models/db/collation.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) @@ -27,7 +26,7 @@ type CheckCollationsResult struct { InconsistentCollationColumns []string } -func findAvailableCollationsMySQL(x *xorm.Engine) (ret container.Set[string], err error) { +func findAvailableCollationsMySQL(x EngineMigration) (ret container.Set[string], err error) { var res []struct { Collation string } @@ -41,7 +40,7 @@ func findAvailableCollationsMySQL(x *xorm.Engine) (ret container.Set[string], er return ret, nil } -func findAvailableCollationsMSSQL(x *xorm.Engine) (ret container.Set[string], err error) { +func findAvailableCollationsMSSQL(x EngineMigration) (ret container.Set[string], err error) { var res []struct { Name string } @@ -55,7 +54,7 @@ func findAvailableCollationsMSSQL(x *xorm.Engine) (ret container.Set[string], er return ret, nil } -func CheckCollations(x *xorm.Engine) (*CheckCollationsResult, error) { +func CheckCollations(x EngineMigration) (*CheckCollationsResult, error) { dbTables, err := x.DBMetas() if err != nil { return nil, err @@ -143,7 +142,7 @@ func CheckCollationsDefaultEngine() (*CheckCollationsResult, error) { return CheckCollations(xormEngine) } -func alterDatabaseCollation(x *xorm.Engine, collation string) error { +func alterDatabaseCollation(x EngineMigration, collation string) error { if x.Dialect().URI().DBType == schemas.MYSQL { _, err := x.Exec("ALTER DATABASE CHARACTER SET utf8mb4 COLLATE " + collation) return err @@ -156,7 +155,7 @@ func alterDatabaseCollation(x *xorm.Engine, collation string) error { } // preprocessDatabaseCollation checks database & table column collation, and alter the database collation if needed -func preprocessDatabaseCollation(x *xorm.Engine) { +func preprocessDatabaseCollation(x EngineMigration) { r, err := CheckCollations(x) if err != nil { log.Error("Failed to check database collation: %v", err) diff --git a/models/db/conn.go b/models/db/conn.go index de6f3cd5ec7..944b6e7b970 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/context.go b/models/db/context.go index 8bb14f1389b..5e74f458ec7 100644 --- a/models/db/context.go +++ b/models/db/context.go @@ -17,12 +17,15 @@ import ( "xorm.io/xorm" ) -type engineContextKeyType struct{} +type contextKey struct{ key string } -var engineContextKey = engineContextKeyType{} +var ( + contextKeyEngine = contextKey{"engine"} + ContextKeyTestFixtures = contextKey{"test-fixtures"} +) func withContextEngine(ctx context.Context, e Engine) context.Context { - return context.WithValue(ctx, engineContextKey, e) + return context.WithValue(ctx, contextKeyEngine, e) } var ( @@ -68,7 +71,7 @@ func contextSafetyCheck(e Engine) { // GetEngine gets an existing db Engine/Statement or creates a new Session func GetEngine(ctx context.Context) Engine { - if engine, ok := ctx.Value(engineContextKey).(Engine); ok { + if engine, ok := ctx.Value(contextKeyEngine).(Engine); ok { // if reusing the existing session, need to do "contextSafetyCheck" because the Iterate creates a "autoResetStatement=false" session contextSafetyCheck(engine) return engine @@ -309,7 +312,7 @@ func InTransaction(ctx context.Context) bool { } func getTransactionSession(ctx context.Context) *xorm.Session { - e, _ := ctx.Value(engineContextKey).(Engine) + e, _ := ctx.Value(contextKeyEngine).(Engine) if sess, ok := e.(*xorm.Session); ok && sess.IsInTx() { return sess } diff --git a/models/db/driver_sqlite_mattn.go b/models/db/driver_sqlite_mattn.go index 4988a43d3f2..a25cb099901 100644 --- a/models/db/driver_sqlite_mattn.go +++ b/models/db/driver_sqlite_mattn.go @@ -1,8 +1,8 @@ -//go:build sqlite - // Copyright 2026 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//go:build sqlite_mattn && sqlite_unlock_notify + package db import ( @@ -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 00000000000..6bd5498a555 --- /dev/null +++ b/models/db/driver_sqlite_modernc.go @@ -0,0 +1,41 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +//go:build !sqlite_mattn + +// 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/db/engine.go b/models/db/engine.go index fbcc3fa15e8..d4ac0b4aca0 100755 --- a/models/db/engine.go +++ b/models/db/engine.go @@ -16,6 +16,10 @@ import ( _ "github.com/microsoft/go-mssqldb" // Needed for the MSSQL driver "xorm.io/xorm" + "xorm.io/xorm/core" + "xorm.io/xorm/dialects" + "xorm.io/xorm/names" + "xorm.io/xorm/schemas" ) var ( @@ -33,6 +37,7 @@ type Engine interface { Truncate(...any) (int64, error) Exec(...any) (sql.Result, error) Find(any, ...any) error + FindAndCount(any, ...any) (int64, error) Get(beans ...any) (bool, error) ID(any) *xorm.Session In(string, ...any) *xorm.Session @@ -61,9 +66,41 @@ type Engine interface { IsTableExist(tableNameOrBean any) (bool, error) } +// Session represents a xorm session interface, used as an abstraction over *xorm.Session. +type Session interface { + Engine + And(query any, args ...any) *xorm.Session + Begin() error + Close() error + Commit() error + IsInTx() bool + Rollback() error + Engine() *xorm.Engine +} + +// EngineMigration is a xorm engine interface used for migrations. +// It extends Engine with additional methods that are only available on the engine (not on the session) +// and are needed by the migration packages. +type EngineMigration interface { + Engine + Close() error + DB() *core.DB + DBMetas() ([]*schemas.Table, error) + Dialect() dialects.Dialect + DropTables(beans ...any) error + NewSession() *xorm.Session + QueryInterface(sqlOrArgs ...any) ([]map[string]any, error) + SetMapper(mapper names.Mapper) + SyncWithOptions(opts xorm.SyncOptions, beans ...any) (*xorm.SyncResult, error) + TableInfo(bean any) (*schemas.Table, error) + TableName(bean any, includeSchema ...bool) string +} + var ( - _ Engine = (*xorm.Engine)(nil) - _ Engine = (*xorm.Session)(nil) + _ Engine = (*xorm.Engine)(nil) + _ Engine = (*xorm.Session)(nil) + _ Session = (*xorm.Session)(nil) + _ EngineMigration = (*xorm.Engine)(nil) ) // RegisterModel registers model, if initFuncs provided, it will be invoked after data model sync diff --git a/models/db/engine_hook.go b/models/db/engine_hook.go index 8709a2c2a13..8d8ed3992cf 100644 --- a/models/db/engine_hook.go +++ b/models/db/engine_hook.go @@ -22,11 +22,17 @@ type EngineHook struct { var _ contexts.Hook = (*EngineHook)(nil) func (*EngineHook) BeforeProcess(c *contexts.ContextHook) (context.Context, error) { + if c.Ctx.Value(ContextKeyTestFixtures) != nil { + return c.Ctx, nil + } ctx, _ := gtprof.GetTracer().Start(c.Ctx, gtprof.TraceSpanDatabase) return ctx, nil } func (h *EngineHook) AfterProcess(c *contexts.ContextHook) error { + if c.Ctx.Value(ContextKeyTestFixtures) != nil { + return nil + } span := gtprof.GetContextSpan(c.Ctx) if span != nil { // Do not record SQL parameters here: diff --git a/models/db/engine_init.go b/models/db/engine_init.go index 65192d3327a..2680bcf5ef3 100644 --- a/models/db/engine_init.go +++ b/models/db/engine_init.go @@ -92,7 +92,7 @@ func UnsetDefaultEngine() { // When called from the "doctor" command, the migration function is a version check // that prevents the doctor from fixing anything in the database if the migration level // is different from the expected value. -func InitEngineWithMigration(ctx context.Context, migrateFunc func(context.Context, *xorm.Engine) error) (err error) { +func InitEngineWithMigration(ctx context.Context, migrateFunc func(context.Context, EngineMigration) error) (err error) { if err = InitEngine(ctx); err != nil { return err } diff --git a/models/db/list.go b/models/db/list.go index 5c005a03501..3d61d7d46c0 100644 --- a/models/db/list.go +++ b/models/db/list.go @@ -9,7 +9,6 @@ import ( "code.gitea.io/gitea/modules/setting" "xorm.io/builder" - "xorm.io/xorm" ) const ( @@ -25,7 +24,7 @@ type Paginator interface { } // SetSessionPagination sets pagination for a database session -func SetSessionPagination(sess Engine, p Paginator) *xorm.Session { +func SetSessionPagination(sess Engine, p Paginator) Session { skip, take := p.GetSkipTake() return sess.Limit(take, skip) diff --git a/models/git/branch.go b/models/git/branch.go index 698c43f1472..db53ca0ac7e 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_list.go b/models/git/branch_list.go index 1445f3a5a02..17cac4531ba 100644 --- a/models/git/branch_list.go +++ b/models/git/branch_list.go @@ -101,7 +101,7 @@ func (opts FindBranchOptions) ToOrders() string { func FindBranchNames(ctx context.Context, opts FindBranchOptions) ([]string, error) { sess := db.GetEngine(ctx).Select("name").Where(opts.ToConds()) if opts.PageSize > 0 && !opts.IsListAll() { - sess = db.SetSessionPagination(sess, &opts.ListOptions) + db.SetSessionPagination(sess, &opts.ListOptions) } var branches []string diff --git a/models/git/branch_test.go b/models/git/branch_test.go index 3832df93509..be674392852 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/git/commit_status.go b/models/git/commit_status.go index 2ae5937a3d8..07beb2372a2 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -25,7 +25,6 @@ import ( "code.gitea.io/gitea/modules/translation" "xorm.io/builder" - "xorm.io/xorm" ) // CommitStatus holds a single Status of a single Commit @@ -329,7 +328,7 @@ type CommitStatusIndex struct { MaxIndex int64 `xorm:"index"` } -func makeRepoCommitQuery(ctx context.Context, repoID int64, sha string) *xorm.Session { +func makeRepoCommitQuery(ctx context.Context, repoID int64, sha string) db.Session { return db.GetEngine(ctx).Table(&CommitStatus{}). Where("repo_id = ?", repoID).And("sha = ?", sha) } @@ -337,12 +336,10 @@ func makeRepoCommitQuery(ctx context.Context, repoID int64, sha string) *xorm.Se // GetLatestCommitStatus returns all statuses with a unique context for a given commit. func GetLatestCommitStatus(ctx context.Context, repoID int64, sha string, listOptions db.ListOptions) ([]*CommitStatus, error) { indices := make([]int64, 0, 10) - sess := makeRepoCommitQuery(ctx, repoID, sha). - Select("max( `index` ) as `index`"). - GroupBy("context_hash"). - OrderBy("max( `index` ) desc") + sess := makeRepoCommitQuery(ctx, repoID, sha) + sess.Select("max( `index` ) as `index`").GroupBy("context_hash").OrderBy("max( `index` ) desc") if !listOptions.IsListAll() { - sess = db.SetSessionPagination(sess, &listOptions) + db.SetSessionPagination(sess, &listOptions) } if err := sess.Find(&indices); err != nil { return nil, err @@ -372,7 +369,7 @@ func GetLatestCommitStatusForPairs(ctx context.Context, repoSHAs []RepoSHA) (map results := make([]result, 0, len(repoSHAs)) - getBase := func() *xorm.Session { + getBase := func() db.Session { return db.GetEngine(ctx).Table(&CommitStatus{}) } @@ -425,7 +422,7 @@ func GetLatestCommitStatusForRepoCommitIDs(ctx context.Context, repoID int64, co SHA string } - getBase := func() *xorm.Session { + getBase := func() db.Session { return db.GetEngine(ctx).Table(&CommitStatus{}).Where("repo_id = ?", repoID) } results := make([]result, 0, len(commitIDs)) diff --git a/models/git/protected_branch.go b/models/git/protected_branch.go index f242f94f7b7..32014615e6e 100644 --- a/models/git/protected_branch.go +++ b/models/git/protected_branch.go @@ -43,6 +43,9 @@ type ProtectedBranch struct { WhitelistDeployKeys bool `xorm:"NOT NULL DEFAULT false"` MergeWhitelistUserIDs []int64 `xorm:"JSON TEXT"` MergeWhitelistTeamIDs []int64 `xorm:"JSON TEXT"` + EnableBypassAllowlist bool `xorm:"NOT NULL DEFAULT false"` + BypassAllowlistUserIDs []int64 `xorm:"JSON TEXT"` + BypassAllowlistTeamIDs []int64 `xorm:"JSON TEXT"` CanForcePush bool `xorm:"NOT NULL DEFAULT false"` EnableForcePushAllowlist bool `xorm:"NOT NULL DEFAULT false"` ForcePushAllowlistUserIDs []int64 `xorm:"JSON TEXT"` @@ -204,6 +207,29 @@ func IsUserMergeWhitelisted(ctx context.Context, protectBranch *ProtectedBranch, return in } +// CanBypassBranchProtection reports whether the user can bypass branch protection checks (status checks, approvals, protected files) +// Either a repo admin (when not blocked) or a user/team on the bypass allowlist can bypass. +func CanBypassBranchProtection(ctx context.Context, protectBranch *ProtectedBranch, user *user_model.User, isRepoAdmin bool) bool { + if isRepoAdmin && !protectBranch.BlockAdminMergeOverride { + return true + } + if !protectBranch.EnableBypassAllowlist { + return false + } + if slices.Contains(protectBranch.BypassAllowlistUserIDs, user.ID) { + return true + } + if len(protectBranch.BypassAllowlistTeamIDs) == 0 { + return false + } + in, err := organization.IsUserInTeams(ctx, user.ID, protectBranch.BypassAllowlistTeamIDs) + if err != nil { + log.Error("IsUserInTeams failed: userID=%d, repoID=%d, allowlistTeamIDs=%v, err=%v", user.ID, protectBranch.RepoID, protectBranch.BypassAllowlistTeamIDs, err) + return false + } + return in +} + // IsUserOfficialReviewer check if user is official reviewer for the branch (counts towards required approvals) func IsUserOfficialReviewer(ctx context.Context, protectBranch *ProtectedBranch, user *user_model.User) (bool, error) { repo, err := repo_model.GetRepositoryByID(ctx, protectBranch.RepoID) @@ -347,6 +373,9 @@ type WhitelistOptions struct { ApprovalsUserIDs []int64 ApprovalsTeamIDs []int64 + + BypassUserIDs []int64 + BypassTeamIDs []int64 } // UpdateProtectBranch saves branch protection options of repository. @@ -387,6 +416,12 @@ func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, prote } protectBranch.ApprovalsWhitelistUserIDs = whitelist + whitelist, err = updateUserWhitelist(ctx, repo, protectBranch.BypassAllowlistUserIDs, opts.BypassUserIDs) + if err != nil { + return err + } + protectBranch.BypassAllowlistUserIDs = whitelist + // if the repo is in an organization whitelist, err = updateTeamWhitelist(ctx, repo, protectBranch.WhitelistTeamIDs, opts.TeamIDs) if err != nil { @@ -412,6 +447,12 @@ func UpdateProtectBranch(ctx context.Context, repo *repo_model.Repository, prote } protectBranch.ApprovalsWhitelistTeamIDs = whitelist + whitelist, err = updateTeamWhitelist(ctx, repo, protectBranch.BypassAllowlistTeamIDs, opts.BypassTeamIDs) + if err != nil { + return err + } + protectBranch.BypassAllowlistTeamIDs = whitelist + // Looks like it's a new rule if protectBranch.ID == 0 { // as it's a new rule and if priority was not set, we need to calc it. diff --git a/models/git/protected_branch_test.go b/models/git/protected_branch_test.go index 3aa1d7daa8a..043e24cbe8d 100644 --- a/models/git/protected_branch_test.go +++ b/models/git/protected_branch_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" + user_model "code.gitea.io/gitea/models/user" "github.com/stretchr/testify/assert" ) @@ -153,3 +154,51 @@ func TestNewProtectBranchPriority(t *testing.T) { assert.NoError(t, err) assert.Equal(t, int64(2), savedPB2.Priority) } + +func TestCanBypassBranchProtection(t *testing.T) { + assert.NoError(t, unittest.PrepareTestDatabase()) + + user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}) // not in team 1 + teamMember := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) + + pb := &ProtectedBranch{ + EnableBypassAllowlist: true, + BypassAllowlistUserIDs: []int64{user.ID}, + } + + testBypass := func(t *testing.T, expected bool, pb *ProtectedBranch, doer *user_model.User, isAdmin bool) { + assert.Equal(t, expected, CanBypassBranchProtection(t.Context(), pb, doer, isAdmin)) + } + // User bypasses via explicit allowlist. + testBypass(t, true, pb, user, false) + + // Non-admin cannot bypass when allowlist is disabled. + pb.EnableBypassAllowlist = false + testBypass(t, false, pb, user, false) + + // Repo admin can bypass independently of allowlist when not blocked. + testBypass(t, true, pb, user, true) + + // Admin override block still allows bypass for allowlisted users. + pb.EnableBypassAllowlist = true + pb.BlockAdminMergeOverride = true + testBypass(t, true, pb, user, false) + + // admin cannot bypass without allowlist membership. + pb.BypassAllowlistUserIDs = nil + testBypass(t, false, pb, user, true) + + // admin can bypass when allowlisted. + pb.BypassAllowlistUserIDs = []int64{user.ID} + testBypass(t, true, pb, user, true) + + // User bypasses via team allowlist membership. + pb.EnableBypassAllowlist = true + pb.BlockAdminMergeOverride = false + pb.BypassAllowlistUserIDs = nil + pb.BypassAllowlistTeamIDs = []int64{1} // team 1 contains user 2 in test fixtures + testBypass(t, true, pb, teamMember, false) + + // User does not bypass when not in allowlisted teams. + testBypass(t, false, pb, user, false) +} diff --git a/models/issues/comment.go b/models/issues/comment.go index acfc07ff220..bb4a38a51ba 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -1124,7 +1124,7 @@ func FindComments(ctx context.Context, opts *FindCommentsOptions) (CommentList, } if opts.Page > 0 { - sess = db.SetSessionPagination(sess, opts) + db.SetSessionPagination(sess, opts) } // WARNING: If you change this order you will need to fix createCodeComment diff --git a/models/issues/issue.go b/models/issues/issue.go index 345b36a82fa..6765defa0c5 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -682,7 +682,7 @@ func (issue *Issue) BlockedByDependencies(ctx context.Context, opts db.ListOptio // sort by repo id then created date, with the issues of the same repo at the beginning of the list OrderBy("CASE WHEN issue.repo_id = ? THEN 0 ELSE issue.repo_id END, issue.created_unix DESC", issue.RepoID) if opts.Page > 0 { - sess = db.SetSessionPagination(sess, &opts) + db.SetSessionPagination(sess, &opts) } total, err = sess.FindAndCount(&issueDeps) diff --git a/models/issues/issue_search.go b/models/issues/issue_search.go index f905e629e38..0a9d5d93d53 100644 --- a/models/issues/issue_search.go +++ b/models/issues/issue_search.go @@ -19,7 +19,6 @@ import ( "code.gitea.io/gitea/modules/util" "xorm.io/builder" - "xorm.io/xorm" ) const ScopeSortPrefix = "scope-" @@ -71,7 +70,7 @@ func (o *IssuesOptions) Copy(edit ...func(options *IssuesOptions)) *IssuesOption // applySorts sort an issues-related session based on the provided // sortType string -func applySorts(sess *xorm.Session, sortType string, priorityRepoID int64) { +func applySorts(sess db.Session, sortType string, priorityRepoID int64) { // Since this sortType is dynamically created, it has to be treated specially. if after, ok := strings.CutPrefix(sortType, ScopeSortPrefix); ok { scope := after @@ -129,7 +128,7 @@ func applySorts(sess *xorm.Session, sortType string, priorityRepoID int64) { } } -func applyLimit(sess *xorm.Session, opts *IssuesOptions) { +func applyLimit(sess db.Session, opts *IssuesOptions) { if opts.Paginator == nil || opts.Paginator.IsListAll() { return } @@ -141,7 +140,7 @@ func applyLimit(sess *xorm.Session, opts *IssuesOptions) { sess.Limit(opts.Paginator.PageSize, start) } -func applyLabelsCondition(sess *xorm.Session, opts *IssuesOptions) { +func applyLabelsCondition(sess db.Session, opts *IssuesOptions) { if len(opts.LabelIDs) > 0 { if opts.LabelIDs[0] == 0 { sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_label)") @@ -182,7 +181,7 @@ func applyLabelsCondition(sess *xorm.Session, opts *IssuesOptions) { } } -func applyMilestoneCondition(sess *xorm.Session, opts *IssuesOptions) { +func applyMilestoneCondition(sess db.Session, opts *IssuesOptions) { if len(opts.MilestoneIDs) == 1 && opts.MilestoneIDs[0] == db.NoConditionID { sess.And("issue.milestone_id = 0") } else if len(opts.MilestoneIDs) > 0 { @@ -197,7 +196,7 @@ func applyMilestoneCondition(sess *xorm.Session, opts *IssuesOptions) { } } -func applyProjectCondition(sess *xorm.Session, opts *IssuesOptions) { +func applyProjectCondition(sess db.Session, opts *IssuesOptions) { projectIDs := util.SliceRemoveAll(opts.ProjectIDs, 0) if len(projectIDs) == 1 && projectIDs[0] == db.NoConditionID { // show those that are in no project sess.And(builder.NotIn("issue.id", builder.Select("issue_id").From("project_issue"))) @@ -211,7 +210,7 @@ func applyProjectCondition(sess *xorm.Session, opts *IssuesOptions) { // do not need to apply any condition } -func applyRepoConditions(sess *xorm.Session, opts *IssuesOptions) { +func applyRepoConditions(sess db.Session, opts *IssuesOptions) { if len(opts.RepoIDs) == 1 { opts.RepoCond = builder.Eq{"issue.repo_id": opts.RepoIDs[0]} } else if len(opts.RepoIDs) > 1 { @@ -228,7 +227,7 @@ func applyRepoConditions(sess *xorm.Session, opts *IssuesOptions) { } } -func applyConditions(sess *xorm.Session, opts *IssuesOptions) { +func applyConditions(sess db.Session, opts *IssuesOptions) { if len(opts.IssueIDs) > 0 { sess.In("issue.id", opts.IssueIDs) } @@ -362,7 +361,7 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, owner *user_mod return cond } -func applyAssigneeCondition(sess *xorm.Session, assigneeID string) { +func applyAssigneeCondition(sess db.Session, assigneeID string) { // old logic: 0 is also treated as "not filtering assignee", because the "assignee" was read as FormInt64 if assigneeID == "(none)" { sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)") @@ -374,7 +373,7 @@ func applyAssigneeCondition(sess *xorm.Session, assigneeID string) { } } -func applyPosterCondition(sess *xorm.Session, posterID string) { +func applyPosterCondition(sess db.Session, posterID string) { // Actually every issue has a poster. // The "(none)" is for internal usage only: when doer tries to search non-existing user as poster, use "(none)" to return empty result. if posterID == "(none)" { @@ -384,13 +383,13 @@ func applyPosterCondition(sess *xorm.Session, posterID string) { } } -func applyMentionedCondition(sess *xorm.Session, mentionedID int64) { +func applyMentionedCondition(sess db.Session, mentionedID int64) { sess.Join("INNER", "issue_user", "issue.id = issue_user.issue_id"). And("issue_user.is_mentioned = ?", true). And("issue_user.uid = ?", mentionedID) } -func applyReviewRequestedCondition(sess *xorm.Session, reviewRequestedID int64) { +func applyReviewRequestedCondition(sess db.Session, reviewRequestedID int64) { existInTeamQuery := builder.Select("team_user.team_id"). From("team_user"). Where(builder.Eq{"team_user.uid": reviewRequestedID}) @@ -415,7 +414,7 @@ func applyReviewRequestedCondition(sess *xorm.Session, reviewRequestedID int64) And(builder.In("issue.id", subQuery)) } -func applyReviewedCondition(sess *xorm.Session, reviewedID int64) { +func applyReviewedCondition(sess db.Session, reviewedID int64) { // Query for pull requests where you are a reviewer or commenter, excluding // any pull requests already returned by the review requested filter. notPoster := builder.Neq{"issue.poster_id": reviewedID} @@ -445,7 +444,7 @@ func applyReviewedCondition(sess *xorm.Session, reviewedID int64) { sess.And(notPoster, builder.Or(reviewed, commented)) } -func applySubscribedCondition(sess *xorm.Session, subscriberID int64) { +func applySubscribedCondition(sess db.Session, subscriberID int64) { sess.And( builder. NotIn("issue.id", diff --git a/models/issues/issue_stats.go b/models/issues/issue_stats.go index adedaa3d3a0..027f0f2bd81 100644 --- a/models/issues/issue_stats.go +++ b/models/issues/issue_stats.go @@ -10,7 +10,6 @@ import ( "code.gitea.io/gitea/models/db" "xorm.io/builder" - "xorm.io/xorm" ) // IssueStats represents issue statistic information. @@ -35,12 +34,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) { @@ -131,7 +128,7 @@ func getIssueStatsChunk(ctx context.Context, opts *IssuesOptions, issueIDs []int return stats, err } -func applyIssuesOptions(sess *xorm.Session, opts *IssuesOptions, issueIDs []int64) *xorm.Session { +func applyIssuesOptions(sess db.Session, opts *IssuesOptions, issueIDs []int64) db.Session { if len(opts.RepoIDs) > 1 { sess.In("issue.repo_id", opts.RepoIDs) } else if len(opts.RepoIDs) == 1 { diff --git a/models/issues/issue_test.go b/models/issues/issue_test.go index b935c0fffdb..99a09de0ec5 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/issues/issue_watch.go b/models/issues/issue_watch.go index f384e086e56..8f8d155436e 100644 --- a/models/issues/issue_watch.go +++ b/models/issues/issue_watch.go @@ -106,7 +106,7 @@ func GetIssueWatchers(ctx context.Context, issueID int64, listOptions db.ListOpt Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id") if listOptions.Page > 0 { - sess = db.SetSessionPagination(sess, &listOptions) + db.SetSessionPagination(sess, &listOptions) watches := make([]*IssueWatch, 0, listOptions.PageSize) return watches, sess.Find(&watches) } diff --git a/models/issues/label.go b/models/issues/label.go index 25d6f1303e8..c120f7530b4 100644 --- a/models/issues/label.go +++ b/models/issues/label.go @@ -396,7 +396,7 @@ func GetLabelsByRepoID(ctx context.Context, repoID int64, sortType string, listO } if listOptions.Page > 0 { - sess = db.SetSessionPagination(sess, &listOptions) + db.SetSessionPagination(sess, &listOptions) } return labels, sess.Find(&labels) @@ -471,7 +471,7 @@ func GetLabelsByOrgID(ctx context.Context, orgID int64, sortType string, listOpt } if listOptions.Page > 0 { - sess = db.SetSessionPagination(sess, &listOptions) + db.SetSessionPagination(sess, &listOptions) } return labels, sess.Find(&labels) diff --git a/models/issues/pull_list.go b/models/issues/pull_list.go index 6a6abca9709..c7a2eb6c484 100644 --- a/models/issues/pull_list.go +++ b/models/issues/pull_list.go @@ -18,7 +18,6 @@ import ( "code.gitea.io/gitea/modules/util" "xorm.io/builder" - "xorm.io/xorm" ) // PullRequestsOptions holds the options for PRs @@ -32,7 +31,7 @@ type PullRequestsOptions struct { BaseBranch string } -func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) *xorm.Session { +func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) db.Session { sess := db.GetEngine(ctx).Where("pull_request.base_repo_id=?", baseRepoID) if opts.BaseBranch != "" { diff --git a/models/issues/reaction.go b/models/issues/reaction.go index 3b5ad6d7ab9..551f8f09d7d 100644 --- a/models/issues/reaction.go +++ b/models/issues/reaction.go @@ -165,7 +165,7 @@ func FindReactions(ctx context.Context, opts FindReactionsOptions) (ReactionList In("reaction.`type`", setting.UI.Reactions). Asc("reaction.issue_id", "reaction.comment_id", "reaction.created_unix", "reaction.id") if opts.Page > 0 { - sess = db.SetSessionPagination(sess, &opts) + db.SetSessionPagination(sess, &opts) reactions := make([]*Reaction, 0, opts.PageSize) count, err := sess.FindAndCount(&reactions) diff --git a/models/issues/review_list.go b/models/issues/review_list.go index d0430cd06d3..80703778a55 100644 --- a/models/issues/review_list.go +++ b/models/issues/review_list.go @@ -121,7 +121,7 @@ func FindReviews(ctx context.Context, opts FindReviewOptions) (ReviewList, error reviews := make([]*Review, 0, 10) sess := db.GetEngine(ctx).Where(opts.toCond()) if opts.Page > 0 && !opts.IsListAll() { - sess = db.SetSessionPagination(sess, &opts) + db.SetSessionPagination(sess, &opts) } return reviews, sess. Asc("created_unix"). @@ -135,7 +135,7 @@ func FindLatestReviews(ctx context.Context, opts FindReviewOptions) (ReviewList, cond := opts.toCond() sess := db.GetEngine(ctx).Where(cond) if opts.Page > 0 { - sess = db.SetSessionPagination(sess, &opts) + db.SetSessionPagination(sess, &opts) } sess.In("id", builder. diff --git a/models/issues/stopwatch.go b/models/issues/stopwatch.go index f119951b091..66e03479bcf 100644 --- a/models/issues/stopwatch.go +++ b/models/issues/stopwatch.go @@ -77,7 +77,7 @@ func GetUserStopwatches(ctx context.Context, userID int64, listOptions db.ListOp sws := make([]*Stopwatch, 0, 8) sess := db.GetEngine(ctx).Where("stopwatch.user_id = ?", userID) if listOptions.Page > 0 { - sess = db.SetSessionPagination(sess, &listOptions) + db.SetSessionPagination(sess, &listOptions) } err := sess.Find(&sws) diff --git a/models/issues/tracked_time.go b/models/issues/tracked_time.go index 0b5c341f1f2..9df868c89a6 100644 --- a/models/issues/tracked_time.go +++ b/models/issues/tracked_time.go @@ -16,7 +16,6 @@ import ( "code.gitea.io/gitea/modules/util" "xorm.io/builder" - "xorm.io/xorm" ) // TrackedTime represents a time that was spent for a specific issue. @@ -140,7 +139,7 @@ func (opts *FindTrackedTimesOptions) toSession(e db.Engine) db.Engine { sess = sess.Where(opts.ToConds()) if opts.Page > 0 { - sess = db.SetSessionPagination(sess, opts) + db.SetSessionPagination(sess, opts) } return sess @@ -344,7 +343,7 @@ func GetIssueTotalTrackedTime(ctx context.Context, opts *IssuesOptions, isClosed } func getIssueTotalTrackedTimeChunk(ctx context.Context, opts *IssuesOptions, isClosed optional.Option[bool], issueIDs []int64) (int64, error) { - sumSession := func(opts *IssuesOptions, issueIDs []int64) *xorm.Session { + sumSession := func(opts *IssuesOptions, issueIDs []int64) db.Session { sess := db.GetEngine(ctx). Table("tracked_time"). Where("tracked_time.deleted = ?", false). @@ -359,7 +358,7 @@ func getIssueTotalTrackedTimeChunk(ctx context.Context, opts *IssuesOptions, isC session := sumSession(opts, issueIDs) if isClosed.Has() { - session = session.And("issue.is_closed = ?", isClosed.Value()) + session.And("issue.is_closed = ?", isClosed.Value()) } return session.SumInt(new(trackedTime), "tracked_time.time") } diff --git a/models/migrations/base/db.go b/models/migrations/base/db.go index 16048c2073b..ae33daf1afe 100644 --- a/models/migrations/base/db.go +++ b/models/migrations/base/db.go @@ -11,17 +11,17 @@ import ( "regexp" "strings" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) // RecreateTables will recreate the tables for the provided beans using the newly provided bean definition and move all data to that new table // WARNING: YOU MUST PROVIDE THE FULL BEAN DEFINITION -func RecreateTables(beans ...any) func(*xorm.Engine) error { - return func(x *xorm.Engine) error { +func RecreateTables(beans ...any) func(db.EngineMigration) error { + return func(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { @@ -41,7 +41,7 @@ func RecreateTables(beans ...any) func(*xorm.Engine) error { // RecreateTable will recreate the table using the newly provided bean definition and move all data to that new table // WARNING: YOU MUST PROVIDE THE FULL BEAN DEFINITION // WARNING: YOU MUST COMMIT THE SESSION AT THE END -func RecreateTable(sess *xorm.Session, bean any) error { +func RecreateTable(sess db.Session, bean any) error { // TODO: This will not work if there are foreign keys tableName := sess.Engine().TableName(bean) @@ -304,7 +304,7 @@ func RecreateTable(sess *xorm.Session, bean any) error { } // WARNING: YOU MUST COMMIT THE SESSION AT THE END -func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...string) (err error) { +func DropTableColumns(sess db.Session, tableName string, columnNames ...string) (err error) { if tableName == "" || len(columnNames) == 0 { return nil } @@ -474,7 +474,7 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin } // ModifyColumn will modify column's type or other property. SQLITE is not supported -func ModifyColumn(x *xorm.Engine, tableName string, col *schemas.Column) error { +func ModifyColumn(x db.EngineMigration, tableName string, col *schemas.Column) error { var indexes map[string]*schemas.Index var err error // MSSQL have to remove index at first, otherwise alter column will fail diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 1b856ff5065..df0fb8fb172 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/v1_10" "code.gitea.io/gitea/models/migrations/v1_11" "code.gitea.io/gitea/models/migrations/v1_12" @@ -35,7 +36,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "xorm.io/xorm" "xorm.io/xorm/names" ) @@ -44,23 +44,23 @@ const minDBVersion = 70 // Gitea 1.5.3 type migration struct { idNumber int64 // DB version is "the last migration's idNumber" + 1 description string - migrate func(context.Context, *xorm.Engine) error + migrate func(context.Context, db.EngineMigration) error } // newMigration creates a new migration -func newMigration[T func(*xorm.Engine) error | func(context.Context, *xorm.Engine) error](idNumber int64, desc string, fn T) *migration { +func newMigration[T func(db.EngineMigration) error | func(context.Context, db.EngineMigration) error](idNumber int64, desc string, fn T) *migration { m := &migration{idNumber: idNumber, description: desc} var ok bool - if m.migrate, ok = any(fn).(func(context.Context, *xorm.Engine) error); !ok { - m.migrate = func(ctx context.Context, x *xorm.Engine) error { - return any(fn).(func(*xorm.Engine) error)(x) + if m.migrate, ok = any(fn).(func(context.Context, db.EngineMigration) error); !ok { + m.migrate = func(ctx context.Context, x db.EngineMigration) error { + return any(fn).(func(db.EngineMigration) error)(x) } } return m } // Migrate executes the migration -func (m *migration) Migrate(ctx context.Context, x *xorm.Engine) error { +func (m *migration) Migrate(ctx context.Context, x db.EngineMigration) error { return m.migrate(ctx, x) } @@ -71,7 +71,7 @@ type Version struct { } // Use noopMigration when there is a migration that has been no-oped -var noopMigration = func(_ *xorm.Engine) error { return nil } +var noopMigration = func(_ db.EngineMigration) error { return nil } var preparedMigrations []*migration @@ -409,13 +409,16 @@ func prepareMigrationTasks() []*migration { // Gitea 1.26.0 ends at migration ID number 330 (database version 331) newMigration(331, "Add ActionRunAttempt model and related action fields", v1_27.AddActionRunAttemptModel), - newMigration(332, "Add support for matrix actions evaluation", v1_27.AddMatrixEvaluationColumnsToActionRunJob), + newMigration(332, "Add last_sync_unix to mirror", v1_27.AddLastSyncUnixToMirror), + newMigration(333, "Add bypass allowlist to branch protection", v1_27.AddBranchProtectionBypassAllowlist), + newMigration(334, "Add cancelling support to action runners", v1_27.AddCancellingSupportToActionRunner), + newMigration(335, "Add support for matrix actions evaluation", v1_27.AddMatrixEvaluationColumnsToActionRunJob), } return preparedMigrations } // GetCurrentDBVersion returns the current db version -func GetCurrentDBVersion(x *xorm.Engine) (int64, error) { +func GetCurrentDBVersion(x db.EngineMigration) (int64, error) { if err := x.Sync(new(Version)); err != nil { return -1, fmt.Errorf("sync: %w", err) } @@ -448,7 +451,7 @@ func ExpectedDBVersion() int64 { } // EnsureUpToDate will check if the db is at the correct version -func EnsureUpToDate(ctx context.Context, x *xorm.Engine) error { +func EnsureUpToDate(ctx context.Context, x db.EngineMigration) error { currentDB, err := GetCurrentDBVersion(x) if err != nil { return err @@ -480,7 +483,7 @@ func migrationIDNumberToDBVersion(idNumber int64) int64 { } // Migrate database to current version -func Migrate(ctx context.Context, x *xorm.Engine) error { +func Migrate(ctx context.Context, x db.EngineMigration) error { migrations := prepareMigrationTasks() maxDBVer := calcDBVersion(migrations) @@ -499,7 +502,7 @@ func Migrate(ctx context.Context, x *xorm.Engine) error { // XORM model framework will create all tables when initializing. currentVersion.ID = 0 currentVersion.Version = maxDBVer - if _, err = x.InsertOne(currentVersion); err != nil { + if _, err = x.Insert(currentVersion); err != nil { return fmt.Errorf("insert: %w", err) } } diff --git a/models/migrations/migrationtest/tests.go b/models/migrations/migrationtest/tests.go index ed8bb16ef1a..be2557a9029 100644 --- a/models/migrations/migrationtest/tests.go +++ b/models/migrations/migrationtest/tests.go @@ -16,7 +16,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) @@ -24,7 +23,7 @@ import ( // Provide models to be sync'd with the database - in particular any models you expect fixtures to be loaded from. // // fixtures in `models/migrations/fixtures/` will be loaded automatically -func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, func()) { +func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (db.EngineMigration, func()) { t.Helper() ourSkip := 2 ourSkip += skip @@ -72,7 +71,7 @@ func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, fu if err := unittest.InitFixtures( unittest.FixturesOptions{ Dir: fixturesDir, - }, x); err != nil { + }); err != nil { t.Errorf("error whilst initializing fixtures from %s: %v", fixturesDir, err) return x, deferFn } @@ -89,7 +88,7 @@ func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, fu return x, deferFn } -func LoadTableSchemasMap(t *testing.T, x *xorm.Engine) map[string]*schemas.Table { +func LoadTableSchemasMap(t *testing.T, x db.EngineMigration) map[string]*schemas.Table { tables, err := x.DBMetas() require.NoError(t, err) tableMap := make(map[string]*schemas.Table) @@ -110,6 +109,7 @@ func mainTest(m *testing.M) int { if err = git.InitFull(); err != nil { return testlogger.MainErrorf("Unable to InitFull: %v", err) } + setting.Database.SlowQueryThreshold = 0 setting.LoadDBSetting() setting.InitLoggersForTest() return m.Run() diff --git a/models/migrations/v1_10/v100.go b/models/migrations/v1_10/v100.go index 1742bea2963..db581ca1751 100644 --- a/models/migrations/v1_10/v100.go +++ b/models/migrations/v1_10/v100.go @@ -8,10 +8,10 @@ import ( "strings" "time" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func UpdateMigrationServiceTypes(x *xorm.Engine) error { +func UpdateMigrationServiceTypes(x db.EngineMigration) error { type Repository struct { ID int64 OriginalServiceType int `xorm:"index default(0)"` diff --git a/models/migrations/v1_10/v101.go b/models/migrations/v1_10/v101.go index 6c8dfe24860..221d151ff6a 100644 --- a/models/migrations/v1_10/v101.go +++ b/models/migrations/v1_10/v101.go @@ -3,11 +3,9 @@ package v1_10 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func ChangeSomeColumnsLengthOfExternalLoginUser(x *xorm.Engine) error { +func ChangeSomeColumnsLengthOfExternalLoginUser(x db.EngineMigration) error { type ExternalLoginUser struct { AccessToken string `xorm:"TEXT"` AccessTokenSecret string `xorm:"TEXT"` diff --git a/models/migrations/v1_10/v88.go b/models/migrations/v1_10/v88.go index eb8e81c19ee..ae129d8e666 100644 --- a/models/migrations/v1_10/v88.go +++ b/models/migrations/v1_10/v88.go @@ -7,14 +7,14 @@ import ( "crypto/sha1" "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) func hashContext(context string) string { return fmt.Sprintf("%x", sha1.Sum([]byte(context))) } -func AddCommitStatusContext(x *xorm.Engine) error { +func AddCommitStatusContext(x db.EngineMigration) error { type CommitStatus struct { ID int64 `xorm:"pk autoincr"` ContextHash string `xorm:"char(40) index"` diff --git a/models/migrations/v1_10/v89.go b/models/migrations/v1_10/v89.go index 0df2a6e17b6..0f9f5a01ea3 100644 --- a/models/migrations/v1_10/v89.go +++ b/models/migrations/v1_10/v89.go @@ -3,9 +3,9 @@ package v1_10 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddOriginalMigrationInfo(x *xorm.Engine) error { +func AddOriginalMigrationInfo(x db.EngineMigration) error { // Issue see models/issue.go type Issue struct { OriginalAuthor string diff --git a/models/migrations/v1_10/v90.go b/models/migrations/v1_10/v90.go index 5521a97e327..b8003ea5e0b 100644 --- a/models/migrations/v1_10/v90.go +++ b/models/migrations/v1_10/v90.go @@ -3,9 +3,9 @@ package v1_10 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func ChangeSomeColumnsLengthOfRepo(x *xorm.Engine) error { +func ChangeSomeColumnsLengthOfRepo(x db.EngineMigration) error { type Repository struct { ID int64 `xorm:"pk autoincr"` Description string `xorm:"TEXT"` diff --git a/models/migrations/v1_10/v91.go b/models/migrations/v1_10/v91.go index 08db6c27421..825c0cf3362 100644 --- a/models/migrations/v1_10/v91.go +++ b/models/migrations/v1_10/v91.go @@ -3,9 +3,9 @@ package v1_10 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddIndexOnRepositoryAndComment(x *xorm.Engine) error { +func AddIndexOnRepositoryAndComment(x db.EngineMigration) error { type Repository struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"index"` diff --git a/models/migrations/v1_10/v92.go b/models/migrations/v1_10/v92.go index b6c04a92348..7fb6d209f13 100644 --- a/models/migrations/v1_10/v92.go +++ b/models/migrations/v1_10/v92.go @@ -4,11 +4,12 @@ package v1_10 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/builder" - "xorm.io/xorm" ) -func RemoveLingeringIndexStatus(x *xorm.Engine) error { +func RemoveLingeringIndexStatus(x db.EngineMigration) error { _, err := x.Exec(builder.Delete(builder.NotIn("`repo_id`", builder.Select("`id`").From("`repository`"))).From("`repo_indexer_status`")) return err } diff --git a/models/migrations/v1_10/v93.go b/models/migrations/v1_10/v93.go index c131be9a8d8..5803722c708 100644 --- a/models/migrations/v1_10/v93.go +++ b/models/migrations/v1_10/v93.go @@ -3,9 +3,9 @@ package v1_10 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddEmailNotificationEnabledToUser(x *xorm.Engine) error { +func AddEmailNotificationEnabledToUser(x db.EngineMigration) error { // User see models/user.go type User struct { EmailNotificationsPreference string `xorm:"VARCHAR(20) NOT NULL DEFAULT 'enabled'"` diff --git a/models/migrations/v1_10/v94.go b/models/migrations/v1_10/v94.go index 13b7d7b303e..df2d016fe05 100644 --- a/models/migrations/v1_10/v94.go +++ b/models/migrations/v1_10/v94.go @@ -3,9 +3,9 @@ package v1_10 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddStatusCheckColumnsForProtectedBranches(x *xorm.Engine) error { +func AddStatusCheckColumnsForProtectedBranches(x db.EngineMigration) error { type ProtectedBranch struct { EnableStatusCheck bool `xorm:"NOT NULL DEFAULT false"` StatusCheckContexts []string `xorm:"JSON TEXT"` diff --git a/models/migrations/v1_10/v95.go b/models/migrations/v1_10/v95.go index 86b52026bfa..2c8bc75e912 100644 --- a/models/migrations/v1_10/v95.go +++ b/models/migrations/v1_10/v95.go @@ -3,9 +3,9 @@ package v1_10 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddCrossReferenceColumns(x *xorm.Engine) error { +func AddCrossReferenceColumns(x db.EngineMigration) error { // Comment see models/comment.go type Comment struct { RefRepoID int64 `xorm:"index"` diff --git a/models/migrations/v1_10/v96.go b/models/migrations/v1_10/v96.go index ca35a169c4a..9950f30dec4 100644 --- a/models/migrations/v1_10/v96.go +++ b/models/migrations/v1_10/v96.go @@ -6,13 +6,12 @@ package v1_10 import ( "path/filepath" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - - "xorm.io/xorm" ) -func DeleteOrphanedAttachments(x *xorm.Engine) error { +func DeleteOrphanedAttachments(x db.EngineMigration) error { type Attachment struct { ID int64 `xorm:"pk autoincr"` UUID string `xorm:"uuid UNIQUE"` diff --git a/models/migrations/v1_10/v97.go b/models/migrations/v1_10/v97.go index 5872bb63e57..6ccac1299fe 100644 --- a/models/migrations/v1_10/v97.go +++ b/models/migrations/v1_10/v97.go @@ -3,9 +3,9 @@ package v1_10 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddRepoAdminChangeTeamAccessColumnForUser(x *xorm.Engine) error { +func AddRepoAdminChangeTeamAccessColumnForUser(x db.EngineMigration) error { type User struct { RepoAdminChangeTeamAccess bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_10/v98.go b/models/migrations/v1_10/v98.go index d21c3264595..427c8da5346 100644 --- a/models/migrations/v1_10/v98.go +++ b/models/migrations/v1_10/v98.go @@ -3,9 +3,9 @@ package v1_10 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddOriginalAuthorOnMigratedReleases(x *xorm.Engine) error { +func AddOriginalAuthorOnMigratedReleases(x db.EngineMigration) error { type Release struct { ID int64 OriginalAuthor string diff --git a/models/migrations/v1_10/v99.go b/models/migrations/v1_10/v99.go index 223c188057b..e0b14f90f67 100644 --- a/models/migrations/v1_10/v99.go +++ b/models/migrations/v1_10/v99.go @@ -4,12 +4,11 @@ package v1_10 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddTaskTable(x *xorm.Engine) error { +func AddTaskTable(x db.EngineMigration) error { // TaskType defines task type type TaskType int diff --git a/models/migrations/v1_11/v102.go b/models/migrations/v1_11/v102.go index e52290afb0a..b66943a10cb 100644 --- a/models/migrations/v1_11/v102.go +++ b/models/migrations/v1_11/v102.go @@ -4,12 +4,11 @@ package v1_11 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func DropColumnHeadUserNameOnPullRequest(x *xorm.Engine) error { +func DropColumnHeadUserNameOnPullRequest(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { diff --git a/models/migrations/v1_11/v103.go b/models/migrations/v1_11/v103.go index a5157101605..d9beed9c28e 100644 --- a/models/migrations/v1_11/v103.go +++ b/models/migrations/v1_11/v103.go @@ -3,11 +3,9 @@ package v1_11 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddWhitelistDeployKeysToBranches(x *xorm.Engine) error { +func AddWhitelistDeployKeysToBranches(x db.EngineMigration) error { type ProtectedBranch struct { ID int64 WhitelistDeployKeys bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/migrations/v1_11/v104.go b/models/migrations/v1_11/v104.go index 3b0d3c64b2f..19ba7d56b3a 100644 --- a/models/migrations/v1_11/v104.go +++ b/models/migrations/v1_11/v104.go @@ -4,12 +4,11 @@ package v1_11 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func RemoveLabelUneededCols(x *xorm.Engine) error { +func RemoveLabelUneededCols(x db.EngineMigration) error { // Make sure the columns exist before dropping them type Label struct { QueryString string diff --git a/models/migrations/v1_11/v105.go b/models/migrations/v1_11/v105.go index d86973a0f68..93c96bb0985 100644 --- a/models/migrations/v1_11/v105.go +++ b/models/migrations/v1_11/v105.go @@ -3,11 +3,9 @@ package v1_11 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddTeamIncludesAllRepositories(x *xorm.Engine) error { +func AddTeamIncludesAllRepositories(x db.EngineMigration) error { type Team struct { ID int64 `xorm:"pk autoincr"` IncludesAllRepositories bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/migrations/v1_11/v106.go b/models/migrations/v1_11/v106.go index edffe186831..61f5be6c417 100644 --- a/models/migrations/v1_11/v106.go +++ b/models/migrations/v1_11/v106.go @@ -3,9 +3,7 @@ package v1_11 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" // RepoWatchMode specifies what kind of watch the user has on a repository type RepoWatchMode int8 @@ -16,7 +14,7 @@ type Watch struct { Mode RepoWatchMode `xorm:"SMALLINT NOT NULL DEFAULT 1"` } -func AddModeColumnToWatch(x *xorm.Engine) error { +func AddModeColumnToWatch(x db.EngineMigration) error { if err := x.Sync(new(Watch)); err != nil { return err } diff --git a/models/migrations/v1_11/v107.go b/models/migrations/v1_11/v107.go index a158e3bb502..7bdd401d16a 100644 --- a/models/migrations/v1_11/v107.go +++ b/models/migrations/v1_11/v107.go @@ -3,11 +3,9 @@ package v1_11 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddTemplateToRepo(x *xorm.Engine) error { +func AddTemplateToRepo(x db.EngineMigration) error { type Repository struct { IsTemplate bool `xorm:"INDEX NOT NULL DEFAULT false"` TemplateID int64 `xorm:"INDEX"` diff --git a/models/migrations/v1_11/v108.go b/models/migrations/v1_11/v108.go index 8f14504cebf..816206d992d 100644 --- a/models/migrations/v1_11/v108.go +++ b/models/migrations/v1_11/v108.go @@ -3,11 +3,9 @@ package v1_11 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddCommentIDOnNotification(x *xorm.Engine) error { +func AddCommentIDOnNotification(x db.EngineMigration) error { type Notification struct { ID int64 `xorm:"pk autoincr"` CommentID int64 diff --git a/models/migrations/v1_11/v109.go b/models/migrations/v1_11/v109.go index f7616aec7b5..8a30905aceb 100644 --- a/models/migrations/v1_11/v109.go +++ b/models/migrations/v1_11/v109.go @@ -3,11 +3,9 @@ package v1_11 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddCanCreateOrgRepoColumnForTeam(x *xorm.Engine) error { +func AddCanCreateOrgRepoColumnForTeam(x db.EngineMigration) error { type Team struct { CanCreateOrgRepo bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_11/v110.go b/models/migrations/v1_11/v110.go index 512f728c035..6f2c63018f2 100644 --- a/models/migrations/v1_11/v110.go +++ b/models/migrations/v1_11/v110.go @@ -4,11 +4,12 @@ package v1_11 import ( - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" + "xorm.io/xorm/schemas" ) -func ChangeReviewContentToText(x *xorm.Engine) error { +func ChangeReviewContentToText(x db.EngineMigration) error { switch x.Dialect().URI().DBType { case schemas.MYSQL: _, err := x.Exec("ALTER TABLE review MODIFY COLUMN content TEXT") diff --git a/models/migrations/v1_11/v111.go b/models/migrations/v1_11/v111.go index 2634906565e..f2e6e7b74cf 100644 --- a/models/migrations/v1_11/v111.go +++ b/models/migrations/v1_11/v111.go @@ -7,10 +7,10 @@ import ( "fmt" "slices" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error { +func AddBranchProtectionCanPushAndEnableWhitelist(x db.EngineMigration) error { type ProtectedBranch struct { CanPush bool `xorm:"NOT NULL DEFAULT false"` EnableApprovalsWhitelist bool `xorm:"NOT NULL DEFAULT false"` @@ -132,7 +132,7 @@ func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error { } // getUserRepoPermission static function based on issues_model.IsOfficialReviewer at 5d78792385 - getUserRepoPermission := func(sess *xorm.Session, repo *Repository, user *User) (Permission, error) { + getUserRepoPermission := func(sess db.Session, repo *Repository, user *User) (Permission, error) { var perm Permission repoOwner := new(User) @@ -305,7 +305,7 @@ func AddBranchProtectionCanPushAndEnableWhitelist(x *xorm.Engine) error { } // isOfficialReviewer static function based on 5d78792385 - isOfficialReviewer := func(sess *xorm.Session, issueID int64, reviewer *User) (bool, error) { + isOfficialReviewer := func(sess db.Session, issueID int64, reviewer *User) (bool, error) { pr := new(PullRequest) has, err := sess.ID(issueID).Get(pr) if err != nil { diff --git a/models/migrations/v1_11/v112.go b/models/migrations/v1_11/v112.go index fe45cf92221..1c6e72be995 100644 --- a/models/migrations/v1_11/v112.go +++ b/models/migrations/v1_11/v112.go @@ -6,15 +6,15 @@ package v1_11 import ( "path/filepath" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "xorm.io/builder" - "xorm.io/xorm" ) -func RemoveAttachmentMissedRepo(x *xorm.Engine) error { +func RemoveAttachmentMissedRepo(x db.EngineMigration) error { type Attachment struct { UUID string `xorm:"uuid"` } diff --git a/models/migrations/v1_11/v113.go b/models/migrations/v1_11/v113.go index a4d54f66fb4..1a3584be8eb 100644 --- a/models/migrations/v1_11/v113.go +++ b/models/migrations/v1_11/v113.go @@ -6,10 +6,10 @@ package v1_11 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func FeatureChangeTargetBranch(x *xorm.Engine) error { +func FeatureChangeTargetBranch(x db.EngineMigration) error { type Comment struct { OldRef string NewRef string diff --git a/models/migrations/v1_11/v114.go b/models/migrations/v1_11/v114.go index 9467a8a90c9..021e28b4372 100644 --- a/models/migrations/v1_11/v114.go +++ b/models/migrations/v1_11/v114.go @@ -6,10 +6,10 @@ package v1_11 import ( "net/url" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func SanitizeOriginalURL(x *xorm.Engine) error { +func SanitizeOriginalURL(x db.EngineMigration) error { type Repository struct { ID int64 OriginalURL string `xorm:"VARCHAR(2048)"` diff --git a/models/migrations/v1_11/v115.go b/models/migrations/v1_11/v115.go index 5933c0520f6..6c13d89b6b3 100644 --- a/models/migrations/v1_11/v115.go +++ b/models/migrations/v1_11/v115.go @@ -12,15 +12,14 @@ import ( "path/filepath" "time" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" - - "xorm.io/xorm" ) -func RenameExistingUserAvatarName(x *xorm.Engine) error { +func RenameExistingUserAvatarName(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() diff --git a/models/migrations/v1_11/v116.go b/models/migrations/v1_11/v116.go index 729fbad18b8..19a40ede9d8 100644 --- a/models/migrations/v1_11/v116.go +++ b/models/migrations/v1_11/v116.go @@ -3,11 +3,9 @@ package v1_11 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func ExtendTrackedTimes(x *xorm.Engine) error { +func ExtendTrackedTimes(x db.EngineMigration) error { type TrackedTime struct { Time int64 `xorm:"NOT NULL"` Deleted bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/migrations/v1_12/v117.go b/models/migrations/v1_12/v117.go index 73b58ca34b2..b9d240226e8 100644 --- a/models/migrations/v1_12/v117.go +++ b/models/migrations/v1_12/v117.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddBlockOnRejectedReviews(x *xorm.Engine) error { +func AddBlockOnRejectedReviews(x db.EngineMigration) error { type ProtectedBranch struct { BlockOnRejectedReviews bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_12/v118.go b/models/migrations/v1_12/v118.go index e8b4249743d..756b112d00d 100644 --- a/models/migrations/v1_12/v118.go +++ b/models/migrations/v1_12/v118.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddReviewCommitAndStale(x *xorm.Engine) error { +func AddReviewCommitAndStale(x db.EngineMigration) error { type Review struct { CommitID string `xorm:"VARCHAR(40)"` Stale bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/migrations/v1_12/v119.go b/models/migrations/v1_12/v119.go index b4bf29a9359..dfbee84d826 100644 --- a/models/migrations/v1_12/v119.go +++ b/models/migrations/v1_12/v119.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func FixMigratedRepositoryServiceType(x *xorm.Engine) error { +func FixMigratedRepositoryServiceType(x db.EngineMigration) error { // structs.GithubService: // GithubService = 2 _, err := x.Exec("UPDATE repository SET original_service_type = ? WHERE original_url LIKE 'https://github.com/%'", 2) diff --git a/models/migrations/v1_12/v120.go b/models/migrations/v1_12/v120.go index 14d515f5a7f..abec02d313b 100644 --- a/models/migrations/v1_12/v120.go +++ b/models/migrations/v1_12/v120.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddOwnerNameOnRepository(x *xorm.Engine) error { +func AddOwnerNameOnRepository(x db.EngineMigration) error { type Repository struct { OwnerName string } diff --git a/models/migrations/v1_12/v121.go b/models/migrations/v1_12/v121.go index a28ae4e1c9f..4036795fcb2 100644 --- a/models/migrations/v1_12/v121.go +++ b/models/migrations/v1_12/v121.go @@ -3,9 +3,9 @@ package v1_12 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddIsRestricted(x *xorm.Engine) error { +func AddIsRestricted(x db.EngineMigration) error { // User see models/user.go type User struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_12/v122.go b/models/migrations/v1_12/v122.go index bc1b175f6ae..5982dd5662f 100644 --- a/models/migrations/v1_12/v122.go +++ b/models/migrations/v1_12/v122.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddRequireSignedCommits(x *xorm.Engine) error { +func AddRequireSignedCommits(x db.EngineMigration) error { type ProtectedBranch struct { RequireSignedCommits bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_12/v123.go b/models/migrations/v1_12/v123.go index 52b10bb8506..3550b710a77 100644 --- a/models/migrations/v1_12/v123.go +++ b/models/migrations/v1_12/v123.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddReactionOriginals(x *xorm.Engine) error { +func AddReactionOriginals(x db.EngineMigration) error { type Reaction struct { OriginalAuthorID int64 `xorm:"INDEX NOT NULL DEFAULT(0)"` OriginalAuthor string diff --git a/models/migrations/v1_12/v124.go b/models/migrations/v1_12/v124.go index 9a93f436d43..d124918f099 100644 --- a/models/migrations/v1_12/v124.go +++ b/models/migrations/v1_12/v124.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddUserRepoMissingColumns(x *xorm.Engine) error { +func AddUserRepoMissingColumns(x db.EngineMigration) error { type VisibleType int type User struct { PasswdHashAlgo string `xorm:"NOT NULL DEFAULT 'pbkdf2'"` diff --git a/models/migrations/v1_12/v125.go b/models/migrations/v1_12/v125.go index 7f582ecff5e..ce947115994 100644 --- a/models/migrations/v1_12/v125.go +++ b/models/migrations/v1_12/v125.go @@ -6,10 +6,10 @@ package v1_12 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddReviewMigrateInfo(x *xorm.Engine) error { +func AddReviewMigrateInfo(x db.EngineMigration) error { type Review struct { OriginalAuthor string OriginalAuthorID int64 diff --git a/models/migrations/v1_12/v126.go b/models/migrations/v1_12/v126.go index 64fd7f74787..41f816353a8 100644 --- a/models/migrations/v1_12/v126.go +++ b/models/migrations/v1_12/v126.go @@ -4,11 +4,12 @@ package v1_12 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/builder" - "xorm.io/xorm" ) -func FixTopicRepositoryCount(x *xorm.Engine) error { +func FixTopicRepositoryCount(x db.EngineMigration) error { _, err := x.Exec(builder.Delete(builder.NotIn("`repo_id`", builder.Select("`id`").From("`repository`"))).From("`repo_topic`")) if err != nil { return err diff --git a/models/migrations/v1_12/v127.go b/models/migrations/v1_12/v127.go index 9bd78db95e4..82b2db2eb54 100644 --- a/models/migrations/v1_12/v127.go +++ b/models/migrations/v1_12/v127.go @@ -6,12 +6,11 @@ package v1_12 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddLanguageStats(x *xorm.Engine) error { +func AddLanguageStats(x db.EngineMigration) error { // LanguageStat see models/repo_language_stats.go type LanguageStat struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_12/v128.go b/models/migrations/v1_12/v128.go index ff5b12af18f..7f337db8bc4 100644 --- a/models/migrations/v1_12/v128.go +++ b/models/migrations/v1_12/v128.go @@ -11,15 +11,14 @@ import ( "strings" "time" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/git/gitcmd" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func FixMergeBase(ctx context.Context, x *xorm.Engine) error { +func FixMergeBase(ctx context.Context, x db.EngineMigration) error { type Repository struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(s) index"` diff --git a/models/migrations/v1_12/v129.go b/models/migrations/v1_12/v129.go index 3e4d3aca685..90666e5f6fd 100644 --- a/models/migrations/v1_12/v129.go +++ b/models/migrations/v1_12/v129.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func PurgeUnusedDependencies(x *xorm.Engine) error { +func PurgeUnusedDependencies(x db.EngineMigration) error { if _, err := x.Exec("DELETE FROM issue_dependency WHERE issue_id NOT IN (SELECT id FROM issue)"); err != nil { return err } diff --git a/models/migrations/v1_12/v130.go b/models/migrations/v1_12/v130.go index 107bb756fd6..5245df0fe56 100644 --- a/models/migrations/v1_12/v130.go +++ b/models/migrations/v1_12/v130.go @@ -4,13 +4,12 @@ package v1_12 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func ExpandWebhooks(x *xorm.Engine) error { +func ExpandWebhooks(x db.EngineMigration) error { type HookEvents struct { Create bool `json:"create"` Delete bool `json:"delete"` diff --git a/models/migrations/v1_12/v131.go b/models/migrations/v1_12/v131.go index 1266c2f1859..cb7d4f01a68 100644 --- a/models/migrations/v1_12/v131.go +++ b/models/migrations/v1_12/v131.go @@ -6,10 +6,10 @@ package v1_12 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddSystemWebhookColumn(x *xorm.Engine) error { +func AddSystemWebhookColumn(x db.EngineMigration) error { type Webhook struct { IsSystemWebhook bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_12/v132.go b/models/migrations/v1_12/v132.go index 8b1ae6db935..2649fd6457e 100644 --- a/models/migrations/v1_12/v132.go +++ b/models/migrations/v1_12/v132.go @@ -6,10 +6,10 @@ package v1_12 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddBranchProtectionProtectedFilesColumn(x *xorm.Engine) error { +func AddBranchProtectionProtectedFilesColumn(x db.EngineMigration) error { type ProtectedBranch struct { ProtectedFilePatterns string `xorm:"TEXT"` } diff --git a/models/migrations/v1_12/v133.go b/models/migrations/v1_12/v133.go index 69e20597d85..8b7e17cd59a 100644 --- a/models/migrations/v1_12/v133.go +++ b/models/migrations/v1_12/v133.go @@ -3,9 +3,9 @@ package v1_12 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddEmailHashTable(x *xorm.Engine) error { +func AddEmailHashTable(x db.EngineMigration) error { // EmailHash represents a pre-generated hash map type EmailHash struct { Hash string `xorm:"pk varchar(32)"` diff --git a/models/migrations/v1_12/v134.go b/models/migrations/v1_12/v134.go index 98bb8dbda72..e804fd6c8d5 100644 --- a/models/migrations/v1_12/v134.go +++ b/models/migrations/v1_12/v134.go @@ -11,14 +11,13 @@ import ( "strings" "time" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/git/gitcmd" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func RefixMergeBase(ctx context.Context, x *xorm.Engine) error { +func RefixMergeBase(ctx context.Context, x db.EngineMigration) error { type Repository struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(s) index"` diff --git a/models/migrations/v1_12/v135.go b/models/migrations/v1_12/v135.go index 5df0ad7fc4f..e9a0bc7c0b1 100644 --- a/models/migrations/v1_12/v135.go +++ b/models/migrations/v1_12/v135.go @@ -6,10 +6,10 @@ package v1_12 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddOrgIDLabelColumn(x *xorm.Engine) error { +func AddOrgIDLabelColumn(x db.EngineMigration) error { type Label struct { OrgID int64 `xorm:"INDEX"` } diff --git a/models/migrations/v1_12/v136.go b/models/migrations/v1_12/v136.go index 20b892b6cc5..7ab2dba9784 100644 --- a/models/migrations/v1_12/v136.go +++ b/models/migrations/v1_12/v136.go @@ -8,16 +8,15 @@ import ( "math" "time" + "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func AddCommitDivergenceToPulls(x *xorm.Engine) error { +func AddCommitDivergenceToPulls(x db.EngineMigration) error { type Repository struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(s) index"` diff --git a/models/migrations/v1_12/v137.go b/models/migrations/v1_12/v137.go index 9d384834882..0d80b1e5752 100644 --- a/models/migrations/v1_12/v137.go +++ b/models/migrations/v1_12/v137.go @@ -3,11 +3,9 @@ package v1_12 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddBlockOnOutdatedBranch(x *xorm.Engine) error { +func AddBlockOnOutdatedBranch(x db.EngineMigration) error { type ProtectedBranch struct { BlockOnOutdatedBranch bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_12/v138.go b/models/migrations/v1_12/v138.go index 4485adeb2dc..33cb5851dc3 100644 --- a/models/migrations/v1_12/v138.go +++ b/models/migrations/v1_12/v138.go @@ -6,10 +6,10 @@ package v1_12 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddResolveDoerIDCommentColumn(x *xorm.Engine) error { +func AddResolveDoerIDCommentColumn(x db.EngineMigration) error { type Comment struct { ResolveDoerID int64 } diff --git a/models/migrations/v1_12/v139.go b/models/migrations/v1_12/v139.go index a3799841ac5..d0f35dcc456 100644 --- a/models/migrations/v1_12/v139.go +++ b/models/migrations/v1_12/v139.go @@ -4,12 +4,11 @@ package v1_12 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func PrependRefsHeadsToIssueRefs(x *xorm.Engine) error { +func PrependRefsHeadsToIssueRefs(x db.EngineMigration) error { var query string switch { diff --git a/models/migrations/v1_13/v140.go b/models/migrations/v1_13/v140.go index a9a047bca9d..53057048ca5 100644 --- a/models/migrations/v1_13/v140.go +++ b/models/migrations/v1_13/v140.go @@ -6,13 +6,12 @@ package v1_13 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func FixLanguageStatsToSaveSize(x *xorm.Engine) error { +func FixLanguageStatsToSaveSize(x db.EngineMigration) error { // LanguageStat see models/repo_language_stats.go type LanguageStat struct { Size int64 `xorm:"NOT NULL DEFAULT 0"` diff --git a/models/migrations/v1_13/v141.go b/models/migrations/v1_13/v141.go index b54bc1727cb..c1a935b16da 100644 --- a/models/migrations/v1_13/v141.go +++ b/models/migrations/v1_13/v141.go @@ -6,10 +6,10 @@ package v1_13 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddKeepActivityPrivateUserColumn(x *xorm.Engine) error { +func AddKeepActivityPrivateUserColumn(x db.EngineMigration) error { type User struct { KeepActivityPrivate bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_13/v142.go b/models/migrations/v1_13/v142.go index d08a0ae0bf4..5207960aec2 100644 --- a/models/migrations/v1_13/v142.go +++ b/models/migrations/v1_13/v142.go @@ -4,13 +4,13 @@ package v1_13 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "xorm.io/builder" - "xorm.io/xorm" ) -func SetIsArchivedToFalse(x *xorm.Engine) error { +func SetIsArchivedToFalse(x db.EngineMigration) error { type Repository struct { IsArchived bool `xorm:"INDEX"` } diff --git a/models/migrations/v1_13/v143.go b/models/migrations/v1_13/v143.go index b9a856ed0fa..84e68c304d3 100644 --- a/models/migrations/v1_13/v143.go +++ b/models/migrations/v1_13/v143.go @@ -4,12 +4,11 @@ package v1_13 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" - - "xorm.io/xorm" ) -func RecalculateStars(x *xorm.Engine) (err error) { +func RecalculateStars(x db.EngineMigration) (err error) { // because of issue https://github.com/go-gitea/gitea/issues/11949, // recalculate Stars number for all users to fully fix it. diff --git a/models/migrations/v1_13/v144.go b/models/migrations/v1_13/v144.go index 9352d78bc88..4e85694f6f9 100644 --- a/models/migrations/v1_13/v144.go +++ b/models/migrations/v1_13/v144.go @@ -4,13 +4,13 @@ package v1_13 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "xorm.io/builder" - "xorm.io/xorm" ) -func UpdateMatrixWebhookHTTPMethod(x *xorm.Engine) error { +func UpdateMatrixWebhookHTTPMethod(x db.EngineMigration) error { matrixHookTaskType := 9 // value comes from the models package type Webhook struct { HTTPMethod string diff --git a/models/migrations/v1_13/v145.go b/models/migrations/v1_13/v145.go index 86ebb4f9d95..0bca23fc76b 100644 --- a/models/migrations/v1_13/v145.go +++ b/models/migrations/v1_13/v145.go @@ -6,12 +6,11 @@ package v1_13 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func IncreaseLanguageField(x *xorm.Engine) error { +func IncreaseLanguageField(x db.EngineMigration) error { type LanguageStat struct { RepoID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"` Language string `xorm:"VARCHAR(50) UNIQUE(s) INDEX NOT NULL"` diff --git a/models/migrations/v1_13/v146.go b/models/migrations/v1_13/v146.go index 355c772c268..29ee1025b3e 100644 --- a/models/migrations/v1_13/v146.go +++ b/models/migrations/v1_13/v146.go @@ -4,12 +4,11 @@ package v1_13 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddProjectsInfo(x *xorm.Engine) error { +func AddProjectsInfo(x db.EngineMigration) error { // Create new tables type ( ProjectType uint8 diff --git a/models/migrations/v1_13/v147.go b/models/migrations/v1_13/v147.go index 0059c062203..af755c10a5c 100644 --- a/models/migrations/v1_13/v147.go +++ b/models/migrations/v1_13/v147.go @@ -4,12 +4,11 @@ package v1_13 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreateReviewsForCodeComments(x *xorm.Engine) error { +func CreateReviewsForCodeComments(x db.EngineMigration) error { // Review type Review struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_13/v148.go b/models/migrations/v1_13/v148.go index d276db3d61d..e54f5c4ba5b 100644 --- a/models/migrations/v1_13/v148.go +++ b/models/migrations/v1_13/v148.go @@ -3,11 +3,9 @@ package v1_13 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func PurgeInvalidDependenciesComments(x *xorm.Engine) error { +func PurgeInvalidDependenciesComments(x db.EngineMigration) error { _, err := x.Exec("DELETE FROM comment WHERE dependent_issue_id != 0 AND dependent_issue_id NOT IN (SELECT id FROM issue)") return err } diff --git a/models/migrations/v1_13/v149.go b/models/migrations/v1_13/v149.go index a96b8e5ac7d..c3fcf85b32e 100644 --- a/models/migrations/v1_13/v149.go +++ b/models/migrations/v1_13/v149.go @@ -6,12 +6,11 @@ package v1_13 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddCreatedAndUpdatedToMilestones(x *xorm.Engine) error { +func AddCreatedAndUpdatedToMilestones(x db.EngineMigration) error { type Milestone struct { CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` diff --git a/models/migrations/v1_13/v150.go b/models/migrations/v1_13/v150.go index 590ea729030..0714cae4db6 100644 --- a/models/migrations/v1_13/v150.go +++ b/models/migrations/v1_13/v150.go @@ -4,13 +4,12 @@ package v1_13 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddPrimaryKeyToRepoTopic(x *xorm.Engine) error { +func AddPrimaryKeyToRepoTopic(x db.EngineMigration) error { // Topic represents a topic of repositories type Topic struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_13/v151.go b/models/migrations/v1_13/v151.go index 454929534fe..cef17bc8d5e 100644 --- a/models/migrations/v1_13/v151.go +++ b/models/migrations/v1_13/v151.go @@ -9,14 +9,14 @@ import ( "fmt" "strings" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) -func SetDefaultPasswordToArgon2(x *xorm.Engine) error { +func SetDefaultPasswordToArgon2(x db.EngineMigration) error { switch { case setting.Database.Type.IsMySQL(): _, err := x.Exec("ALTER TABLE `user` ALTER passwd_hash_algo SET DEFAULT 'argon2';") diff --git a/models/migrations/v1_13/v152.go b/models/migrations/v1_13/v152.go index 648e26446fe..24d45b6c347 100644 --- a/models/migrations/v1_13/v152.go +++ b/models/migrations/v1_13/v152.go @@ -3,9 +3,9 @@ package v1_13 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddTrustModelToRepository(x *xorm.Engine) error { +func AddTrustModelToRepository(x db.EngineMigration) error { type Repository struct { TrustModel int } diff --git a/models/migrations/v1_13/v153.go b/models/migrations/v1_13/v153.go index e5462fc1624..0c13b2cb89c 100644 --- a/models/migrations/v1_13/v153.go +++ b/models/migrations/v1_13/v153.go @@ -3,11 +3,9 @@ package v1_13 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddTeamReviewRequestSupport(x *xorm.Engine) error { +func AddTeamReviewRequestSupport(x db.EngineMigration) error { type Review struct { ReviewerTeamID int64 `xorm:"NOT NULL DEFAULT 0"` } diff --git a/models/migrations/v1_13/v154.go b/models/migrations/v1_13/v154.go index 5477d1b8891..63e415e7ce5 100644 --- a/models/migrations/v1_13/v154.go +++ b/models/migrations/v1_13/v154.go @@ -4,12 +4,11 @@ package v1_13 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddTimeStamps(x *xorm.Engine) error { +func AddTimeStamps(x db.EngineMigration) error { // this will add timestamps where it is useful to have // Star represents a starred repo by an user. diff --git a/models/migrations/v1_14/v155.go b/models/migrations/v1_14/v155.go index 505a9ae0334..de93cb5d8c1 100644 --- a/models/migrations/v1_14/v155.go +++ b/models/migrations/v1_14/v155.go @@ -6,10 +6,10 @@ package v1_14 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddChangedProtectedFilesPullRequestColumn(x *xorm.Engine) error { +func AddChangedProtectedFilesPullRequestColumn(x db.EngineMigration) error { type PullRequest struct { ChangedProtectedFiles []string `xorm:"TEXT JSON"` } diff --git a/models/migrations/v1_14/v156.go b/models/migrations/v1_14/v156.go index 593d3f9c70c..c9b17306d06 100644 --- a/models/migrations/v1_14/v156.go +++ b/models/migrations/v1_14/v156.go @@ -9,11 +9,10 @@ import ( "path/filepath" "strings" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) // Copy paste from models/repo.go because we cannot import models package @@ -25,7 +24,7 @@ func userPath(userName string) string { return filepath.Join(setting.RepoRootPath, strings.ToLower(userName)) } -func FixPublisherIDforTagReleases(ctx context.Context, x *xorm.Engine) error { +func FixPublisherIDforTagReleases(ctx context.Context, x db.EngineMigration) error { type Release struct { ID int64 RepoID int64 diff --git a/models/migrations/v1_14/v157.go b/models/migrations/v1_14/v157.go index 2c5625ebbd4..8ce460a978e 100644 --- a/models/migrations/v1_14/v157.go +++ b/models/migrations/v1_14/v157.go @@ -3,11 +3,9 @@ package v1_14 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func FixRepoTopics(x *xorm.Engine) error { +func FixRepoTopics(x db.EngineMigration) error { type Repository struct { ID int64 `xorm:"pk autoincr"` Topics []string `xorm:"TEXT JSON"` diff --git a/models/migrations/v1_14/v158.go b/models/migrations/v1_14/v158.go index 3c57e8e3daa..2b1cde41b51 100644 --- a/models/migrations/v1_14/v158.go +++ b/models/migrations/v1_14/v158.go @@ -7,13 +7,12 @@ import ( "errors" "strconv" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func UpdateCodeCommentReplies(x *xorm.Engine) error { +func UpdateCodeCommentReplies(x db.EngineMigration) error { type Comment struct { ID int64 `xorm:"pk autoincr"` CommitSHA string `xorm:"VARCHAR(40)"` diff --git a/models/migrations/v1_14/v159.go b/models/migrations/v1_14/v159.go index e6f6f0f061a..42da0bfef43 100644 --- a/models/migrations/v1_14/v159.go +++ b/models/migrations/v1_14/v159.go @@ -4,13 +4,12 @@ package v1_14 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func UpdateReactionConstraint(x *xorm.Engine) error { +func UpdateReactionConstraint(x db.EngineMigration) error { // Reaction represents a reactions on issues and comments. type Reaction struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_14/v160.go b/models/migrations/v1_14/v160.go index 73f37989547..fcfd738e4cc 100644 --- a/models/migrations/v1_14/v160.go +++ b/models/migrations/v1_14/v160.go @@ -3,11 +3,9 @@ package v1_14 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddBlockOnOfficialReviewRequests(x *xorm.Engine) error { +func AddBlockOnOfficialReviewRequests(x db.EngineMigration) error { type ProtectedBranch struct { BlockOnOfficialReviewRequests bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_14/v161.go b/models/migrations/v1_14/v161.go index eb92dee77cb..6cecf531133 100644 --- a/models/migrations/v1_14/v161.go +++ b/models/migrations/v1_14/v161.go @@ -6,12 +6,11 @@ package v1_14 import ( "context" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func ConvertTaskTypeToString(x *xorm.Engine) error { +func ConvertTaskTypeToString(x db.EngineMigration) error { const ( GOGS int = iota + 1 SLACK diff --git a/models/migrations/v1_14/v162.go b/models/migrations/v1_14/v162.go index a0ddd36d55f..60c6bfee2cb 100644 --- a/models/migrations/v1_14/v162.go +++ b/models/migrations/v1_14/v162.go @@ -4,12 +4,11 @@ package v1_14 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func ConvertWebhookTaskTypeToString(x *xorm.Engine) error { +func ConvertWebhookTaskTypeToString(x db.EngineMigration) error { const ( GOGS int = iota + 1 SLACK diff --git a/models/migrations/v1_14/v163.go b/models/migrations/v1_14/v163.go index 84c35190b7b..d7e763ee5ca 100644 --- a/models/migrations/v1_14/v163.go +++ b/models/migrations/v1_14/v163.go @@ -4,12 +4,11 @@ package v1_14 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func ConvertTopicNameFrom25To50(x *xorm.Engine) error { +func ConvertTopicNameFrom25To50(x db.EngineMigration) error { type Topic struct { ID int64 `xorm:"pk autoincr"` Name string `xorm:"UNIQUE VARCHAR(50)"` diff --git a/models/migrations/v1_14/v164.go b/models/migrations/v1_14/v164.go index d2fd9b8464a..17adc3f46a4 100644 --- a/models/migrations/v1_14/v164.go +++ b/models/migrations/v1_14/v164.go @@ -6,7 +6,7 @@ package v1_14 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) // OAuth2Grant here is a snapshot of models.OAuth2Grant for this version @@ -29,7 +29,7 @@ func (grant *OAuth2Grant) TableName() string { return "oauth2_grant" } -func AddScopeAndNonceColumnsToOAuth2Grant(x *xorm.Engine) error { +func AddScopeAndNonceColumnsToOAuth2Grant(x db.EngineMigration) error { if err := x.Sync(new(OAuth2Grant)); err != nil { return fmt.Errorf("Sync: %w", err) } diff --git a/models/migrations/v1_14/v165.go b/models/migrations/v1_14/v165.go index 6e1b34156b8..c528049e694 100644 --- a/models/migrations/v1_14/v165.go +++ b/models/migrations/v1_14/v165.go @@ -4,13 +4,13 @@ package v1_14 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) -func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error { +func ConvertHookTaskTypeToVarcharAndTrim(x db.EngineMigration) error { dbType := x.Dialect().URI().DBType if dbType == schemas.SQLITE { // For SQLITE, varchar or char will always be represented as TEXT return nil diff --git a/models/migrations/v1_14/v166.go b/models/migrations/v1_14/v166.go index 4c106bd7daf..e3f53475b18 100644 --- a/models/migrations/v1_14/v166.go +++ b/models/migrations/v1_14/v166.go @@ -7,15 +7,16 @@ import ( "crypto/sha256" "encoding/hex" + "code.gitea.io/gitea/models/db" + "golang.org/x/crypto/argon2" "golang.org/x/crypto/bcrypt" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/scrypt" "xorm.io/builder" - "xorm.io/xorm" ) -func RecalculateUserEmptyPWD(x *xorm.Engine) (err error) { +func RecalculateUserEmptyPWD(x db.EngineMigration) (err error) { const ( algoBcrypt = "bcrypt" algoScrypt = "scrypt" diff --git a/models/migrations/v1_14/v167.go b/models/migrations/v1_14/v167.go index d77bbc401e5..b38f26bd0f1 100644 --- a/models/migrations/v1_14/v167.go +++ b/models/migrations/v1_14/v167.go @@ -6,10 +6,10 @@ package v1_14 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddUserRedirect(x *xorm.Engine) (err error) { +func AddUserRedirect(x db.EngineMigration) (err error) { type UserRedirect struct { ID int64 `xorm:"pk autoincr"` LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"` diff --git a/models/migrations/v1_14/v168.go b/models/migrations/v1_14/v168.go index aa93eec19b0..15d57364a09 100644 --- a/models/migrations/v1_14/v168.go +++ b/models/migrations/v1_14/v168.go @@ -3,8 +3,8 @@ package v1_14 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func RecreateUserTableToFixDefaultValues(_ *xorm.Engine) error { +func RecreateUserTableToFixDefaultValues(_ db.EngineMigration) error { return nil } diff --git a/models/migrations/v1_14/v169.go b/models/migrations/v1_14/v169.go index 4f9df0d96f2..58383488674 100644 --- a/models/migrations/v1_14/v169.go +++ b/models/migrations/v1_14/v169.go @@ -3,11 +3,9 @@ package v1_14 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func CommentTypeDeleteBranchUseOldRef(x *xorm.Engine) error { +func CommentTypeDeleteBranchUseOldRef(x db.EngineMigration) error { _, err := x.Exec("UPDATE comment SET old_ref = commit_sha, commit_sha = '' WHERE type = 11") return err } diff --git a/models/migrations/v1_14/v170.go b/models/migrations/v1_14/v170.go index a2ff4623e14..9e91e56b966 100644 --- a/models/migrations/v1_14/v170.go +++ b/models/migrations/v1_14/v170.go @@ -6,10 +6,10 @@ package v1_14 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddDismissedReviewColumn(x *xorm.Engine) error { +func AddDismissedReviewColumn(x db.EngineMigration) error { type Review struct { Dismissed bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_14/v171.go b/models/migrations/v1_14/v171.go index 7b200e960ad..82d20c43694 100644 --- a/models/migrations/v1_14/v171.go +++ b/models/migrations/v1_14/v171.go @@ -6,10 +6,10 @@ package v1_14 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddSortingColToProjectBoard(x *xorm.Engine) error { +func AddSortingColToProjectBoard(x db.EngineMigration) error { type ProjectBoard struct { Sorting int8 `xorm:"NOT NULL DEFAULT 0"` } diff --git a/models/migrations/v1_14/v172.go b/models/migrations/v1_14/v172.go index bbd61d87b28..3d2ea836476 100644 --- a/models/migrations/v1_14/v172.go +++ b/models/migrations/v1_14/v172.go @@ -4,12 +4,11 @@ package v1_14 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddSessionTable(x *xorm.Engine) error { +func AddSessionTable(x db.EngineMigration) error { type Session struct { Key string `xorm:"pk CHAR(16)"` Data []byte `xorm:"BLOB"` diff --git a/models/migrations/v1_14/v173.go b/models/migrations/v1_14/v173.go index 7752fbe9664..2d11a16ad3b 100644 --- a/models/migrations/v1_14/v173.go +++ b/models/migrations/v1_14/v173.go @@ -6,10 +6,10 @@ package v1_14 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddTimeIDCommentColumn(x *xorm.Engine) error { +func AddTimeIDCommentColumn(x db.EngineMigration) error { type Comment struct { TimeID int64 } diff --git a/models/migrations/v1_14/v174.go b/models/migrations/v1_14/v174.go index 4049e43070d..2eca58b1ced 100644 --- a/models/migrations/v1_14/v174.go +++ b/models/migrations/v1_14/v174.go @@ -6,10 +6,10 @@ package v1_14 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddRepoTransfer(x *xorm.Engine) error { +func AddRepoTransfer(x db.EngineMigration) error { type RepoTransfer struct { ID int64 `xorm:"pk autoincr"` DoerID int64 diff --git a/models/migrations/v1_14/v175.go b/models/migrations/v1_14/v175.go index 92ed1304734..8114c4bd5a5 100644 --- a/models/migrations/v1_14/v175.go +++ b/models/migrations/v1_14/v175.go @@ -7,13 +7,12 @@ import ( "fmt" "regexp" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func FixPostgresIDSequences(x *xorm.Engine) error { +func FixPostgresIDSequences(x db.EngineMigration) error { if !setting.Database.Type.IsPostgreSQL() { return nil } diff --git a/models/migrations/v1_14/v176.go b/models/migrations/v1_14/v176.go index ef5dce9a027..faad5f32f25 100644 --- a/models/migrations/v1_14/v176.go +++ b/models/migrations/v1_14/v176.go @@ -3,14 +3,12 @@ package v1_14 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" // RemoveInvalidLabels looks through the database to look for comments and issue_labels // that refer to labels do not belong to the repository or organization that repository // that the issue is in -func RemoveInvalidLabels(x *xorm.Engine) error { +func RemoveInvalidLabels(x db.EngineMigration) error { type Comment struct { ID int64 `xorm:"pk autoincr"` Type int `xorm:"INDEX"` diff --git a/models/migrations/v1_14/v177.go b/models/migrations/v1_14/v177.go index 96676bf8d94..625f2f387dc 100644 --- a/models/migrations/v1_14/v177.go +++ b/models/migrations/v1_14/v177.go @@ -6,11 +6,11 @@ package v1_14 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) // DeleteOrphanedIssueLabels looks through the database for issue_labels where the label no longer exists and deletes them. -func DeleteOrphanedIssueLabels(x *xorm.Engine) error { +func DeleteOrphanedIssueLabels(x db.EngineMigration) error { type IssueLabel struct { ID int64 `xorm:"pk autoincr"` IssueID int64 `xorm:"UNIQUE(s)"` diff --git a/models/migrations/v1_15/v178.go b/models/migrations/v1_15/v178.go index ca3a5c262e4..2a2a77c6965 100644 --- a/models/migrations/v1_15/v178.go +++ b/models/migrations/v1_15/v178.go @@ -3,11 +3,9 @@ package v1_15 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddLFSMirrorColumns(x *xorm.Engine) error { +func AddLFSMirrorColumns(x db.EngineMigration) error { type Mirror struct { LFS bool `xorm:"lfs_enabled NOT NULL DEFAULT false"` LFSEndpoint string `xorm:"lfs_endpoint TEXT"` diff --git a/models/migrations/v1_15/v179.go b/models/migrations/v1_15/v179.go index d6fb86ffecc..1210f54ac94 100644 --- a/models/migrations/v1_15/v179.go +++ b/models/migrations/v1_15/v179.go @@ -4,13 +4,13 @@ package v1_15 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) -func ConvertAvatarURLToText(x *xorm.Engine) error { +func ConvertAvatarURLToText(x db.EngineMigration) error { dbType := x.Dialect().URI().DBType if dbType == schemas.SQLITE { // For SQLITE, varchar or char will always be represented as TEXT return nil diff --git a/models/migrations/v1_15/v180.go b/models/migrations/v1_15/v180.go index dd132f83306..7e6388a99c5 100644 --- a/models/migrations/v1_15/v180.go +++ b/models/migrations/v1_15/v180.go @@ -4,14 +4,14 @@ package v1_15 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/util" "xorm.io/builder" - "xorm.io/xorm" ) -func DeleteMigrationCredentials(x *xorm.Engine) (err error) { +func DeleteMigrationCredentials(x db.EngineMigration) (err error) { // Task represents a task type Task struct { ID int64 diff --git a/models/migrations/v1_15/v181.go b/models/migrations/v1_15/v181.go index fb1d3d7a75f..f4032ed19e6 100644 --- a/models/migrations/v1_15/v181.go +++ b/models/migrations/v1_15/v181.go @@ -6,10 +6,10 @@ package v1_15 import ( "strings" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddPrimaryEmail2EmailAddress(x *xorm.Engine) error { +func AddPrimaryEmail2EmailAddress(x db.EngineMigration) error { type User struct { ID int64 `xorm:"pk autoincr"` Email string `xorm:"NOT NULL"` diff --git a/models/migrations/v1_15/v182.go b/models/migrations/v1_15/v182.go index f53ff11df9c..1b577ea359d 100644 --- a/models/migrations/v1_15/v182.go +++ b/models/migrations/v1_15/v182.go @@ -3,11 +3,9 @@ package v1_15 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddIssueResourceIndexTable(x *xorm.Engine) error { +func AddIssueResourceIndexTable(x db.EngineMigration) error { type ResourceIndex struct { GroupID int64 `xorm:"pk"` MaxIndex int64 `xorm:"index"` diff --git a/models/migrations/v1_15/v183.go b/models/migrations/v1_15/v183.go index 5d0582f03d4..30835ea3b89 100644 --- a/models/migrations/v1_15/v183.go +++ b/models/migrations/v1_15/v183.go @@ -7,12 +7,11 @@ import ( "fmt" "time" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreatePushMirrorTable(x *xorm.Engine) error { +func CreatePushMirrorTable(x db.EngineMigration) error { type PushMirror struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX"` diff --git a/models/migrations/v1_15/v184.go b/models/migrations/v1_15/v184.go index 2823bc1f7af..9933b12a490 100644 --- a/models/migrations/v1_15/v184.go +++ b/models/migrations/v1_15/v184.go @@ -7,13 +7,12 @@ import ( "context" "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func RenameTaskErrorsToMessage(x *xorm.Engine) error { +func RenameTaskErrorsToMessage(x db.EngineMigration) error { type Task struct { Errors string `xorm:"TEXT"` // if task failed, saved the error reason Type int diff --git a/models/migrations/v1_15/v185.go b/models/migrations/v1_15/v185.go index 60af59edca4..e4750c6766d 100644 --- a/models/migrations/v1_15/v185.go +++ b/models/migrations/v1_15/v185.go @@ -3,11 +3,9 @@ package v1_15 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddRepoArchiver(x *xorm.Engine) error { +func AddRepoArchiver(x db.EngineMigration) error { // RepoArchiver represents all archivers type RepoArchiver struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_15/v186.go b/models/migrations/v1_15/v186.go index 67dc97d13d7..da8ba69ca96 100644 --- a/models/migrations/v1_15/v186.go +++ b/models/migrations/v1_15/v186.go @@ -4,12 +4,11 @@ package v1_15 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreateProtectedTagTable(x *xorm.Engine) error { +func CreateProtectedTagTable(x db.EngineMigration) error { type ProtectedTag struct { ID int64 `xorm:"pk autoincr"` RepoID int64 diff --git a/models/migrations/v1_15/v187.go b/models/migrations/v1_15/v187.go index 5fd90c65fbf..2bb27edfac4 100644 --- a/models/migrations/v1_15/v187.go +++ b/models/migrations/v1_15/v187.go @@ -4,12 +4,11 @@ package v1_15 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func DropWebhookColumns(x *xorm.Engine) error { +func DropWebhookColumns(x db.EngineMigration) error { // Make sure the columns exist before dropping them type Webhook struct { Signature string `xorm:"TEXT"` diff --git a/models/migrations/v1_15/v188.go b/models/migrations/v1_15/v188.go index 4494e6ff055..a29005abc78 100644 --- a/models/migrations/v1_15/v188.go +++ b/models/migrations/v1_15/v188.go @@ -3,9 +3,9 @@ package v1_15 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddKeyIsVerified(x *xorm.Engine) error { +func AddKeyIsVerified(x db.EngineMigration) error { type GPGKey struct { Verified bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_16/v189.go b/models/migrations/v1_16/v189.go index 6bc99e58ab7..1b39770f44d 100644 --- a/models/migrations/v1_16/v189.go +++ b/models/migrations/v1_16/v189.go @@ -7,13 +7,12 @@ import ( "encoding/binary" "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/json" - - "xorm.io/xorm" ) -func UnwrapLDAPSourceCfg(x *xorm.Engine) error { +func UnwrapLDAPSourceCfg(x db.EngineMigration) error { jsonUnmarshalHandleDoubleEncode := func(bs []byte, v any) error { err := json.Unmarshal(bs, v) if err != nil { diff --git a/models/migrations/v1_16/v190.go b/models/migrations/v1_16/v190.go index 1eb6b6ddb4f..d6d5d885b5a 100644 --- a/models/migrations/v1_16/v190.go +++ b/models/migrations/v1_16/v190.go @@ -6,10 +6,10 @@ package v1_16 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddAgitFlowPullRequest(x *xorm.Engine) error { +func AddAgitFlowPullRequest(x db.EngineMigration) error { type PullRequestFlow int type PullRequest struct { diff --git a/models/migrations/v1_16/v191.go b/models/migrations/v1_16/v191.go index 957c82e484c..03f287c8279 100644 --- a/models/migrations/v1_16/v191.go +++ b/models/migrations/v1_16/v191.go @@ -4,12 +4,11 @@ package v1_16 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func AlterIssueAndCommentTextFieldsToLongText(x *xorm.Engine) error { +func AlterIssueAndCommentTextFieldsToLongText(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { diff --git a/models/migrations/v1_16/v192.go b/models/migrations/v1_16/v192.go index 9d03fbe3c8f..ce0a69a8ce6 100644 --- a/models/migrations/v1_16/v192.go +++ b/models/migrations/v1_16/v192.go @@ -4,12 +4,11 @@ package v1_16 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func RecreateIssueResourceIndexTable(x *xorm.Engine) error { +func RecreateIssueResourceIndexTable(x db.EngineMigration) error { type IssueIndex struct { GroupID int64 `xorm:"pk"` MaxIndex int64 `xorm:"index"` diff --git a/models/migrations/v1_16/v193.go b/models/migrations/v1_16/v193.go index a5af2de3805..615f2140184 100644 --- a/models/migrations/v1_16/v193.go +++ b/models/migrations/v1_16/v193.go @@ -3,11 +3,9 @@ package v1_16 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddRepoIDForAttachment(x *xorm.Engine) error { +func AddRepoIDForAttachment(x db.EngineMigration) error { type Attachment struct { ID int64 `xorm:"pk autoincr"` UUID string `xorm:"uuid UNIQUE"` diff --git a/models/migrations/v1_16/v194.go b/models/migrations/v1_16/v194.go index 2e4ed8340e6..00b4fccc21d 100644 --- a/models/migrations/v1_16/v194.go +++ b/models/migrations/v1_16/v194.go @@ -6,10 +6,10 @@ package v1_16 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddBranchProtectionUnprotectedFilesColumn(x *xorm.Engine) error { +func AddBranchProtectionUnprotectedFilesColumn(x db.EngineMigration) error { type ProtectedBranch struct { UnprotectedFilePatterns string `xorm:"TEXT"` } diff --git a/models/migrations/v1_16/v195.go b/models/migrations/v1_16/v195.go index 4fd42b7bd23..6b1bc0b4fd9 100644 --- a/models/migrations/v1_16/v195.go +++ b/models/migrations/v1_16/v195.go @@ -6,10 +6,10 @@ package v1_16 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddTableCommitStatusIndex(x *xorm.Engine) error { +func AddTableCommitStatusIndex(x db.EngineMigration) error { // CommitStatusIndex represents a table for commit status index type CommitStatusIndex struct { ID int64 diff --git a/models/migrations/v1_16/v196.go b/models/migrations/v1_16/v196.go index 6c9caa100f1..64b80aa789b 100644 --- a/models/migrations/v1_16/v196.go +++ b/models/migrations/v1_16/v196.go @@ -6,10 +6,10 @@ package v1_16 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddColorColToProjectBoard(x *xorm.Engine) error { +func AddColorColToProjectBoard(x db.EngineMigration) error { type ProjectBoard struct { Color string `xorm:"VARCHAR(7)"` } diff --git a/models/migrations/v1_16/v197.go b/models/migrations/v1_16/v197.go index 862bdfdcbdb..81abe84a27d 100644 --- a/models/migrations/v1_16/v197.go +++ b/models/migrations/v1_16/v197.go @@ -3,11 +3,9 @@ package v1_16 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddRenamedBranchTable(x *xorm.Engine) error { +func AddRenamedBranchTable(x db.EngineMigration) error { type RenamedBranch struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX NOT NULL"` diff --git a/models/migrations/v1_16/v198.go b/models/migrations/v1_16/v198.go index f35ede138a0..c0bc0691a0a 100644 --- a/models/migrations/v1_16/v198.go +++ b/models/migrations/v1_16/v198.go @@ -6,12 +6,11 @@ package v1_16 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddTableIssueContentHistory(x *xorm.Engine) error { +func AddTableIssueContentHistory(x db.EngineMigration) error { type IssueContentHistory struct { ID int64 `xorm:"pk autoincr"` PosterID int64 diff --git a/models/migrations/v1_16/v200.go b/models/migrations/v1_16/v200.go index de57fad8fe7..5e83711dadc 100644 --- a/models/migrations/v1_16/v200.go +++ b/models/migrations/v1_16/v200.go @@ -6,10 +6,10 @@ package v1_16 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddTableAppState(x *xorm.Engine) error { +func AddTableAppState(x db.EngineMigration) error { type AppState struct { ID string `xorm:"pk varchar(200)"` Revision int64 diff --git a/models/migrations/v1_16/v201.go b/models/migrations/v1_16/v201.go index 2c43698b0c9..c4708c4dde7 100644 --- a/models/migrations/v1_16/v201.go +++ b/models/migrations/v1_16/v201.go @@ -3,11 +3,9 @@ package v1_16 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func DropTableRemoteVersion(x *xorm.Engine) error { +func DropTableRemoteVersion(x db.EngineMigration) error { // drop the orphaned table introduced in `v199`, now the update checker also uses AppState, do not need this table _ = x.DropTables("remote_version") return nil diff --git a/models/migrations/v1_16/v202.go b/models/migrations/v1_16/v202.go index d8c8fdcadc3..2152e58f978 100644 --- a/models/migrations/v1_16/v202.go +++ b/models/migrations/v1_16/v202.go @@ -6,10 +6,10 @@ package v1_16 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func CreateUserSettingsTable(x *xorm.Engine) error { +func CreateUserSettingsTable(x db.EngineMigration) error { type UserSetting struct { ID int64 `xorm:"pk autoincr"` UserID int64 `xorm:"index unique(key_userid)"` // to load all of someone's settings diff --git a/models/migrations/v1_16/v203.go b/models/migrations/v1_16/v203.go index c3241cba576..19d7397eb61 100644 --- a/models/migrations/v1_16/v203.go +++ b/models/migrations/v1_16/v203.go @@ -3,11 +3,9 @@ package v1_16 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddProjectIssueSorting(x *xorm.Engine) error { +func AddProjectIssueSorting(x db.EngineMigration) error { // ProjectIssue saves relation from issue to a project type ProjectIssue struct { Sorting int64 `xorm:"NOT NULL DEFAULT 0"` diff --git a/models/migrations/v1_16/v204.go b/models/migrations/v1_16/v204.go index 4d375307e76..c0bfe9e7fb4 100644 --- a/models/migrations/v1_16/v204.go +++ b/models/migrations/v1_16/v204.go @@ -3,9 +3,9 @@ package v1_16 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddSSHKeyIsVerified(x *xorm.Engine) error { +func AddSSHKeyIsVerified(x db.EngineMigration) error { type PublicKey struct { Verified bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_16/v205.go b/models/migrations/v1_16/v205.go index 78241bad5b2..3e1b393b70a 100644 --- a/models/migrations/v1_16/v205.go +++ b/models/migrations/v1_16/v205.go @@ -4,13 +4,13 @@ package v1_16 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) -func MigrateUserPasswordSalt(x *xorm.Engine) error { +func MigrateUserPasswordSalt(x db.EngineMigration) error { dbType := x.Dialect().URI().DBType // For SQLITE, the max length doesn't matter. if dbType == schemas.SQLITE { diff --git a/models/migrations/v1_16/v206.go b/models/migrations/v1_16/v206.go index 01a9c386eb2..b883b137beb 100644 --- a/models/migrations/v1_16/v206.go +++ b/models/migrations/v1_16/v206.go @@ -6,10 +6,10 @@ package v1_16 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func AddAuthorizeColForTeamUnit(x *xorm.Engine) error { +func AddAuthorizeColForTeamUnit(x db.EngineMigration) error { type TeamUnit struct { ID int64 `xorm:"pk autoincr"` OrgID int64 `xorm:"INDEX"` diff --git a/models/migrations/v1_16/v207.go b/models/migrations/v1_16/v207.go index 19126ead1f4..9608e1103e3 100644 --- a/models/migrations/v1_16/v207.go +++ b/models/migrations/v1_16/v207.go @@ -3,11 +3,9 @@ package v1_16 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddWebAuthnCred(x *xorm.Engine) error { +func AddWebAuthnCred(x db.EngineMigration) error { // NO-OP Don't migrate here - let v210 do this. return nil diff --git a/models/migrations/v1_16/v208.go b/models/migrations/v1_16/v208.go index fb643324f48..534de313fc5 100644 --- a/models/migrations/v1_16/v208.go +++ b/models/migrations/v1_16/v208.go @@ -3,11 +3,9 @@ package v1_16 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func UseBase32HexForCredIDInWebAuthnCredential(x *xorm.Engine) error { +func UseBase32HexForCredIDInWebAuthnCredential(x db.EngineMigration) error { // noop return nil } diff --git a/models/migrations/v1_16/v209.go b/models/migrations/v1_16/v209.go index 230838647bb..c96415142fa 100644 --- a/models/migrations/v1_16/v209.go +++ b/models/migrations/v1_16/v209.go @@ -3,11 +3,9 @@ package v1_16 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func IncreaseCredentialIDTo410(x *xorm.Engine) error { +func IncreaseCredentialIDTo410(x db.EngineMigration) error { // no-op // v208 was completely wrong // So now we have to no-op again. diff --git a/models/migrations/v1_16/v210.go b/models/migrations/v1_16/v210.go index 0b94baf8e3d..bbc3cc8e525 100644 --- a/models/migrations/v1_16/v210.go +++ b/models/migrations/v1_16/v210.go @@ -8,16 +8,16 @@ import ( "fmt" "strings" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/timeutil" "github.com/tstranex/u2f" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) // v208 migration was completely broken -func RemigrateU2FCredentials(x *xorm.Engine) error { +func RemigrateU2FCredentials(x db.EngineMigration) error { // Create webauthnCredential table type webauthnCredential struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_17/v211.go b/models/migrations/v1_17/v211.go index 517cf19388d..0070ae22c39 100644 --- a/models/migrations/v1_17/v211.go +++ b/models/migrations/v1_17/v211.go @@ -3,10 +3,8 @@ package v1_17 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func CreateForeignReferenceTable(_ *xorm.Engine) error { +func CreateForeignReferenceTable(_ db.EngineMigration) error { return nil // This table was dropped in v1_19/v237.go } diff --git a/models/migrations/v1_17/v212.go b/models/migrations/v1_17/v212.go index 788792211f5..24de310546d 100644 --- a/models/migrations/v1_17/v212.go +++ b/models/migrations/v1_17/v212.go @@ -4,12 +4,11 @@ package v1_17 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddPackageTables(x *xorm.Engine) error { +func AddPackageTables(x db.EngineMigration) error { type Package struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"` diff --git a/models/migrations/v1_17/v213.go b/models/migrations/v1_17/v213.go index b2bbdf72795..c988999e6b2 100644 --- a/models/migrations/v1_17/v213.go +++ b/models/migrations/v1_17/v213.go @@ -3,11 +3,9 @@ package v1_17 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddAllowMaintainerEdit(x *xorm.Engine) error { +func AddAllowMaintainerEdit(x db.EngineMigration) error { // PullRequest represents relation between pull request and repositories. type PullRequest struct { AllowMaintainerEdit bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/migrations/v1_17/v214.go b/models/migrations/v1_17/v214.go index 1925324f0f1..9576e1a6932 100644 --- a/models/migrations/v1_17/v214.go +++ b/models/migrations/v1_17/v214.go @@ -3,11 +3,9 @@ package v1_17 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddAutoMergeTable(x *xorm.Engine) error { +func AddAutoMergeTable(x db.EngineMigration) error { type MergeStyle string type PullAutoMerge struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_17/v215.go b/models/migrations/v1_17/v215.go index 748539225d3..39310d23550 100644 --- a/models/migrations/v1_17/v215.go +++ b/models/migrations/v1_17/v215.go @@ -4,13 +4,12 @@ package v1_17 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/pull" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddReviewViewedFiles(x *xorm.Engine) error { +func AddReviewViewedFiles(x db.EngineMigration) error { type ReviewState struct { ID int64 `xorm:"pk autoincr"` UserID int64 `xorm:"NOT NULL UNIQUE(pull_commit_user)"` diff --git a/models/migrations/v1_17/v217.go b/models/migrations/v1_17/v217.go index 04626bcbc59..2a3cb3af785 100644 --- a/models/migrations/v1_17/v217.go +++ b/models/migrations/v1_17/v217.go @@ -4,12 +4,11 @@ package v1_17 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func AlterHookTaskTextFieldsToLongText(x *xorm.Engine) error { +func AlterHookTaskTextFieldsToLongText(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { diff --git a/models/migrations/v1_17/v218.go b/models/migrations/v1_17/v218.go index 17d4cd89d4e..fbaf1e4f7ac 100644 --- a/models/migrations/v1_17/v218.go +++ b/models/migrations/v1_17/v218.go @@ -4,10 +4,10 @@ package v1_17 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) @@ -47,6 +47,6 @@ func (*improveActionTableIndicesAction) TableIndices() []*schemas.Index { return indices } -func ImproveActionTableIndices(x *xorm.Engine) error { +func ImproveActionTableIndices(x db.EngineMigration) error { return x.Sync(&improveActionTableIndicesAction{}) } diff --git a/models/migrations/v1_17/v219.go b/models/migrations/v1_17/v219.go index 6e335cb813a..a87a1190a81 100644 --- a/models/migrations/v1_17/v219.go +++ b/models/migrations/v1_17/v219.go @@ -6,13 +6,12 @@ package v1_17 import ( "time" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddSyncOnCommitColForPushMirror(x *xorm.Engine) error { +func AddSyncOnCommitColForPushMirror(x db.EngineMigration) error { type PushMirror struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX"` diff --git a/models/migrations/v1_17/v220.go b/models/migrations/v1_17/v220.go index 4ac8c58e1ec..39e6e1a150f 100644 --- a/models/migrations/v1_17/v220.go +++ b/models/migrations/v1_17/v220.go @@ -4,14 +4,14 @@ package v1_17 import ( + "code.gitea.io/gitea/models/db" packages_model "code.gitea.io/gitea/models/packages" container_module "code.gitea.io/gitea/modules/packages/container" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) -func AddContainerRepositoryProperty(x *xorm.Engine) (err error) { +func AddContainerRepositoryProperty(x db.EngineMigration) (err error) { switch x.Dialect().URI().DBType { case schemas.SQLITE: _, err = x.Exec("INSERT INTO package_property (ref_type, ref_id, name, value) SELECT ?, p.id, ?, u.lower_name || '/' || p.lower_name FROM package p JOIN `user` u ON p.owner_id = u.id WHERE p.type = ?", diff --git a/models/migrations/v1_17/v221.go b/models/migrations/v1_17/v221.go index 9e6a67eb183..31c41e17d3f 100644 --- a/models/migrations/v1_17/v221.go +++ b/models/migrations/v1_17/v221.go @@ -7,12 +7,11 @@ import ( "encoding/base32" "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func StoreWebauthnCredentialIDAsBytes(x *xorm.Engine) error { +func StoreWebauthnCredentialIDAsBytes(x db.EngineMigration) error { // Create webauthnCredential table type webauthnCredential struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_17/v222.go b/models/migrations/v1_17/v222.go index a5ea537d8a4..4c33dcdffbe 100644 --- a/models/migrations/v1_17/v222.go +++ b/models/migrations/v1_17/v222.go @@ -8,13 +8,12 @@ import ( "errors" "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func DropOldCredentialIDColumn(x *xorm.Engine) error { +func DropOldCredentialIDColumn(x db.EngineMigration) error { // This migration maybe rerun so that we should check if it has been run credentialIDExist, err := x.Dialect().IsColumnExist(x.DB(), context.Background(), "webauthn_credential", "credential_id") if err != nil { diff --git a/models/migrations/v1_17/v223.go b/models/migrations/v1_17/v223.go index b2bfb76551d..b0eac197bf8 100644 --- a/models/migrations/v1_17/v223.go +++ b/models/migrations/v1_17/v223.go @@ -7,14 +7,13 @@ import ( "context" "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func RenameCredentialIDBytes(x *xorm.Engine) error { +func RenameCredentialIDBytes(x db.EngineMigration) error { // This migration maybe rerun so that we should check if it has been run credentialIDExist, err := x.Dialect().IsColumnExist(x.DB(), context.Background(), "webauthn_credential", "credential_id") if err != nil { diff --git a/models/migrations/v1_18/v224.go b/models/migrations/v1_18/v224.go index 6dc12020eaa..4a43528b1ae 100644 --- a/models/migrations/v1_18/v224.go +++ b/models/migrations/v1_18/v224.go @@ -3,11 +3,9 @@ package v1_18 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func CreateUserBadgesTable(x *xorm.Engine) error { +func CreateUserBadgesTable(x db.EngineMigration) error { type Badge struct { ID int64 `xorm:"pk autoincr"` Description string diff --git a/models/migrations/v1_18/v225.go b/models/migrations/v1_18/v225.go index bc6117e38f5..fc6ceb91f39 100644 --- a/models/migrations/v1_18/v225.go +++ b/models/migrations/v1_18/v225.go @@ -4,12 +4,11 @@ package v1_18 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func AlterPublicGPGKeyContentFieldsToMediumText(x *xorm.Engine) error { +func AlterPublicGPGKeyContentFieldsToMediumText(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { diff --git a/models/migrations/v1_18/v226.go b/models/migrations/v1_18/v226.go index 8ed9761476d..69c2bf0751f 100644 --- a/models/migrations/v1_18/v226.go +++ b/models/migrations/v1_18/v226.go @@ -4,11 +4,12 @@ package v1_18 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/builder" - "xorm.io/xorm" ) -func FixPackageSemverField(x *xorm.Engine) error { +func FixPackageSemverField(x db.EngineMigration) error { _, err := x.Exec(builder.Update(builder.Eq{"semver_compatible": false}).From("`package`").Where(builder.In("`type`", "conan", "generic"))) return err } diff --git a/models/migrations/v1_18/v227.go b/models/migrations/v1_18/v227.go index 3aca686d597..c47727cb5ed 100644 --- a/models/migrations/v1_18/v227.go +++ b/models/migrations/v1_18/v227.go @@ -4,9 +4,8 @@ package v1_18 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) type SystemSetting struct { @@ -18,6 +17,6 @@ type SystemSetting struct { Updated timeutil.TimeStamp `xorm:"updated"` } -func CreateSystemSettingsTable(x *xorm.Engine) error { +func CreateSystemSettingsTable(x db.EngineMigration) error { return x.Sync(new(SystemSetting)) } diff --git a/models/migrations/v1_18/v228.go b/models/migrations/v1_18/v228.go index b13f6461bd8..e5c10414803 100644 --- a/models/migrations/v1_18/v228.go +++ b/models/migrations/v1_18/v228.go @@ -4,12 +4,11 @@ package v1_18 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddTeamInviteTable(x *xorm.Engine) error { +func AddTeamInviteTable(x db.EngineMigration) error { type TeamInvite struct { ID int64 `xorm:"pk autoincr"` Token string `xorm:"UNIQUE(token) INDEX NOT NULL DEFAULT ''"` diff --git a/models/migrations/v1_18/v229.go b/models/migrations/v1_18/v229.go index 1f69724365a..fe8798aa6d5 100644 --- a/models/migrations/v1_18/v229.go +++ b/models/migrations/v1_18/v229.go @@ -6,13 +6,13 @@ package v1_18 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/issues" "xorm.io/builder" - "xorm.io/xorm" ) -func UpdateOpenMilestoneCounts(x *xorm.Engine) error { +func UpdateOpenMilestoneCounts(x db.EngineMigration) error { var openMilestoneIDs []int64 err := x.Table("milestone").Select("id").Where(builder.Neq{"is_closed": 1}).Find(&openMilestoneIDs) if err != nil { diff --git a/models/migrations/v1_18/v230.go b/models/migrations/v1_18/v230.go index 078fce7643d..2a890e7a754 100644 --- a/models/migrations/v1_18/v230.go +++ b/models/migrations/v1_18/v230.go @@ -3,12 +3,10 @@ package v1_18 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" // AddConfidentialColumnToOAuth2ApplicationTable: add ConfidentialClient column, setting existing rows to true -func AddConfidentialClientColumnToOAuth2ApplicationTable(x *xorm.Engine) error { +func AddConfidentialClientColumnToOAuth2ApplicationTable(x db.EngineMigration) error { type oauth2Application struct { ID int64 ConfidentialClient bool `xorm:"NOT NULL DEFAULT TRUE"` diff --git a/models/migrations/v1_19/v231.go b/models/migrations/v1_19/v231.go index 8ef1e4e7438..980a23d82cf 100644 --- a/models/migrations/v1_19/v231.go +++ b/models/migrations/v1_19/v231.go @@ -3,11 +3,9 @@ package v1_19 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddIndexForHookTask(x *xorm.Engine) error { +func AddIndexForHookTask(x db.EngineMigration) error { type HookTask struct { ID int64 `xorm:"pk autoincr"` HookID int64 `xorm:"index"` diff --git a/models/migrations/v1_19/v232.go b/models/migrations/v1_19/v232.go index 493dbc6df83..d39b1527d90 100644 --- a/models/migrations/v1_19/v232.go +++ b/models/migrations/v1_19/v232.go @@ -4,12 +4,11 @@ package v1_19 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func AlterPackageVersionMetadataToLongText(x *xorm.Engine) error { +func AlterPackageVersionMetadataToLongText(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { diff --git a/models/migrations/v1_19/v233.go b/models/migrations/v1_19/v233.go index 44ced874b32..576dfbe04d2 100644 --- a/models/migrations/v1_19/v233.go +++ b/models/migrations/v1_19/v233.go @@ -6,15 +6,15 @@ package v1_19 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/secret" "code.gitea.io/gitea/modules/setting" "xorm.io/builder" - "xorm.io/xorm" ) -func batchProcess[T any](x *xorm.Engine, buf []T, query func(limit, start int) *xorm.Session, process func(*xorm.Session, T) error) error { +func batchProcess[T any](x db.EngineMigration, buf []T, query func(limit, start int) db.Session, process func(db.Session, T) error) error { size := cap(buf) start := 0 for { @@ -51,7 +51,7 @@ func batchProcess[T any](x *xorm.Engine, buf []T, query func(limit, start int) * } } -func AddHeaderAuthorizationEncryptedColWebhook(x *xorm.Engine) error { +func AddHeaderAuthorizationEncryptedColWebhook(x db.EngineMigration) error { // Add the column to the table type Webhook struct { ID int64 `xorm:"pk autoincr"` @@ -80,10 +80,10 @@ func AddHeaderAuthorizationEncryptedColWebhook(x *xorm.Engine) error { err = batchProcess(x, make([]*Webhook, 0, 50), - func(limit, start int) *xorm.Session { + func(limit, start int) db.Session { return x.Where("type=?", "matrix").OrderBy("id").Limit(limit, start) }, - func(sess *xorm.Session, hook *Webhook) error { + func(sess db.Session, hook *Webhook) error { // retrieve token from meta var withToken MatrixMetaWithAccessToken err := json.Unmarshal([]byte(hook.Meta), &withToken) @@ -141,13 +141,13 @@ func AddHeaderAuthorizationEncryptedColWebhook(x *xorm.Engine) error { err = batchProcess(x, make([]*HookTask, 0, 50), - func(limit, start int) *xorm.Session { + func(limit, start int) db.Session { return x.Where(builder.And( builder.In("hook_id", builder.Select("id").From("webhook").Where(builder.Eq{"type": "matrix"})), builder.Like{"payload_content", "access_token"}, )).OrderBy("id").Limit(limit, 0) // ignore the provided "start", since other payload were already converted and don't contain 'payload_content' anymore }, - func(sess *xorm.Session, hookTask *HookTask) error { + func(sess db.Session, hookTask *HookTask) error { // retrieve token from payload_content var withToken MatrixPayloadUnsafe err := json.Unmarshal([]byte(hookTask.PayloadContent), &withToken) diff --git a/models/migrations/v1_19/v234.go b/models/migrations/v1_19/v234.go index 3475384d6f4..45b1acd537b 100644 --- a/models/migrations/v1_19/v234.go +++ b/models/migrations/v1_19/v234.go @@ -4,12 +4,11 @@ package v1_19 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreatePackageCleanupRuleTable(x *xorm.Engine) error { +func CreatePackageCleanupRuleTable(x db.EngineMigration) error { type PackageCleanupRule struct { ID int64 `xorm:"pk autoincr"` Enabled bool `xorm:"INDEX NOT NULL DEFAULT false"` diff --git a/models/migrations/v1_19/v235.go b/models/migrations/v1_19/v235.go index 297d90f65a2..e867c79453b 100644 --- a/models/migrations/v1_19/v235.go +++ b/models/migrations/v1_19/v235.go @@ -3,11 +3,9 @@ package v1_19 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddIndexForAccessToken(x *xorm.Engine) error { +func AddIndexForAccessToken(x db.EngineMigration) error { type AccessToken struct { TokenLastEight string `xorm:"INDEX token_last_eight"` } diff --git a/models/migrations/v1_19/v236.go b/models/migrations/v1_19/v236.go index 0ed4d97a272..5e0a8a7b41c 100644 --- a/models/migrations/v1_19/v236.go +++ b/models/migrations/v1_19/v236.go @@ -4,12 +4,11 @@ package v1_19 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreateSecretsTable(x *xorm.Engine) error { +func CreateSecretsTable(x db.EngineMigration) error { type Secret struct { ID int64 OwnerID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL"` diff --git a/models/migrations/v1_19/v237.go b/models/migrations/v1_19/v237.go index cf30226ccd8..c7632060446 100644 --- a/models/migrations/v1_19/v237.go +++ b/models/migrations/v1_19/v237.go @@ -3,11 +3,9 @@ package v1_19 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func DropForeignReferenceTable(x *xorm.Engine) error { +func DropForeignReferenceTable(x db.EngineMigration) error { // Drop the table introduced in `v211`, it's considered badly designed and doesn't look like to be used. // See: https://github.com/go-gitea/gitea/issues/21086#issuecomment-1318217453 type ForeignReference struct{} diff --git a/models/migrations/v1_19/v238.go b/models/migrations/v1_19/v238.go index de681bfc7a4..2566492fcda 100644 --- a/models/migrations/v1_19/v238.go +++ b/models/migrations/v1_19/v238.go @@ -4,13 +4,12 @@ package v1_19 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) // AddUpdatedUnixToLFSMetaObject adds an updated column to the LFSMetaObject to allow for garbage collection -func AddUpdatedUnixToLFSMetaObject(x *xorm.Engine) error { +func AddUpdatedUnixToLFSMetaObject(x db.EngineMigration) error { // Drop the table introduced in `v211`, it's considered badly designed and doesn't look like to be used. // See: https://github.com/go-gitea/gitea/issues/21086#issuecomment-1318217453 // LFSMetaObject stores metadata for LFS tracked files. diff --git a/models/migrations/v1_19/v239.go b/models/migrations/v1_19/v239.go index 8f4a65be95d..3d3f0ac0722 100644 --- a/models/migrations/v1_19/v239.go +++ b/models/migrations/v1_19/v239.go @@ -3,11 +3,9 @@ package v1_19 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddScopeForAccessTokens(x *xorm.Engine) error { +func AddScopeForAccessTokens(x db.EngineMigration) error { type AccessToken struct { Scope string } diff --git a/models/migrations/v1_19/v240.go b/models/migrations/v1_19/v240.go index 7fdbaeb9dc9..01a17b34763 100644 --- a/models/migrations/v1_19/v240.go +++ b/models/migrations/v1_19/v240.go @@ -6,11 +6,9 @@ package v1_19 import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddActionsTables(x *xorm.Engine) error { +func AddActionsTables(x db.EngineMigration) error { type ActionRunner struct { ID int64 UUID string `xorm:"CHAR(36) UNIQUE"` diff --git a/models/migrations/v1_19/v241.go b/models/migrations/v1_19/v241.go index e35801a0572..582993e81e6 100644 --- a/models/migrations/v1_19/v241.go +++ b/models/migrations/v1_19/v241.go @@ -3,12 +3,10 @@ package v1_19 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" // AddCardTypeToProjectTable: add CardType column, setting existing rows to CardTypeTextOnly -func AddCardTypeToProjectTable(x *xorm.Engine) error { +func AddCardTypeToProjectTable(x db.EngineMigration) error { type Project struct { CardType int `xorm:"NOT NULL DEFAULT 0"` } diff --git a/models/migrations/v1_19/v242.go b/models/migrations/v1_19/v242.go index e9e759eaaa9..9922eadce8d 100644 --- a/models/migrations/v1_19/v242.go +++ b/models/migrations/v1_19/v242.go @@ -4,13 +4,12 @@ package v1_19 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) // AlterPublicGPGKeyImportContentFieldToMediumText: set GPGKeyImport Content field to MEDIUMTEXT -func AlterPublicGPGKeyImportContentFieldToMediumText(x *xorm.Engine) error { +func AlterPublicGPGKeyImportContentFieldToMediumText(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() if err := sess.Begin(); err != nil { diff --git a/models/migrations/v1_19/v243.go b/models/migrations/v1_19/v243.go index 9c3f3725949..99f7e97608e 100644 --- a/models/migrations/v1_19/v243.go +++ b/models/migrations/v1_19/v243.go @@ -3,11 +3,9 @@ package v1_19 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddExclusiveLabel(x *xorm.Engine) error { +func AddExclusiveLabel(x db.EngineMigration) error { type Label struct { Exclusive bool } diff --git a/models/migrations/v1_20/v244.go b/models/migrations/v1_20/v244.go index 76cdccaca5b..e90c411938c 100644 --- a/models/migrations/v1_20/v244.go +++ b/models/migrations/v1_20/v244.go @@ -3,11 +3,9 @@ package v1_20 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddNeedApprovalToActionRun(x *xorm.Engine) error { +func AddNeedApprovalToActionRun(x db.EngineMigration) error { /* New index: TriggerUserID New fields: NeedApproval, ApprovedBy diff --git a/models/migrations/v1_20/v245.go b/models/migrations/v1_20/v245.go index 4acb11416c3..213038316a0 100644 --- a/models/migrations/v1_20/v245.go +++ b/models/migrations/v1_20/v245.go @@ -6,13 +6,12 @@ package v1_20 import ( "context" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func RenameWebhookOrgToOwner(x *xorm.Engine) error { +func RenameWebhookOrgToOwner(x db.EngineMigration) error { type Webhook struct { OrgID int64 `xorm:"INDEX"` } diff --git a/models/migrations/v1_20/v246.go b/models/migrations/v1_20/v246.go index 22bf7234043..a8f88ac04c0 100644 --- a/models/migrations/v1_20/v246.go +++ b/models/migrations/v1_20/v246.go @@ -3,11 +3,9 @@ package v1_20 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddNewColumnForProject(x *xorm.Engine) error { +func AddNewColumnForProject(x db.EngineMigration) error { type Project struct { OwnerID int64 `xorm:"INDEX"` } diff --git a/models/migrations/v1_20/v247.go b/models/migrations/v1_20/v247.go index 4f82937e185..f8402b405c5 100644 --- a/models/migrations/v1_20/v247.go +++ b/models/migrations/v1_20/v247.go @@ -4,13 +4,12 @@ package v1_20 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" - - "xorm.io/xorm" ) // FixIncorrectProjectType: set individual project's type from 3(TypeOrganization) to 1(TypeIndividual) -func FixIncorrectProjectType(x *xorm.Engine) error { +func FixIncorrectProjectType(x db.EngineMigration) error { type User struct { ID int64 `xorm:"pk autoincr"` Type int diff --git a/models/migrations/v1_20/v248.go b/models/migrations/v1_20/v248.go index 4f2091e4bca..5b76b5fb55c 100644 --- a/models/migrations/v1_20/v248.go +++ b/models/migrations/v1_20/v248.go @@ -3,9 +3,9 @@ package v1_20 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddVersionToActionRunner(x *xorm.Engine) error { +func AddVersionToActionRunner(x db.EngineMigration) error { type ActionRunner struct { Version string `xorm:"VARCHAR(64)"` // the version of act_runner } diff --git a/models/migrations/v1_20/v249.go b/models/migrations/v1_20/v249.go index c6d3a177ca3..53bd2c40c98 100644 --- a/models/migrations/v1_20/v249.go +++ b/models/migrations/v1_20/v249.go @@ -4,9 +4,9 @@ package v1_20 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) @@ -40,6 +40,6 @@ func (a *Action) TableIndices() []*schemas.Index { return indices } -func ImproveActionTableIndices(x *xorm.Engine) error { +func ImproveActionTableIndices(x db.EngineMigration) error { return x.Sync(new(Action)) } diff --git a/models/migrations/v1_20/v250.go b/models/migrations/v1_20/v250.go index ec45e6e5c31..b011c5b0511 100644 --- a/models/migrations/v1_20/v250.go +++ b/models/migrations/v1_20/v250.go @@ -6,12 +6,11 @@ package v1_20 import ( "strings" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/json" - - "xorm.io/xorm" ) -func ChangeContainerMetadataMultiArch(x *xorm.Engine) error { +func ChangeContainerMetadataMultiArch(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() diff --git a/models/migrations/v1_20/v251.go b/models/migrations/v1_20/v251.go index a274c22a731..98676a572f9 100644 --- a/models/migrations/v1_20/v251.go +++ b/models/migrations/v1_20/v251.go @@ -4,12 +4,11 @@ package v1_20 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" - - "xorm.io/xorm" ) -func FixIncorrectOwnerTeamUnitAccessMode(x *xorm.Engine) error { +func FixIncorrectOwnerTeamUnitAccessMode(x db.EngineMigration) error { type UnitType int type AccessMode int diff --git a/models/migrations/v1_20/v252.go b/models/migrations/v1_20/v252.go index d6aa6027534..2c86663b91a 100644 --- a/models/migrations/v1_20/v252.go +++ b/models/migrations/v1_20/v252.go @@ -4,12 +4,11 @@ package v1_20 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" - - "xorm.io/xorm" ) -func FixIncorrectAdminTeamUnitAccessMode(x *xorm.Engine) error { +func FixIncorrectAdminTeamUnitAccessMode(x db.EngineMigration) error { type UnitType int type AccessMode int diff --git a/models/migrations/v1_20/v253.go b/models/migrations/v1_20/v253.go index c96454dbf92..74d8c693333 100644 --- a/models/migrations/v1_20/v253.go +++ b/models/migrations/v1_20/v253.go @@ -4,12 +4,11 @@ package v1_20 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" - - "xorm.io/xorm" ) -func FixExternalTrackerAndExternalWikiAccessModeInOwnerAndAdminTeam(x *xorm.Engine) error { +func FixExternalTrackerAndExternalWikiAccessModeInOwnerAndAdminTeam(x db.EngineMigration) error { type UnitType int type AccessMode int diff --git a/models/migrations/v1_20/v254.go b/models/migrations/v1_20/v254.go index 9cdbfb39164..912ad36b4a2 100644 --- a/models/migrations/v1_20/v254.go +++ b/models/migrations/v1_20/v254.go @@ -3,11 +3,9 @@ package v1_20 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddActionTaskOutputTable(x *xorm.Engine) error { +func AddActionTaskOutputTable(x db.EngineMigration) error { type ActionTaskOutput struct { ID int64 TaskID int64 `xorm:"INDEX UNIQUE(task_id_output_key)"` diff --git a/models/migrations/v1_20/v255.go b/models/migrations/v1_20/v255.go index caf198700e0..3ec64d43c4b 100644 --- a/models/migrations/v1_20/v255.go +++ b/models/migrations/v1_20/v255.go @@ -4,12 +4,11 @@ package v1_20 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddArchivedUnixToRepository(x *xorm.Engine) error { +func AddArchivedUnixToRepository(x db.EngineMigration) error { type Repository struct { ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT 0"` } diff --git a/models/migrations/v1_20/v256.go b/models/migrations/v1_20/v256.go index 7b84c1e1544..126b1e6f199 100644 --- a/models/migrations/v1_20/v256.go +++ b/models/migrations/v1_20/v256.go @@ -3,11 +3,9 @@ package v1_20 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddIsInternalColumnToPackage(x *xorm.Engine) error { +func AddIsInternalColumnToPackage(x db.EngineMigration) error { type Package struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"` diff --git a/models/migrations/v1_20/v257.go b/models/migrations/v1_20/v257.go index 9d5f7c07dfc..6e47d1387ab 100644 --- a/models/migrations/v1_20/v257.go +++ b/models/migrations/v1_20/v257.go @@ -4,12 +4,11 @@ package v1_20 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreateActionArtifactTable(x *xorm.Engine) error { +func CreateActionArtifactTable(x db.EngineMigration) error { // ActionArtifact is a file that is stored in the artifact storage. type ActionArtifact struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_20/v258.go b/models/migrations/v1_20/v258.go index 1d3faffdaed..4d0ec565cfa 100644 --- a/models/migrations/v1_20/v258.go +++ b/models/migrations/v1_20/v258.go @@ -3,11 +3,9 @@ package v1_20 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddPinOrderToIssue(x *xorm.Engine) error { +func AddPinOrderToIssue(x db.EngineMigration) error { type Issue struct { PinOrder int `xorm:"DEFAULT 0"` } diff --git a/models/migrations/v1_20/v259.go b/models/migrations/v1_20/v259.go index 9e0dc9b61d9..e356e97582e 100644 --- a/models/migrations/v1_20/v259.go +++ b/models/migrations/v1_20/v259.go @@ -7,9 +7,8 @@ import ( "fmt" "strings" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" - - "xorm.io/xorm" ) // unknownAccessTokenScope represents the scope for an access token that isn't @@ -319,7 +318,7 @@ type AccessToken struct { Scope string } -func ConvertScopedAccessTokens(x *xorm.Engine) error { +func ConvertScopedAccessTokens(x db.EngineMigration) error { var tokens []*AccessToken if err := x.Find(&tokens); err != nil { diff --git a/models/migrations/v1_21/v260.go b/models/migrations/v1_21/v260.go index 8540c58ae86..a146ee68f93 100644 --- a/models/migrations/v1_21/v260.go +++ b/models/migrations/v1_21/v260.go @@ -4,12 +4,11 @@ package v1_21 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func DropCustomLabelsColumnOfActionRunner(x *xorm.Engine) error { +func DropCustomLabelsColumnOfActionRunner(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() diff --git a/models/migrations/v1_21/v261.go b/models/migrations/v1_21/v261.go index 122b98eb93b..54026cf2f63 100644 --- a/models/migrations/v1_21/v261.go +++ b/models/migrations/v1_21/v261.go @@ -4,12 +4,11 @@ package v1_21 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreateVariableTable(x *xorm.Engine) error { +func CreateVariableTable(x db.EngineMigration) error { type ActionVariable struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(owner_repo_name)"` diff --git a/models/migrations/v1_21/v262.go b/models/migrations/v1_21/v262.go index 6e88e29b9db..aea7dadce74 100644 --- a/models/migrations/v1_21/v262.go +++ b/models/migrations/v1_21/v262.go @@ -3,11 +3,9 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddTriggerEventToActionRun(x *xorm.Engine) error { +func AddTriggerEventToActionRun(x db.EngineMigration) error { type ActionRun struct { TriggerEvent string } diff --git a/models/migrations/v1_21/v263.go b/models/migrations/v1_21/v263.go index 55c418bde0d..5b57c3cfb2b 100644 --- a/models/migrations/v1_21/v263.go +++ b/models/migrations/v1_21/v263.go @@ -6,11 +6,11 @@ package v1_21 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) // AddGitSizeAndLFSSizeToRepositoryTable: add GitSize and LFSSize columns to Repository -func AddGitSizeAndLFSSizeToRepositoryTable(x *xorm.Engine) error { +func AddGitSizeAndLFSSizeToRepositoryTable(x db.EngineMigration) error { type Repository struct { GitSize int64 `xorm:"NOT NULL DEFAULT 0"` LFSSize int64 `xorm:"NOT NULL DEFAULT 0"` diff --git a/models/migrations/v1_21/v264.go b/models/migrations/v1_21/v264.go index 7fc0ec60240..4c64c3f6864 100644 --- a/models/migrations/v1_21/v264.go +++ b/models/migrations/v1_21/v264.go @@ -9,11 +9,9 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddBranchTable(x *xorm.Engine) error { +func AddBranchTable(x db.EngineMigration) error { type Branch struct { ID int64 RepoID int64 `xorm:"UNIQUE(s)"` diff --git a/models/migrations/v1_21/v265.go b/models/migrations/v1_21/v265.go index b6892acc277..8c58989c476 100644 --- a/models/migrations/v1_21/v265.go +++ b/models/migrations/v1_21/v265.go @@ -3,11 +3,9 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AlterActionArtifactTable(x *xorm.Engine) error { +func AlterActionArtifactTable(x db.EngineMigration) error { // ActionArtifact is a file that is stored in the artifact storage. type ActionArtifact struct { RunID int64 `xorm:"index unique(runid_name_path)"` // The run id of the artifact diff --git a/models/migrations/v1_21/v266.go b/models/migrations/v1_21/v266.go index 440549e868b..c9d8a2d0990 100644 --- a/models/migrations/v1_21/v266.go +++ b/models/migrations/v1_21/v266.go @@ -3,11 +3,9 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func ReduceCommitStatus(x *xorm.Engine) error { +func ReduceCommitStatus(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() diff --git a/models/migrations/v1_21/v267.go b/models/migrations/v1_21/v267.go index 394139a17e2..62eff40c1d5 100644 --- a/models/migrations/v1_21/v267.go +++ b/models/migrations/v1_21/v267.go @@ -4,12 +4,11 @@ package v1_21 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreateActionTasksVersionTable(x *xorm.Engine) error { +func CreateActionTasksVersionTable(x db.EngineMigration) error { type ActionTasksVersion struct { ID int64 `xorm:"pk autoincr"` OwnerID int64 `xorm:"UNIQUE(owner_repo)"` diff --git a/models/migrations/v1_21/v268.go b/models/migrations/v1_21/v268.go index b677d2383e9..c3809c125f1 100644 --- a/models/migrations/v1_21/v268.go +++ b/models/migrations/v1_21/v268.go @@ -3,12 +3,10 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" // UpdateActionsRefIndex updates the index of actions ref field -func UpdateActionsRefIndex(x *xorm.Engine) error { +func UpdateActionsRefIndex(x db.EngineMigration) error { type ActionRun struct { Ref string `xorm:"index"` // the commit/tag/… causing the run } diff --git a/models/migrations/v1_21/v269.go b/models/migrations/v1_21/v269.go index 042040927d4..6d4fd2f7755 100644 --- a/models/migrations/v1_21/v269.go +++ b/models/migrations/v1_21/v269.go @@ -3,10 +3,8 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func DropDeletedBranchTable(x *xorm.Engine) error { +func DropDeletedBranchTable(x db.EngineMigration) error { return x.DropTables("deleted_branch") } diff --git a/models/migrations/v1_21/v270.go b/models/migrations/v1_21/v270.go index ab7c5660bad..dec8a263f5c 100644 --- a/models/migrations/v1_21/v270.go +++ b/models/migrations/v1_21/v270.go @@ -3,11 +3,9 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func FixPackagePropertyTypo(x *xorm.Engine) error { +func FixPackagePropertyTypo(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() diff --git a/models/migrations/v1_21/v271.go b/models/migrations/v1_21/v271.go index 05e1af1351d..06db190e1a9 100644 --- a/models/migrations/v1_21/v271.go +++ b/models/migrations/v1_21/v271.go @@ -4,12 +4,11 @@ package v1_21 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddArchivedUnixColumInLabelTable(x *xorm.Engine) error { +func AddArchivedUnixColumInLabelTable(x db.EngineMigration) error { type Label struct { ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT NULL"` } diff --git a/models/migrations/v1_21/v272.go b/models/migrations/v1_21/v272.go index 14c1e0c4b0f..b9ac2c9132e 100644 --- a/models/migrations/v1_21/v272.go +++ b/models/migrations/v1_21/v272.go @@ -3,11 +3,9 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddVersionToActionRunTable(x *xorm.Engine) error { +func AddVersionToActionRunTable(x db.EngineMigration) error { type ActionRun struct { Version int `xorm:"version default 0"` } diff --git a/models/migrations/v1_21/v273.go b/models/migrations/v1_21/v273.go index e614a56a7dc..a647a85b09c 100644 --- a/models/migrations/v1_21/v273.go +++ b/models/migrations/v1_21/v273.go @@ -4,12 +4,11 @@ package v1_21 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddActionScheduleTable(x *xorm.Engine) error { +func AddActionScheduleTable(x db.EngineMigration) error { type ActionSchedule struct { ID int64 Title string diff --git a/models/migrations/v1_21/v274.go b/models/migrations/v1_21/v274.go index d0b557a1519..e10ef7adbc7 100644 --- a/models/migrations/v1_21/v274.go +++ b/models/migrations/v1_21/v274.go @@ -6,12 +6,11 @@ package v1_21 import ( "time" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddExpiredUnixColumnInActionArtifactTable(x *xorm.Engine) error { +func AddExpiredUnixColumnInActionArtifactTable(x db.EngineMigration) error { type ActionArtifact struct { ExpiredUnix timeutil.TimeStamp `xorm:"index"` // time when the artifact will be expired } @@ -21,7 +20,7 @@ func AddExpiredUnixColumnInActionArtifactTable(x *xorm.Engine) error { return updateArtifactsExpiredUnixTo90Days(x) } -func updateArtifactsExpiredUnixTo90Days(x *xorm.Engine) error { +func updateArtifactsExpiredUnixTo90Days(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() diff --git a/models/migrations/v1_21/v275.go b/models/migrations/v1_21/v275.go index 2bfe5c72fa9..7e435f902dd 100644 --- a/models/migrations/v1_21/v275.go +++ b/models/migrations/v1_21/v275.go @@ -3,11 +3,9 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddScheduleIDForActionRun(x *xorm.Engine) error { +func AddScheduleIDForActionRun(x db.EngineMigration) error { type ActionRun struct { ScheduleID int64 } diff --git a/models/migrations/v1_21/v276.go b/models/migrations/v1_21/v276.go index be24b31902e..b5494ae46fe 100644 --- a/models/migrations/v1_21/v276.go +++ b/models/migrations/v1_21/v276.go @@ -6,14 +6,13 @@ package v1_21 import ( "context" + "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func AddRemoteAddressToMirrors(x *xorm.Engine) error { +func AddRemoteAddressToMirrors(x db.EngineMigration) error { type Mirror struct { RemoteAddress string `xorm:"VARCHAR(2048)"` } @@ -33,7 +32,7 @@ func AddRemoteAddressToMirrors(x *xorm.Engine) error { return migratePushMirrors(x) } -func migratePullMirrors(x *xorm.Engine) error { +func migratePullMirrors(x db.EngineMigration) error { type Mirror struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX"` @@ -95,7 +94,7 @@ func migratePullMirrors(x *xorm.Engine) error { return sess.Commit() } -func migratePushMirrors(x *xorm.Engine) error { +func migratePushMirrors(x db.EngineMigration) error { type PushMirror struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX"` diff --git a/models/migrations/v1_21/v277.go b/models/migrations/v1_21/v277.go index 0c102edddec..46b6325671a 100644 --- a/models/migrations/v1_21/v277.go +++ b/models/migrations/v1_21/v277.go @@ -3,11 +3,9 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddIndexToIssueUserIssueID(x *xorm.Engine) error { +func AddIndexToIssueUserIssueID(x db.EngineMigration) error { type IssueUser struct { IssueID int64 `xorm:"INDEX"` } diff --git a/models/migrations/v1_21/v278.go b/models/migrations/v1_21/v278.go index 846f2286780..1d53d10e842 100644 --- a/models/migrations/v1_21/v278.go +++ b/models/migrations/v1_21/v278.go @@ -3,11 +3,9 @@ package v1_21 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddIndexToCommentDependentIssueID(x *xorm.Engine) error { +func AddIndexToCommentDependentIssueID(x db.EngineMigration) error { type Comment struct { DependentIssueID int64 `xorm:"index"` } diff --git a/models/migrations/v1_21/v279.go b/models/migrations/v1_21/v279.go index beb39effe1a..5961ac57762 100644 --- a/models/migrations/v1_21/v279.go +++ b/models/migrations/v1_21/v279.go @@ -4,10 +4,12 @@ package v1_21 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddIndexToActionUserID(x *xorm.Engine) error { +func AddIndexToActionUserID(x db.EngineMigration) error { type Action struct { UserID int64 `xorm:"INDEX"` } diff --git a/models/migrations/v1_22/v280.go b/models/migrations/v1_22/v280.go index 2271cb60896..aab89dfd337 100644 --- a/models/migrations/v1_22/v280.go +++ b/models/migrations/v1_22/v280.go @@ -3,11 +3,9 @@ package v1_22 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func RenameUserThemes(x *xorm.Engine) error { +func RenameUserThemes(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() diff --git a/models/migrations/v1_22/v281.go b/models/migrations/v1_22/v281.go index 129ec2cba09..7678a5b0571 100644 --- a/models/migrations/v1_22/v281.go +++ b/models/migrations/v1_22/v281.go @@ -4,12 +4,11 @@ package v1_22 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func CreateAuthTokenTable(x *xorm.Engine) error { +func CreateAuthTokenTable(x db.EngineMigration) error { type AuthToken struct { ID string `xorm:"pk"` TokenHash string diff --git a/models/migrations/v1_22/v282.go b/models/migrations/v1_22/v282.go index eed64c30f79..0ae350e4eba 100644 --- a/models/migrations/v1_22/v282.go +++ b/models/migrations/v1_22/v282.go @@ -3,11 +3,9 @@ package v1_22 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddIndexToPullAutoMergeDoerID(x *xorm.Engine) error { +func AddIndexToPullAutoMergeDoerID(x db.EngineMigration) error { type PullAutoMerge struct { DoerID int64 `xorm:"INDEX NOT NULL"` } diff --git a/models/migrations/v1_22/v283.go b/models/migrations/v1_22/v283.go index 0eca031b654..e984b7113b2 100644 --- a/models/migrations/v1_22/v283.go +++ b/models/migrations/v1_22/v283.go @@ -6,11 +6,12 @@ package v1_22 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" + "xorm.io/xorm/schemas" ) -func AddCombinedIndexToIssueUser(x *xorm.Engine) error { +func AddCombinedIndexToIssueUser(x db.EngineMigration) error { type OldIssueUser struct { IssueID int64 UID int64 diff --git a/models/migrations/v1_22/v284.go b/models/migrations/v1_22/v284.go index 31b38f6aed8..5d445293881 100644 --- a/models/migrations/v1_22/v284.go +++ b/models/migrations/v1_22/v284.go @@ -4,10 +4,12 @@ package v1_22 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddIgnoreStaleApprovalsColumnToProtectedBranchTable(x *xorm.Engine) error { +func AddIgnoreStaleApprovalsColumnToProtectedBranchTable(x db.EngineMigration) error { type ProtectedBranch struct { IgnoreStaleApprovals bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_22/v285.go b/models/migrations/v1_22/v285.go index fed89f670e0..54d5ca6bc56 100644 --- a/models/migrations/v1_22/v285.go +++ b/models/migrations/v1_22/v285.go @@ -6,10 +6,12 @@ package v1_22 import ( "time" + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddPreviousDurationToActionRun(x *xorm.Engine) error { +func AddPreviousDurationToActionRun(x db.EngineMigration) error { type ActionRun struct { PreviousDuration time.Duration } diff --git a/models/migrations/v1_22/v286.go b/models/migrations/v1_22/v286.go index f3ba50dbb63..b0804c82ebf 100644 --- a/models/migrations/v1_22/v286.go +++ b/models/migrations/v1_22/v286.go @@ -6,13 +6,14 @@ import ( "errors" "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "xorm.io/xorm" ) -func expandHashReferencesToSha256(x *xorm.Engine) error { +func expandHashReferencesToSha256(x db.EngineMigration) error { alteredTables := [][2]string{ {"commit_status", "context_hash"}, {"comment", "commit_sha"}, @@ -81,7 +82,7 @@ func expandHashReferencesToSha256(x *xorm.Engine) error { return db.Commit() } -func addObjectFormatNameToRepository(x *xorm.Engine) error { +func addObjectFormatNameToRepository(x db.EngineMigration) error { type Repository struct { ObjectFormatName string `xorm:"VARCHAR(6) NOT NULL DEFAULT 'sha1'"` } @@ -99,7 +100,7 @@ func addObjectFormatNameToRepository(x *xorm.Engine) error { return err } -func AdjustDBForSha256(x *xorm.Engine) error { +func AdjustDBForSha256(x db.EngineMigration) error { if err := expandHashReferencesToSha256(x); err != nil { return err } diff --git a/models/migrations/v1_22/v286_test.go b/models/migrations/v1_22/v286_test.go index 1bd7fac2f18..11d1026277e 100644 --- a/models/migrations/v1_22/v286_test.go +++ b/models/migrations/v1_22/v286_test.go @@ -6,13 +6,13 @@ package v1_22 import ( "testing" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/migrationtest" "github.com/stretchr/testify/assert" - "xorm.io/xorm" ) -func PrepareOldRepository(t *testing.T) (*xorm.Engine, func()) { +func PrepareOldRepository(t *testing.T) (db.EngineMigration, func()) { type Repository struct { // old struct ID int64 `xorm:"pk autoincr"` } diff --git a/models/migrations/v1_22/v287.go b/models/migrations/v1_22/v287.go index 5fd901f9ded..715f70a5963 100644 --- a/models/migrations/v1_22/v287.go +++ b/models/migrations/v1_22/v287.go @@ -3,9 +3,7 @@ package v1_22 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" type BadgeUnique struct { ID int64 `xorm:"pk autoincr"` @@ -16,7 +14,7 @@ func (BadgeUnique) TableName() string { return "badge" } -func UseSlugInsteadOfIDForBadges(x *xorm.Engine) error { +func UseSlugInsteadOfIDForBadges(x db.EngineMigration) error { type Badge struct { Slug string } diff --git a/models/migrations/v1_22/v288.go b/models/migrations/v1_22/v288.go index 26c850c2188..a2b6f6a6077 100644 --- a/models/migrations/v1_22/v288.go +++ b/models/migrations/v1_22/v288.go @@ -4,9 +4,8 @@ package v1_22 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) type Blocking struct { @@ -21,6 +20,6 @@ func (*Blocking) TableName() string { return "user_blocking" } -func AddUserBlockingTable(x *xorm.Engine) error { +func AddUserBlockingTable(x db.EngineMigration) error { return x.Sync(&Blocking{}) } diff --git a/models/migrations/v1_22/v289.go b/models/migrations/v1_22/v289.go index 78689a4ffae..11499b68695 100644 --- a/models/migrations/v1_22/v289.go +++ b/models/migrations/v1_22/v289.go @@ -3,9 +3,13 @@ package v1_22 -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/models/db" -func AddDefaultWikiBranch(x *xorm.Engine) error { + "xorm.io/xorm" +) + +func AddDefaultWikiBranch(x db.EngineMigration) error { type Repository struct { ID int64 DefaultWikiBranch string diff --git a/models/migrations/v1_22/v290.go b/models/migrations/v1_22/v290.go index 0f4d78410c1..ec43cefcd92 100644 --- a/models/migrations/v1_22/v290.go +++ b/models/migrations/v1_22/v290.go @@ -4,6 +4,8 @@ package v1_22 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) @@ -11,7 +13,7 @@ type HookTask struct { PayloadVersion int `xorm:"DEFAULT 1"` } -func AddPayloadVersionToHookTaskTable(x *xorm.Engine) error { +func AddPayloadVersionToHookTaskTable(x db.EngineMigration) error { // create missing column if _, err := x.SyncWithOptions(xorm.SyncOptions{ IgnoreIndices: true, diff --git a/models/migrations/v1_22/v291.go b/models/migrations/v1_22/v291.go index 823a644a955..67d928dd4db 100644 --- a/models/migrations/v1_22/v291.go +++ b/models/migrations/v1_22/v291.go @@ -3,9 +3,13 @@ package v1_22 -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/models/db" -func AddCommentIDIndexofAttachment(x *xorm.Engine) error { + "xorm.io/xorm" +) + +func AddCommentIDIndexofAttachment(x db.EngineMigration) error { type Attachment struct { CommentID int64 `xorm:"INDEX"` } diff --git a/models/migrations/v1_22/v293.go b/models/migrations/v1_22/v293.go index 5299b8618f0..54016bc43d3 100644 --- a/models/migrations/v1_22/v293.go +++ b/models/migrations/v1_22/v293.go @@ -4,14 +4,13 @@ package v1_22 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) // CheckProjectColumnsConsistency ensures there is exactly one default board per project present -func CheckProjectColumnsConsistency(x *xorm.Engine) error { +func CheckProjectColumnsConsistency(x db.EngineMigration) error { sess := x.NewSession() defer sess.Close() @@ -79,7 +78,7 @@ func CheckProjectColumnsConsistency(x *xorm.Engine) error { return removeDuplicatedBoardDefault(x) } -func removeDuplicatedBoardDefault(x *xorm.Engine) error { +func removeDuplicatedBoardDefault(x db.EngineMigration) error { type ProjectInfo struct { ProjectID int64 DefaultNum int diff --git a/models/migrations/v1_22/v294.go b/models/migrations/v1_22/v294.go index 8776e51a165..a839bd7b3bd 100644 --- a/models/migrations/v1_22/v294.go +++ b/models/migrations/v1_22/v294.go @@ -6,12 +6,13 @@ package v1_22 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" + "xorm.io/xorm/schemas" ) // AddUniqueIndexForProjectIssue adds unique indexes for project issue table -func AddUniqueIndexForProjectIssue(x *xorm.Engine) error { +func AddUniqueIndexForProjectIssue(x db.EngineMigration) error { // remove possible duplicated records in table project_issue type result struct { IssueID int64 diff --git a/models/migrations/v1_22/v295.go b/models/migrations/v1_22/v295.go index 319b1a399b3..86655d9e0d8 100644 --- a/models/migrations/v1_22/v295.go +++ b/models/migrations/v1_22/v295.go @@ -3,9 +3,9 @@ package v1_22 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddCommitStatusSummary(x *xorm.Engine) error { +func AddCommitStatusSummary(x db.EngineMigration) error { type CommitStatusSummary struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX UNIQUE(repo_id_sha)"` @@ -14,5 +14,5 @@ func AddCommitStatusSummary(x *xorm.Engine) error { } // there is no migrations because if there is no data on this table, it will fall back to get data // from commit status - return x.Sync2(new(CommitStatusSummary)) + return x.Sync(new(CommitStatusSummary)) } diff --git a/models/migrations/v1_22/v296.go b/models/migrations/v1_22/v296.go index 75350f9f654..17981d18b62 100644 --- a/models/migrations/v1_22/v296.go +++ b/models/migrations/v1_22/v296.go @@ -3,9 +3,9 @@ package v1_22 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddCommitStatusSummary2(x *xorm.Engine) error { +func AddCommitStatusSummary2(x db.EngineMigration) error { type CommitStatusSummary struct { ID int64 `xorm:"pk autoincr"` TargetURL string `xorm:"TEXT"` diff --git a/models/migrations/v1_22/v297.go b/models/migrations/v1_22/v297.go index 9a4405f2666..aea13a1e2a0 100644 --- a/models/migrations/v1_22/v297.go +++ b/models/migrations/v1_22/v297.go @@ -4,12 +4,11 @@ package v1_22 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/perm" - - "xorm.io/xorm" ) -func AddRepoUnitEveryoneAccessMode(x *xorm.Engine) error { +func AddRepoUnitEveryoneAccessMode(x db.EngineMigration) error { type RepoUnit struct { //revive:disable-line:exported EveryoneAccessMode perm.AccessMode `xorm:"NOT NULL DEFAULT 0"` } diff --git a/models/migrations/v1_22/v298.go b/models/migrations/v1_22/v298.go index 7700173a004..bf6ebb3bd98 100644 --- a/models/migrations/v1_22/v298.go +++ b/models/migrations/v1_22/v298.go @@ -3,8 +3,8 @@ package v1_22 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func DropWronglyCreatedTable(x *xorm.Engine) error { +func DropWronglyCreatedTable(x db.EngineMigration) error { return x.DropTables("o_auth2_application") } diff --git a/models/migrations/v1_23/v299.go b/models/migrations/v1_23/v299.go index 11021d8855f..50f8e8c0d05 100644 --- a/models/migrations/v1_23/v299.go +++ b/models/migrations/v1_23/v299.go @@ -3,9 +3,13 @@ package v1_23 -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/models/db" -func AddContentVersionToIssueAndComment(x *xorm.Engine) error { + "xorm.io/xorm" +) + +func AddContentVersionToIssueAndComment(x db.EngineMigration) error { type Issue struct { ContentVersion int `xorm:"NOT NULL DEFAULT 0"` } diff --git a/models/migrations/v1_23/v300.go b/models/migrations/v1_23/v300.go index 13c6489c5e4..5ed11b68f71 100644 --- a/models/migrations/v1_23/v300.go +++ b/models/migrations/v1_23/v300.go @@ -3,9 +3,13 @@ package v1_23 -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/models/db" -func AddForcePushBranchProtection(x *xorm.Engine) error { + "xorm.io/xorm" +) + +func AddForcePushBranchProtection(x db.EngineMigration) error { type ProtectedBranch struct { CanForcePush bool `xorm:"NOT NULL DEFAULT false"` EnableForcePushAllowlist bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/migrations/v1_23/v301.go b/models/migrations/v1_23/v301.go index ed8e9ef0599..cd7c90a69cd 100644 --- a/models/migrations/v1_23/v301.go +++ b/models/migrations/v1_23/v301.go @@ -3,10 +3,14 @@ package v1_23 -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/models/db" + + "xorm.io/xorm" +) // AddSkipSeconderyAuthToOAuth2ApplicationTable: add SkipSecondaryAuthorization column, setting existing rows to false -func AddSkipSecondaryAuthColumnToOAuth2ApplicationTable(x *xorm.Engine) error { +func AddSkipSecondaryAuthColumnToOAuth2ApplicationTable(x db.EngineMigration) error { type oauth2Application struct { SkipSecondaryAuthorization bool `xorm:"NOT NULL DEFAULT FALSE"` } diff --git a/models/migrations/v1_23/v302.go b/models/migrations/v1_23/v302.go index e4a50b3ec88..804782332ff 100644 --- a/models/migrations/v1_23/v302.go +++ b/models/migrations/v1_23/v302.go @@ -4,12 +4,13 @@ package v1_23 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" "xorm.io/xorm" ) -func AddIndexToActionTaskStoppedLogExpired(x *xorm.Engine) error { +func AddIndexToActionTaskStoppedLogExpired(x db.EngineMigration) error { type ActionTask struct { Stopped timeutil.TimeStamp `xorm:"index(stopped_log_expired)"` LogExpired bool `xorm:"index(stopped_log_expired)"` diff --git a/models/migrations/v1_23/v303.go b/models/migrations/v1_23/v303.go index dc541a9535a..80a7ecf43fc 100644 --- a/models/migrations/v1_23/v303.go +++ b/models/migrations/v1_23/v303.go @@ -4,6 +4,8 @@ package v1_23 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) @@ -14,7 +16,7 @@ type CommentMetaData struct { ProjectTitle string `json:"project_title"` } -func AddCommentMetaDataColumn(x *xorm.Engine) error { +func AddCommentMetaDataColumn(x db.EngineMigration) error { type Comment struct { CommentMetaData *CommentMetaData `xorm:"JSON TEXT"` // put all non-index metadata in a single field } diff --git a/models/migrations/v1_23/v304.go b/models/migrations/v1_23/v304.go index 35d4d4881a9..915ba8707f6 100644 --- a/models/migrations/v1_23/v304.go +++ b/models/migrations/v1_23/v304.go @@ -3,9 +3,13 @@ package v1_23 -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/models/db" -func AddIndexForReleaseSha1(x *xorm.Engine) error { + "xorm.io/xorm" +) + +func AddIndexForReleaseSha1(x db.EngineMigration) error { type Release struct { Sha1 string `xorm:"INDEX VARCHAR(64)"` } diff --git a/models/migrations/v1_23/v305.go b/models/migrations/v1_23/v305.go index 3762279de1b..e4c7fdb9e0c 100644 --- a/models/migrations/v1_23/v305.go +++ b/models/migrations/v1_23/v305.go @@ -4,12 +4,11 @@ package v1_23 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddRepositoryLicenses(x *xorm.Engine) error { +func AddRepositoryLicenses(x db.EngineMigration) error { type RepoLicense struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"UNIQUE(s) NOT NULL"` diff --git a/models/migrations/v1_23/v306.go b/models/migrations/v1_23/v306.go index c5c89dbeb8f..eb1a2a1bda1 100644 --- a/models/migrations/v1_23/v306.go +++ b/models/migrations/v1_23/v306.go @@ -3,9 +3,13 @@ package v1_23 -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/models/db" -func AddBlockAdminMergeOverrideBranchProtection(x *xorm.Engine) error { + "xorm.io/xorm" +) + +func AddBlockAdminMergeOverrideBranchProtection(x db.EngineMigration) error { type ProtectedBranch struct { BlockAdminMergeOverride bool `xorm:"NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_23/v307.go b/models/migrations/v1_23/v307.go index 54a69d250b7..618d7ee2772 100644 --- a/models/migrations/v1_23/v307.go +++ b/models/migrations/v1_23/v307.go @@ -4,12 +4,11 @@ package v1_23 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func FixMilestoneNoDueDate(x *xorm.Engine) error { +func FixMilestoneNoDueDate(x db.EngineMigration) error { type Milestone struct { DeadlineUnix timeutil.TimeStamp } diff --git a/models/migrations/v1_23/v308.go b/models/migrations/v1_23/v308.go index 695fdfcc2de..137cf618740 100644 --- a/models/migrations/v1_23/v308.go +++ b/models/migrations/v1_23/v308.go @@ -4,9 +4,9 @@ package v1_23 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) @@ -47,6 +47,6 @@ func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index { return indices } -func AddNewIndexForUserDashboard(x *xorm.Engine) error { +func AddNewIndexForUserDashboard(x db.EngineMigration) error { return x.Sync(new(improveActionTableIndicesAction)) } diff --git a/models/migrations/v1_23/v309.go b/models/migrations/v1_23/v309.go index e629b718a80..a622c9f10da 100644 --- a/models/migrations/v1_23/v309.go +++ b/models/migrations/v1_23/v309.go @@ -4,9 +4,9 @@ package v1_23 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) @@ -72,6 +72,6 @@ func (*improveNotificationTableIndicesAction) TableIndices() []*schemas.Index { return indices } -func ImproveNotificationTableIndices(x *xorm.Engine) error { +func ImproveNotificationTableIndices(x db.EngineMigration) error { return x.Sync(&improveNotificationTableIndicesAction{}) } diff --git a/models/migrations/v1_23/v310.go b/models/migrations/v1_23/v310.go index 074b1c54d35..5f009bab4a9 100644 --- a/models/migrations/v1_23/v310.go +++ b/models/migrations/v1_23/v310.go @@ -4,10 +4,12 @@ package v1_23 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddPriorityToProtectedBranch(x *xorm.Engine) error { +func AddPriorityToProtectedBranch(x db.EngineMigration) error { type ProtectedBranch struct { Priority int64 `xorm:"NOT NULL DEFAULT 0"` } diff --git a/models/migrations/v1_23/v311.go b/models/migrations/v1_23/v311.go index ef48085c79b..e229a8b98a3 100644 --- a/models/migrations/v1_23/v311.go +++ b/models/migrations/v1_23/v311.go @@ -4,10 +4,12 @@ package v1_23 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddTimeEstimateColumnToIssueTable(x *xorm.Engine) error { +func AddTimeEstimateColumnToIssueTable(x db.EngineMigration) error { type Issue struct { TimeEstimate int64 `xorm:"NOT NULL DEFAULT 0"` } diff --git a/models/migrations/v1_24/v312.go b/models/migrations/v1_24/v312.go index 823b0eae403..4c8fbbb4538 100644 --- a/models/migrations/v1_24/v312.go +++ b/models/migrations/v1_24/v312.go @@ -4,6 +4,8 @@ package v1_24 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) @@ -16,7 +18,7 @@ func (pullAutoMerge) TableName() string { return "pull_auto_merge" } -func AddDeleteBranchAfterMergeForAutoMerge(x *xorm.Engine) error { +func AddDeleteBranchAfterMergeForAutoMerge(x db.EngineMigration) error { _, err := x.SyncWithOptions(xorm.SyncOptions{ IgnoreConstrains: true, IgnoreIndices: true, diff --git a/models/migrations/v1_24/v313.go b/models/migrations/v1_24/v313.go index 7e6cda6bfd3..3f12488def4 100644 --- a/models/migrations/v1_24/v313.go +++ b/models/migrations/v1_24/v313.go @@ -4,12 +4,11 @@ package v1_24 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func MovePinOrderToTableIssuePin(x *xorm.Engine) error { +func MovePinOrderToTableIssuePin(x db.EngineMigration) error { type IssuePin struct { ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"UNIQUE(s) NOT NULL"` diff --git a/models/migrations/v1_24/v314.go b/models/migrations/v1_24/v314.go index 51cb2e34aa9..19d26d42dab 100644 --- a/models/migrations/v1_24/v314.go +++ b/models/migrations/v1_24/v314.go @@ -3,11 +3,9 @@ package v1_24 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func UpdateOwnerIDOfRepoLevelActionsTables(x *xorm.Engine) error { +func UpdateOwnerIDOfRepoLevelActionsTables(x db.EngineMigration) error { if _, err := x.Exec("UPDATE `action_runner` SET `owner_id` = 0 WHERE `repo_id` > 0 AND `owner_id` > 0"); err != nil { return err } diff --git a/models/migrations/v1_24/v315.go b/models/migrations/v1_24/v315.go index 52b9b447856..efac5b3ddb0 100644 --- a/models/migrations/v1_24/v315.go +++ b/models/migrations/v1_24/v315.go @@ -4,10 +4,12 @@ package v1_24 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddEphemeralToActionRunner(x *xorm.Engine) error { +func AddEphemeralToActionRunner(x db.EngineMigration) error { type ActionRunner struct { Ephemeral bool `xorm:"ephemeral NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_24/v316.go b/models/migrations/v1_24/v316.go index 14e888f9eea..0cdbb89c597 100644 --- a/models/migrations/v1_24/v316.go +++ b/models/migrations/v1_24/v316.go @@ -4,10 +4,12 @@ package v1_24 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddDescriptionForSecretsAndVariables(x *xorm.Engine) error { +func AddDescriptionForSecretsAndVariables(x db.EngineMigration) error { type Secret struct { Description string `xorm:"TEXT"` } diff --git a/models/migrations/v1_24/v317.go b/models/migrations/v1_24/v317.go index a13db2dd27e..7e40bdb9a16 100644 --- a/models/migrations/v1_24/v317.go +++ b/models/migrations/v1_24/v317.go @@ -4,9 +4,9 @@ package v1_24 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) @@ -51,6 +51,6 @@ func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index { return indices } -func AddNewIndexForUserDashboard(x *xorm.Engine) error { +func AddNewIndexForUserDashboard(x db.EngineMigration) error { return x.Sync(new(improveActionTableIndicesAction)) } diff --git a/models/migrations/v1_24/v318.go b/models/migrations/v1_24/v318.go index 9b4a5409609..3b2f342a662 100644 --- a/models/migrations/v1_24/v318.go +++ b/models/migrations/v1_24/v318.go @@ -4,12 +4,13 @@ package v1_24 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/perm" "xorm.io/xorm" ) -func AddRepoUnitAnonymousAccessMode(x *xorm.Engine) error { +func AddRepoUnitAnonymousAccessMode(x db.EngineMigration) error { type RepoUnit struct { //revive:disable-line:exported AnonymousAccessMode perm.AccessMode `xorm:"NOT NULL DEFAULT 0"` } diff --git a/models/migrations/v1_24/v319.go b/models/migrations/v1_24/v319.go index 648081f74e0..e57ce846533 100644 --- a/models/migrations/v1_24/v319.go +++ b/models/migrations/v1_24/v319.go @@ -4,10 +4,12 @@ package v1_24 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddExclusiveOrderColumnToLabelTable(x *xorm.Engine) error { +func AddExclusiveOrderColumnToLabelTable(x db.EngineMigration) error { type Label struct { ExclusiveOrder int `xorm:"DEFAULT 0"` } diff --git a/models/migrations/v1_24/v320.go b/models/migrations/v1_24/v320.go index ebef71939c2..07d085ccb9b 100644 --- a/models/migrations/v1_24/v320.go +++ b/models/migrations/v1_24/v320.go @@ -4,12 +4,13 @@ package v1_24 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/json" "xorm.io/xorm" ) -func MigrateSkipTwoFactor(x *xorm.Engine) error { +func MigrateSkipTwoFactor(x db.EngineMigration) error { type LoginSource struct { TwoFactorPolicy string `xorm:"two_factor_policy NOT NULL DEFAULT ''"` } diff --git a/models/migrations/v1_25/v321.go b/models/migrations/v1_25/v321.go index 73ef180f485..0282e743a7f 100644 --- a/models/migrations/v1_25/v321.go +++ b/models/migrations/v1_25/v321.go @@ -4,14 +4,14 @@ package v1_25 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/setting" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) -func UseLongTextInSomeColumnsAndFixBugs(x *xorm.Engine) error { +func UseLongTextInSomeColumnsAndFixBugs(x db.EngineMigration) error { if !setting.Database.Type.IsMySQL() { return nil // Only mysql need to change from text to long text, for other databases, they are the same } diff --git a/models/migrations/v1_25/v322.go b/models/migrations/v1_25/v322.go index 32dae9945ae..51312cafb39 100644 --- a/models/migrations/v1_25/v322.go +++ b/models/migrations/v1_25/v322.go @@ -4,13 +4,13 @@ package v1_25 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - "xorm.io/xorm" "xorm.io/xorm/schemas" ) -func ExtendCommentTreePathLength(x *xorm.Engine) error { +func ExtendCommentTreePathLength(x db.EngineMigration) error { dbType := x.Dialect().URI().DBType if dbType == schemas.SQLITE { // For SQLITE, varchar or char will always be represented as TEXT return nil diff --git a/models/migrations/v1_26/v323.go b/models/migrations/v1_26/v323.go index b116f73bf0e..1fadd8b16f4 100644 --- a/models/migrations/v1_26/v323.go +++ b/models/migrations/v1_26/v323.go @@ -4,10 +4,12 @@ package v1_26 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddActionsConcurrency(x *xorm.Engine) error { +func AddActionsConcurrency(x db.EngineMigration) error { type ActionRun struct { RepoID int64 `xorm:"index(repo_concurrency)"` RawConcurrency string diff --git a/models/migrations/v1_26/v324.go b/models/migrations/v1_26/v324.go index 5d96bfa3cae..288295a90c5 100644 --- a/models/migrations/v1_26/v324.go +++ b/models/migrations/v1_26/v324.go @@ -6,10 +6,10 @@ package v1_26 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" ) -func FixClosedMilestoneCompleteness(x *xorm.Engine) error { +func FixClosedMilestoneCompleteness(x db.EngineMigration) error { // Update all milestones to recalculate completeness with the new logic: // - Closed milestones with 0 issues should show 100% // - All other milestones should calculate based on closed/total ratio diff --git a/models/migrations/v1_26/v325.go b/models/migrations/v1_26/v325.go index d81540f44e9..8f753554c13 100644 --- a/models/migrations/v1_26/v325.go +++ b/models/migrations/v1_26/v325.go @@ -3,11 +3,9 @@ package v1_26 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func FixMissedRepoIDWhenMigrateAttachments(x *xorm.Engine) error { +func FixMissedRepoIDWhenMigrateAttachments(x db.EngineMigration) error { _, err := x.Exec("UPDATE `attachment` SET `repo_id` = (SELECT `repo_id` FROM `issue` WHERE `issue`.`id` = `attachment`.`issue_id`) WHERE `issue_id` > 0 AND (`repo_id` IS NULL OR `repo_id` = 0);") if err != nil { return err diff --git a/models/migrations/v1_26/v326.go b/models/migrations/v1_26/v326.go index dcf548bec0e..1b0462862c7 100644 --- a/models/migrations/v1_26/v326.go +++ b/models/migrations/v1_26/v326.go @@ -10,12 +10,11 @@ import ( "strconv" "strings" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" webhook_module "code.gitea.io/gitea/modules/webhook" - - "xorm.io/xorm" ) const ( @@ -92,7 +91,7 @@ type commitSHAAndRuns struct { // Only rows whose resolved run ID is below legacyURLIDThreshold are rewritten. // This is because smaller legacy run indexes are more likely to collide with run ID URLs during runtime resolution, // so this migration prioritizes that lower range and leaves the remaining legacy target URLs to the web compatibility logic. -func FixCommitStatusTargetURLToUseRunAndJobID(x *xorm.Engine) error { +func FixCommitStatusTargetURLToUseRunAndJobID(x db.EngineMigration) error { jobsByRunIDCache := make(map[int64][]int64) repoLinkCache := make(map[int64]string) groups, err := loadLegacyMigrationRunGroups(x) @@ -113,7 +112,7 @@ func FixCommitStatusTargetURLToUseRunAndJobID(x *xorm.Engine) error { return nil } -func loadLegacyMigrationRunGroups(x *xorm.Engine) (map[int64]map[string]*commitSHAAndRuns, error) { +func loadLegacyMigrationRunGroups(x db.EngineMigration) (map[int64]map[string]*commitSHAAndRuns, error) { var runs []migrationActionRun if err := x.Table("action_run"). Where("id < ?", legacyURLIDThreshold). @@ -149,7 +148,7 @@ func loadLegacyMigrationRunGroups(x *xorm.Engine) (map[int64]map[string]*commitS } func migrateCommitStatusTargetURLForGroup( - x *xorm.Engine, + x db.EngineMigration, table string, repoID int64, sha string, @@ -210,7 +209,7 @@ func migrateCommitStatusTargetURLForGroup( return nil } -func getRepoLinkCached(x *xorm.Engine, cache map[int64]string, repoID int64) (string, error) { +func getRepoLinkCached(x db.EngineMigration, cache map[int64]string, repoID int64) (string, error) { if link, ok := cache[repoID]; ok { return link, nil } @@ -228,7 +227,7 @@ func getRepoLinkCached(x *xorm.Engine, cache map[int64]string, repoID int64) (st return link, nil } -func getJobIDByIndexCached(x *xorm.Engine, cache map[int64][]int64, runID, jobIndex int64) (int64, bool, error) { +func getJobIDByIndexCached(x db.EngineMigration, cache map[int64][]int64, runID, jobIndex int64) (int64, bool, error) { jobIDs, ok := cache[runID] if !ok { var jobs []migrationActionRunJob diff --git a/models/migrations/v1_26/v326_test.go b/models/migrations/v1_26/v326_test.go index a0225eb774c..5246b7c7fc4 100644 --- a/models/migrations/v1_26/v326_test.go +++ b/models/migrations/v1_26/v326_test.go @@ -6,6 +6,7 @@ package v1_26 import ( "testing" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/migrationtest" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/test" @@ -15,7 +16,6 @@ import ( _ "code.gitea.io/gitea/models/repo" "github.com/stretchr/testify/require" - "xorm.io/xorm" ) func Test_FixCommitStatusTargetURLToUseRunAndJobID(t *testing.T) { @@ -100,7 +100,7 @@ func Test_FixCommitStatusTargetURLToUseRunAndJobID(t *testing.T) { } } -func assertTargetURL(t *testing.T, x *xorm.Engine, table string, id int64, want string) { +func assertTargetURL(t *testing.T, x db.EngineMigration, table string, id int64, want string) { t.Helper() var row struct { diff --git a/models/migrations/v1_26/v327.go b/models/migrations/v1_26/v327.go index 51af567650d..e0afdb958ea 100644 --- a/models/migrations/v1_26/v327.go +++ b/models/migrations/v1_26/v327.go @@ -3,9 +3,13 @@ package v1_26 -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/models/db" -func AddDisabledToActionRunner(x *xorm.Engine) error { + "xorm.io/xorm" +) + +func AddDisabledToActionRunner(x db.EngineMigration) error { type ActionRunner struct { IsDisabled bool `xorm:"is_disabled NOT NULL DEFAULT false"` } diff --git a/models/migrations/v1_26/v328.go b/models/migrations/v1_26/v328.go index 81047305289..2d9d77cd311 100644 --- a/models/migrations/v1_26/v328.go +++ b/models/migrations/v1_26/v328.go @@ -4,10 +4,12 @@ package v1_26 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddTokenPermissionsToActionRunJob(x *xorm.Engine) error { +func AddTokenPermissionsToActionRunJob(x db.EngineMigration) error { type ActionRunJob struct { TokenPermissions string `xorm:"JSON TEXT"` } diff --git a/models/migrations/v1_26/v329.go b/models/migrations/v1_26/v329.go index 1afd155f05e..74baf074a3c 100644 --- a/models/migrations/v1_26/v329.go +++ b/models/migrations/v1_26/v329.go @@ -6,7 +6,8 @@ package v1_26 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" + "xorm.io/xorm/schemas" ) @@ -27,7 +28,7 @@ func (n *UserBadge) TableIndices() []*schemas.Index { // AddUniqueIndexForUserBadge adds a compound unique indexes for user badge table // and it replaces an old index on user_id -func AddUniqueIndexForUserBadge(x *xorm.Engine) error { +func AddUniqueIndexForUserBadge(x db.EngineMigration) error { // remove possible duplicated records in table user_badge type result struct { UserID int64 diff --git a/models/migrations/v1_26/v330.go b/models/migrations/v1_26/v330.go index 9f77331090b..4d083d7abff 100644 --- a/models/migrations/v1_26/v330.go +++ b/models/migrations/v1_26/v330.go @@ -4,10 +4,12 @@ package v1_26 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -func AddNameToWebhook(x *xorm.Engine) error { +func AddNameToWebhook(x db.EngineMigration) error { type Webhook struct { Name string `xorm:"VARCHAR(255) NOT NULL DEFAULT ''"` } diff --git a/models/migrations/v1_27/v331.go b/models/migrations/v1_27/v331.go index 204b7b661e9..413fb8bd877 100644 --- a/models/migrations/v1_27/v331.go +++ b/models/migrations/v1_27/v331.go @@ -7,6 +7,7 @@ import ( "context" "time" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/timeutil" @@ -90,7 +91,7 @@ func (actionRun) TableName() string { } // AddActionRunAttemptModel adds the ActionRunAttempt table and the supporting ActionRun/ActionRunJob fields. -func AddActionRunAttemptModel(x *xorm.Engine) error { +func AddActionRunAttemptModel(x db.EngineMigration) error { // add "action_run_attempt" if _, err := x.SyncWithOptions(xorm.SyncOptions{ IgnoreDropIndices: true, diff --git a/models/migrations/v1_27/v332.go b/models/migrations/v1_27/v332.go index 5721c987c6d..5c7ef465ebe 100644 --- a/models/migrations/v1_27/v332.go +++ b/models/migrations/v1_27/v332.go @@ -4,21 +4,22 @@ package v1_27 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/xorm" ) -// AddMatrixEvaluationColumnsToActionRunJob adds RawStrategy and IsMatrixEvaluated columns -// to support deferred matrix expansion for jobs whose matrix depends on other jobs' outputs. -func AddMatrixEvaluationColumnsToActionRunJob(x *xorm.Engine) error { - // ActionRunJob maps to the "action_run_job" table by xorm naming convention. - type ActionRunJob struct { - RawStrategy string `xorm:"TEXT"` - IsMatrixEvaluated bool - } - if _, err := x.SyncWithOptions(xorm.SyncOptions{ - IgnoreDropIndices: true, - }, new(ActionRunJob)); err != nil { - return err - } - return nil +type mirrorWithLastSyncUnix struct { + LastSyncUnix int64 `xorm:"INDEX"` +} + +func (mirrorWithLastSyncUnix) TableName() string { + return "mirror" +} + +func AddLastSyncUnixToMirror(x db.EngineMigration) error { + _, err := x.SyncWithOptions(xorm.SyncOptions{ + IgnoreDropIndices: true, + }, new(mirrorWithLastSyncUnix)) + return err } diff --git a/models/migrations/v1_27/v333.go b/models/migrations/v1_27/v333.go new file mode 100644 index 00000000000..d492de40b5c --- /dev/null +++ b/models/migrations/v1_27/v333.go @@ -0,0 +1,24 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_27 + +import ( + "code.gitea.io/gitea/models/db" + + "xorm.io/xorm" +) + +func AddBranchProtectionBypassAllowlist(x db.EngineMigration) error { + type ProtectedBranch struct { + EnableBypassAllowlist bool `xorm:"NOT NULL DEFAULT false"` + BypassAllowlistUserIDs []int64 `xorm:"JSON TEXT"` + BypassAllowlistTeamIDs []int64 `xorm:"JSON TEXT"` + } + + _, err := x.SyncWithOptions(xorm.SyncOptions{ + IgnoreConstrains: true, + IgnoreIndices: true, + }, new(ProtectedBranch)) + return err +} diff --git a/models/migrations/v1_27/v333_test.go b/models/migrations/v1_27/v333_test.go new file mode 100644 index 00000000000..768fa10261a --- /dev/null +++ b/models/migrations/v1_27/v333_test.go @@ -0,0 +1,60 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_27 + +import ( + "testing" + + "code.gitea.io/gitea/models/migrations/migrationtest" + + "github.com/stretchr/testify/require" +) + +func Test_AddBranchProtectionBypassAllowlist(t *testing.T) { + type ProtectedBranch struct { + ID int64 `xorm:"pk autoincr"` + RepoID int64 `xorm:"INDEX"` + BranchName string `xorm:"INDEX"` + EnableBypassAllowlist bool `xorm:"NOT NULL DEFAULT false"` + BypassAllowlistUserIDs []int64 `xorm:"JSON TEXT"` + BypassAllowlistTeamIDs []int64 `xorm:"JSON TEXT"` + } + + x, deferable := migrationtest.PrepareTestEnv(t, 0, new(ProtectedBranch)) + defer deferable() + + // Test with default values + _, err := x.Insert(&ProtectedBranch{RepoID: 1, BranchName: "main"}) + require.NoError(t, err) + + // Test with populated allowlist + _, err = x.Insert(&ProtectedBranch{ + RepoID: 1, + BranchName: "develop", + EnableBypassAllowlist: true, + BypassAllowlistUserIDs: []int64{1, 2, 3}, + BypassAllowlistTeamIDs: []int64{10, 20}, + }) + require.NoError(t, err) + + require.NoError(t, AddBranchProtectionBypassAllowlist(x)) + + // Verify the default values record + var pb ProtectedBranch + has, err := x.Where("repo_id = ? AND branch_name = ?", 1, "main").Get(&pb) + require.NoError(t, err) + require.True(t, has) + require.False(t, pb.EnableBypassAllowlist) + require.Nil(t, pb.BypassAllowlistUserIDs) + require.Nil(t, pb.BypassAllowlistTeamIDs) + + // Verify the populated allowlist record + var pb2 ProtectedBranch + has, err = x.Where("repo_id = ? AND branch_name = ?", 1, "develop").Get(&pb2) + require.NoError(t, err) + require.True(t, has) + require.True(t, pb2.EnableBypassAllowlist) + require.Equal(t, []int64{1, 2, 3}, pb2.BypassAllowlistUserIDs) + require.Equal(t, []int64{10, 20}, pb2.BypassAllowlistTeamIDs) +} diff --git a/models/migrations/v1_27/v334.go b/models/migrations/v1_27/v334.go new file mode 100644 index 00000000000..c6b13740ec2 --- /dev/null +++ b/models/migrations/v1_27/v334.go @@ -0,0 +1,22 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_27 + +import ( + "code.gitea.io/gitea/models/db" + + "xorm.io/xorm" +) + +func AddCancellingSupportToActionRunner(x db.EngineMigration) error { + type ActionRunner struct { + HasCancellingSupport bool `xorm:"has_cancelling_support NOT NULL DEFAULT false"` + } + + _, err := x.SyncWithOptions(xorm.SyncOptions{ + IgnoreConstrains: true, + IgnoreDropIndices: true, + }, new(ActionRunner)) + return err +} diff --git a/models/migrations/v1_27/v334_test.go b/models/migrations/v1_27/v334_test.go new file mode 100644 index 00000000000..29369d53320 --- /dev/null +++ b/models/migrations/v1_27/v334_test.go @@ -0,0 +1,36 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_27 + +import ( + "testing" + + "code.gitea.io/gitea/models/migrations/migrationtest" + + "github.com/stretchr/testify/require" +) + +func TestAddCancellingSupportToActionRunner(t *testing.T) { + type ActionRunner struct { + ID int64 `xorm:"pk autoincr"` + Name string + } + + x, deferable := migrationtest.PrepareTestEnv(t, 0, new(ActionRunner)) + defer deferable() + if x == nil || t.Failed() { + return + } + + _, err := x.Insert(&ActionRunner{Name: "runner"}) + require.NoError(t, err) + + require.NoError(t, AddCancellingSupportToActionRunner(x)) + + var hasCancellingSupport bool + has, err := x.SQL("SELECT has_cancelling_support FROM action_runner WHERE id = ?", 1).Get(&hasCancellingSupport) + require.NoError(t, err) + require.True(t, has) + require.False(t, hasCancellingSupport) +} diff --git a/models/migrations/v1_27/v335.go b/models/migrations/v1_27/v335.go new file mode 100644 index 00000000000..684229f0b4d --- /dev/null +++ b/models/migrations/v1_27/v335.go @@ -0,0 +1,23 @@ +// Copyright 2026 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_27 + +import ( + "code.gitea.io/gitea/models/db" + + "xorm.io/xorm" +) + +// AddMatrixEvaluationColumnsToActionRunJob adds RawStrategy and IsMatrixEvaluated columns +// to support deferred matrix expansion for jobs whose matrix depends on other jobs' outputs. +func AddMatrixEvaluationColumnsToActionRunJob(x db.EngineMigration) error { + type ActionRunJob struct { + RawStrategy string `xorm:"TEXT"` + IsMatrixEvaluated bool + } + _, err := x.SyncWithOptions(xorm.SyncOptions{ + IgnoreDropIndices: true, + }, new(ActionRunJob)) + return err +} diff --git a/models/migrations/v1_6/v70.go b/models/migrations/v1_6/v70.go index 41f09669423..6b20715c70b 100644 --- a/models/migrations/v1_6/v70.go +++ b/models/migrations/v1_6/v70.go @@ -7,12 +7,11 @@ import ( "fmt" "time" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func AddIssueDependencies(x *xorm.Engine) (err error) { +func AddIssueDependencies(x db.EngineMigration) (err error) { type IssueDependency struct { ID int64 `xorm:"pk autoincr"` UserID int64 `xorm:"NOT NULL"` diff --git a/models/migrations/v1_6/v71.go b/models/migrations/v1_6/v71.go index b4dcd87ebae..011dc5511d1 100644 --- a/models/migrations/v1_6/v71.go +++ b/models/migrations/v1_6/v71.go @@ -6,14 +6,13 @@ package v1_6 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" - - "xorm.io/xorm" ) -func AddScratchHash(x *xorm.Engine) error { +func AddScratchHash(x db.EngineMigration) error { // TwoFactor see models/twofactor.go type TwoFactor struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_6/v72.go b/models/migrations/v1_6/v72.go index 9fad88a1b61..5668570f2c1 100644 --- a/models/migrations/v1_6/v72.go +++ b/models/migrations/v1_6/v72.go @@ -6,12 +6,11 @@ package v1_6 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddReview(x *xorm.Engine) error { +func AddReview(x db.EngineMigration) error { // Review see models/review.go type Review struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_7/v73.go b/models/migrations/v1_7/v73.go index e0b7a285375..44a035663af 100644 --- a/models/migrations/v1_7/v73.go +++ b/models/migrations/v1_7/v73.go @@ -3,11 +3,9 @@ package v1_7 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddMustChangePassword(x *xorm.Engine) error { +func AddMustChangePassword(x db.EngineMigration) error { // User see models/user.go type User struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_7/v74.go b/models/migrations/v1_7/v74.go index 376be37a246..447606997e8 100644 --- a/models/migrations/v1_7/v74.go +++ b/models/migrations/v1_7/v74.go @@ -3,9 +3,9 @@ package v1_7 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddApprovalWhitelistsToProtectedBranches(x *xorm.Engine) error { +func AddApprovalWhitelistsToProtectedBranches(x db.EngineMigration) error { type ProtectedBranch struct { ApprovalsWhitelistUserIDs []int64 `xorm:"JSON TEXT"` ApprovalsWhitelistTeamIDs []int64 `xorm:"JSON TEXT"` diff --git a/models/migrations/v1_7/v75.go b/models/migrations/v1_7/v75.go index ef115754664..c80edc0c142 100644 --- a/models/migrations/v1_7/v75.go +++ b/models/migrations/v1_7/v75.go @@ -4,11 +4,12 @@ package v1_7 import ( + "code.gitea.io/gitea/models/db" + "xorm.io/builder" - "xorm.io/xorm" ) -func ClearNonusedData(x *xorm.Engine) error { +func ClearNonusedData(x db.EngineMigration) error { condDelete := func(colName string) builder.Cond { return builder.NotIn(colName, builder.Select("id").From("`user`")) } diff --git a/models/migrations/v1_8/v76.go b/models/migrations/v1_8/v76.go index 81e93075497..f3e5c4aadb4 100644 --- a/models/migrations/v1_8/v76.go +++ b/models/migrations/v1_8/v76.go @@ -6,12 +6,11 @@ package v1_8 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddPullRequestRebaseWithMerge(x *xorm.Engine) error { +func AddPullRequestRebaseWithMerge(x db.EngineMigration) error { // RepoUnit describes all units of a repository type RepoUnit struct { ID int64 diff --git a/models/migrations/v1_8/v77.go b/models/migrations/v1_8/v77.go index 4fe5ebe6350..6350c486d7e 100644 --- a/models/migrations/v1_8/v77.go +++ b/models/migrations/v1_8/v77.go @@ -3,11 +3,9 @@ package v1_8 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddUserDefaultTheme(x *xorm.Engine) error { +func AddUserDefaultTheme(x db.EngineMigration) error { type User struct { Theme string `xorm:"VARCHAR(30) NOT NULL DEFAULT ''"` } diff --git a/models/migrations/v1_8/v78.go b/models/migrations/v1_8/v78.go index e67f4641312..1c2afb712f2 100644 --- a/models/migrations/v1_8/v78.go +++ b/models/migrations/v1_8/v78.go @@ -4,12 +4,11 @@ package v1_8 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" - - "xorm.io/xorm" ) -func RenameRepoIsBareToIsEmpty(x *xorm.Engine) error { +func RenameRepoIsBareToIsEmpty(x db.EngineMigration) error { type Repository struct { ID int64 `xorm:"pk autoincr"` IsBare bool diff --git a/models/migrations/v1_8/v79.go b/models/migrations/v1_8/v79.go index 3f50114d5a5..35d16bcd043 100644 --- a/models/migrations/v1_8/v79.go +++ b/models/migrations/v1_8/v79.go @@ -4,12 +4,11 @@ package v1_8 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/setting" - - "xorm.io/xorm" ) -func AddCanCloseIssuesViaCommitInAnyBranch(x *xorm.Engine) error { +func AddCanCloseIssuesViaCommitInAnyBranch(x db.EngineMigration) error { type Repository struct { ID int64 `xorm:"pk autoincr"` CloseIssuesViaCommitInAnyBranch bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/migrations/v1_8/v80.go b/models/migrations/v1_8/v80.go index 6f9df47a933..2518a8b1e48 100644 --- a/models/migrations/v1_8/v80.go +++ b/models/migrations/v1_8/v80.go @@ -3,9 +3,9 @@ package v1_8 -import "xorm.io/xorm" +import "code.gitea.io/gitea/models/db" -func AddIsLockedToIssues(x *xorm.Engine) error { +func AddIsLockedToIssues(x db.EngineMigration) error { // Issue see models/issue.go type Issue struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/migrations/v1_8/v81.go b/models/migrations/v1_8/v81.go index 3c2acc64584..eac4eb33780 100644 --- a/models/migrations/v1_8/v81.go +++ b/models/migrations/v1_8/v81.go @@ -6,11 +6,12 @@ package v1_8 import ( "fmt" - "xorm.io/xorm" + "code.gitea.io/gitea/models/db" + "xorm.io/xorm/schemas" ) -func ChangeU2FCounterType(x *xorm.Engine) error { +func ChangeU2FCounterType(x db.EngineMigration) error { var err error switch x.Dialect().URI().DBType { diff --git a/models/migrations/v1_9/v82.go b/models/migrations/v1_9/v82.go index 8796b0563db..9fbe06267ff 100644 --- a/models/migrations/v1_9/v82.go +++ b/models/migrations/v1_9/v82.go @@ -7,14 +7,13 @@ import ( "context" "fmt" + "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/gitrepo" - - "xorm.io/xorm" ) -func FixReleaseSha1OnReleaseTable(ctx context.Context, x *xorm.Engine) error { +func FixReleaseSha1OnReleaseTable(ctx context.Context, x db.EngineMigration) error { type Release struct { ID int64 RepoID int64 diff --git a/models/migrations/v1_9/v83.go b/models/migrations/v1_9/v83.go index a0cd57f7c5f..86463869513 100644 --- a/models/migrations/v1_9/v83.go +++ b/models/migrations/v1_9/v83.go @@ -4,12 +4,11 @@ package v1_9 import ( + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/timeutil" - - "xorm.io/xorm" ) -func AddUploaderIDForAttachment(x *xorm.Engine) error { +func AddUploaderIDForAttachment(x db.EngineMigration) error { type Attachment struct { ID int64 `xorm:"pk autoincr"` UUID string `xorm:"uuid UNIQUE"` diff --git a/models/migrations/v1_9/v84.go b/models/migrations/v1_9/v84.go index 423915ae57c..95861f07f04 100644 --- a/models/migrations/v1_9/v84.go +++ b/models/migrations/v1_9/v84.go @@ -3,11 +3,9 @@ package v1_9 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddGPGKeyImport(x *xorm.Engine) error { +func AddGPGKeyImport(x db.EngineMigration) error { type GPGKeyImport struct { KeyID string `xorm:"pk CHAR(16) NOT NULL"` Content string `xorm:"TEXT NOT NULL"` diff --git a/models/migrations/v1_9/v85.go b/models/migrations/v1_9/v85.go index 0e95a71f929..010ed5f7840 100644 --- a/models/migrations/v1_9/v85.go +++ b/models/migrations/v1_9/v85.go @@ -6,15 +6,14 @@ package v1_9 import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" - - "xorm.io/xorm" ) -func HashAppToken(x *xorm.Engine) error { +func HashAppToken(x db.EngineMigration) error { // AccessToken see models/token.go type AccessToken struct { ID int64 `xorm:"pk autoincr"` @@ -98,7 +97,7 @@ func HashAppToken(x *xorm.Engine) error { return resyncHashAppTokenWithUniqueHash(x) } -func resyncHashAppTokenWithUniqueHash(x *xorm.Engine) error { +func resyncHashAppTokenWithUniqueHash(x db.EngineMigration) error { // AccessToken see models/token.go type AccessToken struct { TokenHash string `xorm:"UNIQUE"` // sha256 of token - we will ensure UNIQUE later diff --git a/models/migrations/v1_9/v86.go b/models/migrations/v1_9/v86.go index 9464ff0cf68..c031c784b92 100644 --- a/models/migrations/v1_9/v86.go +++ b/models/migrations/v1_9/v86.go @@ -3,11 +3,9 @@ package v1_9 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddHTTPMethodToWebhook(x *xorm.Engine) error { +func AddHTTPMethodToWebhook(x db.EngineMigration) error { type Webhook struct { HTTPMethod string `xorm:"http_method DEFAULT 'POST'"` } diff --git a/models/migrations/v1_9/v87.go b/models/migrations/v1_9/v87.go index 81a4ebf80d0..03982d1cf71 100644 --- a/models/migrations/v1_9/v87.go +++ b/models/migrations/v1_9/v87.go @@ -3,11 +3,9 @@ package v1_9 -import ( - "xorm.io/xorm" -) +import "code.gitea.io/gitea/models/db" -func AddAvatarFieldToRepository(x *xorm.Engine) error { +func AddAvatarFieldToRepository(x db.EngineMigration) error { type Repository struct { // ID(10-20)-md5(32) - must fit into 64 symbols Avatar string `xorm:"VARCHAR(64)"` diff --git a/models/organization/org.go b/models/organization/org.go index 10a2c330e56..278f0861004 100644 --- a/models/organization/org.go +++ b/models/organization/org.go @@ -19,7 +19,6 @@ import ( "code.gitea.io/gitea/modules/util" "xorm.io/builder" - "xorm.io/xorm" ) // ErrOrgNotExist represents a "OrgNotExist" kind of error. @@ -191,7 +190,7 @@ func (opts FindOrgMembersOpts) PublicOnly() bool { } // applyTeamMatesOnlyFilter make sure restricted users only see public team members and there own team mates -func (opts FindOrgMembersOpts) applyTeamMatesOnlyFilter(sess *xorm.Session) { +func (opts FindOrgMembersOpts) applyTeamMatesOnlyFilter(sess db.Session) { if opts.Doer != nil && opts.IsDoerMember && opts.Doer.IsRestricted { teamMates := builder.Select("DISTINCT team_user.uid"). From("team_user"). @@ -463,7 +462,7 @@ func GetOrgUsersByOrgID(ctx context.Context, opts *FindOrgMembersOpts) ([]*OrgUs } if opts.ListOptions.PageSize > 0 { - sess = db.SetSessionPagination(sess, opts) + db.SetSessionPagination(sess, opts) ous := make([]*OrgUser, 0, opts.PageSize) return ous, sess.Find(&ous) diff --git a/models/organization/org_list.go b/models/organization/org_list.go index f37961b5f62..136417d932c 100644 --- a/models/organization/org_list.go +++ b/models/organization/org_list.go @@ -54,6 +54,12 @@ type FindOrgOptions struct { IncludeVisibility structs.VisibleType } +func (opts *FindOrgOptions) ApplyPublicOnly(publicOnly bool) { + if publicOnly { + opts.IncludeVisibility = structs.VisibleTypePublic + } +} + func queryUserOrgIDs(userID int64, includePrivate bool) *builder.Builder { cond := builder.Eq{"uid": userID} if !includePrivate { diff --git a/models/organization/org_test.go b/models/organization/org_test.go index 7a74c5f5fcc..be27dbb96c3 100644 --- a/models/organization/org_test.go +++ b/models/organization/org_test.go @@ -456,6 +456,22 @@ func TestGetUsersWhoCanCreateOrgRepo(t *testing.T) { assert.NotNil(t, users[5]) } +func TestCanCreateOrgRepoByOwnerTeamWithoutFlag(t *testing.T) { + assert.NoError(t, unittest.PrepareTestDatabase()) + + org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3}) + ownerTeam, err := org.GetOwnerTeam(t.Context()) + require.NoError(t, err) + + ownerTeam.CanCreateOrgRepo = false + _, err = db.GetEngine(t.Context()).ID(ownerTeam.ID).Cols("can_create_org_repo").Update(ownerTeam) + require.NoError(t, err) + + ok, err := organization.CanCreateOrgRepo(t.Context(), org.ID, 2) + require.NoError(t, err) + assert.True(t, ok) +} + func TestUser_RemoveOrgRepo(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) org := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 3}) diff --git a/models/organization/org_user.go b/models/organization/org_user.go index 627c1c2edf0..7d0476606c5 100644 --- a/models/organization/org_user.go +++ b/models/organization/org_user.go @@ -8,6 +8,7 @@ import ( "fmt" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/perm" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" @@ -104,7 +105,7 @@ func IsPublicMembership(ctx context.Context, orgID, uid int64) (bool, error) { // CanCreateOrgRepo returns true if user can create repo in organization func CanCreateOrgRepo(ctx context.Context, orgID, uid int64) (bool, error) { return db.GetEngine(ctx). - Where(builder.Eq{"team.can_create_org_repo": true}). + Where(builder.Eq{"team.can_create_org_repo": true}.Or(builder.Eq{"team.authorize": perm.AccessModeOwner})). Join("INNER", "team_user", "team_user.team_id = team.id"). And("team_user.uid = ?", uid). And("team_user.org_id = ?", orgID). diff --git a/models/organization/team_list.go b/models/organization/team_list.go index 5629cec3661..4d98e3148c0 100644 --- a/models/organization/team_list.go +++ b/models/organization/team_list.go @@ -85,7 +85,7 @@ func SearchTeam(ctx context.Context, opts *SearchTeamOptions) (TeamList, int64, if opts.UserID > 0 { sess = sess.Join("INNER", "team_user", "team_user.team_id = team.id") } - sess = db.SetSessionPagination(sess, opts) + db.SetSessionPagination(sess, opts) teams := make([]*Team, 0, opts.PageSize) count, err := sess.Where(cond).OrderBy("CASE WHEN name=? THEN '' ELSE lower_name END", OwnerTeamName).FindAndCount(&teams) diff --git a/models/packages/container/search.go b/models/packages/container/search.go index 9321d9eb410..ac6a6d7fcea 100644 --- a/models/packages/container/search.go +++ b/models/packages/container/search.go @@ -223,7 +223,7 @@ func SearchImageTags(ctx context.Context, opts *ImageTagsSearchOptions) ([]*pack opts.configureOrderBy(sess) if opts.Paginator != nil { - sess = db.SetSessionPagination(sess, opts) + db.SetSessionPagination(sess, opts) } pvs := make([]*packages.PackageVersion, 0, 10) diff --git a/models/packages/package_file.go b/models/packages/package_file.go index 64bd08f0b21..8715aa5339a 100644 --- a/models/packages/package_file.go +++ b/models/packages/package_file.go @@ -232,7 +232,7 @@ func SearchFiles(ctx context.Context, opts *PackageFileSearchOptions) ([]*Packag Where(opts.toConds()) if opts.Paginator != nil { - sess = db.SetSessionPagination(sess, opts) + db.SetSessionPagination(sess, opts) } pfs := make([]*PackageFile, 0, 10) diff --git a/models/packages/package_version.go b/models/packages/package_version.go index 3e0e1899ea4..8d26c24130b 100644 --- a/models/packages/package_version.go +++ b/models/packages/package_version.go @@ -14,7 +14,6 @@ import ( "code.gitea.io/gitea/modules/util" "xorm.io/builder" - "xorm.io/xorm" ) // ErrDuplicatePackageVersion indicates a duplicated package version error @@ -297,11 +296,11 @@ func (opts *PackageSearchOptions) configureOrderBy(e db.Engine) { e.Desc("package_version.id") // Sort by id for stable order with duplicates in the other field } -func searchVersionsBySession(sess *xorm.Session, opts *PackageSearchOptions) ([]*PackageVersion, int64, error) { +func searchVersionsBySession(sess db.Session, opts *PackageSearchOptions) ([]*PackageVersion, int64, error) { opts.configureOrderBy(sess) pvs := make([]*PackageVersion, 0, 10) if opts.Paginator != nil { - sess = db.SetSessionPagination(sess, opts.Paginator) + db.SetSessionPagination(sess, opts.Paginator) count, err := sess.FindAndCount(&pvs) return pvs, count, err } diff --git a/models/renderhelper/main_test.go b/models/renderhelper/main_test.go index 331450172a6..311207e855c 100644 --- a/models/renderhelper/main_test.go +++ b/models/renderhelper/main_test.go @@ -5,12 +5,19 @@ package renderhelper import ( "context" + "strings" "testing" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/markup" ) +func testRenderString(ctx *markup.RenderContext, content string) (string, error) { + var buf strings.Builder + err := markup.Render(ctx, strings.NewReader(content), &buf) + return buf.String(), err +} + func TestMain(m *testing.M) { unittest.MainTest(m, &unittest.TestOptions{ FixtureFiles: []string{"repository.yml", "user.yml"}, diff --git a/models/renderhelper/repo_comment_test.go b/models/renderhelper/repo_comment_test.go index 1443f8b3c02..e181a5bdb56 100644 --- a/models/renderhelper/repo_comment_test.go +++ b/models/renderhelper/repo_comment_test.go @@ -8,7 +8,6 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" - "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "github.com/stretchr/testify/assert" @@ -21,7 +20,7 @@ func TestRepoComment(t *testing.T) { t.Run("AutoLink", func(t *testing.T) { rctx := NewRenderContextRepoComment(t.Context(), repo1).WithMarkupType(markdown.MarkupName) - rendered, err := markup.RenderString(rctx, ` + rendered, err := testRenderString(rctx, ` 65f1bf27bc3bf70f64657658635e66094edbcb4d #1 @user2 @@ -39,7 +38,7 @@ func TestRepoComment(t *testing.T) { // It is Gitea's old behavior, the relative path is resolved to the repo path // It is different from GitHub, GitHub resolves relative links to current page's path - rendered, err := markup.RenderString(rctx, ` + rendered, err := testRenderString(rctx, ` [/test](/test) [./test](./test) ![/image](/image) @@ -59,7 +58,7 @@ func TestRepoComment(t *testing.T) { WithMarkupType(markdown.MarkupName) // the ref path is only used to render commit message: a commit message is rendered at the commit page with its commit ID path - rendered, err := markup.RenderString(rctx, ` + rendered, err := testRenderString(rctx, ` [/test](/test) [./test](./test) ![/image](/image) @@ -75,7 +74,7 @@ func TestRepoComment(t *testing.T) { t.Run("NoRepo", func(t *testing.T) { rctx := NewRenderContextRepoComment(t.Context(), nil).WithMarkupType(markdown.MarkupName) - rendered, err := markup.RenderString(rctx, "any") + rendered, err := testRenderString(rctx, "any") assert.NoError(t, err) assert.Equal(t, "

any

\n", rendered) }) diff --git a/models/renderhelper/repo_file_test.go b/models/renderhelper/repo_file_test.go index 72d98efc66e..cb2852b3e3b 100644 --- a/models/renderhelper/repo_file_test.go +++ b/models/renderhelper/repo_file_test.go @@ -8,7 +8,6 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" - "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" _ "code.gitea.io/gitea/modules/markup/orgmode" @@ -22,7 +21,7 @@ func TestRepoFile(t *testing.T) { t.Run("AutoLink", func(t *testing.T) { rctx := NewRenderContextRepoFile(t.Context(), repo1).WithMarkupType(markdown.MarkupName) - rendered, err := markup.RenderString(rctx, ` + rendered, err := testRenderString(rctx, ` 65f1bf27bc3bf70f64657658635e66094edbcb4d #1 @user2 @@ -38,7 +37,7 @@ func TestRepoFile(t *testing.T) { t.Run("AbsoluteAndRelative", func(t *testing.T) { rctx := NewRenderContextRepoFile(t.Context(), repo1, RepoFileOptions{CurrentRefSubURL: "branch/main"}). WithMarkupType(markdown.MarkupName) - rendered, err := markup.RenderString(rctx, ` + rendered, err := testRenderString(rctx, ` [/test](/test) [./test](./test) ![/image](/image) @@ -56,7 +55,7 @@ func TestRepoFile(t *testing.T) { t.Run("WithCurrentRefSubURL", func(t *testing.T) { rctx := NewRenderContextRepoFile(t.Context(), repo1, RepoFileOptions{CurrentRefSubURL: "/commit/1234"}). WithMarkupType(markdown.MarkupName) - rendered, err := markup.RenderString(rctx, ` + rendered, err := testRenderString(rctx, ` [/test](/test) ![/image](/image) `) @@ -72,7 +71,7 @@ func TestRepoFile(t *testing.T) { CurrentTreePath: "my-dir", }). WithMarkupType(markdown.MarkupName) - rendered, err := markup.RenderString(rctx, ` + rendered, err := testRenderString(rctx, `