From eddd2fb242589107714968809911071eb2e516e7 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 3 Mar 2022 12:51:13 +0100 Subject: [PATCH 01/11] fix & refactor (#18973) Co-authored-by: Lunny Xiao --- models/repo.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/models/repo.go b/models/repo.go index 821b60d08dd2d..4b2221e6435a5 100644 --- a/models/repo.go +++ b/models/repo.go @@ -956,28 +956,28 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error { } // Remove archives - for i := range archivePaths { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.RepoArchives, "Delete repo archive file", archivePaths[i]) + for _, archive := range archivePaths { + admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.RepoArchives, "Delete repo archive file", archive) } // Remove lfs objects - for i := range lfsPaths { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.LFS, "Delete orphaned LFS file", lfsPaths[i]) + for _, lfsObj := range lfsPaths { + admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.LFS, "Delete orphaned LFS file", lfsObj) } // Remove issue attachment files. - for i := range attachmentPaths { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete issue attachment", attachmentPaths[i]) + for _, attachment := range attachmentPaths { + admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete issue attachment", attachment) } // Remove release attachment files. - for i := range releaseAttachments { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete release attachment", releaseAttachments[i]) + for _, releaseAttachment := range releaseAttachments { + admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete release attachment", releaseAttachment) } // Remove attachment with no issue_id and release_id. - for i := range newAttachmentPaths { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete issue attachment", attachmentPaths[i]) + for _, newAttachment := range newAttachmentPaths { + admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete issue attachment", newAttachment) } if len(repo.Avatar) > 0 { From e800bc0cf46579ca24dca51d19f085bd463e8b05 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 3 Mar 2022 15:28:41 +0100 Subject: [PATCH 02/11] allow overwrite artifacts for github releases (#18987) --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index bba8747482f8c..31706ac213d97 100644 --- a/.drone.yml +++ b/.drone.yml @@ -804,11 +804,12 @@ steps: depends_on: [gpg-sign] - name: github - image: plugins/github-release:1 + image: plugins/github-release:latest pull: always settings: files: - "dist/release/*" + file_exists: overwrite environment: GITHUB_TOKEN: from_secret: github_token From 7a893dab396c24d7e158b190f0a0182ff75bbcfd Mon Sep 17 00:00:00 2001 From: eladyn <59307989+eladyn@users.noreply.github.com> Date: Thu, 3 Mar 2022 16:18:26 +0100 Subject: [PATCH 03/11] ignore missing comment for user notifications (#18954) * ignore missing comment for user notifications * instead fix bug in notifications model * use local variable instead Co-authored-by: Lunny Xiao Co-authored-by: 6543 <6543@obermui.de> --- models/notification.go | 7 ++++--- routers/api/v1/notify/repo.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/models/notification.go b/models/notification.go index 8f5d9d01e6e32..b53d236e433f9 100644 --- a/models/notification.go +++ b/models/notification.go @@ -498,14 +498,15 @@ func (n *Notification) APIURL() string { type NotificationList []*Notification // LoadAttributes load Repo Issue User and Comment if not loaded -func (nl NotificationList) LoadAttributes() (err error) { +func (nl NotificationList) LoadAttributes() error { + var err error for i := 0; i < len(nl); i++ { err = nl[i].LoadAttributes() if err != nil && !IsErrCommentNotExist(err) { - return + return err } } - return + return nil } func (nl NotificationList) getPendingRepoIDs() []int64 { diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go index 8bf5d37116f92..30357ebd3f88d 100644 --- a/routers/api/v1/notify/repo.go +++ b/routers/api/v1/notify/repo.go @@ -121,7 +121,7 @@ func ListRepoNotifications(ctx *context.APIContext) { return } err = nl.LoadAttributes() - if err != nil && !models.IsErrCommentNotExist(err) { + if err != nil { ctx.InternalServerError(err) return } From 286355c7548b273f73f69cb79d8eaff8e05a8622 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Thu, 3 Mar 2022 15:59:26 -0500 Subject: [PATCH 04/11] homebrew updates via cron --- CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4216ee3a13a1e..45344a4d7bbb5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -424,7 +424,6 @@ be reviewed by two maintainers and must pass the automatic tests. * If needed send a frontport PR for the changelog to branch `main` and update the version in `docs/config.yaml` to refer to the new version. * Send PR to [blog repository](https://gitea.com/gitea/blog) announcing the release. * Verify all release assets were correctly published through CI on dl.gitea.io and GitHub releases. Once ACKed: - * send a PR to the [homebrew repo](https://gitea.com/gitea/homebrew-gitea) analog to [this PR](https://gitea.com/gitea/homebrew-gitea/commit/1f9a3fe5eb75b64a96a5336665531abcbd0eef0c) * bump the version of https://dl.gitea.io/gitea/version.json * merge the blog post PR * announce the release in discord `#announcements` From 3c7201682cde10ed551476e13e9e1bfdd971e0c0 Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 4 Mar 2022 00:56:31 +0000 Subject: [PATCH 05/11] Update `go-enry` to v2.8.0 (#18993) - It was reported in the Matrix channel that Chroma [has support](https://github.com/alecthomas/chroma/commit/d40210297631298bde98a8fcfd52c3d2555cc367) for the Fennel language, go-enry only added detection support for this [in v2.7.2](https://github.com/go-enry/go-enry/commit/0affa3ccca37cd781600760956581c5f94ef8a3c). Co-authored-by: techknowlogick --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8dae1cec138c3..44cbb45155594 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/go-asn1-ber/asn1-ber v1.5.3 // indirect github.com/go-chi/chi/v5 v5.0.4 github.com/go-chi/cors v1.2.0 - github.com/go-enry/go-enry/v2 v2.7.1 + github.com/go-enry/go-enry/v2 v2.8.0 github.com/go-git/go-billy/v5 v5.3.1 github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4 github.com/go-ldap/ldap/v3 v3.3.0 diff --git a/go.sum b/go.sum index 28c9f788130ad..71747a16c7190 100644 --- a/go.sum +++ b/go.sum @@ -326,8 +326,8 @@ github.com/go-chi/chi/v5 v5.0.4 h1:5e494iHzsYBiyXQAHHuI4tyJS9M3V84OuX3ufIIGHFo= github.com/go-chi/chi/v5 v5.0.4/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/cors v1.2.0 h1:tV1g1XENQ8ku4Bq3K9ub2AtgG+p16SmzeMSGTwrOKdE= github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= -github.com/go-enry/go-enry/v2 v2.7.1 h1:WCqtfyteIz61GYk9lRVy8HblvIv4cP9GIiwm/6txCbU= -github.com/go-enry/go-enry/v2 v2.7.1/go.mod h1:GVzIiAytiS5uT/QiuakK7TF1u4xDab87Y8V5EJRpsIQ= +github.com/go-enry/go-enry/v2 v2.8.0 h1:KMW4mSG+8uUF6FaD3iPkFqyfC5tF8gRrsYImq6yhHzo= +github.com/go-enry/go-enry/v2 v2.8.0/go.mod h1:GVzIiAytiS5uT/QiuakK7TF1u4xDab87Y8V5EJRpsIQ= github.com/go-enry/go-oniguruma v1.2.1 h1:k8aAMuJfMrqm/56SG2lV9Cfti6tC4x8673aHCcBk+eo= github.com/go-enry/go-oniguruma v1.2.1/go.mod h1:bWDhYP+S6xZQgiRL7wlTScFYBe023B6ilRZbCAD5Hf4= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= From 5184c83f6b702aeec3ea85263e16ccf5ebe89836 Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Fri, 4 Mar 2022 09:30:49 +0100 Subject: [PATCH 06/11] Add config option to disable "Update branch by rebase" (#18745) --- models/repo.go | 2 +- models/repo/repo_unit.go | 3 +++ modules/structs/repo.go | 2 ++ options/locale/locale_en-US.ini | 1 + routers/api/v1/repo/repo.go | 4 ++++ routers/web/repo/setting.go | 1 + services/forms/repo_form.go | 1 + services/pull/update.go | 8 +++++++- templates/repo/settings/options.tmpl | 6 ++++++ templates/swagger/v1_json.tmpl | 5 +++++ 10 files changed, 31 insertions(+), 2 deletions(-) diff --git a/models/repo.go b/models/repo.go index 4b2221e6435a5..6a806b7e258c8 100644 --- a/models/repo.go +++ b/models/repo.go @@ -521,7 +521,7 @@ func CreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_ units = append(units, repo_model.RepoUnit{ RepoID: repo.ID, Type: tp, - Config: &repo_model.PullRequestsConfig{AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true, DefaultMergeStyle: repo_model.MergeStyleMerge}, + Config: &repo_model.PullRequestsConfig{AllowMerge: true, AllowRebase: true, AllowRebaseMerge: true, AllowSquash: true, DefaultMergeStyle: repo_model.MergeStyleMerge, AllowRebaseUpdate: true}, }) } else { units = append(units, repo_model.RepoUnit{ diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go index f526cbdf8b116..37f1c70545060 100644 --- a/models/repo/repo_unit.go +++ b/models/repo/repo_unit.go @@ -115,12 +115,15 @@ type PullRequestsConfig struct { AllowSquash bool AllowManualMerge bool AutodetectManualMerge bool + AllowRebaseUpdate bool DefaultDeleteBranchAfterMerge bool DefaultMergeStyle MergeStyle } // FromDB fills up a PullRequestsConfig from serialized format. func (cfg *PullRequestsConfig) FromDB(bs []byte) error { + // AllowRebaseUpdate = true as default for existing PullRequestConfig in DB + cfg.AllowRebaseUpdate = true return json.UnmarshalHandleDoubleEncode(bs, &cfg) } diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 087ae941f409f..27d0b4f3bae14 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -177,6 +177,8 @@ type EditRepoOption struct { AllowManualMerge *bool `json:"allow_manual_merge,omitempty"` // either `true` to enable AutodetectManualMerge, or `false` to prevent it. `has_pull_requests` must be `true`, Note: In some special cases, misjudgments can occur. AutodetectManualMerge *bool `json:"autodetect_manual_merge,omitempty"` + // either `true` to allow updating pull request branch by rebase, or `false` to prevent it. `has_pull_requests` must be `true`. + AllowRebaseUpdate *bool `json:"allow_rebase_update,omitempty"` // set to `true` to delete pr branch after merge by default DefaultDeleteBranchAfterMerge *bool `json:"default_delete_branch_after_merge,omitempty"` // set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", or "squash". `has_pull_requests` must be `true`. diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f52fef3c0590b..6a7f9bb47c85f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1786,6 +1786,7 @@ settings.pulls.allow_rebase_merge_commit = Enable Rebasing with explicit merge c settings.pulls.allow_squash_commits = Enable Squashing to Merge Commits settings.pulls.allow_manual_merge = Enable Mark PR as manually merged settings.pulls.enable_autodetect_manual_merge = Enable autodetect manual merge (Note: In some special cases, misjudgments can occur) +settings.pulls.allow_rebase_update = Enable updating pull request branch by rebase settings.pulls.default_delete_branch_after_merge = Delete pull request branch after merge by default settings.projects_desc = Enable Repository Projects settings.admin_settings = Administrator Settings diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 7a7fe218e820f..560139c457991 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -860,6 +860,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error { AllowSquash: true, AllowManualMerge: true, AutodetectManualMerge: false, + AllowRebaseUpdate: true, DefaultDeleteBranchAfterMerge: false, DefaultMergeStyle: repo_model.MergeStyleMerge, } @@ -888,6 +889,9 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error { if opts.AutodetectManualMerge != nil { config.AutodetectManualMerge = *opts.AutodetectManualMerge } + if opts.AllowRebaseUpdate != nil { + config.AllowRebaseUpdate = *opts.AllowRebaseUpdate + } if opts.DefaultDeleteBranchAfterMerge != nil { config.DefaultDeleteBranchAfterMerge = *opts.DefaultDeleteBranchAfterMerge } diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index 8e249af55d072..5f7b948b8cac5 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -472,6 +472,7 @@ func SettingsPost(ctx *context.Context) { AllowSquash: form.PullsAllowSquash, AllowManualMerge: form.PullsAllowManualMerge, AutodetectManualMerge: form.EnableAutodetectManualMerge, + AllowRebaseUpdate: form.PullsAllowRebaseUpdate, DefaultDeleteBranchAfterMerge: form.DefaultDeleteBranchAfterMerge, DefaultMergeStyle: repo_model.MergeStyle(form.PullsDefaultMergeStyle), }, diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index da709ef800240..3760c71f2a1fd 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -151,6 +151,7 @@ type RepoSettingForm struct { PullsAllowManualMerge bool PullsDefaultMergeStyle string EnableAutodetectManualMerge bool + PullsAllowRebaseUpdate bool DefaultDeleteBranchAfterMerge bool EnableTimetracker bool AllowOnlyContributorsToTrackTime bool diff --git a/services/pull/update.go b/services/pull/update.go index f32dfad2ca6c1..2ad58ecd29ac8 100644 --- a/services/pull/update.go +++ b/services/pull/update.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models" repo_model "code.gitea.io/gitea/models/repo" + "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" @@ -97,7 +98,12 @@ func IsUserAllowedToUpdate(pull *models.PullRequest, user *user_model.User) (mer // can't do rebase on protected branch because need force push if pr.ProtectedBranch == nil { - rebaseAllowed = true + prUnit, err := pr.BaseRepo.GetUnit(unit.TypePullRequests) + if err != nil { + log.Error("pr.BaseRepo.GetUnit(unit.TypePullRequests): %v", err) + return false, false, err + } + rebaseAllowed = prUnit.PullRequestsConfig().AllowRebaseUpdate } // Update function need push permission diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index adcb6dd3df2d2..7695345010d42 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -448,6 +448,12 @@ +
+
+ + +
+
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 69abe24020978..3bc6158183e02 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -14809,6 +14809,11 @@ "type": "boolean", "x-go-name": "AllowRebaseMerge" }, + "allow_rebase_update": { + "description": "either `true` to allow updating pull request branch by rebase, or `false` to prevent it. `has_pull_requests` must be `true`.", + "type": "boolean", + "x-go-name": "AllowRebaseUpdate" + }, "allow_squash_merge": { "description": "either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. `has_pull_requests` must be `true`.", "type": "boolean", From e46a8c90ea11a24bbaa1ccaaf6600d5374ec26cf Mon Sep 17 00:00:00 2001 From: "Otto Richter (fnetX)" Date: Fri, 4 Mar 2022 19:29:12 +0100 Subject: [PATCH 07/11] Fix potential assignee query for repo (#18994) * Fix potential assignee query for repo * Add tests for `GetRepoAssignees` - As per https://github.com/go-gitea/gitea/pull/18994#issuecomment-1058506640 Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Gusted Co-authored-by: Lunny Xiao --- models/repo.go | 2 +- models/repo_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/models/repo.go b/models/repo.go index 6a806b7e258c8..38527c74dcb47 100644 --- a/models/repo.go +++ b/models/repo.go @@ -153,7 +153,7 @@ func getRepoAssignees(ctx context.Context, repo *repo_model.Repository) (_ []*us userIDs := make([]int64, 0, 10) if err = e.Table("access"). Where("repo_id = ? AND mode >= ?", repo.ID, perm.AccessModeWrite). - Select("id"). + Select("user_id"). Find(&userIDs); err != nil { return nil, err } diff --git a/models/repo_test.go b/models/repo_test.go index c0790e532d751..ea250be9763c3 100644 --- a/models/repo_test.go +++ b/models/repo_test.go @@ -167,3 +167,21 @@ func TestLinkedRepository(t *testing.T) { }) } } + +func TestRepoAssignees(t *testing.T) { + assert.NoError(t, unittest.PrepareTestDatabase()) + + repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}).(*repo_model.Repository) + users, err := GetRepoAssignees(repo2) + assert.NoError(t, err) + assert.Len(t, users, 1) + assert.Equal(t, users[0].ID, int64(2)) + + repo21 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 21}).(*repo_model.Repository) + users, err = GetRepoAssignees(repo21) + assert.NoError(t, err) + assert.Len(t, users, 3) + assert.Equal(t, users[0].ID, int64(15)) + assert.Equal(t, users[1].ID, int64(18)) + assert.Equal(t, users[2].ID, int64(16)) +} From 95c8d53d280307568a4637db1eb3ccf28c8dc0a9 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 4 Mar 2022 20:53:35 +0100 Subject: [PATCH 08/11] Add a "admin user generate-access-token" subcommand (#17722) * Add a "admin user generate-access-token" subcommand Fixes #17721 * Update cmd/admin.go Co-authored-by: wxiaoguang * Update cmd/admin.go Co-authored-by: wxiaoguang * Fix code to match new interfaces Signed-off-by: Andrew Thornton Co-authored-by: wxiaoguang Co-authored-by: zeripath --- cmd/admin.go | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/cmd/admin.go b/cmd/admin.go index 66c7959ab3987..70d44c39e047d 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -56,6 +56,7 @@ var ( microcmdUserList, microcmdUserChangePassword, microcmdUserDelete, + microcmdUserGenerateAccessToken, }, } @@ -154,6 +155,27 @@ var ( Action: runDeleteUser, } + microcmdUserGenerateAccessToken = cli.Command{ + Name: "generate-access-token", + Usage: "Generate a access token for a specific user", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "username,u", + Usage: "Username", + }, + cli.StringFlag{ + Name: "token-name,t", + Usage: "Token name", + Value: "gitea-admin", + }, + cli.BoolFlag{ + Name: "raw", + Usage: "Display only the token value", + }, + }, + Action: runGenerateAccessToken, + } + subcmdRepoSyncReleases = cli.Command{ Name: "repo-sync-releases", Usage: "Synchronize repository releases with tags", @@ -641,6 +663,41 @@ func runDeleteUser(c *cli.Context) error { return user_service.DeleteUser(user) } +func runGenerateAccessToken(c *cli.Context) error { + if !c.IsSet("username") { + return fmt.Errorf("You must provide the username to generate a token for them") + } + + ctx, cancel := installSignals() + defer cancel() + + if err := initDB(ctx); err != nil { + return err + } + + user, err := user_model.GetUserByName(c.String("username")) + if err != nil { + return err + } + + t := &models.AccessToken{ + Name: c.String("token-name"), + UID: user.ID, + } + + if err := models.NewAccessToken(t); err != nil { + return err + } + + if c.Bool("raw") { + fmt.Printf("%s\n", t.Token) + } else { + fmt.Printf("Access token was successfully created: %s\n", t.Token) + } + + return nil +} + func runRepoSyncReleases(_ *cli.Context) error { ctx, cancel := installSignals() defer cancel() From 997deecbfa77fe00d8260da2921073a0565dc735 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 5 Mar 2022 04:57:26 +0800 Subject: [PATCH 09/11] Fix the editor height in review box (#19003) Fix the height problem in https://github.com/go-gitea/gitea/pull/18862#issuecomment-1059329539 I have tested this fix. # Screenshots ### Min-height image ### Max-height image --- web_src/js/features/repo-issue.js | 3 ++- web_src/less/_review.less | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index 4f791c7704a6b..43ce8a9f1b1f9 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -462,7 +462,8 @@ export function initRepoPullRequestReview() { (async () => { // the editor's height is too large in some cases, and the panel cannot be scrolled with page now because there is `.repository .diff-detail-box.sticky { position: sticky; }` // the temporary solution is to make the editor's height smaller (about 4 lines). GitHub also only show 4 lines for default. We can improve the UI (including Dropzone area) in future - await createCommentEasyMDE($reviewBox.find('textarea'), {minHeight: '80px', maxHeight: 'calc(100vh - 360px)'}); + // EasyMDE's options can not handle minHeight & maxHeight together correctly, we have to set max-height for .CodeMirror-scroll in CSS. + await createCommentEasyMDE($reviewBox.find('textarea'), {minHeight: '80px'}); initCompImagePaste($reviewBox); })(); } diff --git a/web_src/less/_review.less b/web_src/less/_review.less index 1070ad7ddedcf..ac9f57cfbedfd 100644 --- a/web_src/less/_review.less +++ b/web_src/less/_review.less @@ -197,6 +197,13 @@ a.blob-excerpt:hover { color: #fff; } +// See the comment of createCommentEasyMDE() for the review editor +// EasyMDE's options can not handle minHeight & maxHeight together correctly, we have to set minHeight in JS code +#review-box .CodeMirror-scroll { + min-height: 80px; + max-height: calc(100vh - 360px); +} + @media @mediaSm { #review-box > .menu { > .ui.segment { From 814750e647722ecf5ed2938844744bed139fffd5 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 5 Mar 2022 04:59:29 +0800 Subject: [PATCH 10/11] Fix update hint bug (#18996) --- templates/admin/dashboard.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index d9e056973aeef..5a4b82f1b963e 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -5,7 +5,7 @@ {{template "base/alert" .}} {{if .NeedUpdate}}
-

{{.i18n.Tr "admin.dashboard.new_version_hint" (.RemoteVersion | Str2html) (AppVer | Str2html)}}

+

{{(.i18n.Tr "admin.dashboard.new_version_hint" .RemoteVersion AppVer) | Str2html}}

{{end}}

From 3e28fa72cedc559e0dc3396d0676a5d1dab12624 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 6 Mar 2022 01:53:34 +0800 Subject: [PATCH 11/11] Fix EasyMDE error when input Enter (#19004) Co-authored-by: Lunny Xiao --- web_src/js/features/comp/EasyMDE.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/js/features/comp/EasyMDE.js b/web_src/js/features/comp/EasyMDE.js index af28c0b0ee436..0327a1e0238c0 100644 --- a/web_src/js/features/comp/EasyMDE.js +++ b/web_src/js/features/comp/EasyMDE.js @@ -74,10 +74,10 @@ export async function createCommentEasyMDE(textarea, easyMDEOptions = {}) { const inputField = easyMDE.codemirror.getInputField(); inputField.classList.add('js-quick-submit'); easyMDE.codemirror.setOption('extraKeys', { - Enter: () => { + Enter: (cm) => { const tributeContainer = document.querySelector('.tribute-container'); if (!tributeContainer || tributeContainer.style.display === 'none') { - return window.CodeMirror.Pass; + cm.execCommand('newlineAndIndent'); } }, Backspace: (cm) => {