diff --git a/.drone.yml b/.drone.yml index 83eb0d7019..62e7ecbd7b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -12,6 +12,9 @@ trigger: - push - tag - pull_request + paths: + exclude: + - docs/** volumes: - name: deps @@ -112,7 +115,6 @@ steps: image: golang:1.19 # this step is kept as the lowest version of golang that we support pull: always environment: - GO111MODULE: on GOPROXY: https://goproxy.io commands: - go build -o gitea_no_gcc # test if build succeeds without the sqlite tag @@ -124,7 +126,6 @@ steps: - name: build-backend-arm64 image: golang:1.20 environment: - GO111MODULE: on GOPROXY: https://goproxy.io GOOS: linux GOARCH: arm64 @@ -140,7 +141,6 @@ steps: - name: build-backend-windows image: golang:1.20 environment: - GO111MODULE: on GOPROXY: https://goproxy.io GOOS: windows GOARCH: amd64 @@ -155,7 +155,6 @@ steps: - name: build-backend-386 image: golang:1.20 environment: - GO111MODULE: on GOPROXY: https://goproxy.io GOOS: linux GOARCH: 386 @@ -183,6 +182,9 @@ trigger: - push - tag - pull_request + paths: + exclude: + - docs/** volumes: - name: deps @@ -410,6 +412,9 @@ trigger: - push - tag - pull_request + paths: + exclude: + - docs/** volumes: - name: deps @@ -517,6 +522,9 @@ depends_on: trigger: event: - pull_request + paths: + exclude: + - docs/** volumes: - name: deps @@ -693,6 +701,9 @@ trigger: - "release/*" event: - push + paths: + exclude: + - docs/** depends_on: - testing-amd64 @@ -944,6 +955,9 @@ trigger: - push - tag - pull_request + paths: + include: + - docs/** steps: - name: build-docs @@ -982,7 +996,10 @@ depends_on: trigger: ref: - - "refs/tags/**" + include: + - "refs/tags/**" + exclude: + - "refs/tags/**-rc*" event: exclude: - cron @@ -1030,6 +1047,68 @@ steps: event: exclude: - pull_request +--- + +kind: pipeline +type: docker +name: docker-linux-amd64-release-candidate-version + +platform: + os: linux + arch: amd64 + +depends_on: + - testing-amd64 + - testing-arm64 + +trigger: + ref: + - "refs/tags/**-rc*" + event: + exclude: + - cron + +steps: + - name: fetch-tags + image: docker:git + pull: always + commands: + - git config --global --add safe.directory /drone/src + - git fetch --tags --force + + - name: publish + image: techknowlogick/drone-docker:latest + pull: always + settings: + tags: ${DRONE_TAG##v}-linux-amd64 + repo: gitea/gitea + build_args: + - GOPROXY=https://goproxy.io + password: + from_secret: docker_password + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request + + - name: publish-rootless + image: techknowlogick/drone-docker:latest + settings: + dockerfile: Dockerfile.rootless + tags: ${DRONE_TAG##v}-linux-amd64-rootless + repo: gitea/gitea + build_args: + - GOPROXY=https://goproxy.io + password: + from_secret: docker_password + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request --- kind: pipeline @@ -1173,6 +1252,9 @@ depends_on: trigger: ref: - "refs/pull/**" + paths: + exclude: + - docs/** steps: - name: dryrun @@ -1206,7 +1288,10 @@ depends_on: trigger: ref: - - "refs/tags/**" + include: + - "refs/tags/**" + exclude: + - "refs/tags/**-rc*" event: exclude: - cron @@ -1255,6 +1340,68 @@ steps: exclude: - pull_request +--- +kind: pipeline +type: docker +name: docker-linux-arm64-release-candidate-version + +platform: + os: linux + arch: arm64 + +depends_on: + - testing-amd64 + - testing-arm64 + +trigger: + ref: + - "refs/tags/**-rc*" + event: + exclude: + - cron + +steps: + - name: fetch-tags + image: docker:git + pull: always + commands: + - git config --global --add safe.directory /drone/src + - git fetch --tags --force + + - name: publish + image: techknowlogick/drone-docker:latest + pull: always + settings: + tags: ${DRONE_TAG##v}-linux-arm64 + repo: gitea/gitea + build_args: + - GOPROXY=https://goproxy.io + password: + from_secret: docker_password + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request + + - name: publish-rootless + image: techknowlogick/drone-docker:latest + settings: + dockerfile: Dockerfile.rootless + tags: ${DRONE_TAG##v}-linux-arm64-rootless + repo: gitea/gitea + build_args: + - GOPROXY=https://goproxy.io + password: + from_secret: docker_password + username: + from_secret: docker_username + when: + event: + exclude: + - pull_request + --- kind: pipeline type: docker @@ -1424,7 +1571,9 @@ trigger: depends_on: - docker-linux-amd64-release-version + - docker-linux-amd64-release-candidate-version - docker-linux-arm64-release-version + - docker-linux-arm64-release-candidate-version --- kind: pipeline @@ -1506,6 +1655,8 @@ depends_on: - docker-linux-arm64-release - docker-linux-amd64-release-version - docker-linux-arm64-release-version + - docker-linux-amd64-release-candidate-version + - docker-linux-arm64-release-candidate-version - docker-linux-amd64-release-branch - docker-linux-arm64-release-branch - docker-manifest diff --git a/.eslintrc.yaml b/.eslintrc.yaml index fdd86a4647..a73df2ee34 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -149,7 +149,7 @@ rules: jquery/no-global-eval: [2] jquery/no-grep: [2] jquery/no-has: [2] - jquery/no-hide: [0] + jquery/no-hide: [2] jquery/no-html: [0] jquery/no-in-array: [2] jquery/no-is-array: [2] @@ -166,13 +166,13 @@ rules: jquery/no-proxy: [2] jquery/no-ready: [0] jquery/no-serialize: [2] - jquery/no-show: [0] + jquery/no-show: [2] jquery/no-size: [2] jquery/no-sizzle: [0] jquery/no-slide: [0] jquery/no-submit: [0] jquery/no-text: [0] - jquery/no-toggle: [0] + jquery/no-toggle: [2] jquery/no-trigger: [0] jquery/no-trim: [2] jquery/no-val: [0] diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3a12bb8f72..b752abb794 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,9 +1,9 @@ - Please check the following: - -1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for bug fixes. -2. Read contributing guidelines: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md -3. Describe what your pull request does and which issue you're targeting (if any) - ---> +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. Describe what your pull request does and which issue you're targeting (if any). +4. It is recommended to enable "Allow edits by maintainers", so maintainers can help more easily. +5. 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 `---`. +6. Delete all these tips before posting. + diff --git a/.stylelintrc.yaml b/.stylelintrc.yaml index d51a08bf8e..ca0f16b07b 100644 --- a/.stylelintrc.yaml +++ b/.stylelintrc.yaml @@ -1,44 +1,133 @@ -extends: stylelint-config-standard - plugins: - stylelint-declaration-strict-value overrides: - files: ["**/*.less"] customSyntax: postcss-less - - files: ["**/*.less"] - rules: - scale-unlimited/declaration-strict-value: [color, { - ignoreValues: /^(inherit|transparent|unset|initial)$/ - }] - files: ["**/chroma/*", "**/codemirror/*", "**/standalone/*", "**/console/*"] rules: scale-unlimited/declaration-strict-value: null rules: alpha-value-notation: null + annotation-no-unknown: true + at-rule-allowed-list: null + at-rule-disallowed-list: null at-rule-empty-line-before: null - block-closing-brace-empty-line-before: null + at-rule-no-unknown: true + at-rule-no-vendor-prefix: true + at-rule-property-required-list: null + block-no-empty: true color-function-notation: null + color-hex-alpha: null color-hex-length: null + color-named: null + color-no-hex: null + color-no-invalid-hex: true comment-empty-line-before: null + comment-no-empty: true + comment-pattern: null + comment-whitespace-inside: null + comment-word-disallowed-list: null + custom-media-pattern: null + custom-property-empty-line-before: null + custom-property-no-missing-var-function: true + custom-property-pattern: null + declaration-block-no-duplicate-custom-properties: true + declaration-block-no-duplicate-properties: [true, {ignore: [consecutive-duplicates-with-different-values]}] declaration-block-no-redundant-longhand-properties: null + declaration-block-no-shorthand-property-overrides: null declaration-block-single-line-max-declarations: null declaration-empty-line-before: null + declaration-no-important: null + declaration-property-max-values: null + declaration-property-unit-allowed-list: null + declaration-property-unit-disallowed-list: null + declaration-property-value-allowed-list: null + declaration-property-value-disallowed-list: null + declaration-property-value-no-unknown: true + font-family-name-quotes: always-where-recommended + font-family-no-duplicate-names: true + font-family-no-missing-generic-family-keyword: true + font-weight-notation: null + function-allowed-list: null + function-calc-no-unspaced-operator: true + function-disallowed-list: null + function-linear-gradient-no-nonstandard-direction: true + function-name-case: lower function-no-unknown: null + function-url-no-scheme-relative: null + function-url-quotes: always + function-url-scheme-allowed-list: null + function-url-scheme-disallowed-list: null hue-degree-notation: null import-notation: string - indentation: 2 - max-line-length: null + keyframe-block-no-duplicate-selectors: true + keyframe-declaration-no-important: true + keyframe-selector-notation: null + keyframes-name-pattern: null + length-zero-no-unit: true + max-nesting-depth: null + media-feature-name-allowed-list: null + media-feature-name-disallowed-list: null + media-feature-name-no-unknown: true + media-feature-name-no-vendor-prefix: true + media-feature-name-unit-allowed-list: null + media-feature-name-value-allowed-list: null + media-feature-range-notation: null + named-grid-areas-no-invalid: true no-descending-specificity: null + no-duplicate-at-import-rules: true + no-duplicate-selectors: true + no-empty-source: true + no-invalid-double-slash-comments: true no-invalid-position-at-import-rule: null - number-leading-zero: never + no-irregular-whitespace: true + no-unknown-animations: null number-max-precision: null + property-allowed-list: null + property-disallowed-list: null + property-no-unknown: true property-no-vendor-prefix: null rule-empty-line-before: null + rule-selector-property-disallowed-list: null + scale-unlimited/declaration-strict-value: [color, {ignoreValues: /^(inherit|transparent|unset|initial|currentcolor)$/}] + selector-attribute-name-disallowed-list: null + selector-attribute-operator-allowed-list: null + selector-attribute-operator-disallowed-list: null + selector-attribute-quotes: always selector-class-pattern: null + selector-combinator-allowed-list: null + selector-combinator-disallowed-list: null + selector-disallowed-list: null selector-id-pattern: null + selector-max-attribute: null + selector-max-class: null + selector-max-combinators: null + selector-max-compound-selectors: null + selector-max-id: null + selector-max-pseudo-class: null + selector-max-specificity: null + selector-max-type: null + selector-max-universal: null + selector-nested-pattern: null + selector-no-qualifying-type: null + selector-no-vendor-prefix: true + selector-not-notation: null + selector-pseudo-class-allowed-list: null + selector-pseudo-class-disallowed-list: null + selector-pseudo-class-no-unknown: true + selector-pseudo-element-allowed-list: null selector-pseudo-element-colon-notation: double + selector-pseudo-element-disallowed-list: null + selector-pseudo-element-no-unknown: true + selector-type-case: lower + selector-type-no-unknown: [true, {ignore: [custom-elements]}] shorthand-property-no-redundant-values: true - string-quotes: null - value-no-vendor-prefix: null + string-no-newline: true + time-min-milliseconds: null + unit-allowed-list: null + unit-disallowed-list: null + unit-no-unknown: true + value-keyword-case: null + value-no-vendor-prefix: [true, {ignoreValues: [box, inline-box]}] diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b52673a0..507722f31b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,56 @@ This changelog goes through all 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.io). +## [1.18.5](https://github.com/go-gitea/gitea/releases/tag/v1.18.5) - 2023-02-21 + +* ENHANCEMENTS + * Hide 2FA status from other members in organization members list (#22999) (#23023) +* BUGFIXES + * Add force_merge to merge request and fix checking mergable (#23010) (#23032) + * Use `--message=%s` for git commit message (#23028) (#23029) + * Render access log template as text instead of HTML (#23013) (#23025) + * Fix the Manually Merged form (#23015) (#23017) + * Use beforeCommit instead of baseCommit (#22949) (#22996) + * Display attachments of review comment when comment content is blank (#23035) (#23046) + * Return empty url for submodule tree entries (#23043) (#23048) + +## [1.18.4](https://github.com/go-gitea/gitea/releases/tag/1.18.4) - 2023-02-20 + +* SECURITY + * Provide the ability to set password hash algorithm parameters (#22942) (#22943) + * Add command to bulk set must-change-password (#22823) (#22928) +* ENHANCEMENTS + * Use import of OCI structs (#22765) (#22805) + * Fix color of tertiary button on dark theme (#22739) (#22744) + * Link issue and pull requests status change in UI notifications directly to their event in the timelined view. (#22627) (#22642) +* BUGFIXES + * Notify on container image create (#22806) (#22965) + * Fix blame view missing lines (#22826) (#22929) + * Fix incorrect role labels for migrated issues and comments (#22914) (#22923) + * Fix PR file tree folders no longer collapsing (#22864) (#22872) + * Escape filename when assemble URL (#22850) (#22871) + * Fix isAllowed of escapeStreamer (#22814) (#22837) + * Load issue before accessing index in merge message (#22822) (#22830) + * Improve trace logging for pulls and processes (#22633) (#22812) + * Fix restore repo bug, clarify the problem of ForeignIndex (#22776) (#22794) + * Add default user visibility to cli command "admin user create" (#22750) (#22760) + * Escape path for the file list (#22741) (#22757) + * Fix bugs with WebAuthn preventing sign in and registration. (#22651) (#22721) + * Add missing close bracket in imagediff (#22710) (#22712) + * Move code comments to a standalone file and fix the bug when adding a reply to an outdated review appears to not post(#20821) (#22707) + * Fix line spacing for plaintext previews (#22699) (#22701) + * Fix wrong hint when deleting a branch successfully from pull request UI (#22673) (#22698) + * Fix README TOC links (#22577) (#22677) + * Fix missing message in git hook when pull requests disabled on fork (#22625) (#22658) + * Improve checkIfPRContentChanged (#22611) (#22644) + * Prevent duplicate labels when importing more than 99 (#22591) (#22598) + * Don't return duplicated users who can create org repo (#22560) (#22562) +* BUILD + * Upgrade golangcilint to v1.51.0 (#22764) +* MISC + * Use proxy for pull mirror (#22771) (#22772) + * Use `--index-url` in PyPi description (#22620) (#22636) + ## [1.18.3](https://github.com/go-gitea/gitea/releases/tag/v1.18.3) - 2023-01-23 * SECURITY diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7a23448e0a..2cea0a4c57 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -299,9 +299,7 @@ known as the release freeze. All the feature pull requests should be merged before feature freeze. And, during the frozen period, a corresponding release branch is open for fixes backported from main branch. Release candidates are made during this period for user testing to -obtain a final version that is maintained in this branch. A release is -maintained by issuing patch releases to only correct critical problems -such as crashes or security issues. +obtain a final version that is maintained in this branch. Major release cycles are seasonal. They always begin on the 25th and end on the 24th (i.e., the 25th of December to March 24th). @@ -311,6 +309,16 @@ for the previous version. For example, if the latest, published release is v1.2, then minor changes for the previous release—e.g., v1.1.0 -> v1.1.1—are still possible. +The previous release gets fixes for: + +- Security issues +- Critical bugs +- Regressions +- Build issues +- Necessary enhancements (including necessary UI/UX fixes) + +The backported fixes should avoid breaking downgrade between minor releases as much as possible. + ## Maintainers To make sure every PR is checked, we have [team diff --git a/Dockerfile b/Dockerfile index 89f000882c..fad8ae1790 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,5 +64,7 @@ CMD ["/bin/s6-svscan", "/etc/s6"] COPY docker/root / COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini +COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/* +RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh diff --git a/Dockerfile.rootless b/Dockerfile.rootless index e92ce857d3..98051f7ddb 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -54,7 +54,9 @@ RUN chown git:git /var/lib/gitea /etc/gitea COPY docker/rootless / COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini +COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-setup.sh /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini +RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh #git:git USER 1000:1000 diff --git a/MAINTAINERS b/MAINTAINERS index a37d336de3..9464d57914 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -47,3 +47,7 @@ Wim (@42wim) Xinyu Zhou (@xin-u) Jason Song (@wolfogre) Yarden Shoham (@yardenshoham) +Yu Tian (@Zettat123) +Eddie Yang <576951401@qq.com> (@yp05327) +Dong Ge (@sillyguodong) +Xinyi Gong (@HesterG) diff --git a/Makefile b/Makefile index 717d7cafc6..3a590559d1 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.4.0 GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0 GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.10 MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/misspell@v0.3.4 -SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.3 +SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.30.4 XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1.5.0 GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@latest diff --git a/assets/go-licenses.json b/assets/go-licenses.json index e78e7968ac..c94d276fd6 100644 --- a/assets/go-licenses.json +++ b/assets/go-licenses.json @@ -932,7 +932,7 @@ { "name": "github.com/urfave/cli", "path": "github.com/urfave/cli/LICENSE", - "licenseText": "MIT License\n\nCopyright (c) 2016 Jeremy Saenz \u0026 Contributors\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" + "licenseText": "MIT License\n\nCopyright (c) 2023 Jeremy Saenz \u0026 Contributors\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/valyala/fastjson", diff --git a/cmd/admin_user_change_password.go b/cmd/admin_user_change_password.go index 1b7c73370d..7866bde912 100644 --- a/cmd/admin_user_change_password.go +++ b/cmd/admin_user_change_password.go @@ -9,7 +9,7 @@ import ( "fmt" user_model "code.gitea.io/gitea/models/user" - pwd "code.gitea.io/gitea/modules/password" + pwd "code.gitea.io/gitea/modules/auth/password" "code.gitea.io/gitea/modules/setting" "github.com/urfave/cli" diff --git a/cmd/admin_user_create.go b/cmd/admin_user_create.go index 579c6f2f62..09eaad54be 100644 --- a/cmd/admin_user_create.go +++ b/cmd/admin_user_create.go @@ -10,7 +10,7 @@ import ( auth_model "code.gitea.io/gitea/models/auth" user_model "code.gitea.io/gitea/models/user" - pwd "code.gitea.io/gitea/modules/password" + pwd "code.gitea.io/gitea/modules/auth/password" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" diff --git a/cmd/cmd.go b/cmd/cmd.go index 493519e135..18d5db3987 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -57,9 +57,10 @@ func confirm() (bool, error) { } func initDB(ctx context.Context) error { - setting.LoadFromExisting() - setting.InitDBConfig() - setting.NewXORMLogService(false) + setting.InitProviderFromExistingFile() + setting.LoadCommonSettings() + setting.LoadDBSetting() + setting.InitSQLLog(false) if setting.Database.Type == "" { log.Fatal(`Database settings are missing from the configuration file: %q. diff --git a/cmd/convert.go b/cmd/convert.go index b9ed9f1627..30e7d01e11 100644 --- a/cmd/convert.go +++ b/cmd/convert.go @@ -32,7 +32,7 @@ func runConvert(ctx *cli.Context) error { log.Info("AppPath: %s", setting.AppPath) log.Info("AppWorkPath: %s", setting.AppWorkPath) log.Info("Custom path: %s", setting.CustomPath) - log.Info("Log path: %s", setting.LogRootPath) + log.Info("Log path: %s", setting.Log.RootPath) log.Info("Configuration file: %s", setting.CustomConf) if !setting.Database.UseMySQL { diff --git a/cmd/doctor.go b/cmd/doctor.go index ceb6e3fbab..e7baad60c1 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -87,14 +87,16 @@ func runRecreateTable(ctx *cli.Context) error { golog.SetPrefix("") golog.SetOutput(log.NewLoggerAsWriter("INFO", log.GetLogger(log.DEFAULT))) - setting.LoadFromExisting() - setting.InitDBConfig() + setting.InitProviderFromExistingFile() + setting.LoadCommonSettings() + setting.LoadDBSetting() - setting.EnableXORMLog = ctx.Bool("debug") + setting.Log.EnableXORMLog = ctx.Bool("debug") setting.Database.LogSQL = ctx.Bool("debug") - setting.Cfg.Section("log").Key("XORM").SetValue(",") + // FIXME: don't use CfgProvider directly + setting.CfgProvider.Section("log").Key("XORM").SetValue(",") - setting.NewXORMLogService(!ctx.Bool("debug")) + setting.InitSQLLog(!ctx.Bool("debug")) stdCtx, cancel := installSignals() defer cancel() diff --git a/cmd/dump.go b/cmd/dump.go index f40ddbac23..c879d2fbee 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -181,20 +181,22 @@ func runDump(ctx *cli.Context) error { } fileName += "." + outType } - setting.LoadFromExisting() + setting.InitProviderFromExistingFile() + setting.LoadCommonSettings() // make sure we are logging to the console no matter what the configuration tells us do to - if _, err := setting.Cfg.Section("log").NewKey("MODE", "console"); err != nil { + // FIXME: don't use CfgProvider directly + if _, err := setting.CfgProvider.Section("log").NewKey("MODE", "console"); err != nil { fatal("Setting logging mode to console failed: %v", err) } - if _, err := setting.Cfg.Section("log.console").NewKey("STDERR", "true"); err != nil { + if _, err := setting.CfgProvider.Section("log.console").NewKey("STDERR", "true"); err != nil { fatal("Setting console logger to stderr failed: %v", err) } if !setting.InstallLock { log.Error("Is '%s' really the right config path?\n", setting.CustomConf) return fmt.Errorf("gitea is not initialized") } - setting.NewServices() // cannot access session settings otherwise + setting.LoadSettings() // cannot access session settings otherwise stdCtx, cancel := installSignals() defer cancel() @@ -322,7 +324,7 @@ func runDump(ctx *cli.Context) error { log.Info("Packing data directory...%s", setting.AppDataPath) var excludes []string - if setting.Cfg.Section("session").Key("PROVIDER").Value() == "file" { + if setting.SessionConfig.OriginalProvider == "file" { var opts session.Options if err = json.Unmarshal([]byte(setting.SessionConfig.ProviderConfig), &opts); err != nil { return err @@ -339,7 +341,7 @@ func runDump(ctx *cli.Context) error { excludes = append(excludes, setting.LFS.Path) excludes = append(excludes, setting.Attachment.Path) excludes = append(excludes, setting.Packages.Path) - excludes = append(excludes, setting.LogRootPath) + excludes = append(excludes, setting.Log.RootPath) excludes = append(excludes, absFileName) if err := addRecursiveExclude(w, "data", setting.AppDataPath, excludes, verbose); err != nil { fatal("Failed to include data directory: %v", err) @@ -378,12 +380,12 @@ func runDump(ctx *cli.Context) error { if ctx.IsSet("skip-log") && ctx.Bool("skip-log") { log.Info("Skip dumping log files") } else { - isExist, err := util.IsExist(setting.LogRootPath) + isExist, err := util.IsExist(setting.Log.RootPath) if err != nil { - log.Error("Unable to check if %s exists. Error: %v", setting.LogRootPath, err) + log.Error("Unable to check if %s exists. Error: %v", setting.Log.RootPath, err) } if isExist { - if err := addRecursiveExclude(w, "log", setting.LogRootPath, []string{absFileName}, verbose); err != nil { + if err := addRecursiveExclude(w, "log", setting.Log.RootPath, []string{absFileName}, verbose); err != nil { fatal("Failed to include log: %v", err) } } diff --git a/cmd/dump_repo.go b/cmd/dump_repo.go index b7b9b3ccc7..0d3970466c 100644 --- a/cmd/dump_repo.go +++ b/cmd/dump_repo.go @@ -94,7 +94,7 @@ func runDumpRepository(ctx *cli.Context) error { log.Info("AppPath: %s", setting.AppPath) log.Info("AppWorkPath: %s", setting.AppWorkPath) log.Info("Custom path: %s", setting.CustomPath) - log.Info("Log path: %s", setting.LogRootPath) + log.Info("Log path: %s", setting.Log.RootPath) log.Info("Configuration file: %s", setting.CustomConf) var ( diff --git a/cmd/embedded.go b/cmd/embedded.go index 118781895e..d87fc0187c 100644 --- a/cmd/embedded.go +++ b/cmd/embedded.go @@ -112,7 +112,8 @@ func initEmbeddedExtractor(c *cli.Context) error { log.DelNamedLogger(log.DEFAULT) // Read configuration file - setting.LoadAllowEmpty() + setting.InitProviderAllowEmpty() + setting.LoadCommonSettings() pats, err := getPatterns(c.Args()) if err != nil { diff --git a/cmd/mailer.go b/cmd/mailer.go index af6613f159..d05fee12bc 100644 --- a/cmd/mailer.go +++ b/cmd/mailer.go @@ -17,7 +17,8 @@ func runSendMail(c *cli.Context) error { ctx, cancel := installSignals() defer cancel() - setting.LoadFromExisting() + setting.InitProviderFromExistingFile() + setting.LoadCommonSettings() if err := argsSet(c, "title"); err != nil { return err diff --git a/cmd/main_test.go b/cmd/main_test.go index 9aacdf7bba..ba323af472 100644 --- a/cmd/main_test.go +++ b/cmd/main_test.go @@ -12,7 +12,7 @@ import ( func init() { setting.SetCustomPathAndConf("", "", "") - setting.LoadForTest() + setting.InitProviderAndLoadCommonSettingsForTest() } func TestMain(m *testing.M) { diff --git a/cmd/migrate.go b/cmd/migrate.go index 2546fca21d..efa791bc65 100644 --- a/cmd/migrate.go +++ b/cmd/migrate.go @@ -33,7 +33,7 @@ func runMigrate(ctx *cli.Context) error { log.Info("AppPath: %s", setting.AppPath) log.Info("AppWorkPath: %s", setting.AppWorkPath) log.Info("Custom path: %s", setting.CustomPath) - log.Info("Log path: %s", setting.LogRootPath) + log.Info("Log path: %s", setting.Log.RootPath) log.Info("Configuration file: %s", setting.CustomConf) if err := db.InitEngineWithMigration(context.Background(), migrations.Migrate); err != nil { diff --git a/cmd/migrate_storage.go b/cmd/migrate_storage.go index 0b8ebe7c8d..dfa7212e5b 100644 --- a/cmd/migrate_storage.go +++ b/cmd/migrate_storage.go @@ -136,7 +136,7 @@ func runMigrateStorage(ctx *cli.Context) error { log.Info("AppPath: %s", setting.AppPath) log.Info("AppWorkPath: %s", setting.AppWorkPath) log.Info("Custom path: %s", setting.CustomPath) - log.Info("Log path: %s", setting.LogRootPath) + log.Info("Log path: %s", setting.Log.RootPath) log.Info("Configuration file: %s", setting.CustomConf) if err := db.InitEngineWithMigration(context.Background(), migrations.Migrate); err != nil { diff --git a/cmd/restore_repo.go b/cmd/restore_repo.go index 23932f821c..c7dff41966 100644 --- a/cmd/restore_repo.go +++ b/cmd/restore_repo.go @@ -54,7 +54,8 @@ func runRestoreRepository(c *cli.Context) error { ctx, cancel := installSignals() defer cancel() - setting.LoadFromExisting() + setting.InitProviderFromExistingFile() + setting.LoadCommonSettings() var units []string if s := c.String("units"); s != "" { units = strings.Split(s, ",") diff --git a/cmd/serv.go b/cmd/serv.go index 346c918b18..145d1b9e93 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -61,7 +61,8 @@ func setup(logPath string, debug bool) { } else { _ = log.NewLogger(1000, "console", "console", `{"level":"fatal","stacktracelevel":"NONE","stderr":true}`) } - setting.LoadFromExisting() + setting.InitProviderFromExistingFile() + setting.LoadCommonSettings() if debug { setting.RunMode = "dev" } diff --git a/cmd/web.go b/cmd/web.go index 49a0335615..8722ddb609 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -158,7 +158,8 @@ func runWeb(ctx *cli.Context) error { log.Info("Global init") // Perform global initialization - setting.LoadFromExisting() + setting.InitProviderFromExistingFile() + setting.LoadCommonSettings() routers.GlobalInitInstalled(graceful.GetManager().HammerContext()) // We check that AppDataPath exists here (it should have been created during installation) diff --git a/contrib/autocompletion/README b/contrib/autocompletion/README new file mode 100644 index 0000000000..1defd219d8 --- /dev/null +++ b/contrib/autocompletion/README @@ -0,0 +1,17 @@ +Bash and Zsh completion +======================= + +From within the gitea root run: + +```bash +source contrib/autocompletion/bash_autocomplete +``` + +or for zsh run: + +```bash +source contrib/autocompletion/zsh_autocomplete +``` + +These scripts will check if gitea is on the path and if so add autocompletion for `gitea`. Or if not autocompletion will work for `./gitea`. +If gitea has been installed as a different program pass in the `PROG` environment variable to set the correct program name. diff --git a/contrib/autocompletion/bash_autocomplete b/contrib/autocompletion/bash_autocomplete new file mode 100755 index 0000000000..5cb62f26a7 --- /dev/null +++ b/contrib/autocompletion/bash_autocomplete @@ -0,0 +1,30 @@ +#! /bin/bash +# Heavily inspired by https://github.com/urfave/cli + +_cli_bash_autocomplete() { + if [[ "${COMP_WORDS[0]}" != "source" ]]; then + local cur opts base + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + if [[ "$cur" == "-"* ]]; then + opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) + else + opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) + fi + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi +} + +if [ -z "$PROG" ] && [ ! "$(command -v gitea &> /dev/null)" ] ; then + complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete gitea +elif [ -z "$PROG" ]; then + complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete ./gitea + complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete "$PWD/gitea" +else + complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete "$PROG" + unset PROG +fi + + + diff --git a/contrib/autocompletion/zsh_autocomplete b/contrib/autocompletion/zsh_autocomplete new file mode 100644 index 0000000000..b3b40df503 --- /dev/null +++ b/contrib/autocompletion/zsh_autocomplete @@ -0,0 +1,30 @@ +#compdef ${PROG:=gitea} + + +# Heavily inspired by https://github.com/urfave/cli + +_cli_zsh_autocomplete() { + + local -a opts + local cur + cur=${words[-1]} + if [[ "$cur" == "-"* ]]; then + opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}") + else + opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") + fi + + if [[ "${opts[1]}" != "" ]]; then + _describe 'values' opts + else + _files + fi + + return +} + +if [ -z $PROG ] ; then + compdef _cli_zsh_autocomplete gitea +else + compdef _cli_zsh_autocomplete $(basename $PROG) +fi diff --git a/contrib/pr/checkout.go b/contrib/pr/checkout.go index b31a4a8c68..f12d8a9419 100644 --- a/contrib/pr/checkout.go +++ b/contrib/pr/checkout.go @@ -49,7 +49,8 @@ func runPR() { log.Fatal(err) } setting.SetCustomPathAndConf("", "", "") - setting.LoadAllowEmpty() + setting.InitProviderAllowEmpty() + setting.LoadCommonSettings() setting.RepoRootPath, err = os.MkdirTemp(os.TempDir(), "repos") if err != nil { @@ -82,7 +83,7 @@ func runPR() { setting.Database.Path = ":memory:" setting.Database.Timeout = 500 */ - dbCfg := setting.Cfg.Section("database") + dbCfg := setting.CfgProvider.Section("database") dbCfg.NewKey("DB_TYPE", "sqlite3") dbCfg.NewKey("PATH", ":memory:") diff --git a/docker/manifest.rootless.tmpl b/docker/manifest.rootless.tmpl index 9559416470..ef48dd1684 100644 --- a/docker/manifest.rootless.tmpl +++ b/docker/manifest.rootless.tmpl @@ -1,10 +1,12 @@ image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}{{#if (hasPrefix "refs/heads/release/v" build.ref)}}{{trimPrefix "refs/heads/release/v" build.ref}}-{{/if}}dev{{/if}}-rootless {{#if build.tags}} +{{#unless (contains "-rc" build.tag)}} tags: {{#each build.tags}} - {{this}}-rootless {{/each}} - "latest-rootless" +{{/unless}} {{/if}} manifests: - diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl index 4cd4ea4ea2..018d87e979 100644 --- a/docker/manifest.tmpl +++ b/docker/manifest.tmpl @@ -1,10 +1,12 @@ image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}{{#if (hasPrefix "refs/heads/release/v" build.ref)}}{{trimPrefix "refs/heads/release/v" build.ref}}-{{/if}}dev{{/if}} {{#if build.tags}} +{{#unless (contains "-rc" build.tag)}} tags: {{#each build.tags}} - {{this}} {{/each}} - "latest" +{{/unless}} {{/if}} manifests: - diff --git a/docs/config.yaml b/docs/config.yaml index 0a6d5d13f2..26f096b1cf 100644 --- a/docs/config.yaml +++ b/docs/config.yaml @@ -18,7 +18,7 @@ params: description: Git with a cup of tea author: The Gitea Authors website: https://docs.gitea.io - version: 1.18.1 + version: 1.18.5 minGoVersion: 1.19 goVersion: 1.20 minNodeVersion: 16 diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 04344b15dc..462556c9b6 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -568,7 +568,22 @@ Certain queues have defaults that override the defaults set in `[queue]` (this o - `IMPORT_LOCAL_PATHS`: **false**: Set to `false` to prevent all users (including admin) from importing local path on server. - `INTERNAL_TOKEN`: **\**: Secret used to validate communication within Gitea binary. - `INTERNAL_TOKEN_URI`: ****: Instead of defining INTERNAL_TOKEN in the configuration, this configuration option can be used to give Gitea a path to a file that contains the internal token (example value: `file:/etc/gitea/internal_token`) -- `PASSWORD_HASH_ALGO`: **pbkdf2**: The hash algorithm to use \[argon2, pbkdf2, scrypt, bcrypt\], argon2 will spend more memory than others. +- `PASSWORD_HASH_ALGO`: **pbkdf2**: The hash algorithm to use \[argon2, pbkdf2, pbkdf2_v1, pbkdf2_hi, scrypt, bcrypt\], argon2 and scrypt will spend significant amounts of memory. + - Note: The default parameters for `pbkdf2` hashing have changed - the previous settings are available as `pbkdf2_v1` but are not recommended. + - The hash functions may be tuned by using `$` after the algorithm: + - `argon2$