From 2401e6e1210cb41481e7443ab256a0ee9bda44f4 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Mon, 28 Aug 2023 00:22:48 +0000 Subject: [PATCH 1/9] [skip ci] Updated licenses and gitignores --- options/license/GNU-compiler-exception | 6 ++++++ options/license/MIT-testregex | 17 +++++++++++++++ options/license/SANE-exception | 20 ++++++++++++++++++ options/license/Soundex | 16 +++++++------- options/license/TTYP0 | 29 ++++++++++++++++++++++++++ options/license/libpng-2.0 | 2 +- options/license/stunnel-exception | 5 +++++ 7 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 options/license/GNU-compiler-exception create mode 100644 options/license/MIT-testregex create mode 100644 options/license/SANE-exception create mode 100644 options/license/TTYP0 create mode 100644 options/license/stunnel-exception diff --git a/options/license/GNU-compiler-exception b/options/license/GNU-compiler-exception new file mode 100644 index 000000000000..684833ffb4d6 --- /dev/null +++ b/options/license/GNU-compiler-exception @@ -0,0 +1,6 @@ +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this +does not cause the resulting executable to be covered by +the GNU General Public License. This exception does not +however invalidate any other reasons why the executable +file might be covered by the GNU General Public License. diff --git a/options/license/MIT-testregex b/options/license/MIT-testregex new file mode 100644 index 000000000000..321b4bf9bbae --- /dev/null +++ b/options/license/MIT-testregex @@ -0,0 +1,17 @@ + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of THIS SOFTWARE FILE (the "Software"), to deal in the Software + * without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following disclaimer: + * + * THIS SOFTWARE IS PROVIDED BY AT&T ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL AT&T BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/options/license/SANE-exception b/options/license/SANE-exception new file mode 100644 index 000000000000..198a8c67cca5 --- /dev/null +++ b/options/license/SANE-exception @@ -0,0 +1,20 @@ +As a special exception, the authors of sane-airscan give permission for +additional uses of the libraries contained in this release of sane-airscan. + +The exception is that, if you link a sane-airscan library with other files +to produce an executable, this does not by itself cause the +resulting executable to be covered by the GNU General Public +License. Your use of that executable is in no way restricted on +account of linking the sane-airscan library code into it. + +This exception does not, however, invalidate any other reasons why +the executable file might be covered by the GNU General Public +License. + +If you submit changes to sane-airscan to the maintainers to be included in +a subsequent release, you agree by submitting the changes that +those changes may be distributed with this exception intact. + +If you write modifications of your own for sane-airscan, it is your choice +whether to permit this exception to apply to your modifications. +If you do not wish that, delete this exception notice. diff --git a/options/license/Soundex b/options/license/Soundex index b745f29db58f..16c3fa76642f 100644 --- a/options/license/Soundex +++ b/options/license/Soundex @@ -1,7 +1,9 @@ -# (c) Copyright 1998-2007 by Mark Mielke # # Freedom to use -these sources for whatever you want, as long as credit # is -given where credit is due, is hereby granted. You may make -modifications # where you see fit but leave this copyright -somewhere visible. As well, try # to initial any changes you -make so that if I like the changes I can # incorporate them -into later versions. # # - Mark Mielke +(c) Copyright 1998-2007 by Mark Mielke + +Freedom to use these sources for whatever you want, as long as credit +is given where credit is due, is hereby granted. You may make modifications +where you see fit but leave this copyright somewhere visible. As well, try +to initial any changes you make so that if I like the changes I can +incorporate them into later versions. + + - Mark Mielke diff --git a/options/license/TTYP0 b/options/license/TTYP0 new file mode 100644 index 000000000000..3df2e4c4e952 --- /dev/null +++ b/options/license/TTYP0 @@ -0,0 +1,29 @@ +THE TTYP0 LICENSE + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this font software and associated files (the "Software"), +to deal in the Software without restriction, including without +limitation the rights to use, copy, modify, merge, publish, +distribute, embed, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +(1) The above copyright notice, this permission notice, and the + disclaimer below shall be included in all copies or substantial + portions of the Software. + +(2) If the design of any glyphs in the fonts that are contained in the + Software or generated during the installation process is modified + or if additional glyphs are added to the fonts, the fonts + must be renamed. The new names may not contain the word "UW", + irrespective of capitalisation; the new names may contain the word + "ttyp0", irrespective of capitalisation, only if preceded by a + foundry name different from "UW". + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/options/license/libpng-2.0 b/options/license/libpng-2.0 index 1cc8b0deb371..72ae6e44ef68 100644 --- a/options/license/libpng-2.0 +++ b/options/license/libpng-2.0 @@ -10,7 +10,7 @@ PNG Reference Library License version 2 The software is supplied "as is", without warranty of any kind, express or implied, including, without limitation, the warranties of merchantability, fitness for a particular purpose, title, and -non-infringement. In no even shall the Copyright owners, or +non-infringement. In no event shall the Copyright owners, or anyone distributing the software, be liable for any damages or other liability, whether in contract, tort or otherwise, arising from, out of, or in connection with the software, or the use or diff --git a/options/license/stunnel-exception b/options/license/stunnel-exception new file mode 100644 index 000000000000..5e38d00a0f4c --- /dev/null +++ b/options/license/stunnel-exception @@ -0,0 +1,5 @@ +Linking stunnel statically or dynamically with other modules is making a combined work based on stunnel. Thus, the terms and conditions of the GNU General Public License cover the whole combination. + +In addition, as a special exception, the copyright holder of stunnel gives you permission to combine stunnel with free software programs or libraries that are released under the GNU LGPL and with code included in the standard release of OpenSSL under the OpenSSL License (or modified versions of such code, with unchanged license). You may copy and distribute such a system following the terms of the GNU GPL for stunnel and the licenses of the other code concerned. + +Note that people who make modified versions of stunnel are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU General Public License gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception. From c533991519816313dfaa0ddcec183756a97b9348 Mon Sep 17 00:00:00 2001 From: mainboarder Date: Mon, 28 Aug 2023 02:53:16 +0200 Subject: [PATCH 2/9] Expanded minimum RSA Keylength to 3072 (#26604) German Federal Office for Information Security requests in its technical guideline BSI TR-02102-1 RSA Keylength not shorter than 3000bits starting 2024, in the year 2023 3000bits as a recommendation. Gitea should request longer RSA Keys by default in favor of security and drop old clients which do not support longer keys. https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Publikationen/TechnischeRichtlinien/TR02102/BSI-TR-02102.pdf?__blob=publicationFile&v=9 - Page 19, Table 1.2 --------- Co-authored-by: wxiaoguang --- cmd/cert.go | 2 +- custom/conf/app.example.ini | 2 +- docker/root/etc/s6/openssh/setup | 2 +- docs/content/administration/command-line.en-us.md | 2 +- docs/content/administration/command-line.zh-cn.md | 2 +- docs/content/administration/config-cheat-sheet.en-us.md | 2 +- docs/content/administration/config-cheat-sheet.zh-cn.md | 2 +- modules/activitypub/user_settings.go | 2 +- modules/setting/ssh.go | 2 +- tests/integration/api_httpsig_test.go | 3 +++ 10 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/cert.go b/cmd/cert.go index 9ae5ed06ce8a..38241d71a337 100644 --- a/cmd/cert.go +++ b/cmd/cert.go @@ -43,7 +43,7 @@ Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files.`, }, &cli.IntFlag{ Name: "rsa-bits", - Value: 2048, + Value: 3072, Usage: "Size of RSA key to generate. Ignored if --ecdsa-curve is set", }, &cli.StringFlag{ diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index a3d24b1961fa..96a0a3ede93d 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1339,7 +1339,7 @@ LEVEL = Info ;; Define allowed algorithms and their minimum key length (use -1 to disable a type) ;ED25519 = 256 ;ECDSA = 256 -;RSA = 2047 ; we allow 2047 here because an otherwise valid 2048 bit RSA key can be reported as having 2047 bit length +;RSA = 3071 ; we allow 3071 here because an otherwise valid 3072 bit RSA key can be reported as having 3071 bit length ;DSA = -1 ; set to 1024 to switch on ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docker/root/etc/s6/openssh/setup b/docker/root/etc/s6/openssh/setup index f43544d65527..dbb3bafd3524 100755 --- a/docker/root/etc/s6/openssh/setup +++ b/docker/root/etc/s6/openssh/setup @@ -11,7 +11,7 @@ fi if [ ! -f /data/ssh/ssh_host_rsa_key ]; then echo "Generating /data/ssh/ssh_host_rsa_key..." - ssh-keygen -t rsa -b 2048 -f /data/ssh/ssh_host_rsa_key -N "" > /dev/null + ssh-keygen -t rsa -b 3072 -f /data/ssh/ssh_host_rsa_key -N "" > /dev/null fi if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then diff --git a/docs/content/administration/command-line.en-us.md b/docs/content/administration/command-line.en-us.md index 91c6c1e62627..05caff90e433 100644 --- a/docs/content/administration/command-line.en-us.md +++ b/docs/content/administration/command-line.en-us.md @@ -313,7 +313,7 @@ directory and will overwrite any existing files. - `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options are P224, P256, P384, P521. - `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is - set. (default: 2048). + set. (default: 3072). - `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`). - `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s) - `--ca`: If provided, this cert generates it's own certificate authority. Optional. diff --git a/docs/content/administration/command-line.zh-cn.md b/docs/content/administration/command-line.zh-cn.md index bd3d0c72bcf8..6e6bcb6082d4 100644 --- a/docs/content/administration/command-line.zh-cn.md +++ b/docs/content/administration/command-line.zh-cn.md @@ -295,7 +295,7 @@ menu: - 选项: - `--host value`:逗号分隔的主机名和IP地址列表,此证书适用于这些主机。支持使用通配符。必填。 - `--ecdsa-curve value`:用于生成密钥的ECDSA曲线。可选。有效选项为P224、P256、P384、P521。 - - `--rsa-bits value`:要生成的RSA密钥的大小。可选。如果设置了--ecdsa-curve,则忽略此选项。(默认值:2048)。 + - `--rsa-bits value`:要生成的RSA密钥的大小。可选。如果设置了--ecdsa-curve,则忽略此选项。(默认值:3072)。 - `--start-date value`:证书的创建日期。可选。(格式:`Jan 1 15:04:05 2011`)。 - `--duration value`:证书有效期。可选。(默认值:8760h0m0s) - `--ca`:如果提供此选项,则证书将生成自己的证书颁发机构。可选。 diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index 968b47c2302e..311a2b2b7588 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -681,7 +681,7 @@ Define allowed algorithms and their minimum key length (use -1 to disable a type - `ED25519`: **256** - `ECDSA`: **256** -- `RSA`: **2047**: We set 2047 here because an otherwise valid 2048 RSA key can be reported as 2047 length. +- `RSA`: **3071**: We set 3071 here because an otherwise valid 3072 RSA key can be reported as 3071 length. - `DSA`: **-1**: DSA is now disabled by default. Set to **1024** to re-enable but ensure you may need to reconfigure your SSHD provider ## Webhook (`webhook`) diff --git a/docs/content/administration/config-cheat-sheet.zh-cn.md b/docs/content/administration/config-cheat-sheet.zh-cn.md index 87e45aa6934d..39121908c21a 100644 --- a/docs/content/administration/config-cheat-sheet.zh-cn.md +++ b/docs/content/administration/config-cheat-sheet.zh-cn.md @@ -648,7 +648,7 @@ Gitea 创建以下非唯一队列: - `ED25519`:**256** - `ECDSA`:**256** -- `RSA`:**2047**:我们在这里设置为2047,因为一个其他方面有效的2048 RSA密钥可能被报告为2047长度。 +- `RSA`:**3071**:我们在这里设置为2047,因为一个其他方面有效的3072 RSA密钥可能被报告为3071长度。 - `DSA`:**-1**:默认情况下禁用DSA。设置为**1024**以重新启用,但请注意可能需要重新配置您的SSHD提供者 ## Webhook (`webhook`) diff --git a/modules/activitypub/user_settings.go b/modules/activitypub/user_settings.go index 20b3d759c2f9..ef9bc0a864b6 100644 --- a/modules/activitypub/user_settings.go +++ b/modules/activitypub/user_settings.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/gitea/modules/util" ) -const rsaBits = 2048 +const rsaBits = 3072 // GetKeyPair function returns a user's private and public keys func GetKeyPair(user *user_model.User) (pub, priv string, err error) { diff --git a/modules/setting/ssh.go b/modules/setting/ssh.go index bbb7f5ab6cda..ea387e521fad 100644 --- a/modules/setting/ssh.go +++ b/modules/setting/ssh.go @@ -60,7 +60,7 @@ var SSH = struct { ServerMACs: []string{"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1"}, KeygenPath: "", MinimumKeySizeCheck: true, - MinimumKeySizes: map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 2047}, + MinimumKeySizes: map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 3071}, ServerHostKeys: []string{"ssh/gitea.rsa", "ssh/gogs.rsa"}, AuthorizedKeysCommandTemplate: "{{.AppPath}} --config={{.CustomConf}} serv key-{{.Key.ID}}", PerWriteTimeout: PerWriteTimeout, diff --git a/tests/integration/api_httpsig_test.go b/tests/integration/api_httpsig_test.go index 4520364527f1..675ec54ff58f 100644 --- a/tests/integration/api_httpsig_test.go +++ b/tests/integration/api_httpsig_test.go @@ -11,7 +11,9 @@ import ( "testing" auth_model "code.gitea.io/gitea/models/auth" + "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/tests" "github.com/go-fed/httpsig" @@ -52,6 +54,7 @@ fhTNAzWwZoQ91aHdAAAAFHUwMDIyMTQ2QGljdHMtcC1ueC03AQIDBAUG func TestHTTPSigPubKey(t *testing.T) { // Add our public key to user1 defer tests.PrepareTestEnv(t)() + defer test.MockVariableValue(&setting.SSH.MinimumKeySizeCheck, false)() session := loginUser(t, "user1") token := url.QueryEscape(getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteUser)) keysURL := fmt.Sprintf("/api/v1/user/keys?token=%s", token) From 67daa7bcb0cfd3cd7e5efa8667021a7e422f4bdf Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 28 Aug 2023 09:26:23 +0800 Subject: [PATCH 3/9] Remove some transition related code (#26755) Remove transition related code because the transition module has been removed by #26469 --- templates/repo/clone_buttons.tmpl | 4 ++-- web_src/css/helpers.css | 2 -- web_src/js/features/repo-common.js | 6 ------ 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/templates/repo/clone_buttons.tmpl b/templates/repo/clone_buttons.tmpl index 8f5b63128a21..9f008ff5d245 100644 --- a/templates/repo/clone_buttons.tmpl +++ b/templates/repo/clone_buttons.tmpl @@ -1,11 +1,11 @@ {{if $.CloneButtonShowHTTPS}} - {{end}} {{if $.CloneButtonShowSSH}} - {{end}} diff --git a/web_src/css/helpers.css b/web_src/css/helpers.css index f832eff7868e..27b32139bae3 100644 --- a/web_src/css/helpers.css +++ b/web_src/css/helpers.css @@ -105,8 +105,6 @@ Gitea's private styles use `g-` prefix. .gt-border-secondary-left { border-left: 1px solid var(--color-secondary) !important; } .gt-border-secondary-right { border-right: 1px solid var(--color-secondary) !important; } -.gt-no-transition { transition: none !important; } - .gt-bg-red { background: var(--color-red) !important; } .gt-bg-orange { background: var(--color-orange) !important; } .gt-bg-yellow { background: var(--color-yellow) !important; } diff --git a/web_src/js/features/repo-common.js b/web_src/js/features/repo-common.js index d99a1a8da08c..755f2a065326 100644 --- a/web_src/js/features/repo-common.js +++ b/web_src/js/features/repo-common.js @@ -53,12 +53,6 @@ export function initRepoCloneLink() { return; } - // restore animation after first init - setTimeout(() => { - $repoCloneSsh.removeClass('gt-no-transition'); - $repoCloneHttps.removeClass('gt-no-transition'); - }, 100); - $repoCloneSsh.on('click', () => { localStorage.setItem('repo-clone-protocol', 'ssh'); window.updateCloneStates(); From 6945918d34ecc855c99bfc7d7773c3a2d60a3565 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 28 Aug 2023 12:06:47 +0800 Subject: [PATCH 4/9] Fix bug for ctx usage (#26762) Regression from #26158 Fix #26684 --- modules/repository/branch.go | 8 ++++---- services/pull/review.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/repository/branch.go b/modules/repository/branch.go index bffadd62f4d9..8daceecb44ff 100644 --- a/modules/repository/branch.go +++ b/modules/repository/branch.go @@ -106,15 +106,15 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, return int64(len(allBranches)), nil } - if err := db.WithTx(ctx, func(subCtx context.Context) error { + if err := db.WithTx(ctx, func(ctx context.Context) error { if len(toAdd) > 0 { - if err := git_model.AddBranches(subCtx, toAdd); err != nil { + if err := git_model.AddBranches(ctx, toAdd); err != nil { return err } } for _, b := range toUpdate { - if _, err := db.GetEngine(subCtx).ID(b.ID). + if _, err := db.GetEngine(ctx).ID(b.ID). Cols("commit_id, commit_message, pusher_id, commit_time, is_deleted"). Update(b); err != nil { return err @@ -122,7 +122,7 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, } if len(toRemove) > 0 { - if err := git_model.DeleteBranches(subCtx, repo.ID, doerID, toRemove); err != nil { + if err := git_model.DeleteBranches(ctx, repo.ID, doerID, toRemove); err != nil { return err } } diff --git a/services/pull/review.go b/services/pull/review.go index 58470142e114..6e088382f91a 100644 --- a/services/pull/review.go +++ b/services/pull/review.go @@ -333,9 +333,9 @@ func DismissApprovalReviews(ctx context.Context, doer *user_model.User, pull *is return err } - return db.WithTx(ctx, func(subCtx context.Context) error { + return db.WithTx(ctx, func(ctx context.Context) error { for _, review := range reviews { - if err := issues_model.DismissReview(subCtx, review, true); err != nil { + if err := issues_model.DismissReview(ctx, review, true); err != nil { return err } From 8cd46024fdcdaf04cd09be2c25db673e99b0a024 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 28 Aug 2023 13:08:19 +0800 Subject: [PATCH 5/9] refactor(API): refactor secret creation and update functionality (#26751) According to the GitHub API Spec: https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret Merge the Create and Update secret into a single API. - Remove the `CreateSecretOption` struct and replace it with `CreateOrUpdateSecretOption` in `modules/structs/secret.go` - Update the `CreateOrUpdateOrgSecret` function in `routers/api/v1/org/action.go` to use `CreateOrUpdateSecretOption` instead of `UpdateSecretOption` - Remove the `CreateOrgSecret` function in `routers/api/v1/org/action.go` and replace it with `CreateOrUpdateOrgSecret` - Update the Swagger documentation in `routers/api/v1/swagger/options.go` and `templates/swagger/v1_json.tmpl` to reflect the changes in the struct names and function names Signed-off-by: Bo-Yi Wu --- modules/structs/secret.go | 16 +---- routers/api/v1/api.go | 3 +- routers/api/v1/org/action.go | 74 ++++++-------------- routers/api/v1/swagger/options.go | 5 +- templates/swagger/v1_json.tmpl | 108 +++++++----------------------- 5 files changed, 51 insertions(+), 155 deletions(-) diff --git a/modules/structs/secret.go b/modules/structs/secret.go index 52221b51f0a3..a0673ca08c9e 100644 --- a/modules/structs/secret.go +++ b/modules/structs/secret.go @@ -14,21 +14,9 @@ type Secret struct { Created time.Time `json:"created_at"` } -// CreateSecretOption options when creating secret +// CreateOrUpdateSecretOption options when creating or updating secret // swagger:model -type CreateSecretOption struct { - // Name of the secret to create - // - // required: true - // unique: true - Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` - // Data of the secret to create - Data string `json:"data" binding:"Required"` -} - -// UpdateSecretOption options when updating secret -// swagger:model -type UpdateSecretOption struct { +type CreateOrUpdateSecretOption struct { // Data of the secret to update // // required: true diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 2d644507d5f7..6424931a4734 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1300,9 +1300,8 @@ func Routes() *web.Route { }) m.Group("/actions/secrets", func() { m.Get("", reqToken(), reqOrgOwnership(), org.ListActionsSecrets) - m.Post("", reqToken(), reqOrgOwnership(), bind(api.CreateSecretOption{}), org.CreateOrgSecret) m.Combo("/{secretname}"). - Put(reqToken(), reqOrgOwnership(), bind(api.UpdateSecretOption{}), org.UpdateOrgSecret). + Put(reqToken(), reqOrgOwnership(), bind(api.CreateOrUpdateSecretOption{}), org.CreateOrUpdateOrgSecret). Delete(reqToken(), reqOrgOwnership(), org.DeleteOrgSecret) }) m.Group("/public_members", func() { diff --git a/routers/api/v1/org/action.go b/routers/api/v1/org/action.go index 9697a11363de..ee18cca26de7 100644 --- a/routers/api/v1/org/action.go +++ b/routers/api/v1/org/action.go @@ -12,7 +12,6 @@ import ( "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/routers/api/v1/utils" "code.gitea.io/gitea/routers/web/shared/actions" - "code.gitea.io/gitea/services/convert" ) // ListActionsSecrets list an organization's actions secrets @@ -74,55 +73,11 @@ func listActionsSecrets(ctx *context.APIContext) { ctx.JSON(http.StatusOK, apiSecrets) } -// CreateOrgSecret create one secret of the organization -func CreateOrgSecret(ctx *context.APIContext) { - // swagger:operation POST /orgs/{org}/actions/secrets organization createOrgSecret - // --- - // summary: Create a secret in an organization - // consumes: - // - application/json - // produces: - // - application/json - // parameters: - // - name: org - // in: path - // description: name of organization - // type: string - // required: true - // - name: body - // in: body - // schema: - // "$ref": "#/definitions/CreateSecretOption" - // responses: - // "201": - // "$ref": "#/responses/Secret" - // "400": - // "$ref": "#/responses/error" - // "404": - // "$ref": "#/responses/notFound" - // "403": - // "$ref": "#/responses/forbidden" - opt := web.GetForm(ctx).(*api.CreateSecretOption) - if err := actions.NameRegexMatch(opt.Name); err != nil { - ctx.Error(http.StatusBadRequest, "CreateOrgSecret", err) - return - } - s, err := secret_model.InsertEncryptedSecret( - ctx, ctx.Org.Organization.ID, 0, opt.Name, actions.ReserveLineBreakForTextarea(opt.Data), - ) - if err != nil { - ctx.Error(http.StatusInternalServerError, "InsertEncryptedSecret", err) - return - } - - ctx.JSON(http.StatusCreated, convert.ToSecret(s)) -} - -// UpdateOrgSecret update one secret of the organization -func UpdateOrgSecret(ctx *context.APIContext) { +// create or update one secret of the organization +func CreateOrUpdateOrgSecret(ctx *context.APIContext) { // swagger:operation PUT /orgs/{org}/actions/secrets/{secretname} organization updateOrgSecret // --- - // summary: Update a secret value in an organization + // summary: Create or Update a secret value in an organization // consumes: // - application/json // produces: @@ -141,19 +96,34 @@ func UpdateOrgSecret(ctx *context.APIContext) { // - name: body // in: body // schema: - // "$ref": "#/definitions/UpdateSecretOption" + // "$ref": "#/definitions/CreateOrUpdateSecretOption" // responses: + // "201": + // description: response when creating a secret // "204": - // description: update one secret of the organization + // description: response when updating a secret + // "400": + // "$ref": "#/responses/error" // "403": // "$ref": "#/responses/forbidden" secretName := ctx.Params(":secretname") - opt := web.GetForm(ctx).(*api.UpdateSecretOption) + if err := actions.NameRegexMatch(secretName); err != nil { + ctx.Error(http.StatusBadRequest, "CreateOrUpdateOrgSecret", err) + return + } + opt := web.GetForm(ctx).(*api.CreateOrUpdateSecretOption) err := secret_model.UpdateSecret( ctx, ctx.Org.Organization.ID, 0, secretName, opt.Data, ) if secret_model.IsErrSecretNotFound(err) { - ctx.NotFound(err) + _, err := secret_model.InsertEncryptedSecret( + ctx, ctx.Org.Organization.ID, 0, secretName, actions.ReserveLineBreakForTextarea(opt.Data), + ) + if err != nil { + ctx.Error(http.StatusInternalServerError, "InsertEncryptedSecret", err) + return + } + ctx.Status(http.StatusCreated) return } if err != nil { diff --git a/routers/api/v1/swagger/options.go b/routers/api/v1/swagger/options.go index e41ee667760a..6f7859df62ed 100644 --- a/routers/api/v1/swagger/options.go +++ b/routers/api/v1/swagger/options.go @@ -189,8 +189,5 @@ type swaggerParameterBodies struct { UpdateRepoAvatarOptions api.UpdateRepoAvatarOption // in:body - CreateSecretOption api.CreateSecretOption - - // in:body - UpdateSecretOption api.UpdateSecretOption + CreateOrUpdateSecretOption api.CreateOrUpdateSecretOption } diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index ca4e1c4606c3..d37f4463f55c 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -1586,49 +1586,6 @@ "$ref": "#/responses/SecretList" } } - }, - "post": { - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "organization" - ], - "summary": "Create a secret in an organization", - "operationId": "createOrgSecret", - "parameters": [ - { - "type": "string", - "description": "name of organization", - "name": "org", - "in": "path", - "required": true - }, - { - "name": "body", - "in": "body", - "schema": { - "$ref": "#/definitions/CreateSecretOption" - } - } - ], - "responses": { - "201": { - "$ref": "#/responses/Secret" - }, - "400": { - "$ref": "#/responses/error" - }, - "403": { - "$ref": "#/responses/forbidden" - }, - "404": { - "$ref": "#/responses/notFound" - } - } } }, "/orgs/{org}/actions/secrets/{secretname}": { @@ -1642,7 +1599,7 @@ "tags": [ "organization" ], - "summary": "Update a secret value in an organization", + "summary": "Create or Update a secret value in an organization", "operationId": "updateOrgSecret", "parameters": [ { @@ -1663,13 +1620,19 @@ "name": "body", "in": "body", "schema": { - "$ref": "#/definitions/UpdateSecretOption" + "$ref": "#/definitions/CreateOrUpdateSecretOption" } } ], "responses": { + "201": { + "description": "response when creating a secret" + }, "204": { - "description": "update one secret of the organization" + "description": "response when updating a secret" + }, + "400": { + "$ref": "#/responses/error" }, "403": { "$ref": "#/responses/forbidden" @@ -17283,6 +17246,21 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "CreateOrUpdateSecretOption": { + "description": "CreateOrUpdateSecretOption options when creating or updating secret", + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "description": "Data of the secret to update", + "type": "string", + "x-go-name": "Data" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "CreateOrgOption": { "description": "CreateOrgOption options for creating an organization", "type": "object", @@ -17569,27 +17547,6 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, - "CreateSecretOption": { - "description": "CreateSecretOption options when creating secret", - "type": "object", - "required": [ - "name" - ], - "properties": { - "data": { - "description": "Data of the secret to create", - "type": "string", - "x-go-name": "Data" - }, - "name": { - "description": "Name of the secret to create", - "type": "string", - "uniqueItems": true, - "x-go-name": "Name" - } - }, - "x-go-package": "code.gitea.io/gitea/modules/structs" - }, "CreateStatusOption": { "description": "CreateStatusOption holds the information needed to create a new CommitStatus for a Commit", "type": "object", @@ -21978,21 +21935,6 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, - "UpdateSecretOption": { - "description": "UpdateSecretOption options when updating secret", - "type": "object", - "required": [ - "data" - ], - "properties": { - "data": { - "description": "Data of the secret to update", - "type": "string", - "x-go-name": "Data" - } - }, - "x-go-package": "code.gitea.io/gitea/modules/structs" - }, "UpdateUserAvatarOption": { "description": "UpdateUserAvatarUserOption options when updating the user avatar", "type": "object", @@ -23309,7 +23251,7 @@ "parameterBodies": { "description": "parameterBodies", "schema": { - "$ref": "#/definitions/UpdateSecretOption" + "$ref": "#/definitions/CreateOrUpdateSecretOption" } }, "redirect": { From a587d2526163153a4d992527fe6040d578beaa83 Mon Sep 17 00:00:00 2001 From: merlleu Date: Mon, 28 Aug 2023 09:05:39 +0200 Subject: [PATCH 6/9] Add auth-required to config.json for Cargo http registry (#26729) Cargo registry-auth feature requires config.json to have a property auth-required set to true in order to send token to all registry requests. This is ok for git index because you can manually edit the config.json file to add the auth-required, but when using sparse (setting index url to "sparse+https://git.example.com/api/packages/{owner}/cargo/"), the config.json is dynamically rendered, and does not reflect changes to the config.json file in the repo. I see two approaches: - Serve the real config.json file when fetching the config.json on the cargo service. - Automatically detect if the registry requires authorization. (This is what I implemented in this PR). What the PR does: - When a cargo index repository is created, on the config.json, set auth-required to wether or not the repository is private. - When the cargo/config.json endpoint is called, set auth-required to wether or not the request was authorized using an API token. --- routers/api/packages/cargo/cargo.go | 4 +++- services/packages/cargo/index.go | 15 +++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/routers/api/packages/cargo/cargo.go b/routers/api/packages/cargo/cargo.go index a2e835df578b..8c370339cd57 100644 --- a/routers/api/packages/cargo/cargo.go +++ b/routers/api/packages/cargo/cargo.go @@ -16,6 +16,8 @@ import ( "code.gitea.io/gitea/modules/log" packages_module "code.gitea.io/gitea/modules/packages" cargo_module "code.gitea.io/gitea/modules/packages/cargo" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers/api/packages/helper" "code.gitea.io/gitea/services/convert" @@ -48,7 +50,7 @@ func apiError(ctx *context.Context, status int, obj any) { // https://rust-lang.github.io/rfcs/2789-sparse-index.html func RepositoryConfig(ctx *context.Context) { - ctx.JSON(http.StatusOK, cargo_service.BuildConfig(ctx.Package.Owner)) + ctx.JSON(http.StatusOK, cargo_service.BuildConfig(ctx.Package.Owner, setting.Service.RequireSignInView || ctx.Package.Owner.Visibility != structs.VisibleTypePublic)) } func EnumeratePackageVersions(ctx *context.Context) { diff --git a/services/packages/cargo/index.go b/services/packages/cargo/index.go index 1c2d17b504fc..867cd796d381 100644 --- a/services/packages/cargo/index.go +++ b/services/packages/cargo/index.go @@ -21,6 +21,7 @@ import ( cargo_module "code.gitea.io/gitea/modules/packages/cargo" repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" files_service "code.gitea.io/gitea/services/repository/files" ) @@ -220,14 +221,16 @@ func getOrCreateIndexRepository(ctx context.Context, doer, owner *user_model.Use } type Config struct { - DownloadURL string `json:"dl"` - APIURL string `json:"api"` + DownloadURL string `json:"dl"` + APIURL string `json:"api"` + AuthRequired bool `json:"auth-required"` } -func BuildConfig(owner *user_model.User) *Config { +func BuildConfig(owner *user_model.User, isPrivate bool) *Config { return &Config{ - DownloadURL: setting.AppURL + "api/packages/" + owner.Name + "/cargo/api/v1/crates", - APIURL: setting.AppURL + "api/packages/" + owner.Name + "/cargo", + DownloadURL: setting.AppURL + "api/packages/" + owner.Name + "/cargo/api/v1/crates", + APIURL: setting.AppURL + "api/packages/" + owner.Name + "/cargo", + AuthRequired: isPrivate, } } @@ -239,7 +242,7 @@ func createOrUpdateConfigFile(ctx context.Context, repo *repo_model.Repository, "Initialize Cargo Config", func(t *files_service.TemporaryUploadRepository) error { var b bytes.Buffer - err := json.NewEncoder(&b).Encode(BuildConfig(owner)) + err := json.NewEncoder(&b).Encode(BuildConfig(owner, setting.Service.RequireSignInView || owner.Visibility != structs.VisibleTypePublic || repo.IsPrivate)) if err != nil { return err } From 4803766f7a5d1ca86a1e62949dcd9a9ff8d0f64c Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 28 Aug 2023 22:14:51 +0800 Subject: [PATCH 7/9] Refactor some CSS styles and simplify code (#26771) Refactor some CSS styles and simplify code. Some styles are not in use, remove them. --- templates/code/searchresults.tmpl | 4 +- templates/projects/view.tmpl | 8 +--- templates/repo/branch/list.tmpl | 6 +-- templates/repo/icon.tmpl | 30 +++++++------- templates/repo/issue/label_precolors.tmpl | 38 ++++++++++-------- .../repo/issue/labels/edit_delete_label.tmpl | 4 +- templates/repo/issue/labels/label_new.tmpl | 4 +- templates/repo/search.tmpl | 4 +- web_src/css/base.css | 40 ++++++------------- 9 files changed, 60 insertions(+), 78 deletions(-) diff --git a/templates/code/searchresults.tmpl b/templates/code/searchresults.tmpl index 684e2860bff4..faac69670530 100644 --- a/templates/code/searchresults.tmpl +++ b/templates/code/searchresults.tmpl @@ -1,6 +1,6 @@ - diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index bd045995b29b..d2535e1e307f 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -132,11 +132,11 @@ {{else}} {{if not .LatestPullRequest.IsSameRepo}}{{.LatestPullRequest.BaseRepo.FullName}}{{end}}#{{.LatestPullRequest.Issue.Index}} {{if .LatestPullRequest.HasMerged}} - {{svg "octicon-git-merge" 16 "gt-mr-2"}}{{$.locale.Tr "repo.pulls.merged"}} + {{svg "octicon-git-merge" 16 "gt-mr-2"}}{{$.locale.Tr "repo.pulls.merged"}} {{else if .LatestPullRequest.Issue.IsClosed}} - {{svg "octicon-git-pull-request" 16 "gt-mr-2"}}{{$.locale.Tr "repo.issues.closed_title"}} + {{svg "octicon-git-pull-request" 16 "gt-mr-2"}}{{$.locale.Tr "repo.issues.closed_title"}} {{else}} - {{svg "octicon-git-pull-request" 16 "gt-mr-2"}}{{$.locale.Tr "repo.issues.open_title"}} + {{svg "octicon-git-pull-request" 16 "gt-mr-2"}}{{$.locale.Tr "repo.issues.open_title"}} {{end}} {{end}} diff --git a/templates/repo/icon.tmpl b/templates/repo/icon.tmpl index 6c63e6eca698..0568b74f6308 100644 --- a/templates/repo/icon.tmpl +++ b/templates/repo/icon.tmpl @@ -1,16 +1,14 @@ -
- {{$avatarLink := .RelAvatarLink}} - {{if $avatarLink}} - {{.FullName}} - {{else if $.IsTemplate}} - {{svg "octicon-repo-template" 32}} - {{else if $.IsPrivate}} - {{svg "octicon-lock" 32}} - {{else if $.IsMirror}} - {{svg "octicon-mirror" 32}} - {{else if $.IsFork}} - {{svg "octicon-repo-forked" 32}} - {{else}} - {{svg "octicon-repo" 32}} - {{end}} -
+{{$avatarLink := .RelAvatarLink}} +{{if $avatarLink}} + {{.FullName}} +{{else if $.IsTemplate}} + {{svg "octicon-repo-template" 32}} +{{else if $.IsPrivate}} + {{svg "octicon-lock" 32}} +{{else if $.IsMirror}} + {{svg "octicon-mirror" 32}} +{{else if $.IsFork}} + {{svg "octicon-repo-forked" 32}} +{{else}} + {{svg "octicon-repo" 32}} +{{end}} diff --git a/templates/repo/issue/label_precolors.tmpl b/templates/repo/issue/label_precolors.tmpl index 555595fc14d1..146119b978f6 100644 --- a/templates/repo/issue/label_precolors.tmpl +++ b/templates/repo/issue/label_precolors.tmpl @@ -1,16 +1,22 @@ - - - - - - - - - - - - - - - - +
+
+ + + + + + + + +
+
+ + + + + + + + +
+
diff --git a/templates/repo/issue/labels/edit_delete_label.tmpl b/templates/repo/issue/labels/edit_delete_label.tmpl index d64782090cc8..98efc6aa9421 100644 --- a/templates/repo/issue/labels/edit_delete_label.tmpl +++ b/templates/repo/issue/labels/edit_delete_label.tmpl @@ -54,9 +54,7 @@
-
- {{template "repo/issue/label_precolors"}} -
+ {{template "repo/issue/label_precolors"}}
diff --git a/templates/repo/issue/labels/label_new.tmpl b/templates/repo/issue/labels/label_new.tmpl index 41dced4a5bf8..1d3069f1bb79 100644 --- a/templates/repo/issue/labels/label_new.tmpl +++ b/templates/repo/issue/labels/label_new.tmpl @@ -29,9 +29,7 @@
-
- {{template "repo/issue/label_precolors"}} -
+ {{template "repo/issue/label_precolors"}}
diff --git a/templates/repo/search.tmpl b/templates/repo/search.tmpl index 816be9d12cd4..cf088442b3a0 100644 --- a/templates/repo/search.tmpl +++ b/templates/repo/search.tmpl @@ -27,9 +27,9 @@ {{.locale.Tr "repo.search.results" (.Keyword|Escape) (.RepoLink|Escape) (.RepoName|Escape) | Str2html}} {{if .SearchResults}} -
+
{{range $term := .SearchResultLanguages}} - + {{$term.Language}}
{{$term.Count}}
diff --git a/web_src/css/base.css b/web_src/css/base.css index d9c57932fc2e..481e231f3e1b 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -474,7 +474,7 @@ a.label, /* fix Fomantic's line-height cutting off "g" on Windows Chrome with Segoe UI */ .ui.input > input { - line-height: 1.3; + line-height: var(--line-height-default); } .ui.input.focus > input, @@ -951,6 +951,7 @@ img.ui.avatar, filter: saturate(2); } +/* TODO: use gt-word-break instead */ .dont-break-out { overflow-wrap: break-word; word-wrap: break-word; @@ -1456,10 +1457,6 @@ img.ui.avatar, border-color: var(--color-gold) !important; } -.ui .branch-tag-choice { - line-height: 20px; -} - @media (max-width: 767.98px) { .ui.pagination.menu .item:not(.active,.navigation), .ui.pagination.menu .item.navigation span.navigation_label { @@ -1640,10 +1637,6 @@ img.ui.avatar, margin-left: 0.5rem; } -.repo-icon { - display: inline-block; -} - .activity-bar-graph { background-color: var(--color-primary); color: var(--color-primary-contrast); @@ -1681,10 +1674,6 @@ i.icons .icon:first-child { margin-right: 0; } -i.icon.centerlock { - top: 1em; -} - .ui.label { padding: 0.3em 0.5em; transition: none; @@ -1879,10 +1868,6 @@ a.ui.active.label:hover { width: 100%; } -.octicon-tiny { - font-size: 0.85714286rem; -} - .ui.primary.label, .ui.primary.labels .label, .ui.ui.ui.primary.label { @@ -2037,6 +2022,7 @@ a.ui.basic.label:hover { margin-left: 0; } +/* TODO: replace it with gt-invisible */ .invisible { visibility: hidden; } @@ -2123,11 +2109,6 @@ table th[data-sortt-desc] .svg { box-shadow: 0 0 0 1px var(--color-secondary) inset; } -.text-label { - display: inline-flex !important; - align-items: center !important; -} - .emoji, .reaction { font-size: 1.25em; @@ -2241,14 +2222,14 @@ table th[data-sortt-desc] .svg { } .precolors { - padding-left: 0 !important; - padding-right: 0 !important; - margin: 3px 10px auto !important; - width: 120px !important; + display: flex; + flex-direction: column; + justify-content: center; + margin-left: 1em; } .precolors .color { - float: left; + display: inline-block; width: 15px; height: 15px; } @@ -2303,6 +2284,7 @@ table th[data-sortt-desc] .svg { .ui.ui.button, .ui.ui.dropdown, +.ui.ui.label, .flex-items-inline > .item, .flex-text-inline { display: inline-flex; @@ -2319,6 +2301,10 @@ table th[data-sortt-desc] .svg { vertical-align: middle; } +.ui.ui.circular.label { + justify-content: center; +} + .ui.ui.labeled.button { gap: 0; align-items: stretch; From ac2f8c9ac66a15a9e1799da3e8436928aeada53e Mon Sep 17 00:00:00 2001 From: Chongyi Zheng Date: Mon, 28 Aug 2023 12:43:16 -0400 Subject: [PATCH 8/9] Reduce some allocations in type conversion (#26772) --- modules/log/event_writer_base.go | 2 +- services/packages/rpm/repository.go | 2 +- services/pull/pull.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/log/event_writer_base.go b/modules/log/event_writer_base.go index b8b13e4bc446..c327c48ca20b 100644 --- a/modules/log/event_writer_base.go +++ b/modules/log/event_writer_base.go @@ -90,7 +90,7 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) { if exprRegexp != nil { fileLineCaller := fmt.Sprintf("%s:%d:%s", event.Origin.Filename, event.Origin.Line, event.Origin.Caller) - matched := exprRegexp.Match([]byte(fileLineCaller)) || exprRegexp.Match([]byte(event.Origin.MsgSimpleText)) + matched := exprRegexp.MatchString(fileLineCaller) || exprRegexp.MatchString(event.Origin.MsgSimpleText) if !matched { continue } diff --git a/services/packages/rpm/repository.go b/services/packages/rpm/repository.go index 774613509e7e..cfd70ec23e2c 100644 --- a/services/packages/rpm/repository.go +++ b/services/packages/rpm/repository.go @@ -232,7 +232,7 @@ func buildRepomd(pv *packages_model.PackageVersion, ownerID int64, data []*repoD } var buf bytes.Buffer - buf.Write([]byte(xml.Header)) + buf.WriteString(xml.Header) if err := xml.NewEncoder(&buf).Encode(&Repomd{ Xmlns: "http://linux.duke.edu/metadata/repo", XmlnsRpm: "http://linux.duke.edu/metadata/rpm", diff --git a/services/pull/pull.go b/services/pull/pull.go index 0b6194b1436d..d4352abafec7 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -755,11 +755,11 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ } for _, author := range authors { - if _, err := stringBuilder.Write([]byte("Co-authored-by: ")); err != nil { + if _, err := stringBuilder.WriteString("Co-authored-by: "); err != nil { log.Error("Unable to write to string builder Error: %v", err) return "" } - if _, err := stringBuilder.Write([]byte(author)); err != nil { + if _, err := stringBuilder.WriteString(author); err != nil { log.Error("Unable to write to string builder Error: %v", err) return "" } From dca2f9371d95c2227f43ad7a0ddad579d407afd5 Mon Sep 17 00:00:00 2001 From: delvh Date: Mon, 28 Aug 2023 21:43:59 +0200 Subject: [PATCH 9/9] Unify `border-radius` behavior (#26770) ## Changes - no more hardcoded `border-radius`es (apart from `0`) - no more value inconsistencies - no more guessing what pixel value you should use - two new variables: - `--border-radius-medium` (for elements where the normal border radius does not suffice) - `--border-radius-circle` (for displaying circles) --------- Co-authored-by: silverwind --- web_src/css/base.css | 14 ++++++++------ web_src/css/dashboard.css | 2 +- web_src/css/editor/combomarkdowneditor.css | 8 ++++---- web_src/css/features/codeeditor.css | 2 +- web_src/css/features/console.css | 2 +- web_src/css/features/dropzone.css | 2 +- web_src/css/features/tribute.css | 2 +- web_src/css/form.css | 2 +- web_src/css/markup/content.css | 8 ++++---- web_src/css/modules/animations.css | 2 +- web_src/css/modules/navbar.css | 2 +- web_src/css/modules/toast.css | 4 ++-- web_src/css/repo.css | 20 ++++++++++---------- web_src/css/repo/issue-list.css | 5 ++--- web_src/css/repo/release-tag.css | 4 +--- web_src/css/review.css | 2 +- web_src/css/user.css | 2 +- 17 files changed, 41 insertions(+), 42 deletions(-) diff --git a/web_src/css/base.css b/web_src/css/base.css index 481e231f3e1b..1a88823cb10c 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -16,7 +16,9 @@ --checkbox-mask-indeterminate: url('data:image/svg+xml;utf8,'); --octicon-chevron-right: url('data:image/svg+xml;utf8,'); /* non-color variables */ - --border-radius: 0.28571429rem; + --border-radius: 4px; + --border-radius-medium: 6px; + --border-radius-circle: 100%; --opacity-disabled: 0.55; --height-loading: 16rem; --tab-size: 4; @@ -309,7 +311,7 @@ details summary > * { progress { background: var(--color-secondary-dark-1); - border-radius: 6px; + border-radius: var(--border-radius); border: none; overflow: hidden; } @@ -339,7 +341,7 @@ progress::-moz-progress-bar { ::-webkit-scrollbar-thumb { box-shadow: inset 0 0 0 6px var(--color-primary); border: 2px solid transparent; - border-radius: 5px !important; + border-radius: var(--border-radius); } ::-webkit-scrollbar-thumb:window-inactive { @@ -454,7 +456,7 @@ a.label, .issue-title code { padding: 2px 4px; - border-radius: 6px; + border-radius: var(--border-radius-medium); background-color: var(--color-markup-code-block); } @@ -1510,7 +1512,7 @@ img.ui.avatar, margin-left: 0.4em; height: 0.67em; width: 0.67em; - border-radius: 0.15em; + border-radius: var(--border-radius); } .attention-icon { @@ -2013,7 +2015,7 @@ a.ui.basic.label:hover { .color-icon { display: inline-block; - border-radius: 100%; + border-radius: var(--border-radius-circle); height: 14px; width: 14px; } diff --git a/web_src/css/dashboard.css b/web_src/css/dashboard.css index 402eb7b34b43..6dcf73e2a772 100644 --- a/web_src/css/dashboard.css +++ b/web_src/css/dashboard.css @@ -98,7 +98,7 @@ .feeds code { padding: 2px 4px; - border-radius: 3px; + border-radius: var(--border-radius); background-color: var(--color-markup-code-block); word-break: break-all; } diff --git a/web_src/css/editor/combomarkdowneditor.css b/web_src/css/editor/combomarkdowneditor.css index 63f4ebf89b6e..a82e2b176863 100644 --- a/web_src/css/editor/combomarkdowneditor.css +++ b/web_src/css/editor/combomarkdowneditor.css @@ -83,7 +83,7 @@ text-expander .suggestions { margin-top: 24px; list-style: none; background: var(--color-box-body); - border-radius: 5px; + border-radius: var(--border-radius); border: 1px solid var(--color-secondary); box-shadow: 0 .5rem 1rem var(--color-shadow); } @@ -101,15 +101,15 @@ text-expander .suggestions li + li { } text-expander .suggestions li:first-child { - border-radius: 4px 4px 0 0; + border-radius: var(--border-radius) var(--border-radius) 0 0; } text-expander .suggestions li:last-child { - border-radius: 0 0 4px 4px; + border-radius: 0 0 var(--border-radius) var(--border-radius); } text-expander .suggestions li:only-child { - border-radius: 4px; + border-radius: var(--border-radius); } text-expander .suggestions li:hover { diff --git a/web_src/css/features/codeeditor.css b/web_src/css/features/codeeditor.css index 8666ad2f8592..34a104c83383 100644 --- a/web_src/css/features/codeeditor.css +++ b/web_src/css/features/codeeditor.css @@ -44,5 +44,5 @@ position: absolute !important; resize: none !important; overflow: hidden !important; - border-radius: 4px !important; + border-radius: var(--border-radius-medium) !important; } diff --git a/web_src/css/features/console.css b/web_src/css/features/console.css index db187a48df2e..99fb25dae57f 100644 --- a/web_src/css/features/console.css +++ b/web_src/css/features/console.css @@ -4,7 +4,7 @@ background: var(--color-console-bg); color: var(--color-console-fg); font-family: var(--fonts-monospace); - border-radius: 5px; + border-radius: var(--border-radius); word-break: break-word; overflow-wrap: break-word; } diff --git a/web_src/css/features/dropzone.css b/web_src/css/features/dropzone.css index 509dbf1dfe12..cbc32df203c3 100644 --- a/web_src/css/features/dropzone.css +++ b/web_src/css/features/dropzone.css @@ -3,7 +3,7 @@ background: none; box-shadow: none; padding: 0; - border-radius: 4px; + border-radius: var(--border-radius-medium); min-height: 0; } diff --git a/web_src/css/features/tribute.css b/web_src/css/features/tribute.css index 76e3138b65e6..bd843675e144 100644 --- a/web_src/css/features/tribute.css +++ b/web_src/css/features/tribute.css @@ -2,7 +2,7 @@ .tribute-container { box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.25); - border-radius: 0.25rem; + border-radius: var(--border-radius); } .tribute-container ul { diff --git a/web_src/css/form.css b/web_src/css/form.css index 1bd1920955a6..e4efa349486e 100644 --- a/web_src/css/form.css +++ b/web_src/css/form.css @@ -221,7 +221,7 @@ textarea:focus, } .g-recaptcha-style iframe, .h-captcha-style iframe { - border-radius: 5px !important; + border-radius: var(--border-radius) !important; width: 302px !important; height: 76px !important; } diff --git a/web_src/css/markup/content.css b/web_src/css/markup/content.css index d89e02c6404f..59b34b7dd7ce 100644 --- a/web_src/css/markup/content.css +++ b/web_src/css/markup/content.css @@ -180,7 +180,7 @@ appearance: none; position: relative; border: 1px solid var(--color-secondary); - border-radius: 2px; + border-radius: var(--border-radius); background: var(--color-input-background); height: 14px; width: 14px; @@ -433,7 +433,7 @@ font-size: 85%; white-space: break-spaces; background-color: var(--color-markup-code-block); - border-radius: 4px; + border-radius: var(--border-radius); } .markup code br, @@ -466,7 +466,7 @@ font-size: 85%; line-height: 1.45; background-color: var(--color-markup-code-block); - border-radius: 4px; + border-radius: var(--border-radius); } .markup .highlight pre { @@ -504,7 +504,7 @@ vertical-align: middle; background-color: var(--color-markup-code-block); border: 1px solid var(--color-secondary); - border-radius: 3px; + border-radius: var(--border-radius); box-shadow: inset 0 -1px 0 var(--color-secondary); } diff --git a/web_src/css/modules/animations.css b/web_src/css/modules/animations.css index ea1409687a7e..7b3ec360f6f9 100644 --- a/web_src/css/modules/animations.css +++ b/web_src/css/modules/animations.css @@ -26,7 +26,7 @@ border-width: 4px; border-style: solid; border-color: var(--color-secondary) var(--color-secondary) var(--color-secondary-dark-8) var(--color-secondary-dark-8); - border-radius: 100%; + border-radius: var(--border-radius-circle); } .is-loading.small-loading-icon::after { diff --git a/web_src/css/modules/navbar.css b/web_src/css/modules/navbar.css index 66c7f9ec789c..15114f90b2b5 100644 --- a/web_src/css/modules/navbar.css +++ b/web_src/css/modules/navbar.css @@ -134,7 +134,7 @@ top: -9px; min-width: 17px; min-height: 17px; - border-radius: 17px; + border-radius: var(--border-radius-circle); display: flex; align-items: center; justify-content: center; diff --git a/web_src/css/modules/toast.css b/web_src/css/modules/toast.css index c96521f2736b..0bfaa5be4155 100644 --- a/web_src/css/modules/toast.css +++ b/web_src/css/modules/toast.css @@ -4,7 +4,7 @@ opacity: 0; transition: all .2s ease; z-index: 500; - border-radius: 4px; + border-radius: var(--border-radius); box-shadow: 0 8px 24px var(--color-shadow); display: flex; max-width: 50vw; @@ -25,7 +25,7 @@ .toast-close, .toast-icon { color: currentcolor; - border-radius: 3px; + border-radius: var(--border-radius); background: transparent; border: none; display: inline-block; diff --git a/web_src/css/repo.css b/web_src/css/repo.css index 7a24f46702f0..eb3f98774182 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -117,7 +117,7 @@ .repository .issue-content-right #deadlineForm input { width: 12.8rem; - border-radius: 4px 0 0 4px; + border-radius: var(--border-radius) 0 0 var(--border-radius); border-right: 0; white-space: nowrap; } @@ -141,7 +141,7 @@ .repository .filter.menu.labels .label-filter .menu .info code { border: 1px solid var(--color-secondary); - border-radius: 3px; + border-radius: var(--border-radius); padding: 1px 2px; font-size: 11px; } @@ -518,7 +518,7 @@ margin-bottom: 10px; border: 1px solid var(--color-secondary); background: var(--color-box-body); - border-radius: 3px; + border-radius: var(--border-radius); } .repository.file.editor .commit-form-wrapper .commit-form::before, @@ -551,7 +551,7 @@ font: 12px var(--fonts-monospace); color: var(--color-text); background: var(--color-secondary); - border-radius: 3px; + border-radius: var(--border-radius); margin: 0 2px; } @@ -709,7 +709,7 @@ align-items: center !important; font-size: 14px !important; padding: 7px 10px !important; - border-radius: 6px !important; + border-radius: var(--border-radius-medium) !important; } .issue-state-label .svg { @@ -835,7 +835,7 @@ width: 34px; height: 34px; background-color: var(--color-timeline); - border-radius: 50%; + border-radius: var(--border-radius-circle); display: flex; float: left; margin-left: -33px; @@ -1049,7 +1049,7 @@ .merge-section-info code { border: 1px solid var(--color-light-border); - border-radius: 4px; + border-radius: var(--border-radius); padding: 2px 4px; background: var(--color-light); } @@ -2093,7 +2093,7 @@ width: 34px; height: 34px; min-height: 0 !important; - border-radius: 6px; + border-radius: var(--border-radius); display: flex !important; align-items: center; justify-content: center; @@ -2753,7 +2753,7 @@ tbody.commit-list { #new-dependency-drop-list.ui.selection.dropdown { min-width: 0; width: 100%; - border-radius: 4px 0 0 4px; + border-radius: var(--border-radius) 0 0 var(--border-radius); border-right: 0; white-space: nowrap; } @@ -2949,7 +2949,7 @@ tbody.commit-list { margin: 10px 0; background-color: var(--color-markup-code-block); border: 1px solid var(--color-secondary); - border-radius: 3px; + border-radius: var(--border-radius); font-size: 13px; line-height: 1.5; overflow: auto; diff --git a/web_src/css/repo/issue-list.css b/web_src/css/repo/issue-list.css index 2a0a86c0817c..f76b690cb102 100644 --- a/web_src/css/repo/issue-list.css +++ b/web_src/css/repo/issue-list.css @@ -39,7 +39,7 @@ #issue-list .flex-item-body .branches .branch { background-color: var(--color-secondary-alpha-40); - border-radius: 3px; + border-radius: var(--border-radius); padding: 0 4px; } @@ -55,7 +55,6 @@ width: 80px; height: 6px; display: inline-block; - border-radius: 3px; } #issue-list .flex-item-body .checklist progress::-webkit-progress-value { @@ -64,4 +63,4 @@ #issue-list .flex-item-body .checklist progress::-moz-progress-bar { background-color: var(--color-secondary-dark-4); -} \ No newline at end of file +} diff --git a/web_src/css/repo/release-tag.css b/web_src/css/repo/release-tag.css index 70925f5a0e04..cad1aaae61a2 100644 --- a/web_src/css/repo/release-tag.css +++ b/web_src/css/repo/release-tag.css @@ -75,12 +75,10 @@ width: 10px; height: 10px; background-color: var(--color-secondary-dark-3); - z-index: 9; position: absolute; - display: block; left: -5.5px; top: 40px; - border-radius: 100%; + border-radius: var(--border-radius-circle); border: 2.5px solid var(--color-body); } diff --git a/web_src/css/review.css b/web_src/css/review.css index a4c4efd029d1..c831f38976d1 100644 --- a/web_src/css/review.css +++ b/web_src/css/review.css @@ -273,7 +273,7 @@ border: 1px solid transparent; padding: 4px 8px; margin: -8px 0; /* just like other buttons in the diff box header */ - border-radius: 0.285rem; /* just like .ui.tiny.button */ + border-radius: var(--border-radius); font-size: 0.857rem; /* just like .ui.tiny.button */ } diff --git a/web_src/css/user.css b/web_src/css/user.css index 2f951440b61b..af8a2f5adc66 100644 --- a/web_src/css/user.css +++ b/web_src/css/user.css @@ -107,7 +107,7 @@ #readme_profile { padding: 1em 2em; - border-radius: 0.28571429rem; + border-radius: var(--border-radius); background: var(--color-card); border: 1px solid var(--color-secondary); }