From 84d2159ef6a9d299f4b379ea37c0cf17291ad69b Mon Sep 17 00:00:00 2001 From: metiftikci Date: Wed, 19 Feb 2025 03:29:17 +0300 Subject: [PATCH 1/3] fix: add missing locale (#33641) this removed in #23113 but still using in `head_navbar.tmpl` --- options/locale/locale_en-US.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index bce64a81a3..c2c5b07b65 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1702,7 +1702,9 @@ issues.time_estimate_invalid = Time estimate format is invalid issues.start_tracking_history = started working %s issues.tracker_auto_close = Timer will be stopped automatically when this issue gets closed issues.tracking_already_started = `You have already started time tracking on another issue!` +issues.stop_tracking = Stop Timer issues.stop_tracking_history = worked for %[1]s %[2]s +issues.cancel_tracking = Discard issues.cancel_tracking_history = `canceled time tracking %s` issues.del_time = Delete this time log issues.add_time_history = added spent time %[1]s %[2]s From c2e23d3301b1be2b2ad667184030087f92ad2470 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 19 Feb 2025 08:55:19 +0800 Subject: [PATCH 2/3] Fix PR web route permission check (#33636) See the FIXME comment in code. Otherwise, if a repo's issue unit is disabled, then the PRs can't be edited anymore. By the way, make the permission log output look slightly better. --------- Co-authored-by: Lunny Xiao Co-authored-by: metiftikci --- models/perm/access/repo_permission.go | 10 ++++++---- modules/log/logger_impl.go | 23 +++++++++++++++++++---- modules/log/logger_test.go | 14 +++++++++++++- routers/web/web.go | 16 +++++++++------- 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/models/perm/access/repo_permission.go b/models/perm/access/repo_permission.go index e00b7c5320..5e7ecb31ea 100644 --- a/models/perm/access/repo_permission.go +++ b/models/perm/access/repo_permission.go @@ -152,7 +152,7 @@ func (p *Permission) ReadableUnitTypes() []unit.Type { } func (p *Permission) LogString() string { - format := " 0 } +func asLogStringer(v any) LogStringer { + if s, ok := v.(LogStringer); ok { + return s + } else if a := reflect.ValueOf(v); a.Kind() == reflect.Struct { + // in case the receiver is a pointer, but the value is a struct + vp := reflect.New(a.Type()) + vp.Elem().Set(a) + if s, ok := vp.Interface().(LogStringer); ok { + return s + } + } + return nil +} + // Log prepares the log event, if the level matches, the event will be sent to the writers func (l *LoggerImpl) Log(skip int, level Level, format string, logArgs ...any) { if Level(l.level.Load()) > level { @@ -207,11 +222,11 @@ func (l *LoggerImpl) Log(skip int, level Level, format string, logArgs ...any) { // handle LogStringer values for i, v := range msgArgs { if cv, ok := v.(*ColoredValue); ok { - if s, ok := cv.v.(LogStringer); ok { - cv.v = logStringFormatter{v: s} + if ls := asLogStringer(cv.v); ls != nil { + cv.v = logStringFormatter{v: ls} } - } else if s, ok := v.(LogStringer); ok { - msgArgs[i] = logStringFormatter{v: s} + } else if ls := asLogStringer(v); ls != nil { + msgArgs[i] = logStringFormatter{v: ls} } } diff --git a/modules/log/logger_test.go b/modules/log/logger_test.go index 0de14eb411..e794732ce2 100644 --- a/modules/log/logger_test.go +++ b/modules/log/logger_test.go @@ -116,6 +116,14 @@ func (t testLogString) LogString() string { return "log-string" } +type testLogStringPtrReceiver struct { + Field string +} + +func (t *testLogStringPtrReceiver) LogString() string { + return "log-string-ptr-receiver" +} + func TestLoggerLogString(t *testing.T) { logger := NewLoggerWithWriters(context.Background(), "test") @@ -124,9 +132,13 @@ func TestLoggerLogString(t *testing.T) { logger.AddWriters(w1) logger.Info("%s %s %#v %v", testLogString{}, &testLogString{}, testLogString{Field: "detail"}, NewColoredValue(testLogString{}, FgRed)) + logger.Info("%s %s %#v %v", testLogStringPtrReceiver{}, &testLogStringPtrReceiver{}, testLogStringPtrReceiver{Field: "detail"}, NewColoredValue(testLogStringPtrReceiver{}, FgRed)) logger.Close() - assert.Equal(t, []string{"log-string log-string log.testLogString{Field:\"detail\"} \x1b[31mlog-string\x1b[0m\n"}, w1.GetLogs()) + assert.Equal(t, []string{ + "log-string log-string log.testLogString{Field:\"detail\"} \x1b[31mlog-string\x1b[0m\n", + "log-string-ptr-receiver log-string-ptr-receiver &log.testLogStringPtrReceiver{Field:\"detail\"} \x1b[31mlog-string-ptr-receiver\x1b[0m\n", + }, w1.GetLogs()) } func TestLoggerExpressionFilter(t *testing.T) { diff --git a/routers/web/web.go b/routers/web/web.go index bca20b88ab..a5175e8830 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1196,6 +1196,10 @@ func registerRoutes(m *web.Router) { }) }) } + // FIXME: many "pulls" requests are sent to "issues" endpoints correctly, so the issue endpoints have to tolerate pull request permissions at the moment + m.Group("/{username}/{reponame}/{type:issues}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, context.RequireUnitReader(unit.TypeIssues, unit.TypePullRequests)) + m.Group("/{username}/{reponame}/{type:pulls}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, reqUnitPullsReader) + m.Group("/{username}/{reponame}", func() { m.Get("/comments/{id}/attachments", repo.GetCommentAttachments) m.Get("/labels", repo.RetrieveLabelsForList, repo.Labels) @@ -1203,9 +1207,6 @@ func registerRoutes(m *web.Router) { m.Get("/milestone/{id}", context.RepoRef(), repo.MilestoneIssuesAndPulls) m.Get("/issues/suggestions", repo.IssueSuggestions) }, optSignIn, context.RepoAssignment, reqRepoIssuesOrPullsReader) // issue/pull attachments, labels, milestones - - m.Group("/{username}/{reponame}/{type:issues}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, reqUnitIssuesReader) - m.Group("/{username}/{reponame}/{type:pulls}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, reqUnitPullsReader) // end "/{username}/{reponame}": view milestone, label, issue, pull, etc m.Group("/{username}/{reponame}/{type:issues}", func() { @@ -1224,7 +1225,7 @@ func registerRoutes(m *web.Router) { m.Get("/search", repo.SearchRepoIssuesJSON) }, reqUnitIssuesReader) - addIssuesPullsRoutes := func() { + addIssuesPullsUpdateRoutes := func() { // for "/{username}/{reponame}/issues" or "/{username}/{reponame}/pulls" m.Group("/{index}", func() { m.Post("/title", repo.UpdateIssueTitle) @@ -1267,8 +1268,9 @@ func registerRoutes(m *web.Router) { m.Delete("/unpin/{index}", reqRepoAdmin, repo.IssueUnpin) m.Post("/move_pin", reqRepoAdmin, repo.IssuePinMove) } - m.Group("/{type:issues}", addIssuesPullsRoutes, reqUnitIssuesReader, context.RepoMustNotBeArchived()) - m.Group("/{type:pulls}", addIssuesPullsRoutes, reqUnitPullsReader, context.RepoMustNotBeArchived()) + // FIXME: many "pulls" requests are sent to "issues" endpoints incorrectly, so the issue endpoints have to tolerate pull request permissions at the moment + m.Group("/{type:issues}", addIssuesPullsUpdateRoutes, context.RequireUnitReader(unit.TypeIssues, unit.TypePullRequests), context.RepoMustNotBeArchived()) + m.Group("/{type:pulls}", addIssuesPullsUpdateRoutes, reqUnitPullsReader, context.RepoMustNotBeArchived()) m.Group("/comments/{id}", func() { m.Post("", repo.UpdateCommentContent) @@ -1292,7 +1294,7 @@ func registerRoutes(m *web.Router) { m.Post("/delete", repo.DeleteMilestone) }, reqRepoIssuesOrPullsWriter, context.RepoRef()) - // FIXME: need to move these routes to the proper place + // FIXME: many "pulls" requests are sent to "issues" endpoints incorrectly, need to move these routes to the proper place m.Group("/issues", func() { m.Post("/request_review", repo.UpdatePullReviewRequest) m.Post("/dismiss_review", reqRepoAdmin, web.Bind(forms.DismissReviewForm{}), repo.DismissReview) From 40faa6dc78a5b5730a1609ba39daefddac08aa63 Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Wed, 19 Feb 2025 19:35:08 +0100 Subject: [PATCH 3/3] git graph: don't show detached commits (#33645) Current git graph is not usable for mirrors of repos having a lot of PRs, as can be seen at https://demo.gitea.com/ericLemanissier/conan-center-index/graph ![image](https://github.com/user-attachments/assets/ace40dd2-3eea-4d69-8e19-10fb7224e326) Manually running `git log --graph --date-order --all` on such a repo indeed shows: ``` * commit c4a34bd39d7977c8630177c5f88507000ea3e943 |\ Merge: a4bbd3ad6b 35a102c77c | | Author: toge | | Date: Wed Feb 19 08:36:41 2025 +0000 | | | | Merge 35a102c77cbc38d84baca0ca63466fb410336ea8 into a4bbd3ad6bb5a0f8e5117a897d8c55941f533d98 | | | * commit 35a102c77cbc38d84baca0ca63466fb410336ea8 | | Author: toge | | Date: Wed Feb 19 17:36:35 2025 +0900 | | | | update 4.4.2 | | | | * commit 5d610f4fd3c0428731e402a2f618fad9ce055875 | |/| Merge: a4bbd3ad6b fe916fb70a |/| | Author: Antony Peacock | | | Date: Wed Feb 19 08:31:30 2025 +0000 | | | | | | Merge fe916fb70a8bf49503cce70a5c7124bcc4314ddc into a4bbd3ad6bb5a0f8e5117a897d8c55941f533d98 | | | | | * commit fe916fb70a8bf49503cce70a5c7124bcc4314ddc | | | Author: Antony Peacock | | | Date: Wed Feb 19 08:31:18 2025 +0000 | | | | | | Remove parquet cmakelist patch | | | | | | * commit 9f6d2759d650ec3c86d01bb940e829e7e14220c2 | |_|/| Merge: a4bbd3ad6b f0963429b0 |/| | | Author: Thomas Sedlmair | | | | Date: Wed Feb 19 08:03:08 2025 +0100 | | | | | | | | Merge f0963429b0952499da0da7e559f8d53387097307 into a4bbd3ad6bb5a0f8e5117a897d8c55941f533d98 | | | | | | | * commit f0963429b0952499da0da7e559f8d53387097307 | |_|/ Author: Thomas Sedlmair |/| | Date: Wed Feb 19 08:01:43 2025 +0100 | | | | | | added cwt-cucumber 2.5 | | | ``` On the other hand, running `git log --graph --date-order --branches --tags` returns the expected: ``` * commit a4bbd3ad6bb5a0f8e5117a897d8c55941f533d98 (HEAD -> master) | Author: Dan | Date: Fri Feb 14 18:46:11 2025 +0200 | | grpc: add version 1.69.0 (#26446) | | * grpc: add version 1.69.0 | | * add cmake tool requires | | --------- | | Co-authored-by: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> | * commit a7868807cb2e21206ebf95278cb588f29a3e2205 | Author: Guillaume Egles | Date: Thu Feb 13 05:44:35 2025 -0800 | | openssl: add versions `3.0.16`, `3.1.8`, `3.2.4`, `3.3.3`, `3.4.1`, stop publishing revisions for version `3.0.15` (#26578) | * commit 86057d3e63ac71e2fe48c07bb301f2d54187044d | Author: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> | Date: Thu Feb 13 13:34:41 2025 +0000 | | android-ndk: dont set LD and AS variables (#26581) | | * android-ndk: dont set LD and AS variables | | * android-ndk: refactor test package | * commit 123e382fafd2f5e811e10faac02efc275c45ec2a | Author: Nikita | Date: Thu Feb 13 12:29:39 2025 +0300 | | libffi: fix conditionals when building on Windows (#26500) | | * fix: add missing or `clang` | | * fix: libffi - always require as tool `automake` ``` --- services/repository/gitgraph/graph.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/repository/gitgraph/graph.go b/services/repository/gitgraph/graph.go index 7e12be030f..2628a1a55a 100644 --- a/services/repository/gitgraph/graph.go +++ b/services/repository/gitgraph/graph.go @@ -29,7 +29,7 @@ func GetCommitGraph(r *git.Repository, page, maxAllowedColors int, hidePRRefs bo } if len(branches) == 0 { - graphCmd.AddArguments("--all") + graphCmd.AddArguments("--tags", "--branches") } graphCmd.AddArguments("-C", "-M", "--date=iso-strict").