From 6a8ebaf22b8e85049ca44158ff7ff7c10c39e0f2 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 21 Jun 2023 04:44:58 -0400 Subject: [PATCH 01/89] add python/poetry to devcontainer (#25407) with introduction of linter, this adds python/poetry to devcontainer --- .devcontainer/devcontainer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 31e42d0ab30d..be34bfd02d31 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,9 @@ "ghcr.io/devcontainers/features/node:1": { "version":"20" }, - "ghcr.io/devcontainers/features/git-lfs:1.1.0": {} + "ghcr.io/devcontainers/features/git-lfs:1.1.0": {}, + "ghcr.io/devcontainers-contrib/features/poetry:2": {}, + "ghcr.io/devcontainers/features/python:1": {} }, "customizations": { "vscode": { From 59d218987582ae3191a4cb97fbfc4f3aedcff1ad Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 21 Jun 2023 17:14:34 +0800 Subject: [PATCH 02/89] Fix missing commit message body when the message has leading newlines (#25418) Commit with `echo "\nmessage after a blank line\nsecond line of the message" | git commit --cleanup=verbatim -F -` and push. image --- modules/templates/util_render.go | 6 +-- modules/templates/util_render_test.go | 56 +++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 modules/templates/util_render_test.go diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index a26c0531f81d..d23103ce1bc5 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -81,16 +81,16 @@ func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlPrefix, urlDefa // RenderCommitBody extracts the body of a commit message without its title. func RenderCommitBody(ctx context.Context, msg, urlPrefix string, metas map[string]string) template.HTML { - msgLine := strings.TrimRightFunc(msg, unicode.IsSpace) + msgLine := strings.TrimSpace(msg) lineEnd := strings.IndexByte(msgLine, '\n') if lineEnd > 0 { msgLine = msgLine[lineEnd+1:] } else { - return template.HTML("") + return "" } msgLine = strings.TrimLeftFunc(msgLine, unicode.IsSpace) if len(msgLine) == 0 { - return template.HTML("") + return "" } renderedMessage, err := markup.RenderCommitMessage(&markup.RenderContext{ diff --git a/modules/templates/util_render_test.go b/modules/templates/util_render_test.go new file mode 100644 index 000000000000..29d3ed3a56c4 --- /dev/null +++ b/modules/templates/util_render_test.go @@ -0,0 +1,56 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package templates + +import ( + "context" + "html/template" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestRenderCommitBody(t *testing.T) { + type args struct { + ctx context.Context + msg string + urlPrefix string + metas map[string]string + } + tests := []struct { + name string + args args + want template.HTML + }{ + { + name: "multiple lines", + args: args{ + ctx: context.Background(), + msg: "first line\nsecond line", + }, + want: "second line", + }, + { + name: "multiple lines with leading newlines", + args: args{ + ctx: context.Background(), + msg: "\n\n\n\nfirst line\nsecond line", + }, + want: "second line", + }, + { + name: "multiple lines with trailing newlines", + args: args{ + ctx: context.Background(), + msg: "first line\nsecond line\n\n\n", + }, + want: "second line", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equalf(t, tt.want, RenderCommitBody(tt.args.ctx, tt.args.msg, tt.args.urlPrefix, tt.args.metas), "RenderCommitBody(%v, %v, %v, %v)", tt.args.ctx, tt.args.msg, tt.args.urlPrefix, tt.args.metas) + }) + } +} From dfd19fa38c9ee004c5d7e73f51af5981adcb5e6d Mon Sep 17 00:00:00 2001 From: HesterG Date: Wed, 21 Jun 2023 18:15:51 +0800 Subject: [PATCH 03/89] Fine tune project board label colors and modal content background (#25419) - The label text color on project board is not contrasting enough, changed to colors that are same as places that also used `useLightTextOnBackground` function ([util_render.go](https://github.com/go-gitea/gitea/blob/2cdf260f42d178d23a8db70db35664511aeab31e/modules/templates/util_render.go#L136-L141), [Context Popup](https://github.com/go-gitea/gitea/blob/2cdf260f42d178d23a8db70db35664511aeab31e/web_src/js/components/ContextPopup.vue#L81-L84)) - background of modal `content` is `#ffffff` (from fomantic) right now, which does not look good on dark mode, so changed to `var(--color-body)` Before: Screen Shot 2023-06-21 at 14 24 13 Screen Shot 2023-06-21 at 14 25 52 After: Screen Shot 2023-06-21 at 14 19 33 Screen Shot 2023-06-21 at 14 32 42 --- web_src/css/base.css | 4 ++-- web_src/css/modules/modal.css | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web_src/css/base.css b/web_src/css/base.css index 7322b778f362..78bcd4f1c475 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -214,8 +214,8 @@ --color-placeholder-text: #aaa; --color-editor-line-highlight: var(--color-primary-light-6); --color-project-board-bg: var(--color-secondary-light-4); - --color-project-board-dark-label: #555555; - --color-project-board-light-label: #a6aab5; + --color-project-board-dark-label: #111111; + --color-project-board-light-label: #eeeeee; --color-caret: var(--color-text-dark); --color-reaction-bg: #0000000a; --color-reaction-hover-bg: var(--color-primary-light-5); diff --git a/web_src/css/modules/modal.css b/web_src/css/modules/modal.css index a8d3521093e7..5824efb30cf7 100644 --- a/web_src/css/modules/modal.css +++ b/web_src/css/modules/modal.css @@ -35,6 +35,7 @@ .ui.modal > .content, .ui.modal > form > .content { padding: 1.5em; + background: var(--color-body); } .ui.modal > .actions, From ce46834b938eb687152a680669ada95a26304178 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 21 Jun 2023 18:49:25 +0800 Subject: [PATCH 04/89] Remove "CHARSET" config option for MySQL, always use "utf8mb4" (#25413) In modern days, there is no reason to make users set "charset" anymore. Close #25378 ## :warning: BREAKING The key `[database].CHARSET` was removed completely as every newer (>10years) MySQL database supports `utf8mb4` already. There is a (deliberately) undocumented new fallback option if anyone still needs to use it, but we don't recommend using it as it simply causes problems. --- custom/conf/app.example.ini | 3 -- .../config-cheat-sheet.en-us.md | 1 - docs/content/doc/help/faq.en-us.md | 2 -- modules/setting/database.go | 28 ++++++------------- options/locale/locale_en-US.ini | 2 -- routers/install/install.go | 3 -- services/forms/user_form.go | 1 - templates/install.tmpl | 15 ---------- 8 files changed, 9 insertions(+), 46 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index e51f0558831a..13820095aee2 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -344,9 +344,6 @@ NAME = gitea USER = root ;PASSWD = ;Use PASSWD = `your password` for quoting if you use special characters in the password. ;SSL_MODE = false ; either "false" (default), "true", or "skip-verify" -;CHARSET = utf8mb4 ;either "utf8" or "utf8mb4", default is "utf8mb4". -;; -;; NOTICE: for "utf8mb4" you must use MySQL InnoDB > 5.6. Gitea is unable to check this. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; diff --git a/docs/content/doc/administration/config-cheat-sheet.en-us.md b/docs/content/doc/administration/config-cheat-sheet.en-us.md index 64a356555478..77cb784637be 100644 --- a/docs/content/doc/administration/config-cheat-sheet.en-us.md +++ b/docs/content/doc/administration/config-cheat-sheet.en-us.md @@ -443,7 +443,6 @@ The following configuration set `Content-Type: application/vnd.android.package-a - `SQLITE_TIMEOUT`: **500**: Query timeout for SQLite3 only. - `SQLITE_JOURNAL_MODE`: **""**: Change journal mode for SQlite3. Can be used to enable [WAL mode](https://www.sqlite.org/wal.html) when high load causes write congestion. See [SQlite3 docs](https://www.sqlite.org/pragma.html#pragma_journal_mode) for possible values. Defaults to the default for the database file, often DELETE. - `ITERATE_BUFFER_SIZE`: **50**: Internal buffer size for iterating. -- `CHARSET`: **utf8mb4**: For MySQL only, either "utf8" or "utf8mb4". NOTICE: for "utf8mb4" you must use MySQL InnoDB > 5.6. Gitea is unable to check this. - `PATH`: **data/gitea.db**: For SQLite3 only, the database file path. - `LOG_SQL`: **true**: Log the executed SQL. - `DB_RETRIES`: **10**: How many ORM init / DB connect attempts allowed. diff --git a/docs/content/doc/help/faq.en-us.md b/docs/content/doc/help/faq.en-us.md index f609b6c86704..ae59a9b8807c 100644 --- a/docs/content/doc/help/faq.en-us.md +++ b/docs/content/doc/help/faq.en-us.md @@ -396,8 +396,6 @@ Please run `gitea convert`, or run `ALTER DATABASE database_name CHARACTER SET u for the database_name and run `ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;` for each table in the database. -You will also need to change the app.ini database charset to `CHARSET=utf8mb4`. - ## Why are Emoji displaying only as placeholders or in monochrome Gitea requires the system or browser to have one of the supported Emoji fonts installed, which are Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji and Twemoji Mozilla. Generally, the operating system should already provide one of these fonts, but especially on Linux, it may be necessary to install them manually. diff --git a/modules/setting/database.go b/modules/setting/database.go index 7a7c7029a430..709655368c67 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -12,8 +12,6 @@ import ( "path/filepath" "strings" "time" - - "code.gitea.io/gitea/modules/log" ) var ( @@ -36,7 +34,7 @@ var ( SSLMode string Path string LogSQL bool - Charset string + MysqlCharset string Timeout int // seconds SQLiteJournalMode string DBConnectRetries int @@ -60,11 +58,6 @@ func LoadDBSetting() { func loadDBSetting(rootCfg ConfigProvider) { sec := rootCfg.Section("database") Database.Type = DatabaseType(sec.Key("DB_TYPE").String()) - defaultCharset := "utf8" - - if Database.Type.IsMySQL() { - defaultCharset = "utf8mb4" - } Database.Host = sec.Key("HOST").String() Database.Name = sec.Key("NAME").String() @@ -74,10 +67,7 @@ func loadDBSetting(rootCfg ConfigProvider) { } Database.Schema = sec.Key("SCHEMA").String() Database.SSLMode = sec.Key("SSL_MODE").MustString("disable") - Database.Charset = sec.Key("CHARSET").In(defaultCharset, []string{"utf8", "utf8mb4"}) - if Database.Type.IsMySQL() && defaultCharset != "utf8mb4" { - log.Error("Deprecated database mysql charset utf8 support, please use utf8mb4 or convert utf8 to utf8mb4.") - } + Database.MysqlCharset = sec.Key("MYSQL_CHARSET").MustString("utf8mb4") // do not document it, end users won't need it. Database.Path = sec.Key("PATH").MustString(filepath.Join(AppDataPath, "gitea.db")) Database.Timeout = sec.Key("SQLITE_TIMEOUT").MustInt(500) @@ -101,9 +91,9 @@ func loadDBSetting(rootCfg ConfigProvider) { // DBConnStr returns database connection string func DBConnStr() (string, error) { var connStr string - Param := "?" - if strings.Contains(Database.Name, Param) { - Param = "&" + paramSep := "?" + if strings.Contains(Database.Name, paramSep) { + paramSep = "&" } switch Database.Type { case "mysql": @@ -116,15 +106,15 @@ func DBConnStr() (string, error) { tls = "false" } connStr = fmt.Sprintf("%s:%s@%s(%s)/%s%scharset=%s&parseTime=true&tls=%s", - Database.User, Database.Passwd, connType, Database.Host, Database.Name, Param, Database.Charset, tls) + Database.User, Database.Passwd, connType, Database.Host, Database.Name, paramSep, Database.MysqlCharset, tls) case "postgres": - connStr = getPostgreSQLConnectionString(Database.Host, Database.User, Database.Passwd, Database.Name, Param, Database.SSLMode) + connStr = getPostgreSQLConnectionString(Database.Host, Database.User, Database.Passwd, Database.Name, paramSep, Database.SSLMode) case "mssql": host, port := ParseMSSQLHostPort(Database.Host) connStr = fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", host, port, Database.Name, Database.User, Database.Passwd) case "sqlite3": if !EnableSQLite3 { - return "", errors.New("this binary version does not build support for SQLite3") + return "", errors.New("this Gitea binary was not built with SQLite3 support") } if err := os.MkdirAll(path.Dir(Database.Path), os.ModePerm); err != nil { return "", fmt.Errorf("Failed to create directories: %w", err) @@ -136,7 +126,7 @@ func DBConnStr() (string, error) { connStr = fmt.Sprintf("file:%s?cache=shared&mode=rwc&_busy_timeout=%d&_txlock=immediate%s", Database.Path, Database.Timeout, journalMode) default: - return "", fmt.Errorf("Unknown database type: %s", Database.Type) + return "", fmt.Errorf("unknown database type: %s", Database.Type) } return connStr, nil diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 234b898fc1d2..a2c67fbf5592 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -197,11 +197,9 @@ host = Host user = Username password = Password db_name = Database Name -db_helper = Note to MySQL users: please use the InnoDB storage engine and if you use "utf8mb4", your InnoDB version must be greater than 5.6 . db_schema = Schema db_schema_helper = Leave blank for database default ("public"). ssl_mode = SSL -charset = Charset path = Path sqlite_helper = File path for the SQLite3 database.
Enter an absolute path if you run Gitea as a service. reinstall_error = You are trying to install into an existing Gitea database diff --git a/routers/install/install.go b/routers/install/install.go index c94a30b89fcf..f121f313769d 100644 --- a/routers/install/install.go +++ b/routers/install/install.go @@ -99,7 +99,6 @@ func Install(ctx *context.Context) { form.DbName = setting.Database.Name form.DbPath = setting.Database.Path form.DbSchema = setting.Database.Schema - form.Charset = setting.Database.Charset curDBType := setting.Database.Type.String() var isCurDBTypeSupported bool @@ -269,7 +268,6 @@ func SubmitInstall(ctx *context.Context) { setting.Database.Name = form.DbName setting.Database.Schema = form.DbSchema setting.Database.SSLMode = form.SSLMode - setting.Database.Charset = form.Charset setting.Database.Path = form.DbPath setting.Database.LogSQL = !setting.IsProd @@ -388,7 +386,6 @@ func SubmitInstall(ctx *context.Context) { cfg.Section("database").Key("PASSWD").SetValue(setting.Database.Passwd) cfg.Section("database").Key("SCHEMA").SetValue(setting.Database.Schema) cfg.Section("database").Key("SSL_MODE").SetValue(setting.Database.SSLMode) - cfg.Section("database").Key("CHARSET").SetValue(setting.Database.Charset) cfg.Section("database").Key("PATH").SetValue(setting.Database.Path) cfg.Section("database").Key("LOG_SQL").SetValue("false") // LOG_SQL is rarely helpful diff --git a/services/forms/user_form.go b/services/forms/user_form.go index 0a4e2729e7b5..1f5abf94ee12 100644 --- a/services/forms/user_form.go +++ b/services/forms/user_form.go @@ -27,7 +27,6 @@ type InstallForm struct { DbPasswd string DbName string SSLMode string - Charset string `binding:"Required;In(utf8,utf8mb4)"` DbPath string DbSchema string diff --git a/templates/install.tmpl b/templates/install.tmpl index 1cd5dcff8bac..3df4455416df 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -44,7 +44,6 @@
- {{.locale.Tr "install.db_helper"}}
@@ -69,20 +68,6 @@ -
-
- - -
-
-
From 25455bc670910111d8cbb5293f95713416d22a0e Mon Sep 17 00:00:00 2001 From: sebastian-sauer Date: Wed, 21 Jun 2023 18:08:12 +0200 Subject: [PATCH 05/89] Show outdated comments in files changed tab (#24936) If enabled show a clickable label in the comment. A click on the label opens the Conversation tab with the comment focussed - there you're able to view the old diff (or original diff the comment was created on). **Screenshots** ![image](https://github.com/go-gitea/gitea/assets/1135157/63ab9571-a9ee-4900-9f02-94ab0095f9e7) ![image](https://github.com/go-gitea/gitea/assets/1135157/78f7c225-8d76-46f5-acfd-9b8aab988a6c) When resolved and outdated: ![image](https://github.com/go-gitea/gitea/assets/1135157/6ece9ebd-c792-4aa5-9c35-628694e9d093) Option to enable/disable this (stored in user settings - default is disabled): ![image](https://github.com/go-gitea/gitea/assets/1135157/ed99dfe4-76dc-4c12-bd96-e7e62da50ab5) ![image](https://github.com/go-gitea/gitea/assets/1135157/e837a052-e92e-4a28-906d-9db5bacf93a6) fixes #24913 --------- Co-authored-by: silverwind --- models/issues/comment_code.go | 18 +++++++------ models/issues/comment_test.go | 4 +-- models/issues/review.go | 2 +- models/user/setting_keys.go | 2 ++ options/locale/locale_en-US.ini | 3 +++ routers/web/repo/middlewares.go | 25 +++++++++++++++++++ routers/web/repo/pull.go | 2 +- routers/web/repo/pull_review.go | 2 +- routers/web/web.go | 6 ++--- services/gitdiff/gitdiff.go | 4 +-- services/gitdiff/gitdiff_test.go | 14 +++++++++-- templates/repo/diff/comments.tmpl | 6 +++++ templates/repo/diff/conversation.tmpl | 15 +++++++++-- templates/repo/diff/options_dropdown.tmpl | 15 +++++++++++ templates/repo/diff/whitespace_dropdown.tmpl | 10 ++++---- .../repo/issue/view_content/comments.tmpl | 2 +- web_src/css/repo.css | 21 +++++++++------- web_src/css/review.css | 2 +- 18 files changed, 115 insertions(+), 38 deletions(-) diff --git a/models/issues/comment_code.go b/models/issues/comment_code.go index 304ac4569f86..d447d7542cd2 100644 --- a/models/issues/comment_code.go +++ b/models/issues/comment_code.go @@ -18,11 +18,11 @@ import ( type CodeComments map[string]map[int64][]*Comment // FetchCodeComments will return a 2d-map: ["Path"]["Line"] = Comments at line -func FetchCodeComments(ctx context.Context, issue *Issue, currentUser *user_model.User) (CodeComments, error) { - return fetchCodeCommentsByReview(ctx, issue, currentUser, nil) +func FetchCodeComments(ctx context.Context, issue *Issue, currentUser *user_model.User, showOutdatedComments bool) (CodeComments, error) { + return fetchCodeCommentsByReview(ctx, issue, currentUser, nil, showOutdatedComments) } -func fetchCodeCommentsByReview(ctx context.Context, issue *Issue, currentUser *user_model.User, review *Review) (CodeComments, error) { +func fetchCodeCommentsByReview(ctx context.Context, issue *Issue, currentUser *user_model.User, review *Review, showOutdatedComments bool) (CodeComments, error) { pathToLineToComment := make(CodeComments) if review == nil { review = &Review{ID: 0} @@ -33,7 +33,7 @@ func fetchCodeCommentsByReview(ctx context.Context, issue *Issue, currentUser *u ReviewID: review.ID, } - comments, err := findCodeComments(ctx, opts, issue, currentUser, review) + comments, err := findCodeComments(ctx, opts, issue, currentUser, review, showOutdatedComments) if err != nil { return nil, err } @@ -47,15 +47,17 @@ func fetchCodeCommentsByReview(ctx context.Context, issue *Issue, currentUser *u return pathToLineToComment, nil } -func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issue, currentUser *user_model.User, review *Review) ([]*Comment, error) { +func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issue, currentUser *user_model.User, review *Review, showOutdatedComments bool) ([]*Comment, error) { var comments CommentList if review == nil { review = &Review{ID: 0} } conds := opts.ToConds() - if review.ID == 0 { + + if !showOutdatedComments && review.ID == 0 { conds = conds.And(builder.Eq{"invalidated": false}) } + e := db.GetEngine(ctx) if err := e.Where(conds). Asc("comment.created_unix"). @@ -118,12 +120,12 @@ func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issu } // FetchCodeCommentsByLine fetches the code comments for a given treePath and line number -func FetchCodeCommentsByLine(ctx context.Context, issue *Issue, currentUser *user_model.User, treePath string, line int64) ([]*Comment, error) { +func FetchCodeCommentsByLine(ctx context.Context, issue *Issue, currentUser *user_model.User, treePath string, line int64, showOutdatedComments bool) ([]*Comment, error) { opts := FindCommentsOptions{ Type: CommentTypeCode, IssueID: issue.ID, TreePath: treePath, Line: line, } - return findCodeComments(ctx, opts, issue, currentUser, nil) + return findCodeComments(ctx, opts, issue, currentUser, nil, showOutdatedComments) } diff --git a/models/issues/comment_test.go b/models/issues/comment_test.go index 43bad1660f1f..d766625be3dc 100644 --- a/models/issues/comment_test.go +++ b/models/issues/comment_test.go @@ -50,7 +50,7 @@ func TestFetchCodeComments(t *testing.T) { issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2}) user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}) - res, err := issues_model.FetchCodeComments(db.DefaultContext, issue, user) + res, err := issues_model.FetchCodeComments(db.DefaultContext, issue, user, false) assert.NoError(t, err) assert.Contains(t, res, "README.md") assert.Contains(t, res["README.md"], int64(4)) @@ -58,7 +58,7 @@ func TestFetchCodeComments(t *testing.T) { assert.Equal(t, int64(4), res["README.md"][4][0].ID) user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) - res, err = issues_model.FetchCodeComments(db.DefaultContext, issue, user2) + res, err = issues_model.FetchCodeComments(db.DefaultContext, issue, user2, false) assert.NoError(t, err) assert.Len(t, res, 1) } diff --git a/models/issues/review.go b/models/issues/review.go index 3a1ab7468afc..3685c65ce581 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -141,7 +141,7 @@ func (r *Review) LoadCodeComments(ctx context.Context) (err error) { if err = r.loadIssue(ctx); err != nil { return } - r.CodeComments, err = fetchCodeCommentsByReview(ctx, r.Issue, nil, r) + r.CodeComments, err = fetchCodeCommentsByReview(ctx, r.Issue, nil, r, false) return err } diff --git a/models/user/setting_keys.go b/models/user/setting_keys.go index 10255735b317..72b3974eee43 100644 --- a/models/user/setting_keys.go +++ b/models/user/setting_keys.go @@ -8,6 +8,8 @@ const ( SettingsKeyHiddenCommentTypes = "issue.hidden_comment_types" // SettingsKeyDiffWhitespaceBehavior is the setting key for whitespace behavior of diff SettingsKeyDiffWhitespaceBehavior = "diff.whitespace_behaviour" + // SettingsKeyShowOutdatedComments is the setting key wether or not to show outdated comments in PRs + SettingsKeyShowOutdatedComments = "comment_code.show_outdated" // UserActivityPubPrivPem is user's private key UserActivityPubPrivPem = "activitypub.priv_pem" // UserActivityPubPubPem is user's public key diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a2c67fbf5592..70802fc4ca2f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1611,6 +1611,9 @@ issues.review.pending.tooltip = This comment is not currently visible to other u issues.review.review = Review issues.review.reviewers = Reviewers issues.review.outdated = Outdated +issues.review.outdated_description = Content has changed since this comment was made +issues.review.option.show_outdated_comments = Show outdated comments +issues.review.option.hide_outdated_comments = Hide outdated comments issues.review.show_outdated = Show outdated issues.review.hide_outdated = Hide outdated issues.review.show_resolved = Show resolved diff --git a/routers/web/repo/middlewares.go b/routers/web/repo/middlewares.go index 5c38b31154fe..216550ca996c 100644 --- a/routers/web/repo/middlewares.go +++ b/routers/web/repo/middlewares.go @@ -5,6 +5,7 @@ package repo import ( "fmt" + "strconv" system_model "code.gitea.io/gitea/models/system" user_model "code.gitea.io/gitea/models/user" @@ -88,3 +89,27 @@ func SetWhitespaceBehavior(ctx *context.Context) { ctx.Data["WhitespaceBehavior"] = whitespaceBehavior } } + +// SetShowOutdatedComments set the show outdated comments option as context variable +func SetShowOutdatedComments(ctx *context.Context) { + showOutdatedCommentsValue := ctx.FormString("show-outdated") + // var showOutdatedCommentsValue string + + if showOutdatedCommentsValue != "true" && showOutdatedCommentsValue != "false" { + // invalid or no value for this form string -> use default or stored user setting + if ctx.IsSigned { + showOutdatedCommentsValue, _ = user_model.GetUserSetting(ctx.Doer.ID, user_model.SettingsKeyShowOutdatedComments, "false") + } else { + // not logged in user -> use the default value + showOutdatedCommentsValue = "false" + } + } else { + // valid value -> update user setting if user is logged in + if ctx.IsSigned { + _ = user_model.SetUserSetting(ctx.Doer.ID, user_model.SettingsKeyShowOutdatedComments, showOutdatedCommentsValue) + } + } + + showOutdatedComments, _ := strconv.ParseBool(showOutdatedCommentsValue) + ctx.Data["ShowOutdatedComments"] = showOutdatedComments +} diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index ef9d5856da0e..f2a58a35a78a 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -761,7 +761,7 @@ func ViewPullFiles(ctx *context.Context) { "numberOfViewedFiles": diff.NumViewedFiles, } - if err = diff.LoadComments(ctx, issue, ctx.Doer); err != nil { + if err = diff.LoadComments(ctx, issue, ctx.Doer, ctx.Data["ShowOutdatedComments"].(bool)); err != nil { ctx.ServerError("LoadComments", err) return } diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go index 69d36ff4a47e..5aa581136705 100644 --- a/routers/web/repo/pull_review.go +++ b/routers/web/repo/pull_review.go @@ -159,7 +159,7 @@ func UpdateResolveConversation(ctx *context.Context) { } func renderConversation(ctx *context.Context, comment *issues_model.Comment) { - comments, err := issues_model.FetchCodeCommentsByLine(ctx, comment.Issue, ctx.Doer, comment.TreePath, comment.Line) + comments, err := issues_model.FetchCodeCommentsByLine(ctx, comment.Issue, ctx.Doer, comment.TreePath, comment.Line, ctx.Data["ShowOutdatedComments"].(bool)) if err != nil { ctx.ServerError("FetchCodeCommentsByLine", err) return diff --git a/routers/web/web.go b/routers/web/web.go index a7573b38f559..26ad2d54c3a3 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1037,7 +1037,7 @@ func registerRoutes(m *web.Route) { m.Post("/dismiss_review", reqRepoAdmin, web.Bind(forms.DismissReviewForm{}), repo.DismissReview) m.Post("/status", reqRepoIssuesOrPullsWriter, repo.UpdateIssueStatus) m.Post("/delete", reqRepoAdmin, repo.BatchDeleteIssues) - m.Post("/resolve_conversation", reqRepoIssuesOrPullsReader, repo.UpdateResolveConversation) + m.Post("/resolve_conversation", reqRepoIssuesOrPullsReader, repo.SetShowOutdatedComments, repo.UpdateResolveConversation) m.Post("/attachments", repo.UploadIssueAttachment) m.Post("/attachments/remove", repo.DeleteAttachment) m.Delete("/unpin/{index}", reqRepoAdmin, repo.IssueUnpin) @@ -1285,10 +1285,10 @@ func registerRoutes(m *web.Route) { m.Post("/set_allow_maintainer_edit", web.Bind(forms.UpdateAllowEditsForm{}), repo.SetAllowEdits) m.Post("/cleanup", context.RepoMustNotBeArchived(), context.RepoRef(), repo.CleanUpPullRequest) m.Group("/files", func() { - m.Get("", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.ViewPullFiles) + m.Get("", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFiles) m.Group("/reviews", func() { m.Get("/new_comment", repo.RenderNewCodeCommentForm) - m.Post("/comments", web.Bind(forms.CodeCommentForm{}), repo.CreateCodeComment) + m.Post("/comments", web.Bind(forms.CodeCommentForm{}), repo.SetShowOutdatedComments, repo.CreateCodeComment) m.Post("/submit", web.Bind(forms.SubmitReviewForm{}), repo.SubmitReview) }, context.RepoMustNotBeArchived()) }) diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index b6a75f60982f..9adf3b940093 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -450,8 +450,8 @@ type Diff struct { } // LoadComments loads comments into each line -func (diff *Diff) LoadComments(ctx context.Context, issue *issues_model.Issue, currentUser *user_model.User) error { - allComments, err := issues_model.FetchCodeComments(ctx, issue, currentUser) +func (diff *Diff) LoadComments(ctx context.Context, issue *issues_model.Issue, currentUser *user_model.User, showOutdatedComments bool) error { + allComments, err := issues_model.FetchCodeComments(ctx, issue, currentUser, showOutdatedComments) if err != nil { return err } diff --git a/services/gitdiff/gitdiff_test.go b/services/gitdiff/gitdiff_test.go index 389f787dfc44..e270e46fd453 100644 --- a/services/gitdiff/gitdiff_test.go +++ b/services/gitdiff/gitdiff_test.go @@ -594,16 +594,26 @@ func setupDefaultDiff() *Diff { } } -func TestDiff_LoadComments(t *testing.T) { +func TestDiff_LoadCommentsNoOutdated(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2}) user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}) diff := setupDefaultDiff() - assert.NoError(t, diff.LoadComments(db.DefaultContext, issue, user)) + assert.NoError(t, diff.LoadComments(db.DefaultContext, issue, user, false)) assert.Len(t, diff.Files[0].Sections[0].Lines[0].Comments, 2) } +func TestDiff_LoadCommentsWithOutdated(t *testing.T) { + assert.NoError(t, unittest.PrepareTestDatabase()) + + issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2}) + user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}) + diff := setupDefaultDiff() + assert.NoError(t, diff.LoadComments(db.DefaultContext, issue, user, true)) + assert.Len(t, diff.Files[0].Sections[0].Lines[0].Comments, 3) +} + func TestDiffLine_CanComment(t *testing.T) { assert.False(t, (&DiffLine{Type: DiffLineSection}).CanComment()) assert.False(t, (&DiffLine{Type: DiffLineAdd, Comments: []*issues_model.Comment{{Content: "bla"}}}).CanComment()) diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 5b0b32cc97c5..d19ac1f047b9 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -31,6 +31,12 @@ {{end}}
+ {{if .Invalidated}} + {{$referenceUrl := printf "%s#%s" $.root.Issue.Link .HashTag}} + + {{$.root.locale.Tr "repo.issues.review.outdated"}} + + {{end}} {{if and .Review}} {{if eq .Review.Type 0}}
diff --git a/templates/repo/diff/conversation.tmpl b/templates/repo/diff/conversation.tmpl index 8d4064967e17..ce344794ea78 100644 --- a/templates/repo/diff/conversation.tmpl +++ b/templates/repo/diff/conversation.tmpl @@ -1,14 +1,25 @@ {{$resolved := (index .comments 0).IsResolved}} +{{$invalid := (index .comments 0).Invalidated}} {{$resolveDoer := (index .comments 0).ResolveDoer}} {{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}} +{{$referenceUrl := printf "%s#%s" $.Issue.Link (index .comments 0).HashTag}}
{{if $resolved}}
-
+
{{svg "octicon-check" 16 "icon gt-mr-2"}} {{$resolveDoer.Name}} {{$.locale.Tr "repo.issues.review.resolved_by"}} + {{if $invalid}} + + + {{$.locale.Tr "repo.issues.review.outdated"}} + + {{end}}
-
+
diff --git a/templates/repo/diff/whitespace_dropdown.tmpl b/templates/repo/diff/whitespace_dropdown.tmpl index 5a5b8c3dbd30..a1830cb288c9 100644 --- a/templates/repo/diff/whitespace_dropdown.tmpl +++ b/templates/repo/diff/whitespace_dropdown.tmpl @@ -1,25 +1,25 @@ -{{if .IsSplitStyle}}{{svg "gitea-join"}}{{else}}{{svg "gitea-split"}}{{end}} +{{if .IsSplitStyle}}{{svg "gitea-join"}}{{else}}{{svg "gitea-split"}}{{end}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index bfcd292f44c3..9097a180e3b5 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -488,7 +488,7 @@
{{$filename}} {{if $invalid}} - + {{$.locale.Tr "repo.issues.review.outdated"}} {{end}} diff --git a/web_src/css/repo.css b/web_src/css/repo.css index fa9739342161..c84b9e0f35d3 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -1702,6 +1702,10 @@ .repository .diff-box .resolved-placeholder { display: flex; align-items: center; + font-size: 14px !important; + height: 36px; + padding-top: 0; + padding-bottom: 0; } .repository .diff-box .resolved-placeholder .button { @@ -1728,10 +1732,6 @@ text-align: center; } -.repository .diff-file-box .code-diff { - font-size: 12px; -} - .repository .diff-file-box .code-diff td { padding: 0 0 0 10px !important; border-top: 0; @@ -2495,14 +2495,17 @@ left: 7px; } -.comment-header .actions a { - margin-right: 0 !important; +.comment-header .actions a:not(.label) { padding: 0.5rem !important; } -.comment-header-left > * + *, -.comment-header-right > * + * { - margin-left: 0.25rem; +.comment-header .actions .label { + margin: 0 !important; +} + +.comment-header-left, +.comment-header-right { + gap: 4px; } .comment-body { diff --git a/web_src/css/review.css b/web_src/css/review.css index dce23bcd7492..263f821f384d 100644 --- a/web_src/css/review.css +++ b/web_src/css/review.css @@ -128,7 +128,7 @@ } .comment-code-cloud .attached.header { - padding: 0.1rem 1rem; + padding: 1px 8px 1px 12px; } .comment-code-cloud .attached.header .text { From 8afc1b1cb5ad44ab5dd9597a814b19412702ede3 Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Wed, 21 Jun 2023 14:57:18 -0500 Subject: [PATCH 06/89] Move some regexp out of functions (#25430) /cc @KN4CK3R https://github.com/go-gitea/gitea/pull/25294#discussion_r1237425343 I also searched the codebase and found a few more. --------- Signed-off-by: jolheiser --- modules/repository/generate.go | 6 +++--- modules/util/path.go | 5 +++-- services/lfs/server.go | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/repository/generate.go b/modules/repository/generate.go index 102c5af1c91f..cb25daa10b33 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -372,12 +372,12 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ return generateRepo, nil } +var fileNameSanitizeRegexp = regexp.MustCompile(`(?i)\.\.|[<>:\"/\\|?*\x{0000}-\x{001F}]|^(con|prn|aux|nul|com\d|lpt\d)$`) + // Sanitize user input to valid OS filenames // // Based on https://github.com/sindresorhus/filename-reserved-regex // Adds ".." to prevent directory traversal func fileNameSanitize(s string) string { - re := regexp.MustCompile(`(?i)\.\.|[<>:\"/\\|?*\x{0000}-\x{001F}]|^(con|prn|aux|nul|com\d|lpt\d)$`) - - return strings.TrimSpace(re.ReplaceAllString(s, "_")) + return strings.TrimSpace(fileNameSanitizeRegexp.ReplaceAllString(s, "_")) } diff --git a/modules/util/path.go b/modules/util/path.go index 1a68bc748802..58258560dded 100644 --- a/modules/util/path.go +++ b/modules/util/path.go @@ -222,6 +222,8 @@ func isOSWindows() bool { return runtime.GOOS == "windows" } +var driveLetterRegexp = regexp.MustCompile("/[A-Za-z]:/") + // FileURLToPath extracts the path information from a file://... url. func FileURLToPath(u *url.URL) (string, error) { if u.Scheme != "file" { @@ -235,8 +237,7 @@ func FileURLToPath(u *url.URL) (string, error) { } // If it looks like there's a Windows drive letter at the beginning, strip off the leading slash. - re := regexp.MustCompile("/[A-Za-z]:/") - if re.MatchString(path) { + if driveLetterRegexp.MatchString(path) { return path[1:], nil } return path, nil diff --git a/services/lfs/server.go b/services/lfs/server.go index a18e752d4791..b32f218785ed 100644 --- a/services/lfs/server.go +++ b/services/lfs/server.go @@ -77,6 +77,8 @@ func CheckAcceptMediaType(ctx *context.Context) { } } +var rangeHeaderRegexp = regexp.MustCompile(`bytes=(\d+)\-(\d*).*`) + // DownloadHandler gets the content from the content store func DownloadHandler(ctx *context.Context) { rc := getRequestContext(ctx) @@ -92,8 +94,7 @@ func DownloadHandler(ctx *context.Context) { toByte = meta.Size - 1 statusCode := http.StatusOK if rangeHdr := ctx.Req.Header.Get("Range"); rangeHdr != "" { - regex := regexp.MustCompile(`bytes=(\d+)\-(\d*).*`) - match := regex.FindStringSubmatch(rangeHdr) + match := rangeHeaderRegexp.FindStringSubmatch(rangeHdr) if len(match) > 1 { statusCode = http.StatusPartialContent fromByte, _ = strconv.ParseInt(match[1], 10, 32) From 656d3cc71973c547b574866e30e5f3da5327ce25 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 22 Jun 2023 03:59:49 +0200 Subject: [PATCH 07/89] Various UI fixes (#25264) Numerous small UI fixes: - Fix double border in collaborator list - Fix system notice table background - Mute links in repo and org lists - Downsize projects edit buttons - Improve milestones and project list rendering - Condense milestone list entry to a single line of "metas" - Mute ".." button in repo files list --- templates/admin/notice.tmpl | 2 +- templates/projects/view.tmpl | 2 +- templates/repo/issue/milestone_issues.tmpl | 8 ++++++-- templates/repo/issue/milestones.tmpl | 5 +++-- templates/repo/projects/view.tmpl | 2 +- templates/repo/view_list.tmpl | 2 +- templates/shared/issuelist.tmpl | 2 +- templates/user/dashboard/milestones.tmpl | 5 +++-- templates/user/settings/organization.tmpl | 6 +++--- templates/user/settings/repos.tmpl | 4 ++-- web_src/css/base.css | 7 +++++++ web_src/css/repo.css | 4 ---- web_src/css/shared/issuelist.css | 4 ---- web_src/css/shared/milestone.css | 4 ---- 14 files changed, 29 insertions(+), 28 deletions(-) diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl index 3dbae0462575..5cd617a0b591 100644 --- a/templates/admin/notice.tmpl +++ b/templates/admin/notice.tmpl @@ -3,7 +3,7 @@

{{.locale.Tr "admin.notices.system_notice_list"}} ({{.locale.Tr "admin.total" .Total}})

- +
diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index 58dbca2a4bd1..35493775b56e 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -45,7 +45,7 @@ {{if $.CanWriteProjects}}
-
{{if .HasParentPath}} - + {{end}} {{range $item := .Files}} diff --git a/templates/shared/issuelist.tmpl b/templates/shared/issuelist.tmpl index 8ae00a2ba944..192911d13a3b 100644 --- a/templates/shared/issuelist.tmpl +++ b/templates/shared/issuelist.tmpl @@ -84,7 +84,7 @@ {{end}} {{if ne .DeadlineUnix 0}} - + {{svg "octicon-calendar" 14 "gt-mr-2"}} {{DateTime "short" .DeadlineUnix}} diff --git a/templates/user/dashboard/milestones.tmpl b/templates/user/dashboard/milestones.tmpl index 23b7b27116bb..c68d0783b82a 100644 --- a/templates/user/dashboard/milestones.tmpl +++ b/templates/user/dashboard/milestones.tmpl @@ -115,12 +115,13 @@ {{svg "octicon-clock" 14}} {{$.locale.Tr "repo.milestones.closed" $closedDate | Safe}} {{else}} - {{svg "octicon-calendar" 14}} {{if .DeadlineString}} - + + {{svg "octicon-calendar" 14}} {{DateTime "short" .DeadlineString}} {{else}} + {{svg "octicon-calendar" 14}} {{$.locale.Tr "repo.milestones.no_due_date"}} {{end}} {{end}} diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl index 2e10588fd8f2..9b6d0f66c5eb 100644 --- a/templates/user/settings/organization.tmpl +++ b/templates/user/settings/organization.tmpl @@ -23,9 +23,9 @@ - {{avatar $.Context . 28 "mini"}} -
- {{.Name}} +
+ {{avatar $.Context . 28 "mini"}} + {{.Name}}
{{end}} diff --git a/templates/user/settings/repos.tmpl b/templates/user/settings/repos.tmpl index 64b08ca2c540..d2164d199a08 100644 --- a/templates/user/settings/repos.tmpl +++ b/templates/user/settings/repos.tmpl @@ -23,8 +23,8 @@ {{else}} {{svg "octicon-repo"}} {{end}} - {{$repo.OwnerName}}/{{$repo.Name}} - {{FileSize $repo.Size}} + {{$repo.OwnerName}}/{{$repo.Name}} + {{FileSize $repo.Size}} {{if $repo.IsFork}} {{$.locale.Tr "repo.forked_from"}} {{$repo.BaseRepo.OwnerName}}/{{$repo.BaseRepo.Name}} diff --git a/web_src/css/base.css b/web_src/css/base.css index 78bcd4f1c475..23930403963a 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -869,6 +869,13 @@ a.label, border-color: var(--color-secondary); } +.ui.table > tfoot > tr > th, +.ui.table > tfoot > tr > td { + border-color: var(--color-secondary); + background: var(--color-box-body); + color: var(--color-text); +} + img.ui.avatar, .ui.avatar img, .ui.avatar svg { diff --git a/web_src/css/repo.css b/web_src/css/repo.css index c84b9e0f35d3..c93160473080 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -1947,10 +1947,6 @@ line-height: 2em; } -.repository.settings.collaboration .collaborator.list > .item:not(:last-child) { - border-bottom: 1px solid var(--color-secondary); -} - .repository.settings.collaboration #repo-collab-form #search-user-box .results { left: 7px; } diff --git a/web_src/css/shared/issuelist.css b/web_src/css/shared/issuelist.css index ecbeaf1dfdb4..b20fd1a80e1b 100644 --- a/web_src/css/shared/issuelist.css +++ b/web_src/css/shared/issuelist.css @@ -135,10 +135,6 @@ margin-right: -4px; } -.issue.list > .item .desc .overdue { - color: var(--color-red); -} - .issue.list .branches { display: inline-flex; padding: 0 4px; diff --git a/web_src/css/shared/milestone.css b/web_src/css/shared/milestone.css index 511a1be714e0..91e6b5e387c4 100644 --- a/web_src/css/shared/milestone.css +++ b/web_src/css/shared/milestone.css @@ -44,10 +44,6 @@ gap: 8px; } -.milestone-toolbar .group .overdue { - color: var(--color-red); -} - .milestone-toolbar .group > a { font-size: 15px; color: var(--color-text-light-2); From 93cd579269717934b2b8e72d6258b712c1675eaa Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 22 Jun 2023 04:15:19 +0200 Subject: [PATCH 08/89] Switch to ansi_up for ansi rendering in actions (#25401) Fixes: https://github.com/go-gitea/gitea/issues/24777 --- package-lock.json | 32 ++++--------- package.json | 2 +- web_src/js/components/RepoActionView.test.js | 30 ------------ web_src/js/components/RepoActionView.vue | 48 +------------------- web_src/js/render/ansi.js | 44 ++++++++++++++++++ web_src/js/render/ansi.test.js | 21 +++++++++ 6 files changed, 77 insertions(+), 100 deletions(-) delete mode 100644 web_src/js/components/RepoActionView.test.js create mode 100644 web_src/js/render/ansi.js create mode 100644 web_src/js/render/ansi.test.js diff --git a/package-lock.json b/package-lock.json index e808ccf2a8ff..43846cf4a059 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@primer/octicons": "19.3.0", "@webcomponents/custom-elements": "1.6.0", "add-asset-webpack-plugin": "2.0.1", - "ansi-to-html": "0.7.2", + "ansi_up": "5.2.1", "asciinema-player": "3.4.0", "clippie": "4.0.1", "css-loader": "6.8.1", @@ -2465,6 +2465,14 @@ "ajv": "^8.8.2" } }, + "node_modules/ansi_up": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ansi_up/-/ansi_up-5.2.1.tgz", + "integrity": "sha512-5bz5T/7FRmlxA37zDXhG6cAwlcZtfnmNLDJra66EEIT3kYlw5aPJdbkJEhm59D6kA4Wi5ict6u6IDYHJaQlH+g==", + "engines": { + "node": "*" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -2487,20 +2495,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/ansi-to-html": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ansi-to-html/-/ansi-to-html-0.7.2.tgz", - "integrity": "sha512-v6MqmEpNlxF+POuyhKkidusCHWWkaLcGRURzivcU3I9tv7k4JVhFcnukrM5Rlk2rUywdZuzYAZ+kbZqWCnfN3g==", - "dependencies": { - "entities": "^2.2.0" - }, - "bin": { - "ansi-to-html": "bin/ansi-to-html" - }, - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -4210,14 +4204,6 @@ "node": ">=10.13.0" } }, - "node_modules/entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", diff --git a/package.json b/package.json index 0701862cc2a6..dd2eff71956c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "@primer/octicons": "19.3.0", "@webcomponents/custom-elements": "1.6.0", "add-asset-webpack-plugin": "2.0.1", - "ansi-to-html": "0.7.2", + "ansi_up": "5.2.1", "asciinema-player": "3.4.0", "clippie": "4.0.1", "css-loader": "6.8.1", diff --git a/web_src/js/components/RepoActionView.test.js b/web_src/js/components/RepoActionView.test.js deleted file mode 100644 index 011c20d8d193..000000000000 --- a/web_src/js/components/RepoActionView.test.js +++ /dev/null @@ -1,30 +0,0 @@ -import {expect, test} from 'vitest'; - -import {ansiLogToHTML} from './RepoActionView.vue'; -import AnsiToHTML from 'ansi-to-html'; - -test('processConsoleLine', () => { - expect(ansiLogToHTML('abc')).toEqual('abc'); - expect(ansiLogToHTML('abc\n')).toEqual('abc'); - expect(ansiLogToHTML('abc\r\n')).toEqual('abc'); - expect(ansiLogToHTML('\r')).toEqual(''); - expect(ansiLogToHTML('\rx\rabc')).toEqual('x\nabc'); - expect(ansiLogToHTML('\rabc\rx\r')).toEqual('abc\nx'); - - expect(ansiLogToHTML('\x1b[30mblack\x1b[37mwhite')).toEqual('blackwhite'); - expect(ansiLogToHTML(' diff --git a/web_src/js/features/pull-view-file.js b/web_src/js/features/pull-view-file.js index daa520ea7e7f..90ea80516078 100644 --- a/web_src/js/features/pull-view-file.js +++ b/web_src/js/features/pull-view-file.js @@ -1,3 +1,4 @@ +import {diffTreeStore} from '../modules/stores.js'; import {setFileFolding} from './file-fold.js'; const {csrfToken, pageData} = window.config; @@ -53,9 +54,17 @@ export function initViewedCheckboxListenerFor() { const hasChangedLabel = form.parentNode.querySelector('.changed-since-last-review'); hasChangedLabel?.remove(); + const fileName = checkbox.getAttribute('name'); + + // check if the file is in our difftreestore and if we find it -> change the IsViewed status + const fileInPageData = diffTreeStore().files.find((x) => x.Name === fileName); + if (fileInPageData) { + fileInPageData.IsViewed = this.checked; + } + // Unfortunately, actual forms cause too many problems, hence another approach is needed const files = {}; - files[checkbox.getAttribute('name')] = this.checked; + files[fileName] = this.checked; const data = {files}; const headCommitSHA = form.getAttribute('data-headcommit'); if (headCommitSHA) data.headCommitSHA = headCommitSHA; From b8253607fea3a20d371ec1f6a30133e0ad72a2be Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 25 Jun 2023 10:03:09 +0800 Subject: [PATCH 38/89] Revert "Make buttons in a modal form have proper type. (#25446)" (#25485) There is a side effect because some modal doesn't have a proper "ok" button. This reverts commit a954c93a68072042aa7dad717b6fa002c83a58fb. --- web_src/js/features/common-global.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js index 8bbf202eff8b..e5fd7c29fce6 100644 --- a/web_src/js/features/common-global.js +++ b/web_src/js/features/common-global.js @@ -395,8 +395,6 @@ function initGlobalShowModal() { if (colorPickers.length > 0) { initCompColorPicker(); // FIXME: this might cause duplicate init } - // all non-"ok" buttons which do not have "type" should not submit the form, should not be triggered by "Enter" - $modal.find('form button:not(.ok):not([type])').attr('type', 'button'); $modal.modal('setting', { onApprove: () => { // "form-fetch-action" can handle network errors gracefully, From 323c6cba20db618d48f4939d1fcaaa036ec0a0d7 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 25 Jun 2023 10:40:41 +0800 Subject: [PATCH 39/89] Fine tune "dropdown button" icon (#25442) ![image](https://github.com/go-gitea/gitea/assets/2114189/143e043d-85c9-43a4-85ae-ca55f507f738) ---- ![image](https://github.com/go-gitea/gitea/assets/2114189/bcba03a5-732e-4139-bc35-96a7f8bfcb88) --- templates/devtest/gitea-ui.tmpl | 46 +++++++++++++++++++++------------ templates/repo/commit_page.tmpl | 3 ++- web_src/css/base.css | 11 ++++++++ 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/templates/devtest/gitea-ui.tmpl b/templates/devtest/gitea-ui.tmpl index 0da443aade12..2c5a54c1c22b 100644 --- a/templates/devtest/gitea-ui.tmpl +++ b/templates/devtest/gitea-ui.tmpl @@ -165,13 +165,6 @@
item
- diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 2e8732b40b80..8f8e9fa0e81b 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -26,7 +26,8 @@ {{.locale.Tr "repo.diff.browse_source"}} {{if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}{{- /* */ -}} -
{{svg "octicon-reply"}}..{{svg "octicon-reply"}}..
diff --git a/templates/admin/repo/search.tmpl b/templates/admin/repo/search.tmpl index cb9aad1a6649..0d98e3e4f27d 100644 --- a/templates/admin/repo/search.tmpl +++ b/templates/admin/repo/search.tmpl @@ -1,6 +1,12 @@ -