From c7e4629c0245cf6731ea34c2aa6ba4b968ea184a Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 15 Jan 2024 16:43:53 +0900 Subject: [PATCH 01/76] Fix nil pointer panic when exec some gitea cli command (#28791) panic: ![image](https://github.com/go-gitea/gitea/assets/18380374/7fcde2ad-1d42-4b60-b120-3b60a8926e8e) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/49d9f0ca-e590-4a35-8ca2-1317d1b7c939) --- modules/private/actions.go | 3 +++ modules/private/key.go | 3 +++ modules/private/mail.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/modules/private/actions.go b/modules/private/actions.go index c924dac2cd..4ec77dc936 100644 --- a/modules/private/actions.go +++ b/modules/private/actions.go @@ -22,5 +22,8 @@ func GenerateActionsRunnerToken(ctx context.Context, scope string) (string, Resp }) resp, extra := requestJSONResp(req, &responseText{}) + if resp == nil { + return "", extra + } return resp.Text, extra } diff --git a/modules/private/key.go b/modules/private/key.go index 6f7cd87796..aa1e8aa56f 100644 --- a/modules/private/key.go +++ b/modules/private/key.go @@ -27,5 +27,8 @@ func AuthorizedPublicKeyByContent(ctx context.Context, content string) (string, req := newInternalRequest(ctx, reqURL, "POST") req.Param("content", content) resp, extra := requestJSONResp(req, &responseText{}) + if resp == nil { + return "", extra + } return resp.Text, extra } diff --git a/modules/private/mail.go b/modules/private/mail.go index 82216b346b..699f5e5f42 100644 --- a/modules/private/mail.go +++ b/modules/private/mail.go @@ -30,5 +30,8 @@ func SendEmail(ctx context.Context, subject, message string, to []string) (strin }) resp, extra := requestJSONResp(req, &responseText{}) + if resp == nil { + return "", extra + } return resp.Text, extra } From 637451a45ecbc3d127ff2adf27437ce1357493ea Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Mon, 15 Jan 2024 09:49:24 +0100 Subject: [PATCH 02/76] Rework markup link rendering (#26745) Fixes #26548 This PR refactors the rendering of markup links. The old code uses `strings.Replace` to change some urls while the new code uses more context to decide which link should be generated. The added tests should ensure the same output for the old and new behaviour (besides the bug). We may need to refactor the rendering a bit more to make it clear how the different helper methods render the input string. There are lots of options (resolve links / images / mentions / git hashes / emojis / ...) but you don't really know what helper uses which options. For example, we currently support images in the user description which should not be allowed I think:
Profile https://try.gitea.io/KN4CK3R ![grafik](https://github.com/go-gitea/gitea/assets/1666336/109ae422-496d-4200-b52e-b3a528f553e5)
--------- Co-authored-by: wxiaoguang --- models/issues/comment_code.go | 8 +- models/repo/repo.go | 3 +- modules/markup/external/external.go | 13 +- modules/markup/html.go | 57 +-- modules/markup/html_internal_test.go | 30 +- modules/markup/html_test.go | 117 ++++--- modules/markup/markdown/goldmark.go | 30 +- modules/markup/markdown/markdown.go | 6 - modules/markup/markdown/markdown_test.go | 422 +++++++++++++++++++++-- modules/markup/orgmode/orgmode.go | 58 ++-- modules/markup/orgmode/orgmode_test.go | 15 +- modules/markup/renderer.go | 42 ++- modules/templates/helper.go | 1 - modules/templates/util_render.go | 53 +-- modules/templates/util_render_test.go | 141 +++++++- routers/common/markup.go | 12 +- routers/web/feed/convert.go | 19 +- routers/web/feed/profile.go | 6 +- routers/web/org/home.go | 23 +- routers/web/repo/commit.go | 18 +- routers/web/repo/issue.go | 51 +-- routers/web/repo/milestone.go | 20 +- routers/web/repo/projects.go | 20 +- routers/web/repo/release.go | 20 +- routers/web/repo/render.go | 15 +- routers/web/repo/view.go | 58 ++-- routers/web/repo/wiki.go | 10 +- routers/web/shared/user/header.go | 6 +- routers/web/user/home.go | 8 +- routers/web/user/profile.go | 24 +- services/mailer/mail.go | 8 +- services/mailer/mail_release.go | 8 +- templates/repo/branch/list.tmpl | 4 +- templates/repo/commit_page.tmpl | 8 +- templates/repo/commits_list.tmpl | 4 +- templates/repo/commits_list_small.tmpl | 4 +- templates/repo/diff/compare.tmpl | 2 +- templates/repo/graph/commits.tmpl | 2 +- templates/repo/issue/view_title.tmpl | 2 +- templates/repo/view_list.tmpl | 6 +- templates/user/dashboard/feeds.tmpl | 2 +- tests/fuzz/fuzz_test.go | 6 +- 42 files changed, 967 insertions(+), 395 deletions(-) diff --git a/models/issues/comment_code.go b/models/issues/comment_code.go index 25e606f092..384a595dd9 100644 --- a/models/issues/comment_code.go +++ b/models/issues/comment_code.go @@ -109,9 +109,11 @@ func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issu var err error if comment.RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: issue.Repo.Link(), - Metas: issue.Repo.ComposeMetas(ctx), + Ctx: ctx, + Links: markup.Links{ + Base: issue.Repo.Link(), + }, + Metas: issue.Repo.ComposeMetas(ctx), }, comment.Content); err != nil { return nil, err } diff --git a/models/repo/repo.go b/models/repo/repo.go index fb1849a4bb..3695e1f78b 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -584,8 +584,7 @@ func (repo *Repository) CanEnableEditor() bool { // DescriptionHTML does special handles to description and return HTML string. func (repo *Repository) DescriptionHTML(ctx context.Context) template.HTML { desc, err := markup.RenderDescriptionHTML(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: repo.HTMLURL(), + Ctx: ctx, // Don't use Metas to speedup requests }, repo.Description) if err != nil { diff --git a/modules/markup/external/external.go b/modules/markup/external/external.go index ffbb6da4da..122517ed11 100644 --- a/modules/markup/external/external.go +++ b/modules/markup/external/external.go @@ -79,9 +79,10 @@ func envMark(envName string) string { // Render renders the data of the document to HTML via the external tool. func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error { var ( - urlRawPrefix = strings.Replace(ctx.URLPrefix, "/src/", "/raw/", 1) - command = strings.NewReplacer(envMark("GITEA_PREFIX_SRC"), ctx.URLPrefix, - envMark("GITEA_PREFIX_RAW"), urlRawPrefix).Replace(p.Command) + command = strings.NewReplacer( + envMark("GITEA_PREFIX_SRC"), ctx.Links.SrcLink(), + envMark("GITEA_PREFIX_RAW"), ctx.Links.RawLink(), + ).Replace(p.Command) commands = strings.Fields(command) args = commands[1:] ) @@ -121,14 +122,14 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io. ctx.Ctx = graceful.GetManager().ShutdownContext() } - processCtx, _, finished := process.GetManager().AddContext(ctx.Ctx, fmt.Sprintf("Render [%s] for %s", commands[0], ctx.URLPrefix)) + processCtx, _, finished := process.GetManager().AddContext(ctx.Ctx, fmt.Sprintf("Render [%s] for %s", commands[0], ctx.Links.SrcLink())) defer finished() cmd := exec.CommandContext(processCtx, commands[0], args...) cmd.Env = append( os.Environ(), - "GITEA_PREFIX_SRC="+ctx.URLPrefix, - "GITEA_PREFIX_RAW="+urlRawPrefix, + "GITEA_PREFIX_SRC="+ctx.Links.SrcLink(), + "GITEA_PREFIX_RAW="+ctx.Links.RawLink(), ) if !p.IsInputFile { cmd.Stdin = input diff --git a/modules/markup/html.go b/modules/markup/html.go index 05b1c3ef72..a64e4c565d 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -80,15 +80,10 @@ const keywordClass = "issue-keyword" // IsLink reports whether link fits valid format. func IsLink(link []byte) bool { - return isLink(link) -} - -// isLink reports whether link fits valid format. -func isLink(link []byte) bool { return validLinksPattern.Match(link) } -func isLinkStr(link string) bool { +func IsLinkStr(link string) bool { return validLinksPattern.MatchString(link) } @@ -344,7 +339,7 @@ func postProcess(ctx *RenderContext, procs []processor, input io.Reader, output node = node.FirstChild } - visitNode(ctx, procs, procs, node) + visitNode(ctx, procs, node) newNodes := make([]*html.Node, 0, 5) @@ -375,7 +370,7 @@ func postProcess(ctx *RenderContext, procs []processor, input io.Reader, output return nil } -func visitNode(ctx *RenderContext, procs, textProcs []processor, node *html.Node) { +func visitNode(ctx *RenderContext, procs []processor, node *html.Node) { // Add user-content- to IDs and "#" links if they don't already have them for idx, attr := range node.Attr { val := strings.TrimPrefix(attr.Val, "#") @@ -390,35 +385,29 @@ func visitNode(ctx *RenderContext, procs, textProcs []processor, node *html.Node } if attr.Key == "class" && attr.Val == "emoji" { - textProcs = nil + procs = nil } } // We ignore code and pre. switch node.Type { case html.TextNode: - textNode(ctx, textProcs, node) + textNode(ctx, procs, node) case html.ElementNode: if node.Data == "img" { for i, attr := range node.Attr { if attr.Key != "src" { continue } - if len(attr.Val) > 0 && !isLinkStr(attr.Val) && !strings.HasPrefix(attr.Val, "data:image/") { - prefix := ctx.URLPrefix - if ctx.IsWiki { - prefix = util.URLJoin(prefix, "wiki", "raw") - } - prefix = strings.Replace(prefix, "/src/", "/media/", 1) - - attr.Val = util.URLJoin(prefix, attr.Val) + if len(attr.Val) > 0 && !IsLinkStr(attr.Val) && !strings.HasPrefix(attr.Val, "data:image/") { + attr.Val = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsWiki), attr.Val) } attr.Val = camoHandleLink(attr.Val) node.Attr[i] = attr } } else if node.Data == "a" { // Restrict text in links to emojis - textProcs = emojiProcessors + procs = emojiProcessors } else if node.Data == "code" || node.Data == "pre" { return } else if node.Data == "i" { @@ -444,7 +433,7 @@ func visitNode(ctx *RenderContext, procs, textProcs []processor, node *html.Node } } for n := node.FirstChild; n != nil; n = n.NextSibling { - visitNode(ctx, procs, textProcs, n) + visitNode(ctx, procs, n) } } // ignore everything else @@ -641,10 +630,6 @@ func mentionProcessor(ctx *RenderContext, node *html.Node) { } func shortLinkProcessor(ctx *RenderContext, node *html.Node) { - shortLinkProcessorFull(ctx, node, false) -} - -func shortLinkProcessorFull(ctx *RenderContext, node *html.Node, noLink bool) { next := node.NextSibling for node != nil && node != next { m := shortLinkPattern.FindStringSubmatchIndex(node.Data) @@ -665,7 +650,7 @@ func shortLinkProcessorFull(ctx *RenderContext, node *html.Node, noLink bool) { if equalPos := strings.IndexByte(v, '='); equalPos == -1 { // There is no equal in this argument; this is a mandatory arg if props["name"] == "" { - if isLinkStr(v) { + if IsLinkStr(v) { // If we clearly see it is a link, we save it so // But first we need to ensure, that if both mandatory args provided @@ -740,7 +725,7 @@ func shortLinkProcessorFull(ctx *RenderContext, node *html.Node, noLink bool) { DataAtom: atom.A, } childNode.Parent = linkNode - absoluteLink := isLinkStr(link) + absoluteLink := IsLinkStr(link) if !absoluteLink { if image { link = strings.ReplaceAll(link, " ", "+") @@ -751,16 +736,9 @@ func shortLinkProcessorFull(ctx *RenderContext, node *html.Node, noLink bool) { link = url.PathEscape(link) } } - urlPrefix := ctx.URLPrefix if image { if !absoluteLink { - if IsSameDomain(urlPrefix) { - urlPrefix = strings.Replace(urlPrefix, "/src/", "/raw/", 1) - } - if ctx.IsWiki { - link = util.URLJoin("wiki", "raw", link) - } - link = util.URLJoin(urlPrefix, link) + link = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsWiki), link) } title := props["title"] if title == "" { @@ -789,18 +767,15 @@ func shortLinkProcessorFull(ctx *RenderContext, node *html.Node, noLink bool) { } else { if !absoluteLink { if ctx.IsWiki { - link = util.URLJoin("wiki", link) + link = util.URLJoin(ctx.Links.WikiLink(), link) + } else { + link = util.URLJoin(ctx.Links.SrcLink(), link) } - link = util.URLJoin(urlPrefix, link) } childNode.Type = html.TextNode childNode.Data = name } - if noLink { - linkNode = childNode - } else { - linkNode.Attr = []html.Attribute{{Key: "href", Val: link}} - } + linkNode.Attr = []html.Attribute{{Key: "href", Val: link}} replaceContent(node, m[0], m[1], linkNode) node = node.NextSibling.NextSibling } diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go index 7b7f6df701..5ba9561915 100644 --- a/modules/markup/html_internal_test.go +++ b/modules/markup/html_internal_test.go @@ -287,8 +287,8 @@ func TestRender_IssueIndexPattern_Document(t *testing.T) { } func testRenderIssueIndexPattern(t *testing.T, input, expected string, ctx *RenderContext) { - if ctx.URLPrefix == "" { - ctx.URLPrefix = TestAppURL + if ctx.Links.Base == "" { + ctx.Links.Base = TestRepoURL } var buf strings.Builder @@ -303,19 +303,23 @@ func TestRender_AutoLink(t *testing.T) { test := func(input, expected string) { var buffer strings.Builder err := PostProcess(&RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: TestRepoURL, - Metas: localMetas, + Ctx: git.DefaultContext, + Links: Links{ + Base: TestRepoURL, + }, + Metas: localMetas, }, strings.NewReader(input), &buffer) assert.Equal(t, err, nil) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer.String())) buffer.Reset() err = PostProcess(&RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: TestRepoURL, - Metas: localMetas, - IsWiki: true, + Ctx: git.DefaultContext, + Links: Links{ + Base: TestRepoURL, + }, + Metas: localMetas, + IsWiki: true, }, strings.NewReader(input), &buffer) assert.Equal(t, err, nil) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer.String())) @@ -342,9 +346,11 @@ func TestRender_FullIssueURLs(t *testing.T) { test := func(input, expected string) { var result strings.Builder err := postProcess(&RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: TestRepoURL, - Metas: localMetas, + Ctx: git.DefaultContext, + Links: Links{ + Base: TestRepoURL, + }, + Metas: localMetas, }, []processor{fullIssuePatternProcessor}, strings.NewReader(input), &result) assert.NoError(t, err) assert.Equal(t, expected, result.String()) diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 62fd0f5a85..89ecfc036b 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -42,8 +42,10 @@ func TestRender_Commits(t *testing.T) { buffer, err := markup.RenderString(&markup.RenderContext{ Ctx: git.DefaultContext, RelativePath: ".md", - URLPrefix: markup.TestRepoURL, - Metas: localMetas, + Links: markup.Links{ + Base: markup.TestRepoURL, + }, + Metas: localMetas, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) @@ -93,8 +95,10 @@ func TestRender_CrossReferences(t *testing.T) { buffer, err := markup.RenderString(&markup.RenderContext{ Ctx: git.DefaultContext, RelativePath: "a.md", - URLPrefix: setting.AppSubURL, - Metas: localMetas, + Links: markup.Links{ + Base: setting.AppSubURL, + }, + Metas: localMetas, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) @@ -138,7 +142,9 @@ func TestRender_links(t *testing.T) { buffer, err := markup.RenderString(&markup.RenderContext{ Ctx: git.DefaultContext, RelativePath: "a.md", - URLPrefix: markup.TestRepoURL, + Links: markup.Links{ + Base: markup.TestRepoURL, + }, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) @@ -238,7 +244,9 @@ func TestRender_email(t *testing.T) { res, err := markup.RenderString(&markup.RenderContext{ Ctx: git.DefaultContext, RelativePath: "a.md", - URLPrefix: markup.TestRepoURL, + Links: markup.Links{ + Base: markup.TestRepoURL, + }, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(res)) @@ -309,7 +317,9 @@ func TestRender_emoji(t *testing.T) { buffer, err := markup.RenderString(&markup.RenderContext{ Ctx: git.DefaultContext, RelativePath: "a.md", - URLPrefix: markup.TestRepoURL, + Links: markup.Links{ + Base: markup.TestRepoURL, + }, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) @@ -371,29 +381,34 @@ func TestRender_ShortLinks(t *testing.T) { test := func(input, expected, expectedWiki string) { buffer, err := markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: tree, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: markup.TestRepoURL, + BranchPath: "master", + }, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) buffer, err = markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: markup.TestRepoURL, - Metas: localMetas, - IsWiki: true, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: markup.TestRepoURL, + }, + Metas: localMetas, + IsWiki: true, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expectedWiki), strings.TrimSpace(buffer)) } - rawtree := util.URLJoin(markup.TestRepoURL, "raw", "master") + mediatree := util.URLJoin(markup.TestRepoURL, "media", "master") url := util.URLJoin(tree, "Link") otherURL := util.URLJoin(tree, "Other-Link") encodedURL := util.URLJoin(tree, "Link%3F") - imgurl := util.URLJoin(rawtree, "Link.jpg") - otherImgurl := util.URLJoin(rawtree, "Link+Other.jpg") - encodedImgurl := util.URLJoin(rawtree, "Link+%23.jpg") - notencodedImgurl := util.URLJoin(rawtree, "some", "path", "Link+#.jpg") + imgurl := util.URLJoin(mediatree, "Link.jpg") + otherImgurl := util.URLJoin(mediatree, "Link+Other.jpg") + encodedImgurl := util.URLJoin(mediatree, "Link+%23.jpg") + notencodedImgurl := util.URLJoin(mediatree, "some", "path", "Link+#.jpg") urlWiki := util.URLJoin(markup.TestRepoURL, "wiki", "Link") otherURLWiki := util.URLJoin(markup.TestRepoURL, "wiki", "Other-Link") encodedURLWiki := util.URLJoin(markup.TestRepoURL, "wiki", "Link%3F") @@ -475,21 +490,25 @@ func TestRender_ShortLinks(t *testing.T) { func TestRender_RelativeImages(t *testing.T) { setting.AppURL = markup.TestAppURL - tree := util.URLJoin(markup.TestRepoURL, "src", "master") test := func(input, expected, expectedWiki string) { buffer, err := markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: tree, - Metas: localMetas, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: markup.TestRepoURL, + BranchPath: "master", + }, + Metas: localMetas, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) buffer, err = markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: markup.TestRepoURL, - Metas: localMetas, - IsWiki: true, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: markup.TestRepoURL, + }, + Metas: localMetas, + IsWiki: true, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expectedWiki), strings.TrimSpace(buffer)) @@ -521,9 +540,11 @@ func Test_ParseClusterFuzz(t *testing.T) { var res strings.Builder err := markup.PostProcess(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: "https://example.com", - Metas: localMetas, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: "https://example.com", + }, + Metas: localMetas, }, strings.NewReader(data), &res) assert.NoError(t, err) assert.NotContains(t, res.String(), " 0 && !markup.IsLink(link) { - prefix := pc.Get(urlPrefixKey).(string) - if pc.Get(isWikiKey).(bool) { - prefix = giteautil.URLJoin(prefix, "wiki", "raw") - } - prefix = strings.Replace(prefix, "/src/", "/media/", 1) - - lnk := strings.TrimLeft(string(link), "/") - - lnk = giteautil.URLJoin(prefix, lnk) - link = []byte(lnk) + v.Destination = []byte(giteautil.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsWiki), string(link))) } - v.Destination = link parent := n.Parent() // Create a link around image only if parent is not already a link @@ -107,7 +97,7 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa // Create a link wrapper wrap := ast.NewLink() - wrap.Destination = link + wrap.Destination = v.Destination wrap.Title = v.Title wrap.SetAttributeString("target", []byte("_blank")) @@ -143,11 +133,15 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa link[0] != '#' && !bytes.HasPrefix(link, byteMailto) { // special case: this is not a link, a hash link or a mailto:, so it's a // relative URL - lnk := string(link) - if pc.Get(isWikiKey).(bool) { - lnk = giteautil.URLJoin("wiki", lnk) + + var base string + if ctx.IsWiki { + base = ctx.Links.WikiLink() + } else { + base = ctx.Links.Base } - link = []byte(giteautil.URLJoin(pc.Get(urlPrefixKey).(string), lnk)) + + link = []byte(giteautil.URLJoin(base, string(link))) } if len(link) > 0 && link[0] == '#' { link = []byte("#user-content-" + string(link)[1:]) @@ -188,9 +182,7 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa applyElementDir(v) case *ast.Text: if v.SoftLineBreak() && !v.HardLineBreak() { - renderMetas := pc.Get(renderMetasKey).(map[string]string) - mode := renderMetas["mode"] - if mode != "document" { + if ctx.Metas["mode"] != "document" { v.SetHardLineBreak(setting.Markdown.EnableHardLineBreakInComments) } else { v.SetHardLineBreak(setting.Markdown.EnableHardLineBreakInDocuments) diff --git a/modules/markup/markdown/markdown.go b/modules/markup/markdown/markdown.go index 43885889d1..771162b9a3 100644 --- a/modules/markup/markdown/markdown.go +++ b/modules/markup/markdown/markdown.go @@ -34,9 +34,6 @@ var ( ) var ( - urlPrefixKey = parser.NewContextKey() - isWikiKey = parser.NewContextKey() - renderMetasKey = parser.NewContextKey() renderContextKey = parser.NewContextKey() renderConfigKey = parser.NewContextKey() ) @@ -66,9 +63,6 @@ func (l *limitWriter) Write(data []byte) (int, error) { // newParserContext creates a parser.Context with the render context set func newParserContext(ctx *markup.RenderContext) parser.Context { pc := parser.NewContext(parser.WithIDs(newPrefixedIDs())) - pc.Set(urlPrefixKey, ctx.URLPrefix) - pc.Set(isWikiKey, ctx.IsWiki) - pc.Set(renderMetasKey, ctx.Metas) pc.Set(renderContextKey, ctx) return pc } diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 8f855f1b13..957d773acd 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -52,16 +52,20 @@ func TestRender_StandardLinks(t *testing.T) { test := func(input, expected, expectedWiki string) { buffer, err := markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: setting.AppSubURL, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: setting.AppSubURL, + }, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) buffer, err = markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: setting.AppSubURL, - IsWiki: true, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: setting.AppSubURL, + }, + IsWiki: true, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expectedWiki), strings.TrimSpace(buffer)) @@ -83,8 +87,10 @@ func TestRender_Images(t *testing.T) { test := func(input, expected string) { buffer, err := markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: setting.AppSubURL, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: setting.AppSubURL, + }, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) @@ -107,7 +113,6 @@ func TestRender_Images(t *testing.T) { "[!["+title+"]("+url+")]("+href+")", `

`+title+`

`) - url = "/../../.images/src/02/train.jpg" test( "!["+title+"]("+url+")", `

`+title+`

`) @@ -286,14 +291,16 @@ func TestTotal_RenderWiki(t *testing.T) { setting.AppURL = AppURL setting.AppSubURL = AppSubURL - answers := testAnswers(util.URLJoin(AppSubURL, "wiki/"), util.URLJoin(AppSubURL, "wiki", "raw/")) + answers := testAnswers(util.URLJoin(AppSubURL, "wiki"), util.URLJoin(AppSubURL, "wiki", "raw")) for i := 0; i < len(sameCases); i++ { line, err := markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: AppSubURL, - Metas: localMetas, - IsWiki: true, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: setting.AppSubURL, + }, + Metas: localMetas, + IsWiki: true, }, sameCases[i]) assert.NoError(t, err) assert.Equal(t, answers[i], line) @@ -314,9 +321,11 @@ func TestTotal_RenderWiki(t *testing.T) { for i := 0; i < len(testCases); i += 2 { line, err := markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: AppSubURL, - IsWiki: true, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: setting.AppSubURL, + }, + IsWiki: true, }, testCases[i]) assert.NoError(t, err) assert.Equal(t, testCases[i+1], line) @@ -327,13 +336,16 @@ func TestTotal_RenderString(t *testing.T) { setting.AppURL = AppURL setting.AppSubURL = AppSubURL - answers := testAnswers(util.URLJoin(AppSubURL, "src", "master/"), util.URLJoin(AppSubURL, "raw", "master/")) + answers := testAnswers(util.URLJoin(AppSubURL, "src", "master"), util.URLJoin(AppSubURL, "media", "master")) for i := 0; i < len(sameCases); i++ { line, err := markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: util.URLJoin(AppSubURL, "src", "master/"), - Metas: localMetas, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: AppSubURL, + BranchPath: "master", + }, + Metas: localMetas, }, sameCases[i]) assert.NoError(t, err) assert.Equal(t, answers[i], line) @@ -343,8 +355,10 @@ func TestTotal_RenderString(t *testing.T) { for i := 0; i < len(testCases); i += 2 { line, err := markdown.RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: AppSubURL, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: AppSubURL, + }, }, testCases[i]) assert.NoError(t, err) assert.Equal(t, testCases[i+1], line) @@ -556,3 +570,367 @@ foo: bar assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase) } } + +func TestRenderLinks(t *testing.T) { + input := ` space @mention-user +/just/a/path.bin +https://example.com/file.bin +[local link](file.bin) +[remote link](https://example.com) +[[local link|file.bin]] +[[remote link|https://example.com]] +![local image](image.jpg) +![remote image](https://example.com/image.jpg) +[[local image|image.jpg]] +[[remote link|https://example.com/image.jpg]] +https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare +https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit +:+1: +mail@domain.com +@mention-user test +#123 + space +` + cases := []struct { + Links markup.Links + IsWiki bool + Expected string + }{ + { // 0 + Links: markup.Links{}, + IsWiki: false, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 1 + Links: markup.Links{}, + IsWiki: true, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 2 + Links: markup.Links{ + Base: "https://gitea.io/", + }, + IsWiki: false, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 3 + Links: markup.Links{ + Base: "https://gitea.io/", + }, + IsWiki: true, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 4 + Links: markup.Links{ + Base: "/relative/path", + }, + IsWiki: false, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 5 + Links: markup.Links{ + Base: "/relative/path", + }, + IsWiki: true, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 6 + Links: markup.Links{ + Base: "/user/repo", + BranchPath: "branch/main", + }, + IsWiki: false, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 7 + Links: markup.Links{ + Base: "/relative/path", + BranchPath: "branch/main", + }, + IsWiki: true, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 8 + Links: markup.Links{ + Base: "/user/repo", + TreePath: "sub/folder", + }, + IsWiki: false, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 9 + Links: markup.Links{ + Base: "/relative/path", + TreePath: "sub/folder", + }, + IsWiki: true, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 10 + Links: markup.Links{ + Base: "/user/repo", + BranchPath: "branch/main", + TreePath: "sub/folder", + }, + IsWiki: false, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + { // 11 + Links: markup.Links{ + Base: "/relative/path", + BranchPath: "branch/main", + TreePath: "sub/folder", + }, + IsWiki: true, + Expected: `

space @mention-user
+/just/a/path.bin
+https://example.com/file.bin
+local link
+remote link
+local link
+remote link
+local image
+remote image
+local image
+remote link
+https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare
+https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb
+com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
+👍
+mail@domain.com
+@mention-user test
+#123
+space

+`, + }, + } + + for i, c := range cases { + result, err := markdown.RenderString(&markup.RenderContext{Ctx: context.Background(), Links: c.Links, IsWiki: c.IsWiki}, input) + assert.NoError(t, err, "Unexpected error in testcase: %v", i) + assert.Equal(t, c.Expected, result, "Unexpected result in testcase %v", i) + } +} diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go index e7af02b496..abc641fbe2 100644 --- a/modules/markup/orgmode/orgmode.go +++ b/modules/markup/orgmode/orgmode.go @@ -4,7 +4,6 @@ package markup import ( - "bytes" "fmt" "html" "io" @@ -101,8 +100,7 @@ func Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error w := &Writer{ HTMLWriter: htmlWriter, - URLPrefix: ctx.URLPrefix, - IsWiki: ctx.IsWiki, + Ctx: ctx, } htmlWriter.ExtendingWriter = w @@ -132,63 +130,53 @@ func (Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.Wri // Writer implements org.Writer type Writer struct { *org.HTMLWriter - URLPrefix string - IsWiki bool + Ctx *markup.RenderContext } -var byteMailto = []byte("mailto:") +const mailto = "mailto:" -// WriteRegularLink renders images, links or videos -func (r *Writer) WriteRegularLink(l org.RegularLink) { - link := []byte(html.EscapeString(l.URL)) +func (r *Writer) resolveLink(l org.RegularLink) string { + link := html.EscapeString(l.URL) if l.Protocol == "file" { link = link[len("file:"):] } - if len(link) > 0 && !markup.IsLink(link) && - link[0] != '#' && !bytes.HasPrefix(link, byteMailto) { - lnk := string(link) - if r.IsWiki { - lnk = util.URLJoin("wiki", lnk) + if len(link) > 0 && !markup.IsLinkStr(link) && + link[0] != '#' && !strings.HasPrefix(link, mailto) { + base := r.Ctx.Links.Base + switch l.Kind() { + case "image", "video": + base = r.Ctx.Links.ResolveMediaLink(r.Ctx.IsWiki) } - link = []byte(util.URLJoin(r.URLPrefix, lnk)) + link = util.URLJoin(base, link) } + return link +} + +// WriteRegularLink renders images, links or videos +func (r *Writer) WriteRegularLink(l org.RegularLink) { + link := r.resolveLink(l) // Inspired by https://github.com/niklasfasching/go-org/blob/6eb20dbda93cb88c3503f7508dc78cbbc639378f/org/html_writer.go#L406-L427 switch l.Kind() { case "image": if l.Description == nil { - imageSrc := getMediaURL(link) - fmt.Fprintf(r, `%s`, imageSrc, link) + fmt.Fprintf(r, `%s`, link, link) } else { - description := strings.TrimPrefix(org.String(l.Description...), "file:") - imageSrc := getMediaURL([]byte(description)) + imageSrc := r.resolveLink(l.Description[0].(org.RegularLink)) fmt.Fprintf(r, `%s`, link, imageSrc, imageSrc) } case "video": if l.Description == nil { - imageSrc := getMediaURL(link) - fmt.Fprintf(r, ``, imageSrc, link) + fmt.Fprintf(r, ``, link, link) } else { - description := strings.TrimPrefix(org.String(l.Description...), "file:") - videoSrc := getMediaURL([]byte(description)) + videoSrc := r.resolveLink(l.Description[0].(org.RegularLink)) fmt.Fprintf(r, ``, link, videoSrc, videoSrc) } default: - description := string(link) + description := link if l.Description != nil { description = r.WriteNodesAsString(l.Description...) } fmt.Fprintf(r, `%s`, link, description) } } - -func getMediaURL(l []byte) string { - srcURL := string(l) - - // Check if link is valid - if len(srcURL) > 0 && !markup.IsLink(l) { - srcURL = strings.Replace(srcURL, "/src/", "/media/", 1) - } - - return srcURL -} diff --git a/modules/markup/orgmode/orgmode_test.go b/modules/markup/orgmode/orgmode_test.go index 88ae14ebcf..abf5ca8fcf 100644 --- a/modules/markup/orgmode/orgmode_test.go +++ b/modules/markup/orgmode/orgmode_test.go @@ -27,8 +27,10 @@ func TestRender_StandardLinks(t *testing.T) { test := func(input, expected string) { buffer, err := RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: setting.AppSubURL, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: setting.AppSubURL, + }, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) @@ -48,8 +50,10 @@ func TestRender_Media(t *testing.T) { test := func(input, expected string) { buffer, err := RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: setting.AppSubURL, + Ctx: git.DefaultContext, + Links: markup.Links{ + Base: setting.AppSubURL, + }, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) @@ -84,8 +88,7 @@ func TestRender_Source(t *testing.T) { test := func(input, expected string) { buffer, err := RenderString(&markup.RenderContext{ - Ctx: git.DefaultContext, - URLPrefix: setting.AppSubURL, + Ctx: git.DefaultContext, }, input) assert.NoError(t, err) assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer)) diff --git a/modules/markup/renderer.go b/modules/markup/renderer.go index 0331c3742a..5a7adcc553 100644 --- a/modules/markup/renderer.go +++ b/modules/markup/renderer.go @@ -16,6 +16,7 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" "github.com/yuin/goldmark/ast" ) @@ -69,7 +70,7 @@ type RenderContext struct { RelativePath string // relative path from tree root of the branch Type string IsWiki bool - URLPrefix string + Links Links Metas map[string]string DefaultLink string GitRepo *git.Repository @@ -80,6 +81,45 @@ type RenderContext struct { InStandalonePage bool // used by external render. the router "/org/repo/render/..." will output the rendered content in a standalone page } +type Links struct { + Base string + BranchPath string + TreePath string +} + +func (l *Links) HasBranchInfo() bool { + return l.BranchPath != "" +} + +func (l *Links) SrcLink() string { + return util.URLJoin(l.Base, "src", l.BranchPath, l.TreePath) +} + +func (l *Links) MediaLink() string { + return util.URLJoin(l.Base, "media", l.BranchPath, l.TreePath) +} + +func (l *Links) RawLink() string { + return util.URLJoin(l.Base, "raw", l.BranchPath, l.TreePath) +} + +func (l *Links) WikiLink() string { + return util.URLJoin(l.Base, "wiki") +} + +func (l *Links) WikiRawLink() string { + return util.URLJoin(l.Base, "wiki/raw") +} + +func (l *Links) ResolveMediaLink(isWiki bool) string { + if isWiki { + return l.WikiRawLink() + } else if l.HasBranchInfo() { + return l.MediaLink() + } + return l.Base +} + // Cancel runs any cleanup functions that have been registered for this Ctx func (ctx *RenderContext) Cancel() { if ctx == nil { diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 235fd96b73..96cdd9ca46 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -161,7 +161,6 @@ func NewFuncMap() template.FuncMap { "RenderEmoji": RenderEmoji, "RenderEmojiPlain": emoji.ReplaceAliases, "ReactionToEmoji": ReactionToEmoji, - "RenderNote": RenderNote, "RenderMarkdownToHtml": RenderMarkdownToHtml, "RenderLabel": RenderLabel, diff --git a/modules/templates/util_render.go b/modules/templates/util_render.go index 2f6132c6f3..1d9635410b 100644 --- a/modules/templates/util_render.go +++ b/modules/templates/util_render.go @@ -24,21 +24,13 @@ import ( ) // RenderCommitMessage renders commit message with XSS-safe and special links. -func RenderCommitMessage(ctx context.Context, msg, urlPrefix string, metas map[string]string) template.HTML { - return RenderCommitMessageLink(ctx, msg, urlPrefix, "", metas) -} - -// RenderCommitMessageLink renders commit message as a XXS-safe link to the provided -// default url, handling for special links. -func RenderCommitMessageLink(ctx context.Context, msg, urlPrefix, urlDefault string, metas map[string]string) template.HTML { +func RenderCommitMessage(ctx context.Context, msg string, metas map[string]string) template.HTML { cleanMsg := template.HTMLEscapeString(msg) // we can safely assume that it will not return any error, since there // shouldn't be any special HTML. fullMessage, err := markup.RenderCommitMessage(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: urlPrefix, - DefaultLink: urlDefault, - Metas: metas, + Ctx: ctx, + Metas: metas, }, cleanMsg) if err != nil { log.Error("RenderCommitMessage: %v", err) @@ -51,9 +43,9 @@ func RenderCommitMessageLink(ctx context.Context, msg, urlPrefix, urlDefault str return template.HTML(msgLines[0]) } -// RenderCommitMessageLinkSubject renders commit message as a XXS-safe link to +// RenderCommitMessageLinkSubject renders commit message as a XSS-safe link to // the provided default url, handling for special links without email to links. -func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlPrefix, urlDefault string, metas map[string]string) template.HTML { +func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlDefault string, metas map[string]string) template.HTML { msgLine := strings.TrimLeftFunc(msg, unicode.IsSpace) lineEnd := strings.IndexByte(msgLine, '\n') if lineEnd > 0 { @@ -68,7 +60,6 @@ func RenderCommitMessageLinkSubject(ctx context.Context, msg, urlPrefix, urlDefa // shouldn't be any special HTML. renderedMessage, err := markup.RenderCommitMessageSubject(&markup.RenderContext{ Ctx: ctx, - URLPrefix: urlPrefix, DefaultLink: urlDefault, Metas: metas, }, template.HTMLEscapeString(msgLine)) @@ -80,7 +71,7 @@ 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 { +func RenderCommitBody(ctx context.Context, msg string, metas map[string]string) template.HTML { msgLine := strings.TrimSpace(msg) lineEnd := strings.IndexByte(msgLine, '\n') if lineEnd > 0 { @@ -94,9 +85,8 @@ func RenderCommitBody(ctx context.Context, msg, urlPrefix string, metas map[stri } renderedMessage, err := markup.RenderCommitMessage(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: urlPrefix, - Metas: metas, + Ctx: ctx, + Metas: metas, }, template.HTMLEscapeString(msgLine)) if err != nil { log.Error("RenderCommitMessage: %v", err) @@ -115,11 +105,10 @@ func RenderCodeBlock(htmlEscapedTextToRender template.HTML) template.HTML { } // RenderIssueTitle renders issue/pull title with defined post processors -func RenderIssueTitle(ctx context.Context, text, urlPrefix string, metas map[string]string) template.HTML { +func RenderIssueTitle(ctx context.Context, text string, metas map[string]string) template.HTML { renderedText, err := markup.RenderIssueTitle(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: urlPrefix, - Metas: metas, + Ctx: ctx, + Metas: metas, }, template.HTMLEscapeString(text)) if err != nil { log.Error("RenderIssueTitle: %v", err) @@ -211,26 +200,10 @@ func ReactionToEmoji(reaction string) template.HTML { return template.HTML(fmt.Sprintf(`:%s:`, reaction, setting.StaticURLPrefix, url.PathEscape(reaction))) } -// RenderNote renders the contents of a git-notes file as a commit message. -func RenderNote(ctx context.Context, msg, urlPrefix string, metas map[string]string) template.HTML { - cleanMsg := template.HTMLEscapeString(msg) - fullMessage, err := markup.RenderCommitMessage(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: urlPrefix, - Metas: metas, - }, cleanMsg) - if err != nil { - log.Error("RenderNote: %v", err) - return "" - } - return template.HTML(fullMessage) -} - func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML { //nolint:revive output, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: setting.AppSubURL, - Metas: map[string]string{"mode": "document"}, + Ctx: ctx, + Metas: map[string]string{"mode": "document"}, }, input) if err != nil { log.Error("RenderString: %v", err) diff --git a/modules/templates/util_render_test.go b/modules/templates/util_render_test.go index 29d3ed3a56..8648967d38 100644 --- a/modules/templates/util_render_test.go +++ b/modules/templates/util_render_test.go @@ -6,17 +6,64 @@ package templates import ( "context" "html/template" + "os" "testing" + "code.gitea.io/gitea/models/unittest" + "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/markup" + "github.com/stretchr/testify/assert" ) +const testInput = ` space @mention-user +/just/a/path.bin +https://example.com/file.bin +[local link](file.bin) +[remote link](https://example.com) +[[local link|file.bin]] +[[remote link|https://example.com]] +![local image](image.jpg) +![remote image](https://example.com/image.jpg) +[[local image|image.jpg]] +[[remote link|https://example.com/image.jpg]] +https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare +https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit +:+1: +mail@domain.com +@mention-user test +#123 + space +` + +var testMetas = map[string]string{ + "user": "user13", + "repo": "repo11", + "repoPath": "../../tests/gitea-repositories-meta/user13/repo11.git/", + "mode": "comment", +} + +func TestMain(m *testing.M) { + unittest.InitSettings() + if err := git.InitSimple(context.Background()); err != nil { + log.Fatal("git init failed, err: %v", err) + } + markup.Init(&markup.ProcessorHelper{ + IsUsernameMentionable: func(ctx context.Context, username string) bool { + return username == "mention-user" + }, + }) + os.Exit(m.Run()) +} + func TestRenderCommitBody(t *testing.T) { type args struct { - ctx context.Context - msg string - urlPrefix string - metas map[string]string + ctx context.Context + msg string + metas map[string]string } tests := []struct { name string @@ -50,7 +97,91 @@ func TestRenderCommitBody(t *testing.T) { } 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) + assert.Equalf(t, tt.want, RenderCommitBody(tt.args.ctx, tt.args.msg, tt.args.metas), "RenderCommitBody(%v, %v, %v)", tt.args.ctx, tt.args.msg, tt.args.metas) }) } + + expected := `/just/a/path.bin +https://example.com/file.bin +[local link](file.bin) +[remote link](https://example.com) +[[local link|file.bin]] +[[remote link|https://example.com]] +![local image](image.jpg) +![remote image](https://example.com/image.jpg) +[[local image|image.jpg]] +[[remote link|https://example.com/image.jpg]] +88fc37a3c0...12fc37a3c0 (hash) +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare +88fc37a3c0 +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit +👍 +mail@domain.com +@mention-user test +#123 + space` + + assert.EqualValues(t, expected, RenderCommitBody(context.Background(), testInput, testMetas)) +} + +func TestRenderCommitMessage(t *testing.T) { + expected := `space @mention-user ` + + assert.EqualValues(t, expected, RenderCommitMessage(context.Background(), testInput, testMetas)) +} + +func TestRenderCommitMessageLinkSubject(t *testing.T) { + expected := `space @mention-user` + + assert.EqualValues(t, expected, RenderCommitMessageLinkSubject(context.Background(), testInput, "https://example.com/link", testMetas)) +} + +func TestRenderIssueTitle(t *testing.T) { + expected := ` space @mention-user +/just/a/path.bin +https://example.com/file.bin +[local link](file.bin) +[remote link](https://example.com) +[[local link|file.bin]] +[[remote link|https://example.com]] +![local image](image.jpg) +![remote image](https://example.com/image.jpg) +[[local image|image.jpg]] +[[remote link|https://example.com/image.jpg]] +https://example.com/user/repo/compare/88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb#hash +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare +https://example.com/user/repo/commit/88fc37a3c0a4dda553bdcfc80c178a58247f42fb +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit +👍 +mail@domain.com +@mention-user test +#123 + space +` + assert.EqualValues(t, expected, RenderIssueTitle(context.Background(), testInput, testMetas)) +} + +func TestRenderMarkdownToHtml(t *testing.T) { + expected := `

space @mention-user
+/just/a/path.bin +https://example.com/file.bin +local link +remote link +local link +remote link +local image +remote image +local image +remote link +88fc37a3c0...12fc37a3c0 (hash) +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb...12fc37a3c0a4dda553bdcfc80c178a58247f42fb pare +88fc37a3c0 +com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit +👍 +mail@domain.com +@mention-user test +#123 +space

+` + assert.EqualValues(t, expected, RenderMarkdownToHtml(context.Background(), testInput)) } diff --git a/routers/common/markup.go b/routers/common/markup.go index aaedc13de9..a1c2c37ac0 100644 --- a/routers/common/markup.go +++ b/routers/common/markup.go @@ -32,8 +32,10 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr case "markdown": // Raw markdown if err := markdown.RenderRaw(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: urlPrefix, + Ctx: ctx, + Links: markup.Links{ + Base: urlPrefix, + }, }, strings.NewReader(text), ctx.Resp); err != nil { ctx.Error(http.StatusInternalServerError, err.Error()) } @@ -75,8 +77,10 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr } if err := markup.Render(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: urlPrefix, + Ctx: ctx, + Links: markup.Links{ + Base: urlPrefix, + }, Metas: meta, IsWiki: wiki, Type: markupType, diff --git a/routers/web/feed/convert.go b/routers/web/feed/convert.go index 4d4918a8fd..95b1062253 100644 --- a/routers/web/feed/convert.go +++ b/routers/web/feed/convert.go @@ -51,9 +51,11 @@ func toReleaseLink(ctx *context.Context, act *activities_model.Action) string { // If rendering fails, the original markdown text is returned func renderMarkdown(ctx *context.Context, act *activities_model.Action, content string) string { markdownCtx := &markup.RenderContext{ - Ctx: ctx, - URLPrefix: act.GetRepoLink(ctx), - Type: markdown.MarkupName, + Ctx: ctx, + Links: markup.Links{ + Base: act.GetRepoLink(ctx), + }, + Type: markdown.MarkupName, Metas: map[string]string{ "user": act.GetRepoUserName(ctx), "repo": act.GetRepoName(ctx), @@ -199,7 +201,6 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio switch act.OpType { case activities_model.ActionCommitRepo, activities_model.ActionMirrorSyncPush: push := templates.ActionContent2Commits(act) - repoLink := act.GetRepoAbsoluteLink(ctx) for _, commit := range push.Commits { if len(desc) != 0 { @@ -208,7 +209,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio desc += fmt.Sprintf("%s\n%s", html.EscapeString(fmt.Sprintf("%s/commit/%s", act.GetRepoAbsoluteLink(ctx), commit.Sha1)), commit.Sha1, - templates.RenderCommitMessage(ctx, commit.Message, repoLink, nil), + templates.RenderCommitMessage(ctx, commit.Message, nil), ) } @@ -288,9 +289,11 @@ func releasesToFeedItems(ctx *context.Context, releases []*repo_model.Release, i link := &feeds.Link{Href: rel.HTMLURL()} content, err = markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: rel.Repo.Link(), - Metas: rel.Repo.ComposeMetas(ctx), + Ctx: ctx, + Links: markup.Links{ + Base: rel.Repo.Link(), + }, + Metas: rel.Repo.ComposeMetas(ctx), }, rel.Note) if err != nil { diff --git a/routers/web/feed/profile.go b/routers/web/feed/profile.go index ce86727e24..04f84c0c8d 100644 --- a/routers/web/feed/profile.go +++ b/routers/web/feed/profile.go @@ -42,8 +42,10 @@ func showUserFeed(ctx *context.Context, formatType string) { } ctxUserDescription, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: ctx.ContextUser.HTMLURL(), + Ctx: ctx, + Links: markup.Links{ + Base: ctx.ContextUser.HTMLURL(), + }, Metas: map[string]string{ "user": ctx.ContextUser.GetDisplayName(), }, diff --git a/routers/web/org/home.go b/routers/web/org/home.go index cdf280ed4a..8bf02b2c42 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -5,6 +5,7 @@ package org import ( "net/http" + "path" "strings" "code.gitea.io/gitea/models/db" @@ -47,10 +48,8 @@ func Home(ctx *context.Context) { ctx.Data["Title"] = org.DisplayName() if len(org.Description) != 0 { desc, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: ctx.Repo.RepoLink, - Metas: map[string]string{"mode": "document"}, - GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, + Metas: map[string]string{"mode": "document"}, }, org.Description) if err != nil { ctx.ServerError("RenderString", err) @@ -173,14 +172,16 @@ func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repositor if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil { log.Error("failed to GetBlobContent: %v", err) } else { - // Pass URLPrefix to markdown render for the full link of media elements. - // The profile of default branch would be shown. - prefix := profileDbRepo.Link() + "/src/branch/" + util.PathEscapeSegments(profileDbRepo.DefaultBranch) if profileContent, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - GitRepo: profileGitRepo, - URLPrefix: prefix, - Metas: map[string]string{"mode": "document"}, + Ctx: ctx, + GitRepo: profileGitRepo, + Links: markup.Links{ + // Pass repo link to markdown render for the full link of media elements. + // The profile of default branch would be shown. + Base: profileDbRepo.Link(), + BranchPath: path.Join("branch", util.PathEscapeSegments(profileDbRepo.DefaultBranch)), + }, + Metas: map[string]string{"mode": "document"}, }, bytes); err != nil { log.Error("failed to RenderString: %v", err) } else { diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index bd393e7fb7..abb39caa57 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -7,7 +7,9 @@ package repo import ( "errors" "fmt" + "html/template" "net/http" + "path" "strings" asymkey_model "code.gitea.io/gitea/models/asymkey" @@ -21,7 +23,9 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/gitgraph" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/gitdiff" git_service "code.gitea.io/gitea/services/repository" ) @@ -370,9 +374,21 @@ func Diff(ctx *context.Context) { note := &git.Note{} err = git.GetNote(ctx, ctx.Repo.GitRepo, commitID, note) if err == nil { - ctx.Data["Note"] = string(charset.ToUTF8WithFallback(note.Message)) ctx.Data["NoteCommit"] = note.Commit ctx.Data["NoteAuthor"] = user_model.ValidateCommitWithEmail(ctx, note.Commit) + ctx.Data["NoteRendered"], err = markup.RenderCommitMessage(&markup.RenderContext{ + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + BranchPath: path.Join("commit", util.PathEscapeSegments(commitID)), + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, + }, template.HTMLEscapeString(string(charset.ToUTF8WithFallback(note.Message)))) + if err != nil { + ctx.ServerError("RenderCommitMessage", err) + return + } } ctx.Data["BranchName"], err = commit.GetBranchName() diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 2b5ab21172..0d660e3b89 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1436,12 +1436,13 @@ func ViewIssue(ctx *context.Context) { } } ctx.Data["IssueWatch"] = iw - issue.RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, issue.Content) if err != nil { ctx.ServerError("RenderString", err) @@ -1601,10 +1602,12 @@ func ViewIssue(ctx *context.Context) { } comment.RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, comment.Content) if err != nil { ctx.ServerError("RenderString", err) @@ -1678,10 +1681,12 @@ func ViewIssue(ctx *context.Context) { } } else if comment.Type.HasContentSupport() { comment.RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, comment.Content) if err != nil { ctx.ServerError("RenderString", err) @@ -2234,10 +2239,12 @@ func UpdateIssueContent(ctx *context.Context) { } content, err := markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.FormString("context"), // FIXME: <- IS THIS SAFE ? - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.FormString("context"), // FIXME: <- IS THIS SAFE ? + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, issue.Content) if err != nil { ctx.ServerError("RenderString", err) @@ -3143,10 +3150,12 @@ func UpdateCommentContent(ctx *context.Context) { } content, err := markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.FormString("context"), // FIXME: <- IS THIS SAFE ? - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.FormString("context"), // FIXME: <- IS THIS SAFE ? + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, comment.Content) if err != nil { ctx.ServerError("RenderString", err) diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go index fbecabb2b1..19db2abd68 100644 --- a/routers/web/repo/milestone.go +++ b/routers/web/repo/milestone.go @@ -81,10 +81,12 @@ func Milestones(ctx *context.Context) { } for _, m := range miles { m.RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, m.Content) if err != nil { ctx.ServerError("RenderString", err) @@ -275,10 +277,12 @@ func MilestoneIssuesAndPulls(ctx *context.Context) { } milestone.RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, milestone.Content) if err != nil { ctx.ServerError("RenderString", err) diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index 5694575b46..4908bb796d 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -90,10 +90,12 @@ func Projects(ctx *context.Context) { for i := range projects { projects[i].RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, projects[i].Description) if err != nil { ctx.ServerError("RenderString", err) @@ -357,10 +359,12 @@ func ViewProject(ctx *context.Context) { ctx.Data["LinkedPRs"] = linkedPrsMap project.RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, project.Description) if err != nil { ctx.ServerError("RenderString", err) diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 86cb93e49b..fdb247d413 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -136,10 +136,12 @@ func Releases(ctx *context.Context) { } r.Note, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, r.Note) if err != nil { ctx.ServerError("RenderString", err) @@ -287,10 +289,12 @@ func SingleRelease(ctx *context.Context) { } } release.Note, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeMetas(ctx), - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + Metas: ctx.Repo.Repository.ComposeMetas(ctx), + GitRepo: ctx.Repo.GitRepo, + Ctx: ctx, }, release.Note) if err != nil { ctx.ServerError("RenderString", err) diff --git a/routers/web/repo/render.go b/routers/web/repo/render.go index 33476c1d2c..f2c6ab3f8f 100644 --- a/routers/web/repo/render.go +++ b/routers/web/repo/render.go @@ -57,16 +57,15 @@ func RenderFile(ctx *context.Context) { return } - treeLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() - if ctx.Repo.TreePath != "" { - treeLink += "/" + util.PathEscapeSegments(ctx.Repo.TreePath) - } - ctx.Resp.Header().Add("Content-Security-Policy", "frame-src 'self'; sandbox allow-scripts") err = markup.Render(&markup.RenderContext{ - Ctx: ctx, - RelativePath: ctx.Repo.TreePath, - URLPrefix: path.Dir(treeLink), + Ctx: ctx, + RelativePath: ctx.Repo.TreePath, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + BranchPath: ctx.Repo.BranchNameSubURL(), + TreePath: path.Dir(ctx.Repo.TreePath), + }, Metas: ctx.Repo.Repository.ComposeDocumentMetas(ctx), GitRepo: ctx.Repo.GitRepo, InStandalonePage: true, diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 9cf0dff5d8..c2daa3e5e6 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -158,7 +158,7 @@ func findReadmeFileInEntries(ctx *context.Context, entries []*git.TreeEntry, try return "", readmeFile, nil } -func renderDirectory(ctx *context.Context, treeLink string) { +func renderDirectory(ctx *context.Context) { entries := renderDirectoryFiles(ctx, 1*time.Second) if ctx.Written() { return @@ -175,7 +175,7 @@ func renderDirectory(ctx *context.Context, treeLink string) { return } - renderReadmeFile(ctx, subfolder, readmeFile, treeLink) + renderReadmeFile(ctx, subfolder, readmeFile) } // localizedExtensions prepends the provided language code with and without a @@ -259,7 +259,7 @@ func getFileReader(ctx gocontext.Context, repoID int64, blob *git.Blob) ([]byte, return buf, dataRc, &fileInfo{st.IsText(), true, meta.Size, &meta.Pointer, st}, nil } -func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.TreeEntry, readmeTreelink string) { +func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.TreeEntry) { target := readmeFile if readmeFile != nil && readmeFile.IsLink() { target, _ = readmeFile.FollowLinks() @@ -312,9 +312,13 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr ctx.Data["EscapeStatus"], ctx.Data["FileContent"], err = markupRender(ctx, &markup.RenderContext{ Ctx: ctx, RelativePath: path.Join(ctx.Repo.TreePath, readmeFile.Name()), // ctx.Repo.TreePath is the directory not the Readme so we must append the Readme filename (and path). - URLPrefix: path.Join(readmeTreelink, subfolder), - Metas: ctx.Repo.Repository.ComposeDocumentMetas(ctx), - GitRepo: ctx.Repo.GitRepo, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + BranchPath: ctx.Repo.BranchNameSubURL(), + TreePath: path.Join(ctx.Repo.TreePath, subfolder), + }, + Metas: ctx.Repo.Repository.ComposeDocumentMetas(ctx), + GitRepo: ctx.Repo.GitRepo, }, rd) if err != nil { log.Error("Render failed for %s in %-v: %v Falling back to rendering source", readmeFile.Name(), ctx.Repo.Repository, err) @@ -337,7 +341,7 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr } } -func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink string) { +func renderFile(ctx *context.Context, entry *git.TreeEntry) { ctx.Data["IsViewFile"] = true ctx.Data["HideRepoInfo"] = true blob := entry.Blob() @@ -351,7 +355,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName) ctx.Data["FileIsSymlink"] = entry.IsLink() ctx.Data["FileName"] = blob.Name() - ctx.Data["RawFileLink"] = rawLink + "/" + util.PathEscapeSegments(ctx.Repo.TreePath) + ctx.Data["RawFileLink"] = ctx.Repo.RepoLink + "/raw/" + ctx.Repo.BranchNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath) if ctx.Repo.TreePath == ".editorconfig" { _, editorconfigWarning, editorconfigErr := ctx.Repo.GetEditorconfig(ctx.Repo.Commit) @@ -479,9 +483,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st Ctx: ctx, Type: markupType, RelativePath: ctx.Repo.TreePath, - URLPrefix: path.Dir(treeLink), - Metas: metas, - GitRepo: ctx.Repo.GitRepo, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + BranchPath: ctx.Repo.BranchNameSubURL(), + TreePath: path.Dir(ctx.Repo.TreePath), + }, + Metas: metas, + GitRepo: ctx.Repo.GitRepo, }, rd) if err != nil { ctx.ServerError("Render", err) @@ -585,9 +593,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["EscapeStatus"], ctx.Data["FileContent"], err = markupRender(ctx, &markup.RenderContext{ Ctx: ctx, RelativePath: ctx.Repo.TreePath, - URLPrefix: path.Dir(treeLink), - Metas: ctx.Repo.Repository.ComposeDocumentMetas(ctx), - GitRepo: ctx.Repo.GitRepo, + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + BranchPath: ctx.Repo.BranchNameSubURL(), + TreePath: path.Dir(ctx.Repo.TreePath), + }, + Metas: ctx.Repo.Repository.ComposeDocumentMetas(ctx), + GitRepo: ctx.Repo.GitRepo, }, rd) if err != nil { ctx.ServerError("Render", err) @@ -945,14 +957,6 @@ func renderCode(ctx *context.Context) { } ctx.Data["Title"] = title - branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() - treeLink := branchLink - rawLink := ctx.Repo.RepoLink + "/raw/" + ctx.Repo.BranchNameSubURL() - - if len(ctx.Repo.TreePath) > 0 { - treeLink += "/" + util.PathEscapeSegments(ctx.Repo.TreePath) - } - // Get Topics of this repo renderRepoTopics(ctx) if ctx.Written() { @@ -977,9 +981,9 @@ func renderCode(ctx *context.Context) { } if entry.IsDir() { - renderDirectory(ctx, treeLink) + renderDirectory(ctx) } else { - renderFile(ctx, entry, treeLink, rawLink) + renderFile(ctx, entry) } if ctx.Written() { return @@ -1020,6 +1024,12 @@ func renderCode(ctx *context.Context) { } ctx.Data["Paths"] = paths + + branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + treeLink := branchLink + if len(ctx.Repo.TreePath) > 0 { + treeLink += "/" + util.PathEscapeSegments(ctx.Repo.TreePath) + } ctx.Data["TreeLink"] = treeLink ctx.Data["TreeNames"] = treeNames ctx.Data["BranchLink"] = branchLink diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go index 8ea18a186c..4e09f046cf 100644 --- a/routers/web/repo/wiki.go +++ b/routers/web/repo/wiki.go @@ -238,10 +238,12 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) { } rctx := &markup.RenderContext{ - Ctx: ctx, - URLPrefix: ctx.Repo.RepoLink, - Metas: ctx.Repo.Repository.ComposeDocumentMetas(ctx), - IsWiki: true, + Ctx: ctx, + Metas: ctx.Repo.Repository.ComposeDocumentMetas(ctx), + Links: markup.Links{ + Base: ctx.Repo.RepoLink, + }, + IsWiki: true, } buf := &strings.Builder{} diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go index 919a080b42..0f8d64e7b2 100644 --- a/routers/web/shared/user/header.go +++ b/routers/web/shared/user/header.go @@ -47,10 +47,8 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) { if len(ctx.ContextUser.Description) != 0 { content, err := markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Repo.RepoLink, - Metas: map[string]string{"mode": "document"}, - GitRepo: ctx.Repo.GitRepo, - Ctx: ctx, + Metas: map[string]string{"mode": "document"}, + Ctx: ctx, }, ctx.ContextUser.Description) if err != nil { ctx.ServerError("RenderString", err) diff --git a/routers/web/user/home.go b/routers/web/user/home.go index debbb9753c..44920817c9 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -258,9 +258,11 @@ func Milestones(ctx *context.Context) { } milestones[i].RenderedContent, err = markdown.RenderString(&markup.RenderContext{ - URLPrefix: milestones[i].Repo.Link(), - Metas: milestones[i].Repo.ComposeMetas(ctx), - Ctx: ctx, + Links: markup.Links{ + Base: milestones[i].Repo.Link(), + }, + Metas: milestones[i].Repo.ComposeMetas(ctx), + Ctx: ctx, }, milestones[i].Content) if err != nil { ctx.ServerError("RenderString", err) diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index a8ab3dde81..c5305ebcd9 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -7,6 +7,7 @@ package user import ( "fmt" "net/http" + "path" "strings" activities_model "code.gitea.io/gitea/models/activities" @@ -233,18 +234,19 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil { log.Error("failed to GetBlobContent: %v", err) } else { - // Give the URLPrefix to the markdown render for the full link of media element. - // the media link usually be like /[user]/[repoName]/media/branch/[branchName], - // Eg. /Tom/.profile/media/branch/main - // The branch shown on the profile page is the default branch, this need to be in sync with doc, see: - // https://docs.gitea.com/usage/profile-readme - - prefix := profileDbRepo.Link() + "/src/branch/" + util.PathEscapeSegments(profileDbRepo.DefaultBranch) if profileContent, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - GitRepo: profileGitRepo, - URLPrefix: prefix, - Metas: map[string]string{"mode": "document"}, + Ctx: ctx, + GitRepo: profileGitRepo, + Links: markup.Links{ + // Give the repo link to the markdown render for the full link of media element. + // the media link usually be like /[user]/[repoName]/media/branch/[branchName], + // Eg. /Tom/.profile/media/branch/main + // The branch shown on the profile page is the default branch, this need to be in sync with doc, see: + // https://docs.gitea.com/usage/profile-readme + Base: profileDbRepo.Link(), + BranchPath: path.Join("branch", util.PathEscapeSegments(profileDbRepo.DefaultBranch)), + }, + Metas: map[string]string{"mode": "document"}, }, bytes); err != nil { log.Error("failed to RenderString: %v", err) } else { diff --git a/services/mailer/mail.go b/services/mailer/mail.go index b597dd0487..cf80333608 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -220,9 +220,11 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient // This is the body of the new issue or comment, not the mail body body, err := markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: ctx.Issue.Repo.HTMLURL(), - Metas: ctx.Issue.Repo.ComposeMetas(ctx), + Ctx: ctx, + Links: markup.Links{ + Base: ctx.Issue.Repo.HTMLURL(), + }, + Metas: ctx.Issue.Repo.ComposeMetas(ctx), }, ctx.Content) if err != nil { return nil, err diff --git a/services/mailer/mail_release.go b/services/mailer/mail_release.go index 88973a6be2..801c2476c2 100644 --- a/services/mailer/mail_release.go +++ b/services/mailer/mail_release.go @@ -57,9 +57,11 @@ func mailNewRelease(ctx context.Context, lang string, tos []string, rel *repo_mo var err error rel.RenderedNote, err = markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, - URLPrefix: rel.Repo.Link(), - Metas: rel.Repo.ComposeMetas(ctx), + Ctx: ctx, + Links: markup.Links{ + Base: rel.Repo.HTMLURL(), + }, + Metas: rel.Repo.ComposeMetas(ctx), }, rel.Note) if err != nil { log.Error("markdown.RenderString(%d): %v", rel.RepoID, err) diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index cec5b6fc3e..8ae7301c4a 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -25,7 +25,7 @@ {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}} -

{{svg "octicon-git-commit" 16 "gt-mr-2"}}{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage .RepoLink (.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}

+

{{svg "octicon-git-commit" 16 "gt-mr-2"}}{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}

{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} @@ -101,7 +101,7 @@ {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}} -

{{svg "octicon-git-commit" 16 "gt-mr-2"}}{{ShortSha .DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DBBranch.CommitMessage $.RepoLink ($.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}}  {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}

+

{{svg "octicon-git-commit" 16 "gt-mr-2"}}{{ShortSha .DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DBBranch.CommitMessage ($.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}}  {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}

{{end}} diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 2a4240045c..56bcbc21bb 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -19,7 +19,7 @@ {{end}}
-

{{RenderCommitMessage $.Context .Commit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}

+

{{RenderCommitMessage $.Context .Commit.Message ($.Repository.ComposeMetas ctx)}}{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}

{{if not $.PageIsWiki}} {{if IsMultilineCommitMessage .Commit.Message}} -
{{RenderCommitBody $.Context .Commit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}
+
{{RenderCommitBody $.Context .Commit.Message ($.Repository.ComposeMetas ctx)}}
{{end}} {{template "repo/commit_load_branches_and_tags" .}}
@@ -258,7 +258,7 @@
{{end}} - {{if .Note}} + {{if .NoteRendered}}
{{svg "octicon-note" 16 "gt-mr-3"}} {{ctx.Locale.Tr "repo.diff.git-notes"}}: @@ -276,7 +276,7 @@ {{TimeSince .NoteCommit.Author.When ctx.Locale}}
-
{{RenderNote $.Context .Note $.RepoLink ($.Repository.ComposeMetas ctx)}}
+
{{.NoteRendered | Str2html}}
{{end}} {{template "repo/diff/box" .}} diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 77f1684245..7bfed53124 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -60,7 +60,7 @@ {{.Summary | RenderEmoji $.Context}} {{else}} {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} - {{RenderCommitMessageLinkSubject $.Context .Message $commitRepoLink $commitLink ($.Repository.ComposeMetas ctx)}} + {{RenderCommitMessageLinkSubject $.Context .Message $commitLink ($.Repository.ComposeMetas ctx)}} {{end}} {{if IsMultilineCommitMessage .Message}} @@ -68,7 +68,7 @@ {{end}} {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} {{if IsMultilineCommitMessage .Message}} -
{{RenderCommitBody $.Context .Message $commitRepoLink ($.Repository.ComposeMetas ctx)}}
+
{{RenderCommitBody $.Context .Message ($.Repository.ComposeMetas ctx)}}
{{end}} {{if .Committer}} diff --git a/templates/repo/commits_list_small.tmpl b/templates/repo/commits_list_small.tmpl index 63eb5945bc..79e1bd6309 100644 --- a/templates/repo/commits_list_small.tmpl +++ b/templates/repo/commits_list_small.tmpl @@ -38,12 +38,12 @@
- {{RenderCommitMessageLinkSubject $.root.Context .Message ($.comment.Issue.PullRequest.BaseRepo.Link|Escape) $commitLink ($.comment.Issue.PullRequest.BaseRepo.ComposeMetas ctx)}} + {{RenderCommitMessageLinkSubject $.root.Context .Message $commitLink ($.comment.Issue.PullRequest.BaseRepo.ComposeMetas ctx)}} {{if IsMultilineCommitMessage .Message}} {{end}} {{if IsMultilineCommitMessage .Message}} -
{{RenderCommitBody $.root.Context .Message ($.comment.Issue.PullRequest.BaseRepo.Link|Escape) ($.comment.Issue.PullRequest.BaseRepo.ComposeMetas ctx)}}
+
{{RenderCommitBody $.root.Context .Message ($.comment.Issue.PullRequest.BaseRepo.ComposeMetas ctx)}}
{{end}} {{end}} diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl index 42a7bf3c2a..b4d96c3168 100644 --- a/templates/repo/diff/compare.tmpl +++ b/templates/repo/diff/compare.tmpl @@ -194,7 +194,7 @@
{{ctx.Locale.Tr "repo.pulls.has_pull_request" (print (Escape $.RepoLink) "/pulls/" .PullRequest.Issue.Index) (Escape $.RepoRelPath) .PullRequest.Index | Safe}}

- {{RenderIssueTitle $.Context .PullRequest.Issue.Title $.RepoLink ($.Repository.ComposeMetas ctx)}} + {{RenderIssueTitle $.Context .PullRequest.Issue.Title ($.Repository.ComposeMetas ctx)}} #{{.PullRequest.Issue.Index}}

diff --git a/templates/repo/graph/commits.tmpl b/templates/repo/graph/commits.tmpl index 3c63046c6c..61ef1fe10d 100644 --- a/templates/repo/graph/commits.tmpl +++ b/templates/repo/graph/commits.tmpl @@ -29,7 +29,7 @@ - {{RenderCommitMessage $.Context $commit.Subject $.RepoLink ($.Repository.ComposeMetas ctx)}} + {{RenderCommitMessage $.Context $commit.Subject ($.Repository.ComposeMetas ctx)}} {{range $commit.Refs}} diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl index d2c48ff275..7ec48c6734 100644 --- a/templates/repo/issue/view_title.tmpl +++ b/templates/repo/issue/view_title.tmpl @@ -6,7 +6,7 @@

- {{RenderIssueTitle $.Context .Issue.Title $.RepoLink ($.Repository.ComposeMetas ctx) | RenderCodeBlock}} #{{.Issue.Index}} + {{RenderIssueTitle $.Context .Issue.Title ($.Repository.ComposeMetas ctx) | RenderCodeBlock}} #{{.Issue.Index}}
diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 836c633ced..504032aa78 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -26,10 +26,10 @@ {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} {{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}} - {{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $.RepoLink $commitLink ($.Repository.ComposeMetas ctx)}} + {{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $commitLink ($.Repository.ComposeMetas ctx)}} {{if IsMultilineCommitMessage .LatestCommit.Message}} -
{{RenderCommitBody $.Context .LatestCommit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}
+
{{RenderCommitBody $.Context .LatestCommit.Message ($.Repository.ComposeMetas ctx)}}
{{end}}
{{end}} @@ -83,7 +83,7 @@ {{if $commit}} {{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}} - {{RenderCommitMessageLinkSubject $.Context $commit.Message $.RepoLink $commitLink ($.Repository.ComposeMetas ctx)}} + {{RenderCommitMessageLinkSubject $.Context $commit.Message $commitLink ($.Repository.ComposeMetas ctx)}} {{else}}
{{end}} diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index 728715bbc7..a51365e4d6 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -91,7 +91,7 @@ {{ShortSha .Sha1}} - {{RenderCommitMessage $.Context .Message $repoLink ($repo.ComposeMetas ctx)}} + {{RenderCommitMessage $.Context .Message ($repo.ComposeMetas ctx)}}
{{end}} diff --git a/tests/fuzz/fuzz_test.go b/tests/fuzz/fuzz_test.go index 6a7d9d2d32..25a6ed8213 100644 --- a/tests/fuzz/fuzz_test.go +++ b/tests/fuzz/fuzz_test.go @@ -15,8 +15,10 @@ import ( ) var renderContext = markup.RenderContext{ - Ctx: context.Background(), - URLPrefix: "https://example.com/go-gitea/gitea", + Ctx: context.Background(), + Links: markup.Links{ + Base: "https://example.com/go-gitea/gitea", + }, Metas: map[string]string{ "user": "go-gitea", "repo": "gitea", From b0e6c255359f754fd94c81e5762ba634a4b23261 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 15 Jan 2024 19:15:31 +0800 Subject: [PATCH 03/76] Caller should check the ResponseExtra.HasError() first to see whether the request fails (#28796) `resp != nil` doesn't mean the request really succeeded. Add a comment for requestJSONResp to clarify the behavior. --- modules/private/actions.go | 2 +- modules/private/key.go | 2 +- modules/private/mail.go | 2 +- modules/private/request.go | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/private/actions.go b/modules/private/actions.go index 4ec77dc936..a22833632e 100644 --- a/modules/private/actions.go +++ b/modules/private/actions.go @@ -22,7 +22,7 @@ func GenerateActionsRunnerToken(ctx context.Context, scope string) (string, Resp }) resp, extra := requestJSONResp(req, &responseText{}) - if resp == nil { + if extra.HasError() { return "", extra } return resp.Text, extra diff --git a/modules/private/key.go b/modules/private/key.go index aa1e8aa56f..08762bd401 100644 --- a/modules/private/key.go +++ b/modules/private/key.go @@ -27,7 +27,7 @@ func AuthorizedPublicKeyByContent(ctx context.Context, content string) (string, req := newInternalRequest(ctx, reqURL, "POST") req.Param("content", content) resp, extra := requestJSONResp(req, &responseText{}) - if resp == nil { + if extra.HasError() { return "", extra } return resp.Text, extra diff --git a/modules/private/mail.go b/modules/private/mail.go index 699f5e5f42..ac55d6fe4d 100644 --- a/modules/private/mail.go +++ b/modules/private/mail.go @@ -30,7 +30,7 @@ func SendEmail(ctx context.Context, subject, message string, to []string) (strin }) resp, extra := requestJSONResp(req, &responseText{}) - if resp == nil { + if extra.HasError() { return "", extra } return resp.Text, extra diff --git a/modules/private/request.go b/modules/private/request.go index d3f99381a6..2bc43b972d 100644 --- a/modules/private/request.go +++ b/modules/private/request.go @@ -47,6 +47,7 @@ func (re responseError) Error() string { // requestJSONResp sends a request to the gitea server and then parses the response. // If the status code is not 2xx, or any error occurs, the ResponseExtra.Error field is guaranteed to be non-nil, // and the ResponseExtra.UserMsg field will be set to a message for the end user. +// Caller should check the ResponseExtra.HasError() first to see whether the request fails. // // * If the "res" is a struct pointer, the response will be parsed as JSON // * If the "res" is responseText pointer, the response will be stored as text in it From 3793ec4d141c718462a273c02d147645c56c341a Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Mon, 15 Jan 2024 15:07:32 +0100 Subject: [PATCH 04/76] Fix `GetCommitStatuses` (#28787) Fixes #28764. --- models/git/commit_status.go | 54 +++++++++++--------------------- models/git/commit_status_test.go | 15 ++++++++- routers/api/v1/repo/status.go | 5 ++- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/models/git/commit_status.go b/models/git/commit_status.go index 488e45de26..c126d17f20 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -25,7 +25,6 @@ import ( "code.gitea.io/gitea/modules/translation" "xorm.io/builder" - "xorm.io/xorm" ) // CommitStatus holds a single Status of a single Commit @@ -221,57 +220,42 @@ func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus { // CommitStatusOptions holds the options for query commit statuses type CommitStatusOptions struct { db.ListOptions + RepoID int64 + SHA string State string SortType string } -// GetCommitStatuses returns all statuses for a given commit. -func GetCommitStatuses(ctx context.Context, repo *repo_model.Repository, sha string, opts *CommitStatusOptions) ([]*CommitStatus, int64, error) { - if opts.Page <= 0 { - opts.Page = 1 - } - if opts.PageSize <= 0 { - opts.Page = setting.ItemsPerPage +func (opts *CommitStatusOptions) ToConds() builder.Cond { + var cond builder.Cond = builder.Eq{ + "repo_id": opts.RepoID, + "sha": opts.SHA, } - countSession := listCommitStatusesStatement(ctx, repo, sha, opts) - countSession = db.SetSessionPagination(countSession, opts) - maxResults, err := countSession.Count(new(CommitStatus)) - if err != nil { - log.Error("Count PRs: %v", err) - return nil, maxResults, err - } - - statuses := make([]*CommitStatus, 0, opts.PageSize) - findSession := listCommitStatusesStatement(ctx, repo, sha, opts) - findSession = db.SetSessionPagination(findSession, opts) - sortCommitStatusesSession(findSession, opts.SortType) - return statuses, maxResults, findSession.Find(&statuses) -} - -func listCommitStatusesStatement(ctx context.Context, repo *repo_model.Repository, sha string, opts *CommitStatusOptions) *xorm.Session { - sess := db.GetEngine(ctx).Where("repo_id = ?", repo.ID).And("sha = ?", sha) switch opts.State { case "pending", "success", "error", "failure", "warning": - sess.And("state = ?", opts.State) + cond = cond.And(builder.Eq{ + "state": opts.State, + }) } - return sess + + return cond } -func sortCommitStatusesSession(sess *xorm.Session, sortType string) { - switch sortType { +func (opts *CommitStatusOptions) ToOrders() string { + switch opts.SortType { case "oldest": - sess.Asc("created_unix") + return "created_unix ASC" case "recentupdate": - sess.Desc("updated_unix") + return "updated_unix DESC" case "leastupdate": - sess.Asc("updated_unix") + return "updated_unix ASC" case "leastindex": - sess.Desc("index") + return "`index` DESC" case "highestindex": - sess.Asc("index") + return "`index` ASC" default: - sess.Desc("created_unix") + return "created_unix DESC" } } diff --git a/models/git/commit_status_test.go b/models/git/commit_status_test.go index 2197433b3e..f7dd8597ed 100644 --- a/models/git/commit_status_test.go +++ b/models/git/commit_status_test.go @@ -22,7 +22,11 @@ func TestGetCommitStatuses(t *testing.T) { sha1 := "1234123412341234123412341234123412341234" - statuses, maxResults, err := git_model.GetCommitStatuses(db.DefaultContext, repo1, sha1, &git_model.CommitStatusOptions{ListOptions: db.ListOptions{Page: 1, PageSize: 50}}) + statuses, maxResults, err := db.FindAndCount[git_model.CommitStatus](db.DefaultContext, &git_model.CommitStatusOptions{ + ListOptions: db.ListOptions{Page: 1, PageSize: 50}, + RepoID: repo1.ID, + SHA: sha1, + }) assert.NoError(t, err) assert.Equal(t, int(maxResults), 5) assert.Len(t, statuses, 5) @@ -46,4 +50,13 @@ func TestGetCommitStatuses(t *testing.T) { assert.Equal(t, "deploy/awesomeness", statuses[4].Context) assert.Equal(t, structs.CommitStatusError, statuses[4].State) assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[4].APIURL(db.DefaultContext)) + + statuses, maxResults, err = db.FindAndCount[git_model.CommitStatus](db.DefaultContext, &git_model.CommitStatusOptions{ + ListOptions: db.ListOptions{Page: 2, PageSize: 50}, + RepoID: repo1.ID, + SHA: sha1, + }) + assert.NoError(t, err) + assert.Equal(t, int(maxResults), 5) + assert.Empty(t, statuses) } diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index 926d91ca81..b4edf0608c 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" + "code.gitea.io/gitea/models/db" git_model "code.gitea.io/gitea/models/git" "code.gitea.io/gitea/modules/context" api "code.gitea.io/gitea/modules/structs" @@ -194,8 +195,10 @@ func getCommitStatuses(ctx *context.APIContext, sha string) { listOptions := utils.GetListOptions(ctx) - statuses, maxResults, err := git_model.GetCommitStatuses(ctx, repo, sha, &git_model.CommitStatusOptions{ + statuses, maxResults, err := db.FindAndCount[git_model.CommitStatus](ctx, &git_model.CommitStatusOptions{ ListOptions: listOptions, + RepoID: repo.ID, + SHA: sha, SortType: ctx.FormTrim("sort"), State: ctx.FormTrim("state"), }) From 2d343f8987025015f5b61e328cc9e45082e6d3f2 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Mon, 15 Jan 2024 17:37:14 +0300 Subject: [PATCH 05/76] Display latest sync time for pull mirrors on the repo page (#28712) Fixes #25168 --------- Co-authored-by: delvh --- templates/repo/header.tmpl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 9630cd3a6f..c362059ef3 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -28,6 +28,13 @@
{{svg "octicon-repo-template" 18}}
{{end}}

+ {{if $.PullMirror}} +
+ {{ctx.Locale.Tr "repo.mirror_from"}} + {{$.PullMirror.RemoteAddress}} + {{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{TimeSinceUnix $.PullMirror.UpdatedUnix ctx.Locale}}{{end}} +
+ {{end}}
{{if not (or .IsBeingCreated .IsBroken)}}
From 2c3da59e275b69ebf984bb70954f42a7bcb0b49d Mon Sep 17 00:00:00 2001 From: Gwyneth Morgan Date: Mon, 15 Jan 2024 07:07:22 -0800 Subject: [PATCH 06/76] Add ability to see open and closed issues at the same time (#28757) By clicking the currently active "Open" or "Closed" filter button in the issue list, the user can toggle that filter off in order to see all issues regardless of state. The URL "state" parameter will be set to "all" and the "Open"/"Closed" button will not show as active. --- models/issues/tracked_time.go | 12 ++++++---- models/issues/tracked_time_test.go | 9 ++++++-- routers/web/repo/issue.go | 36 +++++++++++++++++++++-------- templates/repo/issue/openclose.tmpl | 4 ++-- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/models/issues/tracked_time.go b/models/issues/tracked_time.go index 884a445d26..91c4832e49 100644 --- a/models/issues/tracked_time.go +++ b/models/issues/tracked_time.go @@ -340,7 +340,7 @@ func GetTrackedTimeByID(ctx context.Context, id int64) (*TrackedTime, error) { } // GetIssueTotalTrackedTime returns the total tracked time for issues by given conditions. -func GetIssueTotalTrackedTime(ctx context.Context, opts *IssuesOptions, isClosed bool) (int64, error) { +func GetIssueTotalTrackedTime(ctx context.Context, opts *IssuesOptions, isClosed util.OptionalBool) (int64, error) { if len(opts.IssueIDs) <= MaxQueryParameters { return getIssueTotalTrackedTimeChunk(ctx, opts, isClosed, opts.IssueIDs) } @@ -363,7 +363,7 @@ func GetIssueTotalTrackedTime(ctx context.Context, opts *IssuesOptions, isClosed return accum, nil } -func getIssueTotalTrackedTimeChunk(ctx context.Context, opts *IssuesOptions, isClosed bool, issueIDs []int64) (int64, error) { +func getIssueTotalTrackedTimeChunk(ctx context.Context, opts *IssuesOptions, isClosed util.OptionalBool, issueIDs []int64) (int64, error) { sumSession := func(opts *IssuesOptions, issueIDs []int64) *xorm.Session { sess := db.GetEngine(ctx). Table("tracked_time"). @@ -377,7 +377,9 @@ func getIssueTotalTrackedTimeChunk(ctx context.Context, opts *IssuesOptions, isC Time int64 } - return sumSession(opts, issueIDs). - And("issue.is_closed = ?", isClosed). - SumInt(new(trackedTime), "tracked_time.time") + session := sumSession(opts, issueIDs) + if !isClosed.IsNone() { + session = session.And("issue.is_closed = ?", isClosed.IsTrue()) + } + return session.SumInt(new(trackedTime), "tracked_time.time") } diff --git a/models/issues/tracked_time_test.go b/models/issues/tracked_time_test.go index 2774234e7b..9beb862ffb 100644 --- a/models/issues/tracked_time_test.go +++ b/models/issues/tracked_time_test.go @@ -11,6 +11,7 @@ import ( issues_model "code.gitea.io/gitea/models/issues" "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" + "code.gitea.io/gitea/modules/util" "github.com/stretchr/testify/assert" ) @@ -119,11 +120,15 @@ func TestTotalTimesForEachUser(t *testing.T) { func TestGetIssueTotalTrackedTime(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - ttt, err := issues_model.GetIssueTotalTrackedTime(db.DefaultContext, &issues_model.IssuesOptions{MilestoneIDs: []int64{1}}, false) + ttt, err := issues_model.GetIssueTotalTrackedTime(db.DefaultContext, &issues_model.IssuesOptions{MilestoneIDs: []int64{1}}, util.OptionalBoolFalse) assert.NoError(t, err) assert.EqualValues(t, 3682, ttt) - ttt, err = issues_model.GetIssueTotalTrackedTime(db.DefaultContext, &issues_model.IssuesOptions{MilestoneIDs: []int64{1}}, true) + ttt, err = issues_model.GetIssueTotalTrackedTime(db.DefaultContext, &issues_model.IssuesOptions{MilestoneIDs: []int64{1}}, util.OptionalBoolTrue) assert.NoError(t, err) assert.EqualValues(t, 0, ttt) + + ttt, err = issues_model.GetIssueTotalTrackedTime(db.DefaultContext, &issues_model.IssuesOptions{MilestoneIDs: []int64{1}}, util.OptionalBoolNone) + assert.NoError(t, err) + assert.EqualValues(t, 3682, ttt) } diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 0d660e3b89..c8c9924a9e 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -237,10 +237,18 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti } } - isShowClosed := ctx.FormString("state") == "closed" - // if open issues are zero and close don't, use closed as default + var isShowClosed util.OptionalBool + switch ctx.FormString("state") { + case "closed": + isShowClosed = util.OptionalBoolTrue + case "all": + isShowClosed = util.OptionalBoolNone + default: + isShowClosed = util.OptionalBoolFalse + } + // if there are closed issues and no open issues, default to showing all issues if len(ctx.FormString("state")) == 0 && issueStats.OpenCount == 0 && issueStats.ClosedCount != 0 { - isShowClosed = true + isShowClosed = util.OptionalBoolNone } if repo.IsTimetrackerEnabled(ctx) { @@ -260,10 +268,13 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti } var total int - if !isShowClosed { - total = int(issueStats.OpenCount) - } else { + switch isShowClosed { + case util.OptionalBoolTrue: total = int(issueStats.ClosedCount) + case util.OptionalBoolNone: + total = int(issueStats.OpenCount + issueStats.ClosedCount) + default: + total = int(issueStats.OpenCount) } pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, 5) @@ -282,7 +293,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti ReviewedID: reviewedID, MilestoneIDs: mileIDs, ProjectID: projectID, - IsClosed: util.OptionalBoolOf(isShowClosed), + IsClosed: isShowClosed, IsPull: isPullOption, LabelIDs: labelIDs, SortType: sortType, @@ -428,6 +439,9 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti ctx.Data["OpenCount"] = issueStats.OpenCount ctx.Data["ClosedCount"] = issueStats.ClosedCount linkStr := "%s?q=%s&type=%s&sort=%s&state=%s&labels=%s&milestone=%d&project=%d&assignee=%d&poster=%d&archived=%t" + ctx.Data["AllStatesLink"] = fmt.Sprintf(linkStr, ctx.Link, + url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "all", url.QueryEscape(selectLabels), + mentionedID, projectID, assigneeID, posterID, archived) ctx.Data["OpenLink"] = fmt.Sprintf(linkStr, ctx.Link, url.QueryEscape(keyword), url.QueryEscape(viewType), url.QueryEscape(sortType), "open", url.QueryEscape(selectLabels), mentionedID, projectID, assigneeID, posterID, archived) @@ -442,11 +456,13 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti ctx.Data["ProjectID"] = projectID ctx.Data["AssigneeID"] = assigneeID ctx.Data["PosterID"] = posterID - ctx.Data["IsShowClosed"] = isShowClosed ctx.Data["Keyword"] = keyword - if isShowClosed { + switch isShowClosed { + case util.OptionalBoolTrue: ctx.Data["State"] = "closed" - } else { + case util.OptionalBoolNone: + ctx.Data["State"] = "all" + default: ctx.Data["State"] = "open" } ctx.Data["ShowArchivedLabels"] = archived diff --git a/templates/repo/issue/openclose.tmpl b/templates/repo/issue/openclose.tmpl index ff5ec3c5a5..38848c51ac 100644 --- a/templates/repo/issue/openclose.tmpl +++ b/templates/repo/issue/openclose.tmpl @@ -1,5 +1,5 @@ {{end}} + + {{if not .ReadmeInList}} +
+
+ {{template "repo/latest_commit" .}} +
+ {{if .LatestCommit}} + {{if .LatestCommit.Committer}} +
+ {{TimeSince .LatestCommit.Committer.When ctx.Locale}} +
+ {{end}} + {{end}} +
+ {{end}} +

{{if .ReadmeInList}} diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 504032aa78..c1ef4ff4cb 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -2,37 +2,7 @@ - {{if not .LatestCommit}} -
- {{else}} - {{if .LatestCommitUser}} - {{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "gt-mr-2"}} - {{if .LatestCommitUser.FullName}} - {{.LatestCommitUser.FullName}} - {{else}} - {{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}} - {{end}} - {{else}} - {{if .LatestCommit.Author}} - {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24 "gt-mr-2"}} - {{.LatestCommit.Author.Name}} - {{end}} - {{end}} - - {{ShortSha .LatestCommit.ID.String}} - {{if .LatestCommit.Signature}} - {{template "repo/shabox_badge" dict "root" $ "verification" .LatestCommitVerification}} - {{end}} - - {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} - {{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}} - {{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $commitLink ($.Repository.ComposeMetas ctx)}} - {{if IsMultilineCommitMessage .LatestCommit.Message}} - -
{{RenderCommitBody $.Context .LatestCommit.Message ($.Repository.ComposeMetas ctx)}}
- {{end}} -
- {{end}} + {{template "repo/latest_commit" .}} {{if .LatestCommit}}{{if .LatestCommit.Committer}}{{TimeSince .LatestCommit.Committer.When ctx.Locale}}{{end}}{{end}} diff --git a/web_src/css/repo.css b/web_src/css/repo.css index f1356fc39b..dfe0d6c77f 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -1260,6 +1260,7 @@ .repository #commits-table td.sha .sha.label, .repository #repo-files-table .sha.label, +.repository #repo-file-commit-box .sha.label, .repository #rev-list .sha.label, .repository .timeline-item.commits-list .singular-commit .sha.label { border: 1px solid var(--color-light-border); @@ -1267,6 +1268,7 @@ .repository #commits-table td.sha .sha.label .ui.signature.avatar, .repository #repo-files-table .sha.label .ui.signature.avatar, +.repository #repo-file-commit-box .sha.label .ui.signature.avatar, .repository #rev-list .sha.label .ui.signature.avatar, .repository .timeline-item.commits-list .singular-commit .sha.label .ui.signature.avatar { height: 16px; @@ -1276,6 +1278,7 @@ .repository #commits-table td.sha .sha.label .detail.icon, .repository #repo-files-table .sha.label .detail.icon, +.repository #repo-file-commit-box .sha.label .detail.icon, .repository #rev-list .sha.label .detail.icon, .repository .timeline-item.commits-list .singular-commit .sha.label .detail.icon { background: var(--color-light); @@ -1291,6 +1294,7 @@ .repository #commits-table td.sha .sha.label .detail.icon img, .repository #repo-files-table .sha.label .detail.icon img, +.repository #repo-file-commit-box .sha.label .detail.icon img, .repository #rev-list .sha.label .detail.icon img, .repository .timeline-item.commits-list .singular-commit .sha.label .detail.icon img { margin-right: 0; @@ -1298,6 +1302,7 @@ .repository #commits-table td.sha .sha.label .detail.icon .svg, .repository #repo-files-table .sha.label .detail.icon .svg, +.repository #repo-file-commit-box .sha.label .detail.icon .svg, .repository #rev-list .sha.label .detail.icon .svg, .repository .timeline-item.commits-list .singular-commit .sha.label .detail.icon .svg { margin: 0 0.25em 0 0; @@ -1305,6 +1310,7 @@ .repository #commits-table td.sha .sha.label .detail.icon > div, .repository #repo-files-table .sha.label .detail.icon > div, +.repository #repo-file-commit-box .sha.label .detail.icon > div, .repository #rev-list .sha.label .detail.icon > div, .repository .timeline-item.commits-list .singular-commit .sha.label .detail.icon > div { display: flex; @@ -1313,6 +1319,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isWarning, .repository #repo-files-table .sha.label.isSigned.isWarning, +.repository #repo-file-commit-box .sha.label.isSigned.isWarning, .repository #rev-list .sha.label.isSigned.isWarning, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isWarning { border: 1px solid var(--color-red-badge); @@ -1321,6 +1328,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isWarning .detail.icon, .repository #repo-files-table .sha.label.isSigned.isWarning .detail.icon, +.repository #repo-file-commit-box .sha.label.isSigned.isWarning .detail.icon, .repository #rev-list .sha.label.isSigned.isWarning .detail.icon, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isWarning .detail.icon { border-left: 1px solid var(--color-red-badge); @@ -1329,6 +1337,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isWarning:hover, .repository #repo-files-table .sha.label.isSigned.isWarning:hover, +.repository #repo-file-commit-box .sha.label.isSigned.isWarning:hover, .repository #rev-list .sha.label.isSigned.isWarning:hover, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isWarning:hover { background: var(--color-red-badge-hover-bg) !important; @@ -1336,6 +1345,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerified, .repository #repo-files-table .sha.label.isSigned.isVerified, +.repository #repo-file-commit-box .sha.label.isSigned.isVerified, .repository #rev-list .sha.label.isSigned.isVerified, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerified { border: 1px solid var(--color-green-badge); @@ -1344,6 +1354,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerified .detail.icon, .repository #repo-files-table .sha.label.isSigned.isVerified .detail.icon, +.repository #repo-file-commit-box .sha.label.isSigned.isVerified .detail.icon, .repository #rev-list .sha.label.isSigned.isVerified .detail.icon, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerified .detail.icon { border-left: 1px solid var(--color-green-badge); @@ -1352,6 +1363,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerified:hover, .repository #repo-files-table .sha.label.isSigned.isVerified:hover, +.repository #repo-file-commit-box .sha.label.isSigned.isVerified:hover, .repository #rev-list .sha.label.isSigned.isVerified:hover, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerified:hover { background: var(--color-green-badge-hover-bg) !important; @@ -1359,6 +1371,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerifiedUntrusted, .repository #repo-files-table .sha.label.isSigned.isVerifiedUntrusted, +.repository #repo-file-commit-box .sha.label.isSigned.isVerifiedUntrusted, .repository #rev-list .sha.label.isSigned.isVerifiedUntrusted, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerifiedUntrusted { border: 1px solid var(--color-yellow-badge); @@ -1367,6 +1380,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerifiedUntrusted .detail.icon, .repository #repo-files-table .sha.label.isSigned.isVerifiedUntrusted .detail.icon, +.repository #repo-file-commit-box .sha.label.isSigned.isVerifiedUntrusted .detail.icon, .repository #rev-list .sha.label.isSigned.isVerifiedUntrusted .detail.icon, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerifiedUntrusted .detail.icon { border-left: 1px solid var(--color-yellow-badge); @@ -1375,6 +1389,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerifiedUntrusted:hover, .repository #repo-files-table .sha.label.isSigned.isVerifiedUntrusted:hover, +.repository #repo-file-commit-box .sha.label.isSigned.isVerifiedUntrusted:hover, .repository #rev-list .sha.label.isSigned.isVerifiedUntrusted:hover, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerifiedUntrusted:hover { background: var(--color-yellow-badge-hover-bg) !important; @@ -1382,6 +1397,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerifiedUnmatched, .repository #repo-files-table .sha.label.isSigned.isVerifiedUnmatched, +.repository #repo-file-commit-box .sha.label.isSigned.isVerifiedUnmatched, .repository #rev-list .sha.label.isSigned.isVerifiedUnmatched, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerifiedUnmatched { border: 1px solid var(--color-orange-badge); @@ -1390,6 +1406,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerifiedUnmatched .detail.icon, .repository #repo-files-table .sha.label.isSigned.isVerifiedUnmatched .detail.icon, +.repository #repo-file-commit-box .sha.label.isSigned.isVerifiedUnmatched .detail.icon, .repository #rev-list .sha.label.isSigned.isVerifiedUnmatched .detail.icon, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerifiedUnmatched .detail.icon { border-left: 1px solid var(--color-orange-badge); @@ -1398,6 +1415,7 @@ .repository #commits-table td.sha .sha.label.isSigned.isVerifiedUnmatched:hover, .repository #repo-files-table .sha.label.isSigned.isVerifiedUnmatched:hover, +.repository #repo-file-commit-box .sha.label.isSigned.isVerifiedUnmatched:hover, .repository #rev-list .sha.label.isSigned.isVerifiedUnmatched:hover, .repository .timeline-item.commits-list .singular-commit .sha.label.isSigned.isVerifiedUnmatched:hover { background: var(--color-orange-badge-hover-bg) !important; From d971dfbae1b6f5f63357fa387c59e2a7cf06100b Mon Sep 17 00:00:00 2001 From: Denys Konovalov Date: Mon, 15 Jan 2024 21:38:13 +0100 Subject: [PATCH 08/76] Fix links in issue card (#28806) Fixes_ https://github.com/go-gitea/gitea/issues/23318#issuecomment-1611086747 --- templates/repo/issue/card.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/repo/issue/card.tmpl b/templates/repo/issue/card.tmpl index 1863ba39d7..14d08fc0ef 100644 --- a/templates/repo/issue/card.tmpl +++ b/templates/repo/issue/card.tmpl @@ -33,7 +33,7 @@
{{if .MilestoneID}}
- + {{svg "octicon-milestone" 16 "gt-mr-2 gt-vm"}} {{.Milestone.Name}} @@ -42,7 +42,7 @@ {{if $.Page.LinkedPRs}} {{range index $.Page.LinkedPRs .ID}}
- + {{svg "octicon-git-merge" 16 "gt-mr-2 gt-vm"}} {{.Title}} #{{.Index}} @@ -61,7 +61,7 @@ {{if or .Labels .Assignees}}
{{range .Labels}} - {{RenderLabel ctx .}} + {{RenderLabel ctx .}} {{end}}
{{range .Assignees}} From 5374d29aa9644a979d8d6e8e100bb4e77641d74f Mon Sep 17 00:00:00 2001 From: crapStone Date: Mon, 15 Jan 2024 22:37:32 +0000 Subject: [PATCH 09/76] Add gist to comparison (#28809) This PR adds a section to the documentation that links to the project [Opengist](https://github.com/thomiceli/opengist) on GitHub. The feature was proposed in #16670 but didn't resonate well with the maintainers. --- docs/content/installation/comparison.en-us.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/content/installation/comparison.en-us.md b/docs/content/installation/comparison.en-us.md index e48410ba6f..1ba4f7ecc2 100644 --- a/docs/content/installation/comparison.en-us.md +++ b/docs/content/installation/comparison.en-us.md @@ -52,6 +52,7 @@ _Symbols used in table:_ | Markdown support | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | CSV support | ✓ | ✘ | ✓ | ✘ | ✘ | ✓ | ✘ | ✘ | | 'GitHub / GitLab pages' | [⚙️][gitea-pages-server], [⚙️][gitea-caddy-plugin] | ✘ | ✓ | ✓ | ✓ | ✘ | ✘ | ✘ | +| Gists / Snippets | [⚙️][opengist] | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | Repo-specific wiki (as a repo itself) | ✓ | ✓ | ✓ | ✓ | ✓ | / | ✘ | ✘ | | Deploy Tokens | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | Repository Tokens with write rights | ✓ | ✘ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | @@ -147,3 +148,4 @@ _Symbols used in table:_ [gitea-caddy-plugin]: https://github.com/42wim/caddy-gitea [gitea-pages-server]: https://codeberg.org/Codeberg/pages-server +[opengist]: https://github.com/thomiceli/opengist From 930e38d010d59281550aeee5feac58e0b6085569 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 16 Jan 2024 15:13:07 +0800 Subject: [PATCH 10/76] Use refname:strip-2 instead of refname:short when syncing tags (#28797) Fix #28694 Generally, `refname:short` should be equal to `refname:lstrip=2` except `core.warnAmbiguousRefs is used to select the strict abbreviation mode.` ref: https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-refname --- modules/git/foreachref/format_test.go | 4 ++-- modules/git/repo_tag.go | 6 ++++-- modules/git/repo_tag_test.go | 18 +++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/git/foreachref/format_test.go b/modules/git/foreachref/format_test.go index 392a95a4e6..8ff239323c 100644 --- a/modules/git/foreachref/format_test.go +++ b/modules/git/foreachref/format_test.go @@ -49,9 +49,9 @@ func TestFormat_Flag(t *testing.T) { { name: "multiple fields", - givenFormat: foreachref.NewFormat("refname:short", "objecttype", "objectname"), + givenFormat: foreachref.NewFormat("refname:lstrip=2", "objecttype", "objectname"), - wantFlag: "refname:short %(refname:short)%00objecttype %(objecttype)%00objectname %(objectname)%00%00", + wantFlag: "refname:lstrip=2 %(refname:lstrip=2)%00objecttype %(objecttype)%00objectname %(objectname)%00%00", }, } diff --git a/modules/git/repo_tag.go b/modules/git/repo_tag.go index 698b9b41f3..af9a75b29c 100644 --- a/modules/git/repo_tag.go +++ b/modules/git/repo_tag.go @@ -112,7 +112,9 @@ func (repo *Repository) GetTagWithID(idStr, name string) (*Tag, error) { // GetTagInfos returns all tag infos of the repository. func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, int, error) { - forEachRefFmt := foreachref.NewFormat("objecttype", "refname:short", "object", "objectname", "creator", "contents", "contents:signature") + // Generally, refname:short should be equal to refname:lstrip=2 except core.warnAmbiguousRefs is used to select the strict abbreviation mode. + // https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-refname + forEachRefFmt := foreachref.NewFormat("objecttype", "refname:lstrip=2", "object", "objectname", "creator", "contents", "contents:signature") stdoutReader, stdoutWriter := io.Pipe() defer stdoutReader.Close() @@ -162,7 +164,7 @@ func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, int, error) { func parseTagRef(objectFormat ObjectFormat, ref map[string]string) (tag *Tag, err error) { tag = &Tag{ Type: ref["objecttype"], - Name: ref["refname:short"], + Name: ref["refname:lstrip=2"], } tag.ID, err = NewIDFromString(ref["objectname"]) diff --git a/modules/git/repo_tag_test.go b/modules/git/repo_tag_test.go index 6b9df1746f..da7b1455a8 100644 --- a/modules/git/repo_tag_test.go +++ b/modules/git/repo_tag_test.go @@ -208,8 +208,8 @@ func TestRepository_parseTagRef(t *testing.T) { name: "lightweight tag", givenRef: map[string]string{ - "objecttype": "commit", - "refname:short": "v1.9.1", + "objecttype": "commit", + "refname:lstrip=2": "v1.9.1", // object will be empty for lightweight tags "object": "", "objectname": "ab23e4b7f4cd0caafe0174c0e7ef6d651ba72889", @@ -237,8 +237,8 @@ func TestRepository_parseTagRef(t *testing.T) { name: "annotated tag", givenRef: map[string]string{ - "objecttype": "tag", - "refname:short": "v0.0.1", + "objecttype": "tag", + "refname:lstrip=2": "v0.0.1", // object will refer to commit hash for annotated tag "object": "3325fd8a973321fd59455492976c042dde3fd1ca", "objectname": "8c68a1f06fc59c655b7e3905b159d761e91c53c9", @@ -266,11 +266,11 @@ func TestRepository_parseTagRef(t *testing.T) { name: "annotated tag with signature", givenRef: map[string]string{ - "objecttype": "tag", - "refname:short": "v0.0.1", - "object": "3325fd8a973321fd59455492976c042dde3fd1ca", - "objectname": "8c68a1f06fc59c655b7e3905b159d761e91c53c9", - "creator": "Foo Bar 1565789218 +0300", + "objecttype": "tag", + "refname:lstrip=2": "v0.0.1", + "object": "3325fd8a973321fd59455492976c042dde3fd1ca", + "objectname": "8c68a1f06fc59c655b7e3905b159d761e91c53c9", + "creator": "Foo Bar 1565789218 +0300", "contents": `Add changelog of v1.9.1 (#7859) * add changelog of v1.9.1 From c08d263a1900aa5ee92f56af8ad1c7a2697d02e1 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 16 Jan 2024 20:54:48 +0800 Subject: [PATCH 11/76] Remove trust model selection from repository creation on web page because it can be changed in settings later (#28814) As more and more options can be set for creating the repository, I don't think we should put all of them into the creation web page which will make things look complicated and confusing. And I think we need some rules about how to decide which should/should not be put in creating a repository page. One rule I can imagine is if this option can be changed later and it's not a MUST on the creation, then it can be removed on the page. So I found trust model is the first one. This PR removed the trust model selections on creating a repository web page and kept others as before. This is also a preparation for #23894 which will add a choice about SHA1 or SHA256 that cannot be changed once the repository created. --- routers/web/repo/repo.go | 2 +- services/forms/repo_form.go | 8 -------- templates/repo/create.tmpl | 26 +------------------------- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index cd5eac057e..b5c550ae45 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -288,7 +288,7 @@ func CreatePost(ctx *context.Context) { DefaultBranch: form.DefaultBranch, AutoInit: form.AutoInit, IsTemplate: form.Template, - TrustModel: repo_model.ToTrustModel(form.TrustModel), + TrustModel: repo_model.DefaultTrustModel, ObjectFormatName: form.ObjectFormatName, }) if err == nil { diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 780fc88000..845eccf817 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -21,13 +21,6 @@ import ( "gitea.com/go-chi/binding" ) -// _______________________________________ _________.______________________ _______________.___. -// \______ \_ _____/\______ \_____ \ / _____/| \__ ___/\_____ \\______ \__ | | -// | _/| __)_ | ___// | \ \_____ \ | | | | / | \| _// | | -// | | \| \ | | / | \/ \| | | | / | \ | \\____ | -// |____|_ /_______ / |____| \_______ /_______ /|___| |____| \_______ /____|_ // ______| -// \/ \/ \/ \/ \/ \/ \/ - // CreateRepoForm form for creating repository type CreateRepoForm struct { UID int64 `binding:"Required"` @@ -50,7 +43,6 @@ type CreateRepoForm struct { Avatar bool Labels bool ProtectedBranch bool - TrustModel string ForkSingleBranch string ObjectFormatName string diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 7b2e51130f..3b4b994be7 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -61,7 +61,7 @@
- +
@@ -185,29 +185,6 @@ {{ctx.Locale.Tr "repo.default_branch_helper"}}
-
- - -
- {{ctx.Locale.Tr "repo.trust_model_helper"}} -
    -
  • {{ctx.Locale.Tr "repo.trust_model_helper_collaborator"}}
  • -
  • {{ctx.Locale.Tr "repo.trust_model_helper_committer"}}
  • -
  • {{ctx.Locale.Tr "repo.trust_model_helper_collaborator_committer"}}
  • -
  • {{ctx.Locale.Tr "repo.trust_model_helper_default"}}
  • -
-
-
@@ -216,7 +193,6 @@
-
From edfb57e6996367ec2c682fd7fdbdb405728c001f Mon Sep 17 00:00:00 2001 From: JakobDev Date: Tue, 16 Jan 2024 15:38:09 +0100 Subject: [PATCH 12/76] Render code block in activity tab (#28816) This is a little bugfix. Inline code is usually rendered in issue titles, but it is missing in the activity tab. Before: ![Screenshot 2024-01-16 at 14-20-51 Test](https://github.com/go-gitea/gitea/assets/15185051/383370f3-0fb2-49de-81cc-014e5cf86727) After: ![grafik](https://github.com/go-gitea/gitea/assets/15185051/83eaf973-ce9a-44ce-beea-2db49fc8bd73) --- templates/repo/activity.tmpl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl index fe592c0000..3149f20670 100644 --- a/templates/repo/activity.tmpl +++ b/templates/repo/activity.tmpl @@ -126,7 +126,7 @@ {{ctx.Locale.Tr "repo.activity.published_release_label"}} {{.TagName}} {{if not .IsTag}} - {{.Title | RenderEmoji $.Context}} + {{.Title | RenderEmoji $.Context | RenderCodeBlock}} {{end}} {{TimeSinceUnix .CreatedUnix ctx.Locale}}

@@ -146,7 +146,7 @@ {{range .Activity.MergedPRs}}

{{ctx.Locale.Tr "repo.activity.merged_prs_label"}} - #{{.Index}} {{.Issue.Title | RenderEmoji $.Context}} + #{{.Index}} {{.Issue.Title | RenderEmoji $.Context | RenderCodeBlock}} {{TimeSinceUnix .MergedUnix ctx.Locale}}

{{end}} @@ -165,7 +165,7 @@ {{range .Activity.OpenedPRs}}

{{ctx.Locale.Tr "repo.activity.opened_prs_label"}} - #{{.Index}} {{.Issue.Title | RenderEmoji $.Context}} + #{{.Index}} {{.Issue.Title | RenderEmoji $.Context | RenderCodeBlock}} {{TimeSinceUnix .Issue.CreatedUnix ctx.Locale}}

{{end}} @@ -184,7 +184,7 @@ {{range .Activity.ClosedIssues}}

{{ctx.Locale.Tr "repo.activity.closed_issue_label"}} - #{{.Index}} {{.Title | RenderEmoji $.Context}} + #{{.Index}} {{.Title | RenderEmoji $.Context | RenderCodeBlock}} {{TimeSinceUnix .ClosedUnix ctx.Locale}}

{{end}} @@ -203,7 +203,7 @@ {{range .Activity.OpenedIssues}}

{{ctx.Locale.Tr "repo.activity.new_issue_label"}} - #{{.Index}} {{.Title | RenderEmoji $.Context}} + #{{.Index}} {{.Title | RenderEmoji $.Context | RenderCodeBlock}} {{TimeSinceUnix .CreatedUnix ctx.Locale}}

{{end}} @@ -221,9 +221,9 @@ {{ctx.Locale.Tr "repo.activity.unresolved_conv_label"}} #{{.Index}} {{if .IsPull}} - {{.Title | RenderEmoji $.Context}} + {{.Title | RenderEmoji $.Context | RenderCodeBlock}} {{else}} - {{.Title | RenderEmoji $.Context}} + {{.Title | RenderEmoji $.Context | RenderCodeBlock}} {{end}} {{TimeSinceUnix .UpdatedUnix ctx.Locale}}

From b8270240bf53cdf4ed3267a395347272cf48b176 Mon Sep 17 00:00:00 2001 From: Mihir Joshi Date: Tue, 16 Jan 2024 20:36:51 +0530 Subject: [PATCH 13/76] Fix reverting a merge commit failing (#28794) Fixes #22236 --- Error occurring currently while trying to revert commit using read-tree -m approach: > 2022/12/26 16:04:43 ...rvices/pull/patch.go:240:AttemptThreeWayMerge() [E] [63a9c61a] Unable to run read-tree -m! Error: exit status 128 - fatal: this operation must be run in a work tree > - fatal: this operation must be run in a work tree We need to clone a non-bare repository for `git read-tree -m` to work. https://github.com/go-gitea/gitea/commit/bb371aee6ecf5e570cdf7b5f7f0d6f47a607a325 adds support to create a non-bare cloned temporary upload repository. After cloning a non-bare temporary upload repository, we [set default index](https://github.com/go-gitea/gitea/blob/main/services/repository/files/cherry_pick.go#L37) (`git read-tree HEAD`). This operation ends up resetting the git index file (see investigation details below), due to which, we need to call `git update-index --refresh` afterward. Here's the diff of the index file before and after we execute SetDefaultIndex: https://www.diffchecker.com/hyOP3eJy/ Notice the **ctime**, **mtime** are set to 0 after SetDefaultIndex. You can reproduce the same behavior using these steps: ```bash $ git clone https://try.gitea.io/me-heer/test.git -s -b main $ cd test $ git read-tree HEAD $ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00 error: Entry '1' not uptodate. Cannot merge. ``` After which, we can fix like this: ``` $ git update-index --refresh $ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00 ``` --- models/fixtures/repo_unit.yml | 7 ++++ models/fixtures/repository.yml | 13 +++++++ models/fixtures/user.yml | 2 +- services/packages/cargo/index.go | 2 +- services/repository/files/cherry_pick.go | 5 ++- services/repository/files/diff.go | 2 +- services/repository/files/patch.go | 2 +- services/repository/files/temp_repo.go | 17 +++++++-- services/repository/files/update.go | 2 +- services/repository/files/upload.go | 2 +- .../user2/test_commit_revert.git/HEAD | 1 + .../user2/test_commit_revert.git/config | 8 +++++ .../user2/test_commit_revert.git/description | 1 + .../user2/test_commit_revert.git/info/exclude | 6 ++++ ...200c8e6707636a6cc3e0d8101fba08b19dcb91.idx | Bin 0 -> 1268 bytes ...00c8e6707636a6cc3e0d8101fba08b19dcb91.pack | Bin 0 -> 609 bytes .../user2/test_commit_revert.git/packed-refs | 3 ++ .../repo_mergecommit_revert_test.go | 34 ++++++++++++++++++ 18 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 tests/gitea-repositories-meta/user2/test_commit_revert.git/HEAD create mode 100644 tests/gitea-repositories-meta/user2/test_commit_revert.git/config create mode 100644 tests/gitea-repositories-meta/user2/test_commit_revert.git/description create mode 100644 tests/gitea-repositories-meta/user2/test_commit_revert.git/info/exclude create mode 100644 tests/gitea-repositories-meta/user2/test_commit_revert.git/objects/pack/pack-91200c8e6707636a6cc3e0d8101fba08b19dcb91.idx create mode 100644 tests/gitea-repositories-meta/user2/test_commit_revert.git/objects/pack/pack-91200c8e6707636a6cc3e0d8101fba08b19dcb91.pack create mode 100644 tests/gitea-repositories-meta/user2/test_commit_revert.git/packed-refs create mode 100644 tests/integration/repo_mergecommit_revert_test.go diff --git a/models/fixtures/repo_unit.yml b/models/fixtures/repo_unit.yml index 0104419550..e6c59f527a 100644 --- a/models/fixtures/repo_unit.yml +++ b/models/fixtures/repo_unit.yml @@ -669,3 +669,10 @@ type: 10 config: "{}" created_unix: 946684810 + +- + id: 101 + repo_id: 59 + type: 1 + config: "{}" + created_unix: 946684810 diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 373c1caa62..f4e8376735 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -1693,3 +1693,16 @@ size: 0 is_fsck_enabled: true close_issues_via_commit_in_any_branch: false + +- + id: 59 + owner_id: 2 + owner_name: user2 + lower_name: test_commit_revert + name: test_commit_revert + default_branch: main + is_empty: false + is_archived: false + is_private: true + status: 0 + num_issues: 0 diff --git a/models/fixtures/user.yml b/models/fixtures/user.yml index fd51379816..79fbb981f6 100644 --- a/models/fixtures/user.yml +++ b/models/fixtures/user.yml @@ -66,7 +66,7 @@ num_followers: 2 num_following: 1 num_stars: 2 - num_repos: 14 + num_repos: 15 num_teams: 0 num_members: 0 visibility: 0 diff --git a/services/packages/cargo/index.go b/services/packages/cargo/index.go index 9514e35bed..e8a8313625 100644 --- a/services/packages/cargo/index.go +++ b/services/packages/cargo/index.go @@ -267,7 +267,7 @@ func alterRepositoryContent(ctx context.Context, doer *user_model.User, repo *re defer t.Close() var lastCommitID string - if err := t.Clone(repo.DefaultBranch); err != nil { + if err := t.Clone(repo.DefaultBranch, true); err != nil { if !git.IsErrBranchNotExist(err) || !repo.IsEmpty { return err } diff --git a/services/repository/files/cherry_pick.go b/services/repository/files/cherry_pick.go index e88ea16119..613b46d8f6 100644 --- a/services/repository/files/cherry_pick.go +++ b/services/repository/files/cherry_pick.go @@ -31,12 +31,15 @@ func CherryPick(ctx context.Context, repo *repo_model.Repository, doer *user_mod log.Error("%v", err) } defer t.Close() - if err := t.Clone(opts.OldBranch); err != nil { + if err := t.Clone(opts.OldBranch, false); err != nil { return nil, err } if err := t.SetDefaultIndex(); err != nil { return nil, err } + if err := t.RefreshIndex(); err != nil { + return nil, err + } // Get the commit of the original branch commit, err := t.GetBranchCommit(opts.OldBranch) diff --git a/services/repository/files/diff.go b/services/repository/files/diff.go index 373249b114..bf8b938e21 100644 --- a/services/repository/files/diff.go +++ b/services/repository/files/diff.go @@ -21,7 +21,7 @@ func GetDiffPreview(ctx context.Context, repo *repo_model.Repository, branch, tr return nil, err } defer t.Close() - if err := t.Clone(branch); err != nil { + if err := t.Clone(branch, true); err != nil { return nil, err } if err := t.SetDefaultIndex(); err != nil { diff --git a/services/repository/files/patch.go b/services/repository/files/patch.go index 96899e6e0e..14f8caaa8c 100644 --- a/services/repository/files/patch.go +++ b/services/repository/files/patch.go @@ -113,7 +113,7 @@ func ApplyDiffPatch(ctx context.Context, repo *repo_model.Repository, doer *user log.Error("%v", err) } defer t.Close() - if err := t.Clone(opts.OldBranch); err != nil { + if err := t.Clone(opts.OldBranch, true); err != nil { return nil, err } if err := t.SetDefaultIndex(); err != nil { diff --git a/services/repository/files/temp_repo.go b/services/repository/files/temp_repo.go index 6a0b7b675c..9fcd335c55 100644 --- a/services/repository/files/temp_repo.go +++ b/services/repository/files/temp_repo.go @@ -51,8 +51,13 @@ func (t *TemporaryUploadRepository) Close() { } // Clone the base repository to our path and set branch as the HEAD -func (t *TemporaryUploadRepository) Clone(branch string) error { - if _, _, err := git.NewCommand(t.ctx, "clone", "-s", "--bare", "-b").AddDynamicArguments(branch, t.repo.RepoPath(), t.basePath).RunStdString(nil); err != nil { +func (t *TemporaryUploadRepository) Clone(branch string, bare bool) error { + cmd := git.NewCommand(t.ctx, "clone", "-s", "-b").AddDynamicArguments(branch, t.repo.RepoPath(), t.basePath) + if bare { + cmd.AddArguments("--bare") + } + + if _, _, err := cmd.RunStdString(nil); err != nil { stderr := err.Error() if matched, _ := regexp.MatchString(".*Remote branch .* not found in upstream origin.*", stderr); matched { return git.ErrBranchNotExist{ @@ -97,6 +102,14 @@ func (t *TemporaryUploadRepository) SetDefaultIndex() error { return nil } +// RefreshIndex looks at the current index and checks to see if merges or updates are needed by checking stat() information. +func (t *TemporaryUploadRepository) RefreshIndex() error { + if _, _, err := git.NewCommand(t.ctx, "update-index", "--refresh").RunStdString(&git.RunOpts{Dir: t.basePath}); err != nil { + return fmt.Errorf("RefreshIndex: %w", err) + } + return nil +} + // LsFiles checks if the given filename arguments are in the index func (t *TemporaryUploadRepository) LsFiles(filenames ...string) ([]string, error) { stdOut := new(bytes.Buffer) diff --git a/services/repository/files/update.go b/services/repository/files/update.go index dd8d9ee425..1892043304 100644 --- a/services/repository/files/update.go +++ b/services/repository/files/update.go @@ -146,7 +146,7 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use } defer t.Close() hasOldBranch := true - if err := t.Clone(opts.OldBranch); err != nil { + if err := t.Clone(opts.OldBranch, true); err != nil { for _, file := range opts.Files { if file.Operation == "delete" { return nil, err diff --git a/services/repository/files/upload.go b/services/repository/files/upload.go index 61e38b55a3..cbfaf49d13 100644 --- a/services/repository/files/upload.go +++ b/services/repository/files/upload.go @@ -87,7 +87,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use defer t.Close() hasOldBranch := true - if err = t.Clone(opts.OldBranch); err != nil { + if err = t.Clone(opts.OldBranch, true); err != nil { if !git.IsErrBranchNotExist(err) || !repo.IsEmpty { return err } diff --git a/tests/gitea-repositories-meta/user2/test_commit_revert.git/HEAD b/tests/gitea-repositories-meta/user2/test_commit_revert.git/HEAD new file mode 100644 index 0000000000..b870d82622 --- /dev/null +++ b/tests/gitea-repositories-meta/user2/test_commit_revert.git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/tests/gitea-repositories-meta/user2/test_commit_revert.git/config b/tests/gitea-repositories-meta/user2/test_commit_revert.git/config new file mode 100644 index 0000000000..57bbcba5be --- /dev/null +++ b/tests/gitea-repositories-meta/user2/test_commit_revert.git/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + ignorecase = true + precomposeunicode = true +[remote "origin"] + url = https://try.gitea.io/me-heer/test_commit_revert.git diff --git a/tests/gitea-repositories-meta/user2/test_commit_revert.git/description b/tests/gitea-repositories-meta/user2/test_commit_revert.git/description new file mode 100644 index 0000000000..498b267a8c --- /dev/null +++ b/tests/gitea-repositories-meta/user2/test_commit_revert.git/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests/gitea-repositories-meta/user2/test_commit_revert.git/info/exclude b/tests/gitea-repositories-meta/user2/test_commit_revert.git/info/exclude new file mode 100644 index 0000000000..a5196d1be8 --- /dev/null +++ b/tests/gitea-repositories-meta/user2/test_commit_revert.git/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests/gitea-repositories-meta/user2/test_commit_revert.git/objects/pack/pack-91200c8e6707636a6cc3e0d8101fba08b19dcb91.idx b/tests/gitea-repositories-meta/user2/test_commit_revert.git/objects/pack/pack-91200c8e6707636a6cc3e0d8101fba08b19dcb91.idx new file mode 100644 index 0000000000000000000000000000000000000000..77bcbe7fb4caeaf783d375068e6ffad1a61ed6f9 GIT binary patch literal 1268 zcmexg;-AdGz`z8=v<8eo3&_PF_YD+g2HH(a%mOrj6c0=oumZz=pfMZJ4dh~WpkAtA ziT!>0sdIKX`Q+r7_O6Ur@4djIQr(9k=xzwdk9FE7To^R}r(d6a^sw8itW75x*G+gB zJLmjK_lrp}ojOnB{w=l+mP?F$x@Cip-r*TtF8d5W?KM9hE4Ed{`{q?8<@3(p#qS*Z z6?X6S>El699d>OwXZKwA@}K@YrklRMmHNzh>-92&^UoPf=J!P_8Ex$p5RAF4$7r)< z|M#umx9-w6^fNoBCjH=l=F9XikL7_y$T?t9-~gm0f!H62{{h2*2Ph^mQGur~ojo}# m=kS9Y0`j{!HqJdgaY~07L(uVgcZ<)l8XQVHe#P^wn?3-RA9Cve literal 0 HcmV?d00001 diff --git a/tests/gitea-repositories-meta/user2/test_commit_revert.git/objects/pack/pack-91200c8e6707636a6cc3e0d8101fba08b19dcb91.pack b/tests/gitea-repositories-meta/user2/test_commit_revert.git/objects/pack/pack-91200c8e6707636a6cc3e0d8101fba08b19dcb91.pack new file mode 100644 index 0000000000000000000000000000000000000000..7271cdaeb87741f0ed005bdae83367b7e3dd76ff GIT binary patch literal 609 zcmWG=boORoU|<4b_8F2DbLRH>`W-e9Y58t>baI49%d8{yD`ORpu-;JE=(f!`Pg%9F zAf9`#t*c0&blku9iJsbyWO}4;yFP z%7iHn>OIYzR$HvRT%NA^8pWv~9j*;B@8BN$p*G1 z_wCH-hqq<^duMh%m^c1IzWwt1r&vRF{EV|RS@eskb64Y;*G!GP6?0}E{4=r8>CO>5 zV>RZ(oyTRC@bZXm;caN>*50C^x=|%mQP)`gYQXv>i(0rD^doqK=5Ygq@QfqhAq5fF ziJvnG&>DY92Q5*&f8<>p`?>?xR*O$FPdH&E=56J^q+*+ic!g3mS89{@ zv53icL`*t=JX*?svmmBHQQ!W~yxN55@}tS&{iixseOrBH-khy&zZLku_@3Fj^;FM) z{zvmR>y);J{Ym@CsKRK~v6QJ|jfw5tr$LTYkrdPCAY9!vsuCoctS>5sd>}s!5 z&*$#%zHj+Wn}^}W1io*UAmv784~*?~gJPg+!^9h?kOkiYS{K0T~q5@A}I(u?f&fy0)1mt&dY@B;~A^`875 Date: Tue, 16 Jan 2024 23:52:19 +0200 Subject: [PATCH 14/76] Bump `@github/relative-time-element` to 4.3.1 (#28819) - Fixes https://github.com/go-gitea/gitea/issues/28747 # Before ![image](https://github.com/go-gitea/gitea/assets/20454870/65d8dc84-680f-4c16-9aa1-b5986102e4e7) # After ![image](https://github.com/go-gitea/gitea/assets/20454870/7cb288e7-ebde-4e94-a10a-cac28d6bdcfd) Signed-off-by: Yarden Shoham --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 52f8c3f1a4..5f4dc9bc2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@citation-js/plugin-software-formats": "0.6.1", "@claviska/jquery-minicolors": "2.3.6", "@github/markdown-toolbar-element": "2.2.1", - "@github/relative-time-element": "4.3.0", + "@github/relative-time-element": "4.3.1", "@github/text-expander-element": "2.6.1", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "19.8.0", @@ -1006,9 +1006,9 @@ "integrity": "sha512-ap+ulyqzG3aVqwKsKjbDdYwM75TQXZpPtmIuPwm+54OTgcC96267oX3cEqd1wSqGsH7O5PonZ//fE9jH7Q4JkA==" }, "node_modules/@github/relative-time-element": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@github/relative-time-element/-/relative-time-element-4.3.0.tgz", - "integrity": "sha512-+tFjX9//HRS1HnBa5cNgfEtE52arwiutYg1TOF+Trk40SPxst9Q8Rtc3BKD6aKsvfbtub68vfhipgchGjj9o7g==" + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@github/relative-time-element/-/relative-time-element-4.3.1.tgz", + "integrity": "sha512-zL79nlhZVCg7x2Pf/HT5MB0mowmErE71VXpF10/3Wy8dQwkninNO1M9aOizh2wKC5LkSpDXqNYjDZwbH0/bcSg==" }, "node_modules/@github/text-expander-element": { "version": "2.6.1", diff --git a/package.json b/package.json index dab7765091..801e85db83 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "@citation-js/plugin-software-formats": "0.6.1", "@claviska/jquery-minicolors": "2.3.6", "@github/markdown-toolbar-element": "2.2.1", - "@github/relative-time-element": "4.3.0", + "@github/relative-time-element": "4.3.1", "@github/text-expander-element": "2.6.1", "@mcaptcha/vanilla-glue": "0.1.0-alpha-3", "@primer/octicons": "19.8.0", From 49eb16867728913d1eb2ced96e0b0b0a358f6ebe Mon Sep 17 00:00:00 2001 From: Viktor Kuzmin Date: Wed, 17 Jan 2024 03:44:56 +0300 Subject: [PATCH 15/76] Retarget depending pulls when the parent branch is deleted (#28686) Sometimes you need to work on a feature which depends on another (unmerged) feature. In this case, you may create a PR based on that feature instead of the main branch. Currently, such PRs will be closed without the possibility to reopen in case the parent feature is merged and its branch is deleted. Automatic target branch change make life a lot easier in such cases. Github and Bitbucket behave in such way. Example: $PR_1$: main <- feature1 $PR_2$: feature1 <- feature2 Currently, merging $PR_1$ and deleting its branch leads to $PR_2$ being closed without the possibility to reopen. This is both annoying and loses the review history when you open a new PR. With this change, $PR_2$ will change its target branch to main ($PR_2$: main <- feature2) after $PR_1$ has been merged and its branch has been deleted. This behavior is enabled by default but can be disabled. For security reasons, this target branch change will not be executed when merging PRs targeting another repo. Fixes #27062 Fixes #18408 --------- Co-authored-by: Denys Konovalov Co-authored-by: delvh --- custom/conf/app.example.ini | 3 + .../config-cheat-sheet.en-us.md | 1 + modules/setting/repository.go | 3 + routers/api/v1/repo/pull.go | 4 + routers/web/repo/pull.go | 6 ++ services/pull/pull.go | 37 ++++++++ tests/integration/pull_create_test.go | 25 +++-- tests/integration/pull_merge_test.go | 95 ++++++++++++++++--- tests/integration/repo_activity_test.go | 8 +- 9 files changed, 158 insertions(+), 24 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 301e88b14e..b0875123b7 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1067,6 +1067,9 @@ LEVEL = Info ;; ;; In addition to testing patches using the three-way merge method, re-test conflicting patches with git apply ;TEST_CONFLICTING_PATCHES_WITH_GIT_APPLY = false +;; +;; Retarget child pull requests to the parent pull request branch target on merge of parent pull request. It only works on merged PRs where the head and base branch target the same repo. +;RETARGET_CHILDREN_ON_MERGE = true ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index c9e99ea54f..eb9b8d1ae9 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -135,6 +135,7 @@ In addition, there is _`StaticRootPath`_ which can be set as a built-in at build - `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`: **false**: In default squash-merge messages include the commit message of all commits comprising the pull request. - `ADD_CO_COMMITTER_TRAILERS`: **true**: Add co-authored-by and co-committed-by trailers to merge commit messages if committer does not match author. - `TEST_CONFLICTING_PATCHES_WITH_GIT_APPLY`: **false**: PR patches are tested using a three-way merge method to discover if there are conflicts. If this setting is set to **true**, conflicting patches will be retested using `git apply` - This was the previous behaviour in 1.18 (and earlier) but is somewhat inefficient. Please report if you find that this setting is required. +- `RETARGET_CHILDREN_ON_MERGE`: **true**: Retarget child pull requests to the parent pull request branch target on merge of parent pull request. It only works on merged PRs where the head and base branch target the same repo. ### Repository - Issue (`repository.issue`) diff --git a/modules/setting/repository.go b/modules/setting/repository.go index 9697a851d3..a6f0ed8833 100644 --- a/modules/setting/repository.go +++ b/modules/setting/repository.go @@ -85,6 +85,7 @@ var ( PopulateSquashCommentWithCommitMessages bool AddCoCommitterTrailers bool TestConflictingPatchesWithGitApply bool + RetargetChildrenOnMerge bool } `ini:"repository.pull-request"` // Issue Setting @@ -209,6 +210,7 @@ var ( PopulateSquashCommentWithCommitMessages bool AddCoCommitterTrailers bool TestConflictingPatchesWithGitApply bool + RetargetChildrenOnMerge bool }{ WorkInProgressPrefixes: []string{"WIP:", "[WIP]"}, // Same as GitHub. See @@ -223,6 +225,7 @@ var ( DefaultMergeMessageOfficialApproversOnly: true, PopulateSquashCommentWithCommitMessages: false, AddCoCommitterTrailers: true, + RetargetChildrenOnMerge: true, }, // Issue settings diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 34129ad595..b1cb7011f1 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -913,6 +913,10 @@ func MergePullRequest(ctx *context.APIContext) { } defer headRepo.Close() } + if err := pull_service.RetargetChildrenOnMerge(ctx, ctx.Doer, pr); err != nil { + ctx.Error(http.StatusInternalServerError, "RetargetChildrenOnMerge", err) + return + } if err := repo_service.DeleteBranch(ctx, ctx.Doer, pr.HeadRepo, headRepo, pr.HeadBranch); err != nil { switch { case git.IsErrBranchNotExist(err): diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 32d82b2a64..e36d7092af 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1587,6 +1587,12 @@ func CleanUpPullRequest(ctx *context.Context) { func deleteBranch(ctx *context.Context, pr *issues_model.PullRequest, gitRepo *git.Repository) { fullBranchName := pr.HeadRepo.FullName() + ":" + pr.HeadBranch + + if err := pull_service.RetargetChildrenOnMerge(ctx, ctx.Doer, pr); err != nil { + ctx.Flash.Error(ctx.Tr("repo.branch.deletion_failed", fullBranchName)) + return + } + if err := repo_service.DeleteBranch(ctx, ctx.Doer, pr.HeadRepo, gitRepo, pr.HeadBranch); err != nil { switch { case git.IsErrBranchNotExist(err): diff --git a/services/pull/pull.go b/services/pull/pull.go index d1630f3792..930954bdfd 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -546,6 +546,43 @@ func (errs errlist) Error() string { return "" } +// RetargetChildrenOnMerge retarget children pull requests on merge if possible +func RetargetChildrenOnMerge(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) error { + if setting.Repository.PullRequest.RetargetChildrenOnMerge && pr.BaseRepoID == pr.HeadRepoID { + return RetargetBranchPulls(ctx, doer, pr.HeadRepoID, pr.HeadBranch, pr.BaseBranch) + } + return nil +} + +// RetargetBranchPulls change target branch for all pull requests whose base branch is the branch +// Both branch and targetBranch must be in the same repo (for security reasons) +func RetargetBranchPulls(ctx context.Context, doer *user_model.User, repoID int64, branch, targetBranch string) error { + prs, err := issues_model.GetUnmergedPullRequestsByBaseInfo(ctx, repoID, branch) + if err != nil { + return err + } + + if err := issues_model.PullRequestList(prs).LoadAttributes(ctx); err != nil { + return err + } + + var errs errlist + for _, pr := range prs { + if err = pr.Issue.LoadRepo(ctx); err != nil { + errs = append(errs, err) + } else if err = ChangeTargetBranch(ctx, pr, doer, targetBranch); err != nil && + !issues_model.IsErrIssueIsClosed(err) && !models.IsErrPullRequestHasMerged(err) && + !issues_model.IsErrPullRequestAlreadyExists(err) { + errs = append(errs, err) + } + } + + if len(errs) > 0 { + return errs + } + return nil +} + // CloseBranchPulls close all the pull requests who's head branch is the branch func CloseBranchPulls(ctx context.Context, doer *user_model.User, repoID int64, branch string) error { prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(ctx, repoID, branch) diff --git a/tests/integration/pull_create_test.go b/tests/integration/pull_create_test.go index a6ee0d9dfa..029ea65d71 100644 --- a/tests/integration/pull_create_test.go +++ b/tests/integration/pull_create_test.go @@ -17,7 +17,7 @@ import ( "github.com/stretchr/testify/assert" ) -func testPullCreate(t *testing.T, session *TestSession, user, repo, branch, title string) *httptest.ResponseRecorder { +func testPullCreate(t *testing.T, session *TestSession, user, repo string, toSelf bool, targetBranch, sourceBranch, title string) *httptest.ResponseRecorder { req := NewRequest(t, "GET", path.Join(user, repo)) resp := session.MakeRequest(t, req, http.StatusOK) @@ -25,8 +25,21 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch, titl htmlDoc := NewHTMLParser(t, resp.Body) link, exists := htmlDoc.doc.Find("#new-pull-request").Attr("href") assert.True(t, exists, "The template has changed") - if branch != "master" { - link = strings.Replace(link, ":master", ":"+branch, 1) + + targetUser := strings.Split(link, "/")[1] + if toSelf && targetUser != user { + link = strings.Replace(link, targetUser, user, 1) + } + + if targetBranch != "master" { + link = strings.Replace(link, "master...", targetBranch+"...", 1) + } + if sourceBranch != "master" { + if targetUser == user { + link = strings.Replace(link, "...master", "..."+sourceBranch, 1) + } else { + link = strings.Replace(link, ":master", ":"+sourceBranch, 1) + } } req = NewRequest(t, "GET", link) @@ -49,7 +62,7 @@ func TestPullCreate(t *testing.T) { session := loginUser(t, "user1") testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title") // check the redirected URL url := test.RedirectURL(resp) @@ -77,7 +90,7 @@ func TestPullCreate_TitleEscape(t *testing.T) { session := loginUser(t, "user1") testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master", "XSS PR") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "XSS PR") // check the redirected URL url := test.RedirectURL(resp) @@ -142,7 +155,7 @@ func TestPullBranchDelete(t *testing.T) { testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testCreateBranch(t, session, "user1", "repo1", "branch/master", "master1", http.StatusSeeOther) testEditFile(t, session, "user1", "repo1", "master1", "README.md", "Hello, World (Edited)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master1", "This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master1", "This is a pull title") // check the redirected URL url := test.RedirectURL(resp) diff --git a/tests/integration/pull_merge_test.go b/tests/integration/pull_merge_test.go index 35af47f802..2aa6742a56 100644 --- a/tests/integration/pull_merge_test.go +++ b/tests/integration/pull_merge_test.go @@ -35,16 +35,23 @@ import ( "github.com/stretchr/testify/assert" ) -func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum string, mergeStyle repo_model.MergeStyle) *httptest.ResponseRecorder { +func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum string, mergeStyle repo_model.MergeStyle, deleteBranch bool) *httptest.ResponseRecorder { req := NewRequest(t, "GET", path.Join(user, repo, "pulls", pullnum)) resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) link := path.Join(user, repo, "pulls", pullnum, "merge") - req = NewRequestWithValues(t, "POST", link, map[string]string{ + + options := map[string]string{ "_csrf": htmlDoc.GetCSRF(), "do": string(mergeStyle), - }) + } + + if deleteBranch { + options["delete_branch_after_merge"] = "on" + } + + req = NewRequestWithValues(t, "POST", link, options) resp = session.MakeRequest(t, req, http.StatusOK) respJSON := struct { @@ -83,11 +90,11 @@ func TestPullMerge(t *testing.T) { testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title") elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) - testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge) + testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false) hookTasks, err = webhook.HookTasks(db.DefaultContext, 1, 1) assert.NoError(t, err) @@ -105,11 +112,11 @@ func TestPullRebase(t *testing.T) { testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title") elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) - testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebase) + testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebase, false) hookTasks, err = webhook.HookTasks(db.DefaultContext, 1, 1) assert.NoError(t, err) @@ -127,11 +134,11 @@ func TestPullRebaseMerge(t *testing.T) { testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title") elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) - testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebaseMerge) + testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebaseMerge, false) hookTasks, err = webhook.HookTasks(db.DefaultContext, 1, 1) assert.NoError(t, err) @@ -150,11 +157,11 @@ func TestPullSquash(t *testing.T) { testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited!)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title") elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) - testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleSquash) + testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleSquash, false) hookTasks, err = webhook.HookTasks(db.DefaultContext, 1, 1) assert.NoError(t, err) @@ -168,11 +175,11 @@ func TestPullCleanUpAfterMerge(t *testing.T) { testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feature/test", "README.md", "Hello, World (Edited - TestPullCleanUpAfterMerge)\n") - resp := testPullCreate(t, session, "user1", "repo1", "feature/test", "This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "feature/test", "This is a pull title") elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) - testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge) + testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false) // Check PR branch deletion resp = testPullCleanUp(t, session, elem[1], elem[2], elem[4]) @@ -203,7 +210,7 @@ func TestCantMergeWorkInProgress(t *testing.T) { testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master", "[wip] This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "[wip] This is a pull title") req := NewRequest(t, "GET", test.RedirectURL(resp)) resp = session.MakeRequest(t, req, http.StatusOK) @@ -435,3 +442,63 @@ func TestConflictChecking(t *testing.T) { assert.False(t, conflictingPR.Mergeable(db.DefaultContext)) }) } + +func TestPullRetargetChildOnBranchDelete(t *testing.T) { + onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) { + session := loginUser(t, "user1") + testEditFileToNewBranch(t, session, "user2", "repo1", "master", "base-pr", "README.md", "Hello, World\n(Edited - TestPullRetargetOnCleanup - base PR)\n") + testRepoFork(t, session, "user2", "repo1", "user1", "repo1") + testEditFileToNewBranch(t, session, "user1", "repo1", "base-pr", "child-pr", "README.md", "Hello, World\n(Edited - TestPullRetargetOnCleanup - base PR)\n(Edited - TestPullRetargetOnCleanup - child PR)") + + respBasePR := testPullCreate(t, session, "user2", "repo1", true, "master", "base-pr", "Base Pull Request") + elemBasePR := strings.Split(test.RedirectURL(respBasePR), "/") + assert.EqualValues(t, "pulls", elemBasePR[3]) + + respChildPR := testPullCreate(t, session, "user1", "repo1", false, "base-pr", "child-pr", "Child Pull Request") + elemChildPR := strings.Split(test.RedirectURL(respChildPR), "/") + assert.EqualValues(t, "pulls", elemChildPR[3]) + + testPullMerge(t, session, elemBasePR[1], elemBasePR[2], elemBasePR[4], repo_model.MergeStyleMerge, true) + + // Check child PR + req := NewRequest(t, "GET", test.RedirectURL(respChildPR)) + resp := session.MakeRequest(t, req, http.StatusOK) + + htmlDoc := NewHTMLParser(t, resp.Body) + targetBranch := htmlDoc.doc.Find("#branch_target>a").Text() + prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text()) + + assert.EqualValues(t, "master", targetBranch) + assert.EqualValues(t, "Open", prStatus) + }) +} + +func TestPullDontRetargetChildOnWrongRepo(t *testing.T) { + onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) { + session := loginUser(t, "user1") + testRepoFork(t, session, "user2", "repo1", "user1", "repo1") + testEditFileToNewBranch(t, session, "user1", "repo1", "master", "base-pr", "README.md", "Hello, World\n(Edited - TestPullDontRetargetChildOnWrongRepo - base PR)\n") + testEditFileToNewBranch(t, session, "user1", "repo1", "base-pr", "child-pr", "README.md", "Hello, World\n(Edited - TestPullDontRetargetChildOnWrongRepo - base PR)\n(Edited - TestPullDontRetargetChildOnWrongRepo - child PR)") + + respBasePR := testPullCreate(t, session, "user1", "repo1", false, "master", "base-pr", "Base Pull Request") + elemBasePR := strings.Split(test.RedirectURL(respBasePR), "/") + assert.EqualValues(t, "pulls", elemBasePR[3]) + + respChildPR := testPullCreate(t, session, "user1", "repo1", true, "base-pr", "child-pr", "Child Pull Request") + elemChildPR := strings.Split(test.RedirectURL(respChildPR), "/") + assert.EqualValues(t, "pulls", elemChildPR[3]) + + testPullMerge(t, session, elemBasePR[1], elemBasePR[2], elemBasePR[4], repo_model.MergeStyleMerge, true) + + // Check child PR + req := NewRequest(t, "GET", test.RedirectURL(respChildPR)) + resp := session.MakeRequest(t, req, http.StatusOK) + + htmlDoc := NewHTMLParser(t, resp.Body) + targetBranch := htmlDoc.doc.Find("#branch_target>a").Text() + prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text()) + + assert.EqualValues(t, "base-pr", targetBranch) + assert.EqualValues(t, "Closed", prStatus) + }) +} diff --git a/tests/integration/repo_activity_test.go b/tests/integration/repo_activity_test.go index c8d0c46d64..792554db4b 100644 --- a/tests/integration/repo_activity_test.go +++ b/tests/integration/repo_activity_test.go @@ -22,16 +22,16 @@ func TestRepoActivity(t *testing.T) { // Create PRs (1 merged & 2 proposed) testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") - resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title") + resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title") elem := strings.Split(test.RedirectURL(resp), "/") assert.EqualValues(t, "pulls", elem[3]) - testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge) + testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false) testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/better_readme", "README.md", "Hello, World (Edited Again)\n") - testPullCreate(t, session, "user1", "repo1", "feat/better_readme", "This is a pull title") + testPullCreate(t, session, "user1", "repo1", false, "master", "feat/better_readme", "This is a pull title") testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/much_better_readme", "README.md", "Hello, World (Edited More)\n") - testPullCreate(t, session, "user1", "repo1", "feat/much_better_readme", "This is a pull title") + testPullCreate(t, session, "user1", "repo1", false, "master", "feat/much_better_readme", "This is a pull title") // Create issues (3 new issues) testNewIssue(t, session, "user2", "repo1", "Issue 1", "Description 1") From ad98ea63ee62c3b9f994bfa6b1ecc8dde617f71f Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Wed, 17 Jan 2024 11:21:16 +0800 Subject: [PATCH 16/76] Fix uploaded artifacts should be overwritten (#28726) Fix `Uploaded artifacts should be overwritten` https://github.com/go-gitea/gitea/issues/28549 When upload different content to uploaded artifact, it checks that content size is not match in db record with previous artifact size, then the new artifact is refused. Now if it finds uploading content size is not matching db record when receiving chunks, it updates db records to follow the latest size value. --- routers/api/actions/artifacts.go | 9 +- routers/api/actions/artifacts_chunks.go | 9 +- .../integration/api_actions_artifact_test.go | 89 +++++++++++++++++++ 3 files changed, 104 insertions(+), 3 deletions(-) diff --git a/routers/api/actions/artifacts.go b/routers/api/actions/artifacts.go index 5bfcc9dfcd..0d2062ad05 100644 --- a/routers/api/actions/artifacts.go +++ b/routers/api/actions/artifacts.go @@ -257,8 +257,11 @@ func (ar artifactRoutes) uploadArtifact(ctx *ArtifactContext) { return } - // update artifact size if zero - if artifact.FileSize == 0 || artifact.FileCompressedSize == 0 { + // update artifact size if zero or not match, over write artifact size + if artifact.FileSize == 0 || + artifact.FileCompressedSize == 0 || + artifact.FileSize != fileRealTotalSize || + artifact.FileCompressedSize != chunksTotalSize { artifact.FileSize = fileRealTotalSize artifact.FileCompressedSize = chunksTotalSize artifact.ContentEncoding = ctx.Req.Header.Get("Content-Encoding") @@ -267,6 +270,8 @@ func (ar artifactRoutes) uploadArtifact(ctx *ArtifactContext) { ctx.Error(http.StatusInternalServerError, "Error update artifact") return } + log.Debug("[artifact] update artifact size, artifact_id: %d, size: %d, compressed size: %d", + artifact.ID, artifact.FileSize, artifact.FileCompressedSize) } ctx.JSON(http.StatusOK, map[string]string{ diff --git a/routers/api/actions/artifacts_chunks.go b/routers/api/actions/artifacts_chunks.go index 36432a0ca0..0713c8bba8 100644 --- a/routers/api/actions/artifacts_chunks.go +++ b/routers/api/actions/artifacts_chunks.go @@ -186,7 +186,14 @@ func mergeChunksForArtifact(ctx *ArtifactContext, chunks []*chunkFileItem, st st }() // save storage path to artifact - log.Debug("[artifact] merge chunks to artifact: %d, %s", artifact.ID, storagePath) + log.Debug("[artifact] merge chunks to artifact: %d, %s, old:%s", artifact.ID, storagePath, artifact.StoragePath) + // if artifact is already uploaded, delete the old file + if artifact.StoragePath != "" { + if err := st.Delete(artifact.StoragePath); err != nil { + log.Warn("Error deleting old artifact: %s, %v", artifact.StoragePath, err) + } + } + artifact.StoragePath = storagePath artifact.Status = int64(actions.ArtifactStatusUploadConfirmed) if err := actions.UpdateArtifactByID(ctx, artifact.ID, artifact); err != nil { diff --git a/tests/integration/api_actions_artifact_test.go b/tests/integration/api_actions_artifact_test.go index 2597d10374..ce2d14cc0c 100644 --- a/tests/integration/api_actions_artifact_test.go +++ b/tests/integration/api_actions_artifact_test.go @@ -287,3 +287,92 @@ func TestActionsArtifactUploadWithRetentionDays(t *testing.T) { AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") MakeRequest(t, req, http.StatusOK) } + +func TestActionsArtifactOverwrite(t *testing.T) { + defer tests.PrepareTestEnv(t)() + + { + // download old artifact uploaded by tests above, it should 1024 A + req := NewRequest(t, "GET", "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts"). + AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") + resp := MakeRequest(t, req, http.StatusOK) + var listResp listArtifactsResponse + DecodeJSON(t, resp, &listResp) + + idx := strings.Index(listResp.Value[0].FileContainerResourceURL, "/api/actions_pipeline/_apis/pipelines/") + url := listResp.Value[0].FileContainerResourceURL[idx+1:] + "?itemPath=artifact" + req = NewRequest(t, "GET", url). + AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") + resp = MakeRequest(t, req, http.StatusOK) + var downloadResp downloadArtifactResponse + DecodeJSON(t, resp, &downloadResp) + + idx = strings.Index(downloadResp.Value[0].ContentLocation, "/api/actions_pipeline/_apis/pipelines/") + url = downloadResp.Value[0].ContentLocation[idx:] + req = NewRequest(t, "GET", url). + AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") + resp = MakeRequest(t, req, http.StatusOK) + body := strings.Repeat("A", 1024) + assert.Equal(t, resp.Body.String(), body) + } + + { + // upload same artifact, it uses 4096 B + req := NewRequestWithJSON(t, "POST", "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts", getUploadArtifactRequest{ + Type: "actions_storage", + Name: "artifact", + }).AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") + resp := MakeRequest(t, req, http.StatusOK) + var uploadResp uploadArtifactResponse + DecodeJSON(t, resp, &uploadResp) + + idx := strings.Index(uploadResp.FileContainerResourceURL, "/api/actions_pipeline/_apis/pipelines/") + url := uploadResp.FileContainerResourceURL[idx:] + "?itemPath=artifact/abc.txt" + body := strings.Repeat("B", 4096) + req = NewRequestWithBody(t, "PUT", url, strings.NewReader(body)). + AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a"). + SetHeader("Content-Range", "bytes 0-4095/4096"). + SetHeader("x-tfs-filelength", "4096"). + SetHeader("x-actions-results-md5", "wUypcJFeZCK5T6r4lfqzqg==") // base64(md5(body)) + MakeRequest(t, req, http.StatusOK) + + // confirm artifact upload + req = NewRequest(t, "PATCH", "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts?artifactName=artifact"). + AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") + MakeRequest(t, req, http.StatusOK) + } + + { + // download artifact again, it should 4096 B + req := NewRequest(t, "GET", "/api/actions_pipeline/_apis/pipelines/workflows/791/artifacts"). + AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") + resp := MakeRequest(t, req, http.StatusOK) + var listResp listArtifactsResponse + DecodeJSON(t, resp, &listResp) + + var uploadedItem listArtifactsResponseItem + for _, item := range listResp.Value { + if item.Name == "artifact" { + uploadedItem = item + break + } + } + assert.Equal(t, uploadedItem.Name, "artifact") + + idx := strings.Index(uploadedItem.FileContainerResourceURL, "/api/actions_pipeline/_apis/pipelines/") + url := uploadedItem.FileContainerResourceURL[idx+1:] + "?itemPath=artifact" + req = NewRequest(t, "GET", url). + AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") + resp = MakeRequest(t, req, http.StatusOK) + var downloadResp downloadArtifactResponse + DecodeJSON(t, resp, &downloadResp) + + idx = strings.Index(downloadResp.Value[0].ContentLocation, "/api/actions_pipeline/_apis/pipelines/") + url = downloadResp.Value[0].ContentLocation[idx:] + req = NewRequest(t, "GET", url). + AddTokenAuth("8061e833a55f6fc0157c98b883e91fcfeeb1a71a") + resp = MakeRequest(t, req, http.StatusOK) + body := strings.Repeat("B", 4096) + assert.Equal(t, resp.Body.String(), body) + } +} From 2bdab948cbbd7b348621f853bb8aecd8a74aa3ee Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 17 Jan 2024 17:26:45 +0800 Subject: [PATCH 17/76] Add missing migration (#28827) Missed from #28498 --- models/migrations/migrations.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 578cbca035..3b4ac24a2c 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -552,6 +552,8 @@ var migrations = []Migration{ NewMigration("Add Index to pull_auto_merge.doer_id", v1_22.AddIndexToPullAutoMergeDoerID), // v283 -> v284 NewMigration("Add combined Index to issue_user.uid and issue_id", v1_22.AddCombinedIndexToIssueUser), + // v284 -> v285 + NewMigration("Add ignore stale approval column on branch table", v1_22.AddIgnoreStaleApprovalsColumnToProtectedBranchTable), } // GetCurrentDBVersion returns the current db version From c8ba17c73ff455ea381c8ab5a81f77d545a672fd Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 17 Jan 2024 17:56:00 +0800 Subject: [PATCH 18/76] Remove duplicated checkinit on git module (#28824) `checkInit` has been invoked in `InitSimple`. So it's unnecessary to invoke it twice in `InitFull`. --- modules/git/git.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/git/git.go b/modules/git/git.go index 166655eb73..24eff05afc 100644 --- a/modules/git/git.go +++ b/modules/git/git.go @@ -166,10 +166,6 @@ func InitSimple(ctx context.Context) error { // InitFull initializes git module with version check and change global variables, sync gitconfig. // It should only be called once at the beginning of the program initialization (TestMain/GlobalInitInstalled) as this code makes unsynchronized changes to variables. func InitFull(ctx context.Context) (err error) { - if err = checkInit(); err != nil { - return err - } - if err = InitSimple(ctx); err != nil { return err } From eba9c0ce48c7d43910eb77db74c6648157663ceb Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 17 Jan 2024 21:27:59 +0800 Subject: [PATCH 19/76] Add testing for CalcCommitStatus (#28823) --- models/git/commit_status_test.go | 115 +++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/models/git/commit_status_test.go b/models/git/commit_status_test.go index f7dd8597ed..74ba4a1006 100644 --- a/models/git/commit_status_test.go +++ b/models/git/commit_status_test.go @@ -60,3 +60,118 @@ func TestGetCommitStatuses(t *testing.T) { assert.Equal(t, int(maxResults), 5) assert.Empty(t, statuses) } + +func Test_CalcCommitStatus(t *testing.T) { + kases := []struct { + statuses []*git_model.CommitStatus + expected *git_model.CommitStatus + }{ + { + statuses: []*git_model.CommitStatus{ + { + State: structs.CommitStatusPending, + }, + }, + expected: &git_model.CommitStatus{ + State: structs.CommitStatusPending, + }, + }, + { + statuses: []*git_model.CommitStatus{ + { + State: structs.CommitStatusSuccess, + }, + { + State: structs.CommitStatusPending, + }, + }, + expected: &git_model.CommitStatus{ + State: structs.CommitStatusPending, + }, + }, + { + statuses: []*git_model.CommitStatus{ + { + State: structs.CommitStatusSuccess, + }, + { + State: structs.CommitStatusPending, + }, + { + State: structs.CommitStatusSuccess, + }, + }, + expected: &git_model.CommitStatus{ + State: structs.CommitStatusPending, + }, + }, + { + statuses: []*git_model.CommitStatus{ + { + State: structs.CommitStatusError, + }, + { + State: structs.CommitStatusPending, + }, + { + State: structs.CommitStatusSuccess, + }, + }, + expected: &git_model.CommitStatus{ + State: structs.CommitStatusError, + }, + }, + { + statuses: []*git_model.CommitStatus{ + { + State: structs.CommitStatusWarning, + }, + { + State: structs.CommitStatusPending, + }, + { + State: structs.CommitStatusSuccess, + }, + }, + expected: &git_model.CommitStatus{ + State: structs.CommitStatusWarning, + }, + }, + { + statuses: []*git_model.CommitStatus{ + { + State: structs.CommitStatusSuccess, + }, + { + State: structs.CommitStatusSuccess, + }, + { + State: structs.CommitStatusSuccess, + }, + }, + expected: &git_model.CommitStatus{ + State: structs.CommitStatusSuccess, + }, + }, + { + statuses: []*git_model.CommitStatus{ + { + State: structs.CommitStatusFailure, + }, + { + State: structs.CommitStatusError, + }, + { + State: structs.CommitStatusWarning, + }, + }, + expected: &git_model.CommitStatus{ + State: structs.CommitStatusError, + }, + }, + } + + for _, kase := range kases { + assert.Equal(t, kase.expected, git_model.CalcCommitStatus(kase.statuses)) + } +} From 4674aea25b54baf08594c54f061dee9e44190f02 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Thu, 18 Jan 2024 19:27:07 +0900 Subject: [PATCH 20/76] Fix display latest sync time for pull mirrors on the repo page (#28841) Follow #28712 1. Missing Locale word `mirror_sync` 2. Maybe forgot checking the conflict from #27760 Before: ![image](https://github.com/go-gitea/gitea/assets/18380374/6100d35b-7fe3-4095-9c24-7875568f7380) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/69647169-b812-45bc-a267-ab28f2df6ef6) --- options/locale/locale_en-US.ini | 1 + templates/repo/header.tmpl | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 90e3ac503a..6f9ba8c884 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -987,6 +987,7 @@ mirror_prune = Prune mirror_prune_desc = Remove obsolete remote-tracking references mirror_interval = Mirror Interval (valid time units are 'h', 'm', 's'). 0 to disable periodic sync. (Minimum interval: %s) mirror_interval_invalid = The mirror interval is not valid. +mirror_sync = synced mirror_sync_on_commit = Sync when commits are pushed mirror_address = Clone From URL mirror_address_desc = Put any required credentials in the Authorization section. diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index c362059ef3..a5ef8daa9a 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -28,13 +28,6 @@
{{svg "octicon-repo-template" 18}}
{{end}}
- {{if $.PullMirror}} -
- {{ctx.Locale.Tr "repo.mirror_from"}} - {{$.PullMirror.RemoteAddress}} - {{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{TimeSinceUnix $.PullMirror.UpdatedUnix ctx.Locale}}{{end}} -
- {{end}}
{{if not (or .IsBeingCreated .IsBroken)}}
@@ -147,7 +140,13 @@
{{end}}
- {{if $.PullMirror}}
{{ctx.Locale.Tr "repo.mirror_from"}} {{$.PullMirror.RemoteAddress}}
{{end}} + {{if $.PullMirror}} +
+ {{ctx.Locale.Tr "repo.mirror_from"}} + {{$.PullMirror.RemoteAddress}} + {{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{TimeSinceUnix $.PullMirror.UpdatedUnix ctx.Locale}}{{end}} +
+ {{end}} {{if .IsFork}}
{{ctx.Locale.Tr "repo.forked_from"}} {{.BaseRepo.FullName}}
{{end}} {{if .IsGenerated}}
{{ctx.Locale.Tr "repo.generated_from"}} {{(.TemplateRepo ctx).FullName}}
{{end}}

From b60a7c3358cdeec3e0a731b68be33b6ba63a6563 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 19 Jan 2024 11:45:23 +0900 Subject: [PATCH 21/76] Return `responseText` instead of string in some functions (#28836) Follow https://github.com/go-gitea/gitea/pull/28796#issuecomment-1891727591 --- cmd/actions.go | 2 +- cmd/keys.go | 2 +- cmd/mailer.go | 2 +- modules/private/actions.go | 8 ++------ modules/private/hook.go | 6 +++--- modules/private/key.go | 10 +++------- modules/private/mail.go | 8 ++------ modules/private/request.go | 10 +++++----- 8 files changed, 18 insertions(+), 30 deletions(-) diff --git a/cmd/actions.go b/cmd/actions.go index 275fd7904e..f582c16c81 100644 --- a/cmd/actions.go +++ b/cmd/actions.go @@ -50,6 +50,6 @@ func runGenerateActionsRunnerToken(c *cli.Context) error { if extra.HasError() { return handleCliResponseExtra(extra) } - _, _ = fmt.Printf("%s\n", respText) + _, _ = fmt.Printf("%s\n", respText.Text) return nil } diff --git a/cmd/keys.go b/cmd/keys.go index 9d5278f109..ceeec48486 100644 --- a/cmd/keys.go +++ b/cmd/keys.go @@ -78,6 +78,6 @@ func runKeys(c *cli.Context) error { if extra.Error != nil { return extra.Error } - _, _ = fmt.Fprintln(c.App.Writer, strings.TrimSpace(authorizedString)) + _, _ = fmt.Fprintln(c.App.Writer, strings.TrimSpace(authorizedString.Text)) return nil } diff --git a/cmd/mailer.go b/cmd/mailer.go index 646330e85a..0c5f2c8c8d 100644 --- a/cmd/mailer.go +++ b/cmd/mailer.go @@ -45,6 +45,6 @@ func runSendMail(c *cli.Context) error { if extra.HasError() { return handleCliResponseExtra(extra) } - _, _ = fmt.Printf("Sent %s email(s) to all users\n", respText) + _, _ = fmt.Printf("Sent %s email(s) to all users\n", respText.Text) return nil } diff --git a/modules/private/actions.go b/modules/private/actions.go index a22833632e..311a283650 100644 --- a/modules/private/actions.go +++ b/modules/private/actions.go @@ -14,16 +14,12 @@ type GenerateTokenRequest struct { } // GenerateActionsRunnerToken calls the internal GenerateActionsRunnerToken function -func GenerateActionsRunnerToken(ctx context.Context, scope string) (string, ResponseExtra) { +func GenerateActionsRunnerToken(ctx context.Context, scope string) (*ResponseText, ResponseExtra) { reqURL := setting.LocalURL + "api/internal/actions/generate_actions_runner_token" req := newInternalRequest(ctx, reqURL, "POST", GenerateTokenRequest{ Scope: scope, }) - resp, extra := requestJSONResp(req, &responseText{}) - if extra.HasError() { - return "", extra - } - return resp.Text, extra + return requestJSONResp(req, &ResponseText{}) } diff --git a/modules/private/hook.go b/modules/private/hook.go index 23e03896e4..cab8c81224 100644 --- a/modules/private/hook.go +++ b/modules/private/hook.go @@ -101,7 +101,7 @@ func HookPreReceive(ctx context.Context, ownerName, repoName string, opts HookOp reqURL := setting.LocalURL + fmt.Sprintf("api/internal/hook/pre-receive/%s/%s", url.PathEscape(ownerName), url.PathEscape(repoName)) req := newInternalRequest(ctx, reqURL, "POST", opts) req.SetReadWriteTimeout(time.Duration(60+len(opts.OldCommitIDs)) * time.Second) - _, extra := requestJSONResp(req, &responseText{}) + _, extra := requestJSONResp(req, &ResponseText{}) return extra } @@ -130,7 +130,7 @@ func SetDefaultBranch(ctx context.Context, ownerName, repoName, branch string) R url.PathEscape(branch), ) req := newInternalRequest(ctx, reqURL, "POST") - _, extra := requestJSONResp(req, &responseText{}) + _, extra := requestJSONResp(req, &ResponseText{}) return extra } @@ -138,6 +138,6 @@ func SetDefaultBranch(ctx context.Context, ownerName, repoName, branch string) R func SSHLog(ctx context.Context, isErr bool, msg string) error { reqURL := setting.LocalURL + "api/internal/ssh/log" req := newInternalRequest(ctx, reqURL, "POST", &SSHLogOption{IsError: isErr, Message: msg}) - _, extra := requestJSONResp(req, &responseText{}) + _, extra := requestJSONResp(req, &ResponseText{}) return extra.Error } diff --git a/modules/private/key.go b/modules/private/key.go index 08762bd401..dcd1714856 100644 --- a/modules/private/key.go +++ b/modules/private/key.go @@ -15,20 +15,16 @@ func UpdatePublicKeyInRepo(ctx context.Context, keyID, repoID int64) error { // Ask for running deliver hook and test pull request tasks. reqURL := setting.LocalURL + fmt.Sprintf("api/internal/ssh/%d/update/%d", keyID, repoID) req := newInternalRequest(ctx, reqURL, "POST") - _, extra := requestJSONResp(req, &responseText{}) + _, extra := requestJSONResp(req, &ResponseText{}) return extra.Error } // AuthorizedPublicKeyByContent searches content as prefix (leak e-mail part) // and returns public key found. -func AuthorizedPublicKeyByContent(ctx context.Context, content string) (string, ResponseExtra) { +func AuthorizedPublicKeyByContent(ctx context.Context, content string) (*ResponseText, ResponseExtra) { // Ask for running deliver hook and test pull request tasks. reqURL := setting.LocalURL + "api/internal/ssh/authorized_keys" req := newInternalRequest(ctx, reqURL, "POST") req.Param("content", content) - resp, extra := requestJSONResp(req, &responseText{}) - if extra.HasError() { - return "", extra - } - return resp.Text, extra + return requestJSONResp(req, &ResponseText{}) } diff --git a/modules/private/mail.go b/modules/private/mail.go index ac55d6fe4d..08de5b7e28 100644 --- a/modules/private/mail.go +++ b/modules/private/mail.go @@ -20,7 +20,7 @@ type Email struct { // It accepts a list of usernames. // If DB contains these users it will send the email to them. // If to list == nil, it's supposed to send emails to every user present in DB -func SendEmail(ctx context.Context, subject, message string, to []string) (string, ResponseExtra) { +func SendEmail(ctx context.Context, subject, message string, to []string) (*ResponseText, ResponseExtra) { reqURL := setting.LocalURL + "api/internal/mail/send" req := newInternalRequest(ctx, reqURL, "POST", Email{ @@ -29,9 +29,5 @@ func SendEmail(ctx context.Context, subject, message string, to []string) (strin To: to, }) - resp, extra := requestJSONResp(req, &responseText{}) - if extra.HasError() { - return "", extra - } - return resp.Text, extra + return requestJSONResp(req, &ResponseText{}) } diff --git a/modules/private/request.go b/modules/private/request.go index 2bc43b972d..58cd261239 100644 --- a/modules/private/request.go +++ b/modules/private/request.go @@ -12,8 +12,8 @@ import ( "code.gitea.io/gitea/modules/json" ) -// responseText is used to get the response as text, instead of parsing it as JSON. -type responseText struct { +// ResponseText is used to get the response as text, instead of parsing it as JSON. +type ResponseText struct { Text string } @@ -50,7 +50,7 @@ func (re responseError) Error() string { // Caller should check the ResponseExtra.HasError() first to see whether the request fails. // // * If the "res" is a struct pointer, the response will be parsed as JSON -// * If the "res" is responseText pointer, the response will be stored as text in it +// * If the "res" is ResponseText pointer, the response will be stored as text in it // * If the "res" is responseCallback pointer, the callback function should set the ResponseExtra fields accordingly func requestJSONResp[T any](req *httplib.Request, res *T) (ret *T, extra ResponseExtra) { resp, err := req.Response() @@ -81,7 +81,7 @@ func requestJSONResp[T any](req *httplib.Request, res *T) (ret *T, extra Respons // now, the StatusCode must be 2xx var v any = res - if respText, ok := v.(*responseText); ok { + if respText, ok := v.(*ResponseText); ok { // get the whole response as a text string bs, err := io.ReadAll(resp.Body) if err != nil { @@ -119,7 +119,7 @@ func requestJSONResp[T any](req *httplib.Request, res *T) (ret *T, extra Respons // requestJSONClientMsg sends a request to the gitea server, server only responds text message status=200 with "success" body // If the request succeeds (200), the argument clientSuccessMsg will be used as ResponseExtra.UserMsg. func requestJSONClientMsg(req *httplib.Request, clientSuccessMsg string) ResponseExtra { - _, extra := requestJSONResp(req, &responseText{}) + _, extra := requestJSONResp(req, &ResponseText{}) if extra.HasError() { return extra } From 1167d523c4c24eba4c159cda04e49a49f458afbf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 19 Jan 2024 06:49:18 +0100 Subject: [PATCH 22/76] Fix archive creating LFS hooks and breaking pull requests (#28848) When LFS hooks are present in gitea-repositories, operations like git push for creating a pull request fail. These repositories are not meant to include LFS files or git push them, that is handled separately. And so they should not have LFS hooks. Installing git-lfs on some systems (like Debian Linux) will automatically set up /etc/gitconfig to create LFS hooks in repositories. For most git commands in Gitea this is not a problem, either because they run on a temporary clone or the git command does not create LFS hooks. But one case where this happens is git archive for creating repository archives. To fix that, add a GIT_CONFIG_NOSYSTEM=1 to disable using the system configuration for that command. According to a comment, GIT_CONFIG_NOSYSTEM is not used for all git commands because the system configuration can be intentionally set up for Gitea to use. Resolves #19810, #21148 --- modules/git/repo_archive.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/git/repo_archive.go b/modules/git/repo_archive.go index 2b45a50f19..1bf1aa41b9 100644 --- a/modules/git/repo_archive.go +++ b/modules/git/repo_archive.go @@ -8,6 +8,7 @@ import ( "context" "fmt" "io" + "os" "path/filepath" "strings" ) @@ -62,11 +63,15 @@ func (repo *Repository) CreateArchive(ctx context.Context, format ArchiveType, t cmd.AddOptionFormat("--format=%s", format.String()) cmd.AddDynamicArguments(commitID) + // Avoid LFS hooks getting installed because of /etc/gitconfig, which can break pull requests. + env := append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1") + var stderr strings.Builder err := cmd.Run(&RunOpts{ Dir: repo.Path, Stdout: target, Stderr: &stderr, + Env: env, }) if err != nil { return ConcatenateError(err, stderr.String()) From 075c4c89ee28590bd4ab8f6cf7338d723c4696eb Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Fri, 19 Jan 2024 07:12:21 +0000 Subject: [PATCH 23/76] tests: missing refs/ in bare repositories (#28844) Git 2.43.0 will not detect a git repository as valid without refs/ subdirectory present. `git gc` cleans this up and puts it in packed-refs. We must keep refs/ non-empty. --- .../user2/test_commit_revert.git/refs/heads/main | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/gitea-repositories-meta/user2/test_commit_revert.git/refs/heads/main diff --git a/tests/gitea-repositories-meta/user2/test_commit_revert.git/refs/heads/main b/tests/gitea-repositories-meta/user2/test_commit_revert.git/refs/heads/main new file mode 100644 index 0000000000..ab80ca3ca6 --- /dev/null +++ b/tests/gitea-repositories-meta/user2/test_commit_revert.git/refs/heads/main @@ -0,0 +1 @@ +deebcbc752e540bab4ce3ee713d3fc8fdc35b2f7 From 461d8b53c2e51a8a6a1715ba40ac61d7e9f93971 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 19 Jan 2024 12:37:10 +0100 Subject: [PATCH 24/76] Fix some RPM registry flaws (#28782) Related #26984 (https://github.com/go-gitea/gitea/pull/26984#issuecomment-1889588912) Fix admin cleanup message. Fix models `Get` not respecting default values. Rebuild RPM repository files after cleanup. Do not add RPM group to package version name. Force stable sorting of Alpine/Debian/RPM repository data. Fix missing deferred `Close`. Add tests for multiple RPM groups. Removed non-cached `ReplaceAllStringRegex`. If there are multiple groups available, it's stated in the package installation screen: ![grafik](https://github.com/go-gitea/gitea/assets/1666336/8f132760-882c-4ab8-9678-77e47dfc4415) --- docs/content/usage/packages/rpm.en-us.md | 49 +- models/packages/package.go | 14 +- models/packages/package_blob.go | 12 +- models/packages/package_file.go | 26 +- models/packages/package_version.go | 12 +- models/packages/rpm/search.go | 23 + modules/packages/rpm/metadata.go | 5 +- modules/templates/util_string.go | 5 - modules/util/slice.go | 8 + options/locale/locale_en-US.ini | 3 + routers/api/packages/api.go | 148 +++-- routers/api/packages/rpm/rpm.go | 31 +- routers/web/admin/packages.go | 2 +- routers/web/user/package.go | 30 +- services/packages/cleanup/cleanup.go | 5 + services/packages/rpm/repository.go | 69 ++- templates/package/content/rpm.tmpl | 32 +- tests/integration/api_packages_rpm_test.go | 638 +++++++++++---------- 18 files changed, 634 insertions(+), 478 deletions(-) create mode 100644 models/packages/rpm/search.go diff --git a/docs/content/usage/packages/rpm.en-us.md b/docs/content/usage/packages/rpm.en-us.md index 586e48d47f..1f93376b7b 100644 --- a/docs/content/usage/packages/rpm.en-us.md +++ b/docs/content/usage/packages/rpm.en-us.md @@ -24,16 +24,26 @@ The following examples use `dnf`. ## Configuring the package registry -To register the RPM registry add the url to the list of known apt sources: +To register the RPM registry add the url to the list of known sources: ```shell dnf config-manager --add-repo https://gitea.example.com/api/packages/{owner}/rpm/{group}.repo ``` -| Placeholder | Description | -| ----------- |----------------------------------------------------| -| `owner` | The owner of the package. | -| `group` | Everything, e.g. `el7`, `rocky/el9` , `test/fc38`.| +| Placeholder | Description | +| ----------- | ----------- | +| `owner` | The owner of the package. | +| `group` | Optional: Everything, e.g. empty, `el7`, `rocky/el9`, `test/fc38`. | + +Example: + +```shell +# without a group +dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm.repo + +# with the group 'centos/el7' +dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm/centos/el7.repo +``` If the registry is private, provide credentials in the url. You can use a password or a [personal access token](development/api-usage.md#authentication): @@ -41,7 +51,7 @@ If the registry is private, provide credentials in the url. You can use a passwo dnf config-manager --add-repo https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/rpm/{group}.repo ``` -You have to add the credentials to the urls in the `rpm.repo` file in `/etc/yum.repos.d` too. +You have to add the credentials to the urls in the created `.repo` file in `/etc/yum.repos.d` too. ## Publish a package @@ -54,11 +64,17 @@ PUT https://gitea.example.com/api/packages/{owner}/rpm/{group}/upload | Parameter | Description | | --------- | ----------- | | `owner` | The owner of the package. | -| `group` | Everything, e.g. `el7`, `rocky/el9` , `test/fc38`.| +| `group` | Optional: Everything, e.g. empty, `el7`, `rocky/el9`, `test/fc38`. | Example request using HTTP Basic authentication: ```shell +# without a group +curl --user your_username:your_password_or_token \ + --upload-file path/to/file.rpm \ + https://gitea.example.com/api/packages/testuser/rpm/upload + +# with the group 'centos/el7' curl --user your_username:your_password_or_token \ --upload-file path/to/file.rpm \ https://gitea.example.com/api/packages/testuser/rpm/centos/el7/upload @@ -83,17 +99,22 @@ To delete an RPM package perform a HTTP DELETE operation. This will delete the p DELETE https://gitea.example.com/api/packages/{owner}/rpm/{group}/package/{package_name}/{package_version}/{architecture} ``` -| Parameter | Description | -|-------------------|----------------------------| -| `owner` | The owner of the package. | -| `group` | The package group . | -| `package_name` | The package name. | -| `package_version` | The package version. | -| `architecture` | The package architecture. | +| Parameter | Description | +| ----------------- | ----------- | +| `owner` | The owner of the package. | +| `group` | Optional: The package group. | +| `package_name` | The package name. | +| `package_version` | The package version. | +| `architecture` | The package architecture. | Example request using HTTP Basic authentication: ```shell +# without a group +curl --user your_username:your_token_or_password -X DELETE \ + https://gitea.example.com/api/packages/testuser/rpm/package/test-package/1.0.0/x86_64 + +# with the group 'centos/el7' curl --user your_username:your_token_or_password -X DELETE \ https://gitea.example.com/api/packages/testuser/rpm/centos/el7/package/test-package/1.0.0/x86_64 ``` diff --git a/models/packages/package.go b/models/packages/package.go index 380a076f9d..65a2574150 100644 --- a/models/packages/package.go +++ b/models/packages/package.go @@ -191,18 +191,18 @@ type Package struct { func TryInsertPackage(ctx context.Context, p *Package) (*Package, error) { e := db.GetEngine(ctx) - key := &Package{ - OwnerID: p.OwnerID, - Type: p.Type, - LowerName: p.LowerName, - } + existing := &Package{} - has, err := e.Get(key) + has, err := e.Where(builder.Eq{ + "owner_id": p.OwnerID, + "type": p.Type, + "lower_name": p.LowerName, + }).Get(existing) if err != nil { return nil, err } if has { - return key, ErrDuplicatePackage + return existing, ErrDuplicatePackage } if _, err = e.Insert(p); err != nil { return nil, err diff --git a/models/packages/package_blob.go b/models/packages/package_blob.go index d1f470d520..d9c30b6533 100644 --- a/models/packages/package_blob.go +++ b/models/packages/package_blob.go @@ -41,12 +41,20 @@ type PackageBlob struct { func GetOrInsertBlob(ctx context.Context, pb *PackageBlob) (*PackageBlob, bool, error) { e := db.GetEngine(ctx) - has, err := e.Get(pb) + existing := &PackageBlob{} + + has, err := e.Where(builder.Eq{ + "size": pb.Size, + "hash_md5": pb.HashMD5, + "hash_sha1": pb.HashSHA1, + "hash_sha256": pb.HashSHA256, + "hash_sha512": pb.HashSHA512, + }).Get(existing) if err != nil { return nil, false, err } if has { - return pb, true, nil + return existing, true, nil } if _, err = e.Insert(pb); err != nil { return nil, false, err diff --git a/models/packages/package_file.go b/models/packages/package_file.go index 1c2c9ac072..1bb6b57a34 100644 --- a/models/packages/package_file.go +++ b/models/packages/package_file.go @@ -46,18 +46,18 @@ type PackageFile struct { func TryInsertFile(ctx context.Context, pf *PackageFile) (*PackageFile, error) { e := db.GetEngine(ctx) - key := &PackageFile{ - VersionID: pf.VersionID, - LowerName: pf.LowerName, - CompositeKey: pf.CompositeKey, - } + existing := &PackageFile{} - has, err := e.Get(key) + has, err := e.Where(builder.Eq{ + "version_id": pf.VersionID, + "lower_name": pf.LowerName, + "composite_key": pf.CompositeKey, + }).Get(existing) if err != nil { return nil, err } if has { - return pf, ErrDuplicatePackageFile + return existing, ErrDuplicatePackageFile } if _, err = e.Insert(pf); err != nil { return nil, err @@ -93,13 +93,13 @@ func GetFileForVersionByName(ctx context.Context, versionID int64, name, key str return nil, ErrPackageFileNotExist } - pf := &PackageFile{ - VersionID: versionID, - LowerName: strings.ToLower(name), - CompositeKey: key, - } + pf := &PackageFile{} - has, err := db.GetEngine(ctx).Get(pf) + has, err := db.GetEngine(ctx).Where(builder.Eq{ + "version_id": versionID, + "lower_name": strings.ToLower(name), + "composite_key": key, + }).Get(pf) if err != nil { return nil, err } diff --git a/models/packages/package_version.go b/models/packages/package_version.go index 9999fc4dab..8fc475691b 100644 --- a/models/packages/package_version.go +++ b/models/packages/package_version.go @@ -39,17 +39,17 @@ type PackageVersion struct { func GetOrInsertVersion(ctx context.Context, pv *PackageVersion) (*PackageVersion, error) { e := db.GetEngine(ctx) - key := &PackageVersion{ - PackageID: pv.PackageID, - LowerVersion: pv.LowerVersion, - } + existing := &PackageVersion{} - has, err := e.Get(key) + has, err := e.Where(builder.Eq{ + "package_id": pv.PackageID, + "lower_version": pv.LowerVersion, + }).Get(existing) if err != nil { return nil, err } if has { - return key, ErrDuplicatePackageVersion + return existing, ErrDuplicatePackageVersion } if _, err = e.Insert(pv); err != nil { return nil, err diff --git a/models/packages/rpm/search.go b/models/packages/rpm/search.go new file mode 100644 index 0000000000..e697421b49 --- /dev/null +++ b/models/packages/rpm/search.go @@ -0,0 +1,23 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package rpm + +import ( + "context" + + packages_model "code.gitea.io/gitea/models/packages" + rpm_module "code.gitea.io/gitea/modules/packages/rpm" +) + +// GetGroups gets all available groups +func GetGroups(ctx context.Context, ownerID int64) ([]string, error) { + return packages_model.GetDistinctPropertyValues( + ctx, + packages_model.TypeRpm, + ownerID, + packages_model.PropertyTypeFile, + rpm_module.PropertyGroup, + nil, + ) +} diff --git a/modules/packages/rpm/metadata.go b/modules/packages/rpm/metadata.go index 1ba4c73e8d..7fc47a53e6 100644 --- a/modules/packages/rpm/metadata.go +++ b/modules/packages/rpm/metadata.go @@ -15,7 +15,10 @@ import ( ) const ( - PropertyMetadata = "rpm.metadata" + PropertyMetadata = "rpm.metadata" + PropertyGroup = "rpm.group" + PropertyArchitecture = "rpm.architecture" + SettingKeyPrivate = "rpm.key.private" SettingKeyPublic = "rpm.key.public" diff --git a/modules/templates/util_string.go b/modules/templates/util_string.go index 613940ccdc..18a0d5cacc 100644 --- a/modules/templates/util_string.go +++ b/modules/templates/util_string.go @@ -4,7 +4,6 @@ package templates import ( - "regexp" "strings" "code.gitea.io/gitea/modules/base" @@ -26,10 +25,6 @@ func (su *StringUtils) Contains(s, substr string) bool { return strings.Contains(s, substr) } -func (su *StringUtils) ReplaceAllStringRegex(s, regex, new string) string { - return regexp.MustCompile(regex).ReplaceAllString(s, new) -} - func (su *StringUtils) Split(s, sep string) []string { return strings.Split(s, sep) } diff --git a/modules/util/slice.go b/modules/util/slice.go index 6d63ab4a77..a7073fedee 100644 --- a/modules/util/slice.go +++ b/modules/util/slice.go @@ -4,6 +4,7 @@ package util import ( + "cmp" "slices" "strings" ) @@ -45,3 +46,10 @@ func SliceSortedEqual[T comparable](s1, s2 []T) bool { func SliceRemoveAll[T comparable](slice []T, target T) []T { return slices.DeleteFunc(slice, func(t T) bool { return t == target }) } + +// Sorted returns the sorted slice +// Note: The parameter is sorted inline. +func Sorted[S ~[]E, E cmp.Ordered](values S) S { + slices.Sort(values) + return values +} diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 6f9ba8c884..e8345595aa 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3414,6 +3414,9 @@ rpm.registry = Setup this registry from the command line: rpm.distros.redhat = on RedHat based distributions rpm.distros.suse = on SUSE based distributions rpm.install = To install the package, run the following command: +rpm.repository = Repository Info +rpm.repository.architectures = Architectures +rpm.repository.multiple_groups = This package is available in multiple groups. rubygems.install = To install the package using gem, run the following command: rubygems.install2 = or add it to the Gemfile: rubygems.dependencies.runtime = Runtime Dependencies diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index 9026387129..d990ebb56a 100644 --- a/routers/api/packages/api.go +++ b/routers/api/packages/api.go @@ -512,7 +512,77 @@ func CommonRoutes() *web.Route { r.Get("/files/{id}/{version}/{filename}", pypi.DownloadPackageFile) r.Get("/simple/{id}", pypi.PackageMetadata) }, reqPackageAccess(perm.AccessModeRead)) - r.Group("/rpm", RpmRoutes(r), reqPackageAccess(perm.AccessModeRead)) + r.Group("/rpm", func() { + r.Group("/repository.key", func() { + r.Head("", rpm.GetRepositoryKey) + r.Get("", rpm.GetRepositoryKey) + }) + + var ( + repoPattern = regexp.MustCompile(`\A(.*?)\.repo\z`) + uploadPattern = regexp.MustCompile(`\A(.*?)/upload\z`) + filePattern = regexp.MustCompile(`\A(.*?)/package/([^/]+)/([^/]+)/([^/]+)(?:/([^/]+\.rpm)|)\z`) + repoFilePattern = regexp.MustCompile(`\A(.*?)/repodata/([^/]+)\z`) + ) + + r.Methods("HEAD,GET,PUT,DELETE", "*", func(ctx *context.Context) { + path := ctx.Params("*") + isHead := ctx.Req.Method == "HEAD" + isGetHead := ctx.Req.Method == "HEAD" || ctx.Req.Method == "GET" + isPut := ctx.Req.Method == "PUT" + isDelete := ctx.Req.Method == "DELETE" + + m := repoPattern.FindStringSubmatch(path) + if len(m) == 2 && isGetHead { + ctx.SetParams("group", strings.Trim(m[1], "/")) + rpm.GetRepositoryConfig(ctx) + return + } + + m = repoFilePattern.FindStringSubmatch(path) + if len(m) == 3 && isGetHead { + ctx.SetParams("group", strings.Trim(m[1], "/")) + ctx.SetParams("filename", m[2]) + if isHead { + rpm.CheckRepositoryFileExistence(ctx) + } else { + rpm.GetRepositoryFile(ctx) + } + return + } + + m = uploadPattern.FindStringSubmatch(path) + if len(m) == 2 && isPut { + reqPackageAccess(perm.AccessModeWrite)(ctx) + if ctx.Written() { + return + } + ctx.SetParams("group", strings.Trim(m[1], "/")) + rpm.UploadPackageFile(ctx) + return + } + + m = filePattern.FindStringSubmatch(path) + if len(m) == 6 && (isGetHead || isDelete) { + ctx.SetParams("group", strings.Trim(m[1], "/")) + ctx.SetParams("name", m[2]) + ctx.SetParams("version", m[3]) + ctx.SetParams("architecture", m[4]) + if isGetHead { + rpm.DownloadPackageFile(ctx) + } else { + reqPackageAccess(perm.AccessModeWrite)(ctx) + if ctx.Written() { + return + } + rpm.DeletePackageFile(ctx) + } + return + } + + ctx.Status(http.StatusNotFound) + }) + }, reqPackageAccess(perm.AccessModeRead)) r.Group("/rubygems", func() { r.Get("/specs.4.8.gz", rubygems.EnumeratePackages) r.Get("/latest_specs.4.8.gz", rubygems.EnumeratePackagesLatest) @@ -577,82 +647,6 @@ func CommonRoutes() *web.Route { return r } -// Support for uploading rpm packages with arbitrary depth paths -func RpmRoutes(r *web.Route) func() { - var ( - groupRepoInfo = regexp.MustCompile(`\A((?:/(?:[^/]+))*|)\.repo\z`) - groupUpload = regexp.MustCompile(`\A((?:/(?:[^/]+))*|)/upload\z`) - groupRpm = regexp.MustCompile(`\A((?:/(?:[^/]+))*|)/package/([^/]+)/([^/]+)/([^/]+)(?:/([^/]+\.rpm)|)\z`) - groupMetadata = regexp.MustCompile(`\A((?:/(?:[^/]+))*|)/repodata/([^/]+)\z`) - ) - - return func() { - r.Methods("HEAD,GET,POST,PUT,PATCH,DELETE", "*", func(ctx *context.Context) { - path := ctx.Params("*") - isHead := ctx.Req.Method == "HEAD" - isGetHead := ctx.Req.Method == "HEAD" || ctx.Req.Method == "GET" - isPut := ctx.Req.Method == "PUT" - isDelete := ctx.Req.Method == "DELETE" - - if path == "/repository.key" && isGetHead { - rpm.GetRepositoryKey(ctx) - return - } - - // get repo - m := groupRepoInfo.FindStringSubmatch(path) - if len(m) == 2 && isGetHead { - ctx.SetParams("group", strings.Trim(m[1], "/")) - rpm.GetRepositoryConfig(ctx) - return - } - // get meta - m = groupMetadata.FindStringSubmatch(path) - if len(m) == 3 && isGetHead { - ctx.SetParams("group", strings.Trim(m[1], "/")) - ctx.SetParams("filename", m[2]) - if isHead { - rpm.CheckRepositoryFileExistence(ctx) - } else { - rpm.GetRepositoryFile(ctx) - } - return - } - // upload - m = groupUpload.FindStringSubmatch(path) - if len(m) == 2 && isPut { - reqPackageAccess(perm.AccessModeWrite)(ctx) - if ctx.Written() { - return - } - ctx.SetParams("group", strings.Trim(m[1], "/")) - rpm.UploadPackageFile(ctx) - return - } - // rpm down/delete - m = groupRpm.FindStringSubmatch(path) - if len(m) == 6 { - ctx.SetParams("group", strings.Trim(m[1], "/")) - ctx.SetParams("name", m[2]) - ctx.SetParams("version", m[3]) - ctx.SetParams("architecture", m[4]) - if isGetHead { - rpm.DownloadPackageFile(ctx) - return - } else if isDelete { - reqPackageAccess(perm.AccessModeWrite)(ctx) - if ctx.Written() { - return - } - rpm.DeletePackageFile(ctx) - } - } - // default - ctx.Status(http.StatusNotFound) - }) - } -} - // ContainerRoutes provides endpoints that implement the OCI API to serve containers // These have to be mounted on `/v2/...` to comply with the OCI spec: // https://github.com/opencontainers/distribution-spec/blob/main/spec.md diff --git a/routers/api/packages/rpm/rpm.go b/routers/api/packages/rpm/rpm.go index 75d19e2b43..5d06680552 100644 --- a/routers/api/packages/rpm/rpm.go +++ b/routers/api/packages/rpm/rpm.go @@ -34,13 +34,17 @@ func apiError(ctx *context.Context, status int, obj any) { // https://dnf.readthedocs.io/en/latest/conf_ref.html func GetRepositoryConfig(ctx *context.Context) { group := ctx.Params("group") + + var groupParts []string if group != "" { - group = fmt.Sprintf("/%s", group) + groupParts = strings.Split(group, "/") } + url := fmt.Sprintf("%sapi/packages/%s/rpm", setting.AppURL, ctx.Package.Owner.Name) - ctx.PlainText(http.StatusOK, `[gitea-`+ctx.Package.Owner.LowerName+strings.ReplaceAll(group, "/", "-")+`] -name=`+ctx.Package.Owner.Name+` - `+setting.AppName+strings.ReplaceAll(group, "/", " - ")+` -baseurl=`+url+group+`/ + + ctx.PlainText(http.StatusOK, `[gitea-`+strings.Join(append([]string{ctx.Package.Owner.LowerName}, groupParts...), "-")+`] +name=`+strings.Join(append([]string{ctx.Package.Owner.Name, setting.AppName}, groupParts...), " - ")+` +baseurl=`+strings.Join(append([]string{url}, groupParts...), "/")+` enabled=1 gpgcheck=1 gpgkey=`+url+`/repository.key`) @@ -157,7 +161,7 @@ func UploadPackageFile(ctx *context.Context) { Owner: ctx.Package.Owner, PackageType: packages_model.TypeRpm, Name: pck.Name, - Version: strings.Trim(fmt.Sprintf("%s/%s", group, pck.Version), "/"), + Version: pck.Version, }, Creator: ctx.Doer, Metadata: pck.VersionMetadata, @@ -171,7 +175,9 @@ func UploadPackageFile(ctx *context.Context) { Data: buf, IsLead: true, Properties: map[string]string{ - rpm_module.PropertyMetadata: string(fileMetadataRaw), + rpm_module.PropertyGroup: group, + rpm_module.PropertyArchitecture: pck.FileMetadata.Architecture, + rpm_module.PropertyMetadata: string(fileMetadataRaw), }, }, ) @@ -187,7 +193,7 @@ func UploadPackageFile(ctx *context.Context) { return } - if err := rpm_service.BuildRepositoryFiles(ctx, ctx.Package.Owner.ID, group); err != nil { + if err := rpm_service.BuildSpecificRepositoryFiles(ctx, ctx.Package.Owner.ID, group); err != nil { apiError(ctx, http.StatusInternalServerError, err) return } @@ -196,20 +202,20 @@ func UploadPackageFile(ctx *context.Context) { } func DownloadPackageFile(ctx *context.Context) { - group := ctx.Params("group") name := ctx.Params("name") version := ctx.Params("version") + s, u, pf, err := packages_service.GetFileStreamByPackageNameAndVersion( ctx, &packages_service.PackageInfo{ Owner: ctx.Package.Owner, PackageType: packages_model.TypeRpm, Name: name, - Version: strings.Trim(fmt.Sprintf("%s/%s", group, version), "/"), + Version: version, }, &packages_service.PackageFileInfo{ Filename: fmt.Sprintf("%s-%s.%s.rpm", name, version, ctx.Params("architecture")), - CompositeKey: group, + CompositeKey: ctx.Params("group"), }, ) if err != nil { @@ -229,6 +235,7 @@ func DeletePackageFile(webctx *context.Context) { name := webctx.Params("name") version := webctx.Params("version") architecture := webctx.Params("architecture") + var pd *packages_model.PackageDescriptor err := db.WithTx(webctx, func(ctx stdctx.Context) error { @@ -236,7 +243,7 @@ func DeletePackageFile(webctx *context.Context) { webctx.Package.Owner.ID, packages_model.TypeRpm, name, - strings.Trim(fmt.Sprintf("%s/%s", group, version), "/"), + version, ) if err != nil { return err @@ -286,7 +293,7 @@ func DeletePackageFile(webctx *context.Context) { notify_service.PackageDelete(webctx, webctx.Doer, pd) } - if err := rpm_service.BuildRepositoryFiles(webctx, webctx.Package.Owner.ID, group); err != nil { + if err := rpm_service.BuildSpecificRepositoryFiles(webctx, webctx.Package.Owner.ID, group); err != nil { apiError(webctx, http.StatusInternalServerError, err) return } diff --git a/routers/web/admin/packages.go b/routers/web/admin/packages.go index f4e1a93a22..35ce215be4 100644 --- a/routers/web/admin/packages.go +++ b/routers/web/admin/packages.go @@ -108,6 +108,6 @@ func CleanupExpiredData(ctx *context.Context) { return } - ctx.Flash.Success(ctx.Tr("packages.cleanup.success")) + ctx.Flash.Success(ctx.Tr("admin.packages.cleanup.success")) ctx.Redirect(setting.AppSubURL + "/admin/packages") } diff --git a/routers/web/user/package.go b/routers/web/user/package.go index d8da6a192e..708af3e43c 100644 --- a/routers/web/user/package.go +++ b/routers/web/user/package.go @@ -19,6 +19,7 @@ import ( "code.gitea.io/gitea/modules/log" alpine_module "code.gitea.io/gitea/modules/packages/alpine" debian_module "code.gitea.io/gitea/modules/packages/debian" + rpm_module "code.gitea.io/gitea/modules/packages/rpm" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" @@ -195,9 +196,9 @@ func ViewPackageVersion(ctx *context.Context) { } } - ctx.Data["Branches"] = branches.Values() - ctx.Data["Repositories"] = repositories.Values() - ctx.Data["Architectures"] = architectures.Values() + ctx.Data["Branches"] = util.Sorted(branches.Values()) + ctx.Data["Repositories"] = util.Sorted(repositories.Values()) + ctx.Data["Architectures"] = util.Sorted(architectures.Values()) case packages_model.TypeDebian: distributions := make(container.Set[string]) components := make(container.Set[string]) @@ -216,9 +217,26 @@ func ViewPackageVersion(ctx *context.Context) { } } - ctx.Data["Distributions"] = distributions.Values() - ctx.Data["Components"] = components.Values() - ctx.Data["Architectures"] = architectures.Values() + ctx.Data["Distributions"] = util.Sorted(distributions.Values()) + ctx.Data["Components"] = util.Sorted(components.Values()) + ctx.Data["Architectures"] = util.Sorted(architectures.Values()) + case packages_model.TypeRpm: + groups := make(container.Set[string]) + architectures := make(container.Set[string]) + + for _, f := range pd.Files { + for _, pp := range f.Properties { + switch pp.Name { + case rpm_module.PropertyGroup: + groups.Add(pp.Value) + case rpm_module.PropertyArchitecture: + architectures.Add(pp.Value) + } + } + } + + ctx.Data["Groups"] = util.Sorted(groups.Values()) + ctx.Data["Architectures"] = util.Sorted(architectures.Values()) } var ( diff --git a/services/packages/cleanup/cleanup.go b/services/packages/cleanup/cleanup.go index 04ee6c4419..0ff8077bc9 100644 --- a/services/packages/cleanup/cleanup.go +++ b/services/packages/cleanup/cleanup.go @@ -19,6 +19,7 @@ import ( cargo_service "code.gitea.io/gitea/services/packages/cargo" container_service "code.gitea.io/gitea/services/packages/container" debian_service "code.gitea.io/gitea/services/packages/debian" + rpm_service "code.gitea.io/gitea/services/packages/rpm" ) // Task method to execute cleanup rules and cleanup expired package data @@ -127,6 +128,10 @@ func ExecuteCleanupRules(outerCtx context.Context) error { if err := alpine_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil { return fmt.Errorf("CleanupRule [%d]: alpine.BuildAllRepositoryFiles failed: %w", pcr.ID, err) } + } else if pcr.Type == packages_model.TypeRpm { + if err := rpm_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil { + return fmt.Errorf("CleanupRule [%d]: rpm.BuildAllRepositoryFiles failed: %w", pcr.ID, err) + } } } return nil diff --git a/services/packages/rpm/repository.go b/services/packages/rpm/repository.go index 7a49efde4f..c52c8a5dd9 100644 --- a/services/packages/rpm/repository.go +++ b/services/packages/rpm/repository.go @@ -18,6 +18,7 @@ import ( "time" packages_model "code.gitea.io/gitea/models/packages" + rpm_model "code.gitea.io/gitea/models/packages/rpm" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/json" packages_module "code.gitea.io/gitea/modules/packages" @@ -96,6 +97,39 @@ func generateKeypair() (string, string, error) { return priv.String(), pub.String(), nil } +// BuildAllRepositoryFiles (re)builds all repository files for every available group +func BuildAllRepositoryFiles(ctx context.Context, ownerID int64) error { + pv, err := GetOrCreateRepositoryVersion(ctx, ownerID) + if err != nil { + return err + } + + // 1. Delete all existing repository files + pfs, err := packages_model.GetFilesByVersionID(ctx, pv.ID) + if err != nil { + return err + } + + for _, pf := range pfs { + if err := packages_service.DeletePackageFile(ctx, pf); err != nil { + return err + } + } + + // 2. (Re)Build repository files for existing packages + groups, err := rpm_model.GetGroups(ctx, ownerID) + if err != nil { + return err + } + for _, group := range groups { + if err := BuildSpecificRepositoryFiles(ctx, ownerID, group); err != nil { + return fmt.Errorf("failed to build repository files [%s]: %w", group, err) + } + } + + return nil +} + type repoChecksum struct { Value string `xml:",chardata"` Type string `xml:"type,attr"` @@ -126,7 +160,7 @@ type packageData struct { type packageCache = map[*packages_model.PackageFile]*packageData // BuildSpecificRepositoryFiles builds metadata files for the repository -func BuildRepositoryFiles(ctx context.Context, ownerID int64, compositeKey string) error { +func BuildSpecificRepositoryFiles(ctx context.Context, ownerID int64, group string) error { pv, err := GetOrCreateRepositoryVersion(ctx, ownerID) if err != nil { return err @@ -136,7 +170,7 @@ func BuildRepositoryFiles(ctx context.Context, ownerID int64, compositeKey strin OwnerID: ownerID, PackageType: packages_model.TypeRpm, Query: "%.rpm", - CompositeKey: compositeKey, + CompositeKey: group, }) if err != nil { return err @@ -195,15 +229,15 @@ func BuildRepositoryFiles(ctx context.Context, ownerID int64, compositeKey strin cache[pf] = pd } - primary, err := buildPrimary(ctx, pv, pfs, cache, compositeKey) + primary, err := buildPrimary(ctx, pv, pfs, cache, group) if err != nil { return err } - filelists, err := buildFilelists(ctx, pv, pfs, cache, compositeKey) + filelists, err := buildFilelists(ctx, pv, pfs, cache, group) if err != nil { return err } - other, err := buildOther(ctx, pv, pfs, cache, compositeKey) + other, err := buildOther(ctx, pv, pfs, cache, group) if err != nil { return err } @@ -217,12 +251,12 @@ func BuildRepositoryFiles(ctx context.Context, ownerID int64, compositeKey strin filelists, other, }, - compositeKey, + group, ) } // https://docs.pulpproject.org/en/2.19/plugins/pulp_rpm/tech-reference/rpm.html#repomd-xml -func buildRepomd(ctx context.Context, pv *packages_model.PackageVersion, ownerID int64, data []*repoData, compositeKey string) error { +func buildRepomd(ctx context.Context, pv *packages_model.PackageVersion, ownerID int64, data []*repoData, group string) error { type Repomd struct { XMLName xml.Name `xml:"repomd"` Xmlns string `xml:"xmlns,attr"` @@ -278,7 +312,7 @@ func buildRepomd(ctx context.Context, pv *packages_model.PackageVersion, ownerID &packages_service.PackageFileCreationInfo{ PackageFileInfo: packages_service.PackageFileInfo{ Filename: file.Name, - CompositeKey: compositeKey, + CompositeKey: group, }, Creator: user_model.NewGhostUser(), Data: file.Data, @@ -295,7 +329,7 @@ func buildRepomd(ctx context.Context, pv *packages_model.PackageVersion, ownerID } // https://docs.pulpproject.org/en/2.19/plugins/pulp_rpm/tech-reference/rpm.html#primary-xml -func buildPrimary(ctx context.Context, pv *packages_model.PackageVersion, pfs []*packages_model.PackageFile, c packageCache, compositeKey string) (*repoData, error) { +func buildPrimary(ctx context.Context, pv *packages_model.PackageVersion, pfs []*packages_model.PackageFile, c packageCache, group string) (*repoData, error) { type Version struct { Epoch string `xml:"epoch,attr"` Version string `xml:"ver,attr"` @@ -434,11 +468,11 @@ func buildPrimary(ctx context.Context, pv *packages_model.PackageVersion, pfs [] XmlnsRpm: "http://linux.duke.edu/metadata/rpm", PackageCount: len(pfs), Packages: packages, - }, compositeKey) + }, group) } // https://docs.pulpproject.org/en/2.19/plugins/pulp_rpm/tech-reference/rpm.html#filelists-xml -func buildFilelists(ctx context.Context, pv *packages_model.PackageVersion, pfs []*packages_model.PackageFile, c packageCache, compositeKey string) (*repoData, error) { //nolint:dupl +func buildFilelists(ctx context.Context, pv *packages_model.PackageVersion, pfs []*packages_model.PackageFile, c packageCache, group string) (*repoData, error) { //nolint:dupl type Version struct { Epoch string `xml:"epoch,attr"` Version string `xml:"ver,attr"` @@ -481,12 +515,11 @@ func buildFilelists(ctx context.Context, pv *packages_model.PackageVersion, pfs Xmlns: "http://linux.duke.edu/metadata/other", PackageCount: len(pfs), Packages: packages, - }, - compositeKey) + }, group) } // https://docs.pulpproject.org/en/2.19/plugins/pulp_rpm/tech-reference/rpm.html#other-xml -func buildOther(ctx context.Context, pv *packages_model.PackageVersion, pfs []*packages_model.PackageFile, c packageCache, compositeKey string) (*repoData, error) { //nolint:dupl +func buildOther(ctx context.Context, pv *packages_model.PackageVersion, pfs []*packages_model.PackageFile, c packageCache, group string) (*repoData, error) { //nolint:dupl type Version struct { Epoch string `xml:"epoch,attr"` Version string `xml:"ver,attr"` @@ -529,7 +562,7 @@ func buildOther(ctx context.Context, pv *packages_model.PackageVersion, pfs []*p Xmlns: "http://linux.duke.edu/metadata/other", PackageCount: len(pfs), Packages: packages, - }, compositeKey) + }, group) } // writtenCounter counts all written bytes @@ -549,8 +582,10 @@ func (wc *writtenCounter) Written() int64 { return wc.written } -func addDataAsFileToRepo(ctx context.Context, pv *packages_model.PackageVersion, filetype string, obj any, compositeKey string) (*repoData, error) { +func addDataAsFileToRepo(ctx context.Context, pv *packages_model.PackageVersion, filetype string, obj any, group string) (*repoData, error) { content, _ := packages_module.NewHashedBuffer() + defer content.Close() + gzw := gzip.NewWriter(content) wc := &writtenCounter{} h := sha256.New() @@ -574,7 +609,7 @@ func addDataAsFileToRepo(ctx context.Context, pv *packages_model.PackageVersion, &packages_service.PackageFileCreationInfo{ PackageFileInfo: packages_service.PackageFileInfo{ Filename: filename, - CompositeKey: compositeKey, + CompositeKey: group, }, Creator: user_model.NewGhostUser(), Data: content, diff --git a/templates/package/content/rpm.tmpl b/templates/package/content/rpm.tmpl index 4fd54a3197..0f128fd3fb 100644 --- a/templates/package/content/rpm.tmpl +++ b/templates/package/content/rpm.tmpl @@ -4,15 +4,21 @@
-
# {{ctx.Locale.Tr "packages.rpm.distros.redhat"}}
-{{$group_name:= StringUtils.ReplaceAllStringRegex .PackageDescriptor.Version.Version "(/[^/]+|[^/]*)\\z" "" -}}
-{{- if $group_name -}}
-{{- $group_name = (print "/" $group_name) -}}
-{{- end -}}
-dnf config-manager --add-repo 
+				
{{- if gt (len .Groups) 1 -}}
+# {{ctx.Locale.Tr "packages.rpm.repository.multiple_groups"}}
+
+{{end -}}
+# {{ctx.Locale.Tr "packages.rpm.distros.redhat"}}
+{{- range $group := .Groups}}
+	{{- if $group}}{{$group = print "/" $group}}{{end}}
+dnf config-manager --add-repo 
+{{- end}}
 
 # {{ctx.Locale.Tr "packages.rpm.distros.suse"}}
-zypper addrepo 
+{{- range $group := .Groups}} + {{- if $group}}{{$group = print "/" $group}}{{end}} +zypper addrepo +{{- end}}
@@ -30,6 +36,18 @@ zypper install {{$.PackageDescriptor.Package.Name}}
+

{{ctx.Locale.Tr "packages.rpm.repository"}}

+
+ + + + + + + +
{{ctx.Locale.Tr "packages.rpm.repository.architectures"}}
{{StringUtils.Join .Architectures ", "}}
+
+ {{if or .PackageDescriptor.Metadata.Summary .PackageDescriptor.Metadata.Description}}

{{ctx.Locale.Tr "packages.about"}}

{{if .PackageDescriptor.Metadata.Summary}}
{{.PackageDescriptor.Metadata.Summary}}
{{end}} diff --git a/tests/integration/api_packages_rpm_test.go b/tests/integration/api_packages_rpm_test.go index 822b0b040e..1dcec6099e 100644 --- a/tests/integration/api_packages_rpm_test.go +++ b/tests/integration/api_packages_rpm_test.go @@ -12,6 +12,7 @@ import ( "io" "net/http" "net/http/httptest" + "strings" "testing" "code.gitea.io/gitea/models/db" @@ -20,6 +21,7 @@ import ( user_model "code.gitea.io/gitea/models/user" rpm_module "code.gitea.io/gitea/modules/packages/rpm" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/tests" "github.com/stretchr/testify/assert" @@ -73,346 +75,362 @@ Mu0UFYgZ/bYnuvn/vz4wtCz8qMwsHUvP0PX3tbYFUctAPdrY6tiiDtcCddDECahx7SuVNP5dpmb5 rootURL := fmt.Sprintf("/api/packages/%s/rpm", user.Name) - t.Run("RepositoryConfig", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() + for _, group := range []string{"", "el9", "el9/stable"} { + t.Run(fmt.Sprintf("[Group:%s]", group), func(t *testing.T) { + var groupParts []string + if group != "" { + groupParts = strings.Split(group, "/") + } + groupURL := strings.Join(append([]string{rootURL}, groupParts...), "/") - req := NewRequest(t, "GET", rootURL+"/el9/stable.repo") - resp := MakeRequest(t, req, http.StatusOK) + t.Run("RepositoryConfig", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() - expected := fmt.Sprintf(`[gitea-%s-el9-stable] -name=%s - %s - el9 - stable -baseurl=%sapi/packages/%s/rpm/el9/stable/ + req := NewRequest(t, "GET", groupURL+".repo") + resp := MakeRequest(t, req, http.StatusOK) + + expected := fmt.Sprintf(`[gitea-%s] +name=%s +baseurl=%s enabled=1 gpgcheck=1 -gpgkey=%sapi/packages/%s/rpm/repository.key`, user.Name, user.Name, setting.AppName, setting.AppURL, user.Name, setting.AppURL, user.Name) +gpgkey=%sapi/packages/%s/rpm/repository.key`, + strings.Join(append([]string{user.LowerName}, groupParts...), "-"), + strings.Join(append([]string{user.Name, setting.AppName}, groupParts...), " - "), + util.URLJoin(setting.AppURL, groupURL), + setting.AppURL, + user.Name, + ) - assert.Equal(t, expected, resp.Body.String()) - }) + assert.Equal(t, expected, resp.Body.String()) + }) - t.Run("RepositoryKey", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() + t.Run("RepositoryKey", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() - req := NewRequest(t, "GET", rootURL+"/repository.key") - resp := MakeRequest(t, req, http.StatusOK) + req := NewRequest(t, "GET", rootURL+"/repository.key") + resp := MakeRequest(t, req, http.StatusOK) - assert.Equal(t, "application/pgp-keys", resp.Header().Get("Content-Type")) - assert.Contains(t, resp.Body.String(), "-----BEGIN PGP PUBLIC KEY BLOCK-----") - }) + assert.Equal(t, "application/pgp-keys", resp.Header().Get("Content-Type")) + assert.Contains(t, resp.Body.String(), "-----BEGIN PGP PUBLIC KEY BLOCK-----") + }) - t.Run("Upload", func(t *testing.T) { - url := rootURL + "/el9/stable/upload" + t.Run("Upload", func(t *testing.T) { + url := groupURL + "/upload" - req := NewRequestWithBody(t, "PUT", url, bytes.NewReader(content)) - MakeRequest(t, req, http.StatusUnauthorized) + req := NewRequestWithBody(t, "PUT", url, bytes.NewReader(content)) + MakeRequest(t, req, http.StatusUnauthorized) - req = NewRequestWithBody(t, "PUT", url, bytes.NewReader(content)). - AddBasicAuth(user.Name) - MakeRequest(t, req, http.StatusCreated) + req = NewRequestWithBody(t, "PUT", url, bytes.NewReader(content)). + AddBasicAuth(user.Name) + MakeRequest(t, req, http.StatusCreated) - pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRpm) - assert.NoError(t, err) - assert.Len(t, pvs, 1) + pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRpm) + assert.NoError(t, err) + assert.Len(t, pvs, 1) - pd, err := packages.GetPackageDescriptor(db.DefaultContext, pvs[0]) - assert.NoError(t, err) - assert.Nil(t, pd.SemVer) - assert.IsType(t, &rpm_module.VersionMetadata{}, pd.Metadata) - assert.Equal(t, packageName, pd.Package.Name) - assert.Equal(t, fmt.Sprintf("el9/stable/%s", packageVersion), pd.Version.Version) + pd, err := packages.GetPackageDescriptor(db.DefaultContext, pvs[0]) + assert.NoError(t, err) + assert.Nil(t, pd.SemVer) + assert.IsType(t, &rpm_module.VersionMetadata{}, pd.Metadata) + assert.Equal(t, packageName, pd.Package.Name) + assert.Equal(t, packageVersion, pd.Version.Version) - pfs, err := packages.GetFilesByVersionID(db.DefaultContext, pvs[0].ID) - assert.NoError(t, err) - assert.Len(t, pfs, 1) - assert.Equal(t, fmt.Sprintf("%s-%s.%s.rpm", packageName, packageVersion, packageArchitecture), pfs[0].Name) - assert.True(t, pfs[0].IsLead) + pfs, err := packages.GetFilesByVersionID(db.DefaultContext, pvs[0].ID) + assert.NoError(t, err) + assert.Len(t, pfs, 1) + assert.Equal(t, fmt.Sprintf("%s-%s.%s.rpm", packageName, packageVersion, packageArchitecture), pfs[0].Name) + assert.True(t, pfs[0].IsLead) - pb, err := packages.GetBlobByID(db.DefaultContext, pfs[0].BlobID) - assert.NoError(t, err) - assert.Equal(t, int64(len(content)), pb.Size) + pb, err := packages.GetBlobByID(db.DefaultContext, pfs[0].BlobID) + assert.NoError(t, err) + assert.Equal(t, int64(len(content)), pb.Size) - req = NewRequestWithBody(t, "PUT", url, bytes.NewReader(content)). - AddBasicAuth(user.Name) - MakeRequest(t, req, http.StatusConflict) - }) + req = NewRequestWithBody(t, "PUT", url, bytes.NewReader(content)). + AddBasicAuth(user.Name) + MakeRequest(t, req, http.StatusConflict) + }) - t.Run("Download", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() + t.Run("Download", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() - req := NewRequest(t, "GET", fmt.Sprintf("%s/el9/stable/package/%s/%s/%s", rootURL, packageName, packageVersion, packageArchitecture)) - resp := MakeRequest(t, req, http.StatusOK) + req := NewRequest(t, "GET", fmt.Sprintf("%s/package/%s/%s/%s", groupURL, packageName, packageVersion, packageArchitecture)) + resp := MakeRequest(t, req, http.StatusOK) - assert.Equal(t, content, resp.Body.Bytes()) - }) + assert.Equal(t, content, resp.Body.Bytes()) + }) - t.Run("Repository", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() + t.Run("Repository", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() - url := rootURL + "/el9/stable/repodata" + url := groupURL + "/repodata" - req := NewRequest(t, "HEAD", url+"/dummy.xml") - MakeRequest(t, req, http.StatusNotFound) + req := NewRequest(t, "HEAD", url+"/dummy.xml") + MakeRequest(t, req, http.StatusNotFound) - req = NewRequest(t, "GET", url+"/dummy.xml") - MakeRequest(t, req, http.StatusNotFound) + req = NewRequest(t, "GET", url+"/dummy.xml") + MakeRequest(t, req, http.StatusNotFound) - t.Run("repomd.xml", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() + t.Run("repomd.xml", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() - req = NewRequest(t, "HEAD", url+"/repomd.xml") - MakeRequest(t, req, http.StatusOK) + req = NewRequest(t, "HEAD", url+"/repomd.xml") + MakeRequest(t, req, http.StatusOK) - req = NewRequest(t, "GET", url+"/repomd.xml") - resp := MakeRequest(t, req, http.StatusOK) + req = NewRequest(t, "GET", url+"/repomd.xml") + resp := MakeRequest(t, req, http.StatusOK) - type Repomd struct { - XMLName xml.Name `xml:"repomd"` - Xmlns string `xml:"xmlns,attr"` - XmlnsRpm string `xml:"xmlns:rpm,attr"` - Data []struct { - Type string `xml:"type,attr"` - Checksum struct { - Value string `xml:",chardata"` - Type string `xml:"type,attr"` - } `xml:"checksum"` - OpenChecksum struct { - Value string `xml:",chardata"` - Type string `xml:"type,attr"` - } `xml:"open-checksum"` - Location struct { - Href string `xml:"href,attr"` - } `xml:"location"` - Timestamp int64 `xml:"timestamp"` - Size int64 `xml:"size"` - OpenSize int64 `xml:"open-size"` - } `xml:"data"` - } + type Repomd struct { + XMLName xml.Name `xml:"repomd"` + Xmlns string `xml:"xmlns,attr"` + XmlnsRpm string `xml:"xmlns:rpm,attr"` + Data []struct { + Type string `xml:"type,attr"` + Checksum struct { + Value string `xml:",chardata"` + Type string `xml:"type,attr"` + } `xml:"checksum"` + OpenChecksum struct { + Value string `xml:",chardata"` + Type string `xml:"type,attr"` + } `xml:"open-checksum"` + Location struct { + Href string `xml:"href,attr"` + } `xml:"location"` + Timestamp int64 `xml:"timestamp"` + Size int64 `xml:"size"` + OpenSize int64 `xml:"open-size"` + } `xml:"data"` + } - var result Repomd - decodeXML(t, resp, &result) + var result Repomd + decodeXML(t, resp, &result) - assert.Len(t, result.Data, 3) - for _, d := range result.Data { - assert.Equal(t, "sha256", d.Checksum.Type) - assert.NotEmpty(t, d.Checksum.Value) - assert.Equal(t, "sha256", d.OpenChecksum.Type) - assert.NotEmpty(t, d.OpenChecksum.Value) - assert.NotEqual(t, d.Checksum.Value, d.OpenChecksum.Value) - assert.Greater(t, d.OpenSize, d.Size) + assert.Len(t, result.Data, 3) + for _, d := range result.Data { + assert.Equal(t, "sha256", d.Checksum.Type) + assert.NotEmpty(t, d.Checksum.Value) + assert.Equal(t, "sha256", d.OpenChecksum.Type) + assert.NotEmpty(t, d.OpenChecksum.Value) + assert.NotEqual(t, d.Checksum.Value, d.OpenChecksum.Value) + assert.Greater(t, d.OpenSize, d.Size) - switch d.Type { - case "primary": - assert.EqualValues(t, 722, d.Size) - assert.EqualValues(t, 1759, d.OpenSize) - assert.Equal(t, "repodata/primary.xml.gz", d.Location.Href) - case "filelists": - assert.EqualValues(t, 257, d.Size) - assert.EqualValues(t, 326, d.OpenSize) - assert.Equal(t, "repodata/filelists.xml.gz", d.Location.Href) - case "other": - assert.EqualValues(t, 306, d.Size) - assert.EqualValues(t, 394, d.OpenSize) - assert.Equal(t, "repodata/other.xml.gz", d.Location.Href) + switch d.Type { + case "primary": + assert.EqualValues(t, 722, d.Size) + assert.EqualValues(t, 1759, d.OpenSize) + assert.Equal(t, "repodata/primary.xml.gz", d.Location.Href) + case "filelists": + assert.EqualValues(t, 257, d.Size) + assert.EqualValues(t, 326, d.OpenSize) + assert.Equal(t, "repodata/filelists.xml.gz", d.Location.Href) + case "other": + assert.EqualValues(t, 306, d.Size) + assert.EqualValues(t, 394, d.OpenSize) + assert.Equal(t, "repodata/other.xml.gz", d.Location.Href) + } + } + }) + + t.Run("repomd.xml.asc", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req = NewRequest(t, "GET", url+"/repomd.xml.asc") + resp := MakeRequest(t, req, http.StatusOK) + + assert.Contains(t, resp.Body.String(), "-----BEGIN PGP SIGNATURE-----") + }) + + decodeGzipXML := func(t testing.TB, resp *httptest.ResponseRecorder, v any) { + t.Helper() + + zr, err := gzip.NewReader(resp.Body) + assert.NoError(t, err) + + assert.NoError(t, xml.NewDecoder(zr).Decode(v)) } - } + + t.Run("primary.xml.gz", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req = NewRequest(t, "GET", url+"/primary.xml.gz") + resp := MakeRequest(t, req, http.StatusOK) + + type EntryList struct { + Entries []*rpm_module.Entry `xml:"entry"` + } + + type Metadata struct { + XMLName xml.Name `xml:"metadata"` + Xmlns string `xml:"xmlns,attr"` + XmlnsRpm string `xml:"xmlns:rpm,attr"` + PackageCount int `xml:"packages,attr"` + Packages []struct { + XMLName xml.Name `xml:"package"` + Type string `xml:"type,attr"` + Name string `xml:"name"` + Architecture string `xml:"arch"` + Version struct { + Epoch string `xml:"epoch,attr"` + Version string `xml:"ver,attr"` + Release string `xml:"rel,attr"` + } `xml:"version"` + Checksum struct { + Checksum string `xml:",chardata"` + Type string `xml:"type,attr"` + Pkgid string `xml:"pkgid,attr"` + } `xml:"checksum"` + Summary string `xml:"summary"` + Description string `xml:"description"` + Packager string `xml:"packager"` + URL string `xml:"url"` + Time struct { + File uint64 `xml:"file,attr"` + Build uint64 `xml:"build,attr"` + } `xml:"time"` + Size struct { + Package int64 `xml:"package,attr"` + Installed uint64 `xml:"installed,attr"` + Archive uint64 `xml:"archive,attr"` + } `xml:"size"` + Location struct { + Href string `xml:"href,attr"` + } `xml:"location"` + Format struct { + License string `xml:"license"` + Vendor string `xml:"vendor"` + Group string `xml:"group"` + Buildhost string `xml:"buildhost"` + Sourcerpm string `xml:"sourcerpm"` + Provides EntryList `xml:"provides"` + Requires EntryList `xml:"requires"` + Conflicts EntryList `xml:"conflicts"` + Obsoletes EntryList `xml:"obsoletes"` + Files []*rpm_module.File `xml:"file"` + } `xml:"format"` + } `xml:"package"` + } + + var result Metadata + decodeGzipXML(t, resp, &result) + + assert.EqualValues(t, 1, result.PackageCount) + assert.Len(t, result.Packages, 1) + p := result.Packages[0] + assert.Equal(t, "rpm", p.Type) + assert.Equal(t, packageName, p.Name) + assert.Equal(t, packageArchitecture, p.Architecture) + assert.Equal(t, "YES", p.Checksum.Pkgid) + assert.Equal(t, "sha256", p.Checksum.Type) + assert.Equal(t, "f1d5d2ffcbe4a7568e98b864f40d923ecca084e9b9bcd5977ed6521c46d3fa4c", p.Checksum.Checksum) + assert.Equal(t, "https://gitea.io", p.URL) + assert.EqualValues(t, len(content), p.Size.Package) + assert.EqualValues(t, 13, p.Size.Installed) + assert.EqualValues(t, 272, p.Size.Archive) + assert.Equal(t, fmt.Sprintf("package/%s/%s/%s/%s", packageName, packageVersion, packageArchitecture, fmt.Sprintf("%s-%s.%s.rpm", packageName, packageVersion, packageArchitecture)), p.Location.Href) + f := p.Format + assert.Equal(t, "MIT", f.License) + assert.Len(t, f.Provides.Entries, 2) + assert.Len(t, f.Requires.Entries, 7) + assert.Empty(t, f.Conflicts.Entries) + assert.Empty(t, f.Obsoletes.Entries) + assert.Len(t, f.Files, 1) + }) + + t.Run("filelists.xml.gz", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req = NewRequest(t, "GET", url+"/filelists.xml.gz") + resp := MakeRequest(t, req, http.StatusOK) + + type Filelists struct { + XMLName xml.Name `xml:"filelists"` + Xmlns string `xml:"xmlns,attr"` + PackageCount int `xml:"packages,attr"` + Packages []struct { + Pkgid string `xml:"pkgid,attr"` + Name string `xml:"name,attr"` + Architecture string `xml:"arch,attr"` + Version struct { + Epoch string `xml:"epoch,attr"` + Version string `xml:"ver,attr"` + Release string `xml:"rel,attr"` + } `xml:"version"` + Files []*rpm_module.File `xml:"file"` + } `xml:"package"` + } + + var result Filelists + decodeGzipXML(t, resp, &result) + + assert.EqualValues(t, 1, result.PackageCount) + assert.Len(t, result.Packages, 1) + p := result.Packages[0] + assert.NotEmpty(t, p.Pkgid) + assert.Equal(t, packageName, p.Name) + assert.Equal(t, packageArchitecture, p.Architecture) + assert.Len(t, p.Files, 1) + f := p.Files[0] + assert.Equal(t, "/usr/local/bin/hello", f.Path) + }) + + t.Run("other.xml.gz", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req = NewRequest(t, "GET", url+"/other.xml.gz") + resp := MakeRequest(t, req, http.StatusOK) + + type Other struct { + XMLName xml.Name `xml:"otherdata"` + Xmlns string `xml:"xmlns,attr"` + PackageCount int `xml:"packages,attr"` + Packages []struct { + Pkgid string `xml:"pkgid,attr"` + Name string `xml:"name,attr"` + Architecture string `xml:"arch,attr"` + Version struct { + Epoch string `xml:"epoch,attr"` + Version string `xml:"ver,attr"` + Release string `xml:"rel,attr"` + } `xml:"version"` + Changelogs []*rpm_module.Changelog `xml:"changelog"` + } `xml:"package"` + } + + var result Other + decodeGzipXML(t, resp, &result) + + assert.EqualValues(t, 1, result.PackageCount) + assert.Len(t, result.Packages, 1) + p := result.Packages[0] + assert.NotEmpty(t, p.Pkgid) + assert.Equal(t, packageName, p.Name) + assert.Equal(t, packageArchitecture, p.Architecture) + assert.Len(t, p.Changelogs, 1) + c := p.Changelogs[0] + assert.Equal(t, "KN4CK3R ", c.Author) + assert.EqualValues(t, 1678276800, c.Date) + assert.Equal(t, "- Changelog message.", c.Text) + }) + }) + + t.Run("Delete", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + + req := NewRequest(t, "DELETE", fmt.Sprintf("%s/package/%s/%s/%s", groupURL, packageName, packageVersion, packageArchitecture)) + MakeRequest(t, req, http.StatusUnauthorized) + + req = NewRequest(t, "DELETE", fmt.Sprintf("%s/package/%s/%s/%s", groupURL, packageName, packageVersion, packageArchitecture)). + AddBasicAuth(user.Name) + MakeRequest(t, req, http.StatusNoContent) + + pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRpm) + assert.NoError(t, err) + assert.Empty(t, pvs) + req = NewRequest(t, "DELETE", fmt.Sprintf("%s/package/%s/%s/%s", groupURL, packageName, packageVersion, packageArchitecture)). + AddBasicAuth(user.Name) + MakeRequest(t, req, http.StatusNotFound) + }) }) - - t.Run("repomd.xml.asc", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - - req = NewRequest(t, "GET", url+"/repomd.xml.asc") - resp := MakeRequest(t, req, http.StatusOK) - - assert.Contains(t, resp.Body.String(), "-----BEGIN PGP SIGNATURE-----") - }) - - decodeGzipXML := func(t testing.TB, resp *httptest.ResponseRecorder, v any) { - t.Helper() - - zr, err := gzip.NewReader(resp.Body) - assert.NoError(t, err) - - assert.NoError(t, xml.NewDecoder(zr).Decode(v)) - } - - t.Run("primary.xml.gz", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - - req = NewRequest(t, "GET", url+"/primary.xml.gz") - resp := MakeRequest(t, req, http.StatusOK) - - type EntryList struct { - Entries []*rpm_module.Entry `xml:"entry"` - } - - type Metadata struct { - XMLName xml.Name `xml:"metadata"` - Xmlns string `xml:"xmlns,attr"` - XmlnsRpm string `xml:"xmlns:rpm,attr"` - PackageCount int `xml:"packages,attr"` - Packages []struct { - XMLName xml.Name `xml:"package"` - Type string `xml:"type,attr"` - Name string `xml:"name"` - Architecture string `xml:"arch"` - Version struct { - Epoch string `xml:"epoch,attr"` - Version string `xml:"ver,attr"` - Release string `xml:"rel,attr"` - } `xml:"version"` - Checksum struct { - Checksum string `xml:",chardata"` - Type string `xml:"type,attr"` - Pkgid string `xml:"pkgid,attr"` - } `xml:"checksum"` - Summary string `xml:"summary"` - Description string `xml:"description"` - Packager string `xml:"packager"` - URL string `xml:"url"` - Time struct { - File uint64 `xml:"file,attr"` - Build uint64 `xml:"build,attr"` - } `xml:"time"` - Size struct { - Package int64 `xml:"package,attr"` - Installed uint64 `xml:"installed,attr"` - Archive uint64 `xml:"archive,attr"` - } `xml:"size"` - Location struct { - Href string `xml:"href,attr"` - } `xml:"location"` - Format struct { - License string `xml:"license"` - Vendor string `xml:"vendor"` - Group string `xml:"group"` - Buildhost string `xml:"buildhost"` - Sourcerpm string `xml:"sourcerpm"` - Provides EntryList `xml:"provides"` - Requires EntryList `xml:"requires"` - Conflicts EntryList `xml:"conflicts"` - Obsoletes EntryList `xml:"obsoletes"` - Files []*rpm_module.File `xml:"file"` - } `xml:"format"` - } `xml:"package"` - } - - var result Metadata - decodeGzipXML(t, resp, &result) - - assert.EqualValues(t, 1, result.PackageCount) - assert.Len(t, result.Packages, 1) - p := result.Packages[0] - assert.Equal(t, "rpm", p.Type) - assert.Equal(t, packageName, p.Name) - assert.Equal(t, packageArchitecture, p.Architecture) - assert.Equal(t, "YES", p.Checksum.Pkgid) - assert.Equal(t, "sha256", p.Checksum.Type) - assert.Equal(t, "f1d5d2ffcbe4a7568e98b864f40d923ecca084e9b9bcd5977ed6521c46d3fa4c", p.Checksum.Checksum) - assert.Equal(t, "https://gitea.io", p.URL) - assert.EqualValues(t, len(content), p.Size.Package) - assert.EqualValues(t, 13, p.Size.Installed) - assert.EqualValues(t, 272, p.Size.Archive) - assert.Equal(t, fmt.Sprintf("package/%s/%s/%s/%s", packageName, packageVersion, packageArchitecture, fmt.Sprintf("%s-%s.%s.rpm", packageName, packageVersion, packageArchitecture)), p.Location.Href) - f := p.Format - assert.Equal(t, "MIT", f.License) - assert.Len(t, f.Provides.Entries, 2) - assert.Len(t, f.Requires.Entries, 7) - assert.Empty(t, f.Conflicts.Entries) - assert.Empty(t, f.Obsoletes.Entries) - assert.Len(t, f.Files, 1) - }) - - t.Run("filelists.xml.gz", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - - req = NewRequest(t, "GET", url+"/filelists.xml.gz") - resp := MakeRequest(t, req, http.StatusOK) - - type Filelists struct { - XMLName xml.Name `xml:"filelists"` - Xmlns string `xml:"xmlns,attr"` - PackageCount int `xml:"packages,attr"` - Packages []struct { - Pkgid string `xml:"pkgid,attr"` - Name string `xml:"name,attr"` - Architecture string `xml:"arch,attr"` - Version struct { - Epoch string `xml:"epoch,attr"` - Version string `xml:"ver,attr"` - Release string `xml:"rel,attr"` - } `xml:"version"` - Files []*rpm_module.File `xml:"file"` - } `xml:"package"` - } - - var result Filelists - decodeGzipXML(t, resp, &result) - - assert.EqualValues(t, 1, result.PackageCount) - assert.Len(t, result.Packages, 1) - p := result.Packages[0] - assert.NotEmpty(t, p.Pkgid) - assert.Equal(t, packageName, p.Name) - assert.Equal(t, packageArchitecture, p.Architecture) - assert.Len(t, p.Files, 1) - f := p.Files[0] - assert.Equal(t, "/usr/local/bin/hello", f.Path) - }) - - t.Run("other.xml.gz", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - - req = NewRequest(t, "GET", url+"/other.xml.gz") - resp := MakeRequest(t, req, http.StatusOK) - - type Other struct { - XMLName xml.Name `xml:"otherdata"` - Xmlns string `xml:"xmlns,attr"` - PackageCount int `xml:"packages,attr"` - Packages []struct { - Pkgid string `xml:"pkgid,attr"` - Name string `xml:"name,attr"` - Architecture string `xml:"arch,attr"` - Version struct { - Epoch string `xml:"epoch,attr"` - Version string `xml:"ver,attr"` - Release string `xml:"rel,attr"` - } `xml:"version"` - Changelogs []*rpm_module.Changelog `xml:"changelog"` - } `xml:"package"` - } - - var result Other - decodeGzipXML(t, resp, &result) - - assert.EqualValues(t, 1, result.PackageCount) - assert.Len(t, result.Packages, 1) - p := result.Packages[0] - assert.NotEmpty(t, p.Pkgid) - assert.Equal(t, packageName, p.Name) - assert.Equal(t, packageArchitecture, p.Architecture) - assert.Len(t, p.Changelogs, 1) - c := p.Changelogs[0] - assert.Equal(t, "KN4CK3R ", c.Author) - assert.EqualValues(t, 1678276800, c.Date) - assert.Equal(t, "- Changelog message.", c.Text) - }) - }) - - t.Run("Delete", func(t *testing.T) { - defer tests.PrintCurrentTest(t)() - - req := NewRequest(t, "DELETE", fmt.Sprintf("%s/el9/stable/package/%s/%s/%s", rootURL, packageName, packageVersion, packageArchitecture)) - MakeRequest(t, req, http.StatusUnauthorized) - - req = NewRequest(t, "DELETE", fmt.Sprintf("%s/el9/stable/package/%s/%s/%s", rootURL, packageName, packageVersion, packageArchitecture)). - AddBasicAuth(user.Name) - MakeRequest(t, req, http.StatusNoContent) - - pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeRpm) - assert.NoError(t, err) - assert.Empty(t, pvs) - req = NewRequest(t, "DELETE", fmt.Sprintf("%s/el9/stable/package/%s/%s/%s", rootURL, packageName, packageVersion, packageArchitecture)). - AddBasicAuth(user.Name) - MakeRequest(t, req, http.StatusNotFound) - }) + } } From 07ba4d9f87cf21b7ce87158ae5651cae3bb35604 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 19 Jan 2024 23:05:49 +0900 Subject: [PATCH 25/76] Fix incorrect action duration time when rerun the job before executed once (#28364) Fix #28323 Reason was mentioned here: https://github.com/go-gitea/gitea/issues/28323#issuecomment-1841867298 ### Changes: (maybe breaking) We can rerun jobs in Gitea, so there will be some problems in calculating duration time. In this PR, I use the exist `Started` and `Stopped` column to record the last run time instead of the total time, and add a new `PreviousDuration` column to record the previous duration time. You can also check the cost time of last run: ![image](https://github.com/go-gitea/gitea/assets/18380374/2ca39145-2c92-401a-b78b-43164f7ae061) --- models/actions/run.go | 13 ++++++++----- models/migrations/migrations.go | 2 ++ models/migrations/v1_22/v285.go | 18 ++++++++++++++++++ routers/web/repo/actions/view.go | 11 +++++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 models/migrations/v1_22/v285.go diff --git a/models/actions/run.go b/models/actions/run.go index 1a3701b0b0..fcac58d515 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -46,10 +46,13 @@ type ActionRun struct { TriggerEvent string // the trigger event defined in the `on` configuration of the triggered workflow Status Status `xorm:"index"` Version int `xorm:"version default 0"` // Status could be updated concomitantly, so an optimistic lock is needed - Started timeutil.TimeStamp - Stopped timeutil.TimeStamp - Created timeutil.TimeStamp `xorm:"created"` - Updated timeutil.TimeStamp `xorm:"updated"` + // Started and Stopped is used for recording last run time, if rerun happened, they will be reset to 0 + Started timeutil.TimeStamp + Stopped timeutil.TimeStamp + // PreviousDuration is used for recording previous duration + PreviousDuration time.Duration + Created timeutil.TimeStamp `xorm:"created"` + Updated timeutil.TimeStamp `xorm:"updated"` } func init() { @@ -118,7 +121,7 @@ func (run *ActionRun) LoadAttributes(ctx context.Context) error { } func (run *ActionRun) Duration() time.Duration { - return calculateDuration(run.Started, run.Stopped, run.Status) + return calculateDuration(run.Started, run.Stopped, run.Status) + run.PreviousDuration } func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) { diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 3b4ac24a2c..21675cab8a 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -554,6 +554,8 @@ var migrations = []Migration{ NewMigration("Add combined Index to issue_user.uid and issue_id", v1_22.AddCombinedIndexToIssueUser), // v284 -> v285 NewMigration("Add ignore stale approval column on branch table", v1_22.AddIgnoreStaleApprovalsColumnToProtectedBranchTable), + // v285 -> v286 + NewMigration("Add PreviousDuration to ActionRun", v1_22.AddPreviousDurationToActionRun), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v1_22/v285.go b/models/migrations/v1_22/v285.go new file mode 100644 index 0000000000..c0dacd40bc --- /dev/null +++ b/models/migrations/v1_22/v285.go @@ -0,0 +1,18 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_22 //nolint + +import ( + "time" + + "xorm.io/xorm" +) + +func AddPreviousDurationToActionRun(x *xorm.Engine) error { + type ActionRun struct { + PreviousDuration time.Duration + } + + return x.Sync(&ActionRun{}) +} diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 1cdae32a32..9cda30d23d 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -279,6 +279,17 @@ func Rerun(ctx *context_module.Context) { return } + // reset run's start and stop time when it is done + if run.Status.IsDone() { + run.PreviousDuration = run.Duration() + run.Started = 0 + run.Stopped = 0 + if err := actions_model.UpdateRun(ctx, run, "started", "stopped", "previous_duration"); err != nil { + ctx.Error(http.StatusInternalServerError, err.Error()) + return + } + } + job, jobs := getRunJobs(ctx, runIndex, jobIndex) if ctx.Written() { return From d68a613ba8fd860863a3465b5b5945b191b87b25 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Fri, 19 Jan 2024 16:05:02 +0000 Subject: [PATCH 26/76] Add support for sha256 repositories (#23894) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently only SHA1 repositories are supported by Gitea. This adds support for alternate SHA256 with the additional aim of easier support for additional hash types in the future. Fixes: #13794 Limited by: https://github.com/go-git/go-git/issues/899 Depend on: #28138 图片 --------- Co-authored-by: Lunny Xiao Co-authored-by: 6543 <6543@obermui.de> --- models/git/commit_status.go | 2 +- models/issues/comment.go | 2 +- models/issues/pull.go | 4 +- models/issues/review.go | 2 +- .../Test_RepositoryFormat/repository.yml | 11 + models/migrations/migrations.go | 2 + models/migrations/v1_22/v286.go | 104 ++++++++++ models/migrations/v1_22/v286_test.go | 62 ++++++ models/pull/review_state.go | 2 +- models/repo/archiver.go | 2 +- models/repo/release.go | 2 +- models/repo/repo.go | 6 +- models/repo/repo_indexer.go | 2 +- modules/git/blame_sha256_test.go | 144 +++++++++++++ modules/git/commit_reader.go | 2 + modules/git/commit_sha256_test.go | 195 ++++++++++++++++++ modules/git/git.go | 8 +- modules/git/object_format.go | 65 +++++- modules/git/object_id.go | 16 ++ modules/git/object_id_gogit.go | 2 + modules/git/repo.go | 13 +- modules/git/repo_base.go | 2 + modules/git/repo_base_gogit.go | 4 + modules/git/repo_base_nogogit.go | 4 + .../git/tests/repos/repo1_bare_sha256/HEAD | 1 + .../git/tests/repos/repo1_bare_sha256/config | 6 + .../tests/repos/repo1_bare_sha256/description | 1 + .../repos/repo1_bare_sha256/info/exclude | 6 + .../tests/repos/repo1_bare_sha256/info/refs | 7 + .../objects/info/commit-graph | Bin 0 -> 2048 bytes .../repo1_bare_sha256/objects/info/packs | 2 + ...65970b0c38c6b495d5fc034bc7a7b95334b.bitmap | Bin 0 -> 710 bytes ...78665970b0c38c6b495d5fc034bc7a7b95334b.idx | Bin 0 -> 2576 bytes ...8665970b0c38c6b495d5fc034bc7a7b95334b.pack | Bin 0 -> 5656 bytes ...78665970b0c38c6b495d5fc034bc7a7b95334b.rev | Bin 0 -> 224 bytes .../tests/repos/repo1_bare_sha256/packed-refs | 8 + .../repos/repo1_bare_sha256/refs/heads/main | 1 + .../git/tests/repos/repo5_pulls_sha256/HEAD | 1 + .../git/tests/repos/repo5_pulls_sha256/config | 6 + .../repos/repo5_pulls_sha256/description | 1 + .../tests/repos/repo5_pulls_sha256/info/refs | 4 + .../objects/info/commit-graph | Bin 0 -> 1544 bytes .../repo5_pulls_sha256/objects/info/packs | 2 + ...45d4a02b788eb26c31022a362312660a29d.bitmap | Bin 0 -> 414 bytes ...fe145d4a02b788eb26c31022a362312660a29d.idx | Bin 0 -> 1736 bytes ...e145d4a02b788eb26c31022a362312660a29d.pack | Bin 0 -> 3140 bytes ...fe145d4a02b788eb26c31022a362312660a29d.rev | Bin 0 -> 140 bytes .../repos/repo5_pulls_sha256/packed-refs | 5 + .../repos/repo5_pulls_sha256/refs/heads/main | 1 + .../git/tests/repos/repo6_blame_sha256/HEAD | 1 + .../git/tests/repos/repo6_blame_sha256/config | 6 + .../repos/repo6_blame_sha256/description | 1 + .../repos/repo6_blame_sha256/info/exclude | 6 + .../tests/repos/repo6_blame_sha256/info/refs | 1 + .../objects/info/commit-graph | Bin 0 -> 1376 bytes .../repo6_blame_sha256/objects/info/packs | 2 + ...1ac24312a5ffc3d3703d7c5cc906bdaee8e.bitmap | Bin 0 -> 318 bytes ...b611ac24312a5ffc3d3703d7c5cc906bdaee8e.idx | Bin 0 -> 1456 bytes ...611ac24312a5ffc3d3703d7c5cc906bdaee8e.pack | Bin 0 -> 904 bytes ...b611ac24312a5ffc3d3703d7c5cc906bdaee8e.rev | Bin 0 -> 112 bytes .../repos/repo6_blame_sha256/packed-refs | 2 + .../repos/repo6_blame_sha256/refs/refs/main | 1 + .../git/tests/repos/repo6_merge_sha256/HEAD | 1 + .../git/tests/repos/repo6_merge_sha256/config | 6 + .../repos/repo6_merge_sha256/description | 1 + .../repos/repo6_merge_sha256/info/exclude | 6 + .../tests/repos/repo6_merge_sha256/info/refs | 4 + .../objects/info/commit-graph | Bin 0 -> 1564 bytes .../repo6_merge_sha256/objects/info/packs | 3 + ...096c7530f577d5c0a79c63d9ac2b44f7510.bitmap | Bin 0 -> 410 bytes ...b6a096c7530f577d5c0a79c63d9ac2b44f7510.idx | Bin 0 -> 1696 bytes ...6a096c7530f577d5c0a79c63d9ac2b44f7510.pack | Bin 0 -> 1556 bytes ...b6a096c7530f577d5c0a79c63d9ac2b44f7510.rev | Bin 0 -> 136 bytes ...e67bb2a4a5501ca1fa3528fad8a9474fba7e50.idx | Bin 0 -> 1176 bytes ...bb2a4a5501ca1fa3528fad8a9474fba7e50.mtimes | Bin 0 -> 84 bytes ...67bb2a4a5501ca1fa3528fad8a9474fba7e50.pack | Bin 0 -> 447 bytes ...e67bb2a4a5501ca1fa3528fad8a9474fba7e50.rev | Bin 0 -> 84 bytes .../repos/repo6_merge_sha256/packed-refs | 5 + .../repos/repo6_merge_sha256/refs/heads/main | 1 + modules/markup/html.go | 36 ++-- modules/markup/html_internal_test.go | 6 +- modules/references/references.go | 2 +- modules/references/references_test.go | 2 +- modules/structs/repo.go | 6 + modules/templates/util_string.go | 4 + options/locale/locale_en-US.ini | 3 + routers/api/v1/repo/repo.go | 2 +- routers/web/githttp.go | 6 +- routers/web/repo/repo.go | 3 +- routers/web/web.go | 14 +- services/repository/create.go | 4 + services/repository/fork.go | 23 ++- templates/admin/repo/list.tmpl | 3 + templates/explore/repo_list.tmpl | 3 + templates/repo/commits_list.tmpl | 2 +- templates/repo/create.tmpl | 13 ++ templates/repo/header.tmpl | 3 + templates/swagger/v1_json.tmpl | 18 ++ 98 files changed, 834 insertions(+), 76 deletions(-) create mode 100644 models/migrations/fixtures/Test_RepositoryFormat/repository.yml create mode 100644 models/migrations/v1_22/v286.go create mode 100644 models/migrations/v1_22/v286_test.go create mode 100644 modules/git/blame_sha256_test.go create mode 100644 modules/git/commit_sha256_test.go create mode 100644 modules/git/tests/repos/repo1_bare_sha256/HEAD create mode 100644 modules/git/tests/repos/repo1_bare_sha256/config create mode 100644 modules/git/tests/repos/repo1_bare_sha256/description create mode 100644 modules/git/tests/repos/repo1_bare_sha256/info/exclude create mode 100644 modules/git/tests/repos/repo1_bare_sha256/info/refs create mode 100644 modules/git/tests/repos/repo1_bare_sha256/objects/info/commit-graph create mode 100644 modules/git/tests/repos/repo1_bare_sha256/objects/info/packs create mode 100644 modules/git/tests/repos/repo1_bare_sha256/objects/pack/pack-c01aa121b9c5e345fe0da2f9be78665970b0c38c6b495d5fc034bc7a7b95334b.bitmap create mode 100644 modules/git/tests/repos/repo1_bare_sha256/objects/pack/pack-c01aa121b9c5e345fe0da2f9be78665970b0c38c6b495d5fc034bc7a7b95334b.idx create mode 100644 modules/git/tests/repos/repo1_bare_sha256/objects/pack/pack-c01aa121b9c5e345fe0da2f9be78665970b0c38c6b495d5fc034bc7a7b95334b.pack create mode 100644 modules/git/tests/repos/repo1_bare_sha256/objects/pack/pack-c01aa121b9c5e345fe0da2f9be78665970b0c38c6b495d5fc034bc7a7b95334b.rev create mode 100644 modules/git/tests/repos/repo1_bare_sha256/packed-refs create mode 100644 modules/git/tests/repos/repo1_bare_sha256/refs/heads/main create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/HEAD create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/config create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/description create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/info/refs create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/objects/info/commit-graph create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/objects/info/packs create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/objects/pack/pack-bfe8f09d42ef5dd1610bf42641fe145d4a02b788eb26c31022a362312660a29d.bitmap create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/objects/pack/pack-bfe8f09d42ef5dd1610bf42641fe145d4a02b788eb26c31022a362312660a29d.idx create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/objects/pack/pack-bfe8f09d42ef5dd1610bf42641fe145d4a02b788eb26c31022a362312660a29d.pack create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/objects/pack/pack-bfe8f09d42ef5dd1610bf42641fe145d4a02b788eb26c31022a362312660a29d.rev create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/packed-refs create mode 100644 modules/git/tests/repos/repo5_pulls_sha256/refs/heads/main create mode 100644 modules/git/tests/repos/repo6_blame_sha256/HEAD create mode 100644 modules/git/tests/repos/repo6_blame_sha256/config create mode 100644 modules/git/tests/repos/repo6_blame_sha256/description create mode 100644 modules/git/tests/repos/repo6_blame_sha256/info/exclude create mode 100644 modules/git/tests/repos/repo6_blame_sha256/info/refs create mode 100644 modules/git/tests/repos/repo6_blame_sha256/objects/info/commit-graph create mode 100644 modules/git/tests/repos/repo6_blame_sha256/objects/info/packs create mode 100644 modules/git/tests/repos/repo6_blame_sha256/objects/pack/pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.bitmap create mode 100644 modules/git/tests/repos/repo6_blame_sha256/objects/pack/pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.idx create mode 100644 modules/git/tests/repos/repo6_blame_sha256/objects/pack/pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.pack create mode 100644 modules/git/tests/repos/repo6_blame_sha256/objects/pack/pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.rev create mode 100644 modules/git/tests/repos/repo6_blame_sha256/packed-refs create mode 100644 modules/git/tests/repos/repo6_blame_sha256/refs/refs/main create mode 100644 modules/git/tests/repos/repo6_merge_sha256/HEAD create mode 100644 modules/git/tests/repos/repo6_merge_sha256/config create mode 100644 modules/git/tests/repos/repo6_merge_sha256/description create mode 100644 modules/git/tests/repos/repo6_merge_sha256/info/exclude create mode 100644 modules/git/tests/repos/repo6_merge_sha256/info/refs create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/info/commit-graph create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/info/packs create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.bitmap create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.idx create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.pack create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.rev create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.idx create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.mtimes create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.pack create mode 100644 modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.rev create mode 100644 modules/git/tests/repos/repo6_merge_sha256/packed-refs create mode 100644 modules/git/tests/repos/repo6_merge_sha256/refs/heads/main diff --git a/models/git/commit_status.go b/models/git/commit_status.go index c126d17f20..1118b6cc8c 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -37,7 +37,7 @@ type CommitStatus struct { SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"` TargetURL string `xorm:"TEXT"` Description string `xorm:"TEXT"` - ContextHash string `xorm:"char(40) index"` + ContextHash string `xorm:"VARCHAR(64) index"` Context string `xorm:"TEXT"` Creator *user_model.User `xorm:"-"` CreatorID int64 diff --git a/models/issues/comment.go b/models/issues/comment.go index a1698d4824..8a3bae5b88 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -270,7 +270,7 @@ type Comment struct { UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` // Reference issue in commit message - CommitSHA string `xorm:"VARCHAR(40)"` + CommitSHA string `xorm:"VARCHAR(64)"` Attachments []*repo_model.Attachment `xorm:"-"` Reactions ReactionList `xorm:"-"` diff --git a/models/issues/pull.go b/models/issues/pull.go index 614ee9a87c..4ae6e38ae1 100644 --- a/models/issues/pull.go +++ b/models/issues/pull.go @@ -171,11 +171,11 @@ type PullRequest struct { HeadBranch string HeadCommitID string `xorm:"-"` BaseBranch string - MergeBase string `xorm:"VARCHAR(40)"` + MergeBase string `xorm:"VARCHAR(64)"` AllowMaintainerEdit bool `xorm:"NOT NULL DEFAULT false"` HasMerged bool `xorm:"INDEX"` - MergedCommitID string `xorm:"VARCHAR(40)"` + MergedCommitID string `xorm:"VARCHAR(64)"` MergerID int64 `xorm:"INDEX"` Merger *user_model.User `xorm:"-"` MergedUnix timeutil.TimeStamp `xorm:"updated INDEX"` diff --git a/models/issues/review.go b/models/issues/review.go index 4cbfa4f443..f2022ae0aa 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -116,7 +116,7 @@ type Review struct { Content string `xorm:"TEXT"` // Official is a review made by an assigned approver (counts towards approval) Official bool `xorm:"NOT NULL DEFAULT false"` - CommitID string `xorm:"VARCHAR(40)"` + CommitID string `xorm:"VARCHAR(64)"` Stale bool `xorm:"NOT NULL DEFAULT false"` Dismissed bool `xorm:"NOT NULL DEFAULT false"` diff --git a/models/migrations/fixtures/Test_RepositoryFormat/repository.yml b/models/migrations/fixtures/Test_RepositoryFormat/repository.yml new file mode 100644 index 0000000000..5a3675917c --- /dev/null +++ b/models/migrations/fixtures/Test_RepositoryFormat/repository.yml @@ -0,0 +1,11 @@ +# type Repository struct { +# ID int64 `xorm:"pk autoincr"` +# } +- + id: 1 +- + id: 2 +- + id: 3 +- + id: 10 diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 21675cab8a..beb1f3bb96 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -556,6 +556,8 @@ var migrations = []Migration{ NewMigration("Add ignore stale approval column on branch table", v1_22.AddIgnoreStaleApprovalsColumnToProtectedBranchTable), // v285 -> v286 NewMigration("Add PreviousDuration to ActionRun", v1_22.AddPreviousDurationToActionRun), + // v286 -> v287 + NewMigration("Add support for SHA256 git repositories", v1_22.AdjustDBForSha256), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v1_22/v286.go b/models/migrations/v1_22/v286.go new file mode 100644 index 0000000000..ef19f64221 --- /dev/null +++ b/models/migrations/v1_22/v286.go @@ -0,0 +1,104 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT +package v1_22 //nolint + +import ( + "errors" + "fmt" + + "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" + + "xorm.io/xorm" +) + +func expandHashReferencesToSha256(x *xorm.Engine) error { + alteredTables := [][2]string{ + {"commit_status", "context_hash"}, + {"comment", "commit_sha"}, + {"pull_request", "merge_base"}, + {"pull_request", "merged_commit_id"}, + {"review", "commit_id"}, + {"review_state", "commit_sha"}, + {"repo_archiver", "commit_id"}, + {"release", "sha1"}, + {"repo_indexer_status", "commit_sha"}, + } + + db := x.NewSession() + defer db.Close() + + if err := db.Begin(); err != nil { + return err + } + + if !setting.Database.Type.IsSQLite3() { + if setting.Database.Type.IsMSSQL() { + // drop indexes that need to be re-created afterwards + droppedIndexes := []string{ + "DROP INDEX commit_status.IDX_commit_status_context_hash", + "DROP INDEX review_state.UQE_review_state_pull_commit_user", + "DROP INDEX repo_archiver.UQE_repo_archiver_s", + } + for _, s := range droppedIndexes { + _, err := db.Exec(s) + if err != nil { + return errors.New(s + " " + err.Error()) + } + } + } + + for _, alts := range alteredTables { + var err error + if setting.Database.Type.IsMySQL() { + _, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` MODIFY COLUMN `%s` VARCHAR(64)", alts[0], alts[1])) + } else if setting.Database.Type.IsMSSQL() { + _, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` VARCHAR(64)", alts[0], alts[1])) + } else { + _, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` TYPE VARCHAR(64)", alts[0], alts[1])) + } + if err != nil { + return fmt.Errorf("alter column '%s' of table '%s' failed: %w", alts[1], alts[0], err) + } + } + + if setting.Database.Type.IsMSSQL() { + recreateIndexes := []string{ + "CREATE INDEX IDX_commit_status_context_hash ON commit_status(context_hash)", + "CREATE UNIQUE INDEX UQE_review_state_pull_commit_user ON review_state(user_id, pull_id, commit_sha)", + "CREATE UNIQUE INDEX UQE_repo_archiver_s ON repo_archiver(repo_id, type, commit_id)", + } + for _, s := range recreateIndexes { + _, err := db.Exec(s) + if err != nil { + return errors.New(s + " " + err.Error()) + } + } + } + } + log.Debug("Updated database tables to hold SHA256 git hash references") + + return db.Commit() +} + +func addObjectFormatNameToRepository(x *xorm.Engine) error { + type Repository struct { + ObjectFormatName string `xorm:"VARCHAR(6) NOT NULL DEFAULT 'sha1'"` + } + + if err := x.Sync(new(Repository)); err != nil { + return err + } + + // Here to catch weird edge-cases where column constraints above are + // not applied by the DB backend + _, err := x.Exec("UPDATE repository set object_format_name = 'sha1' WHERE object_format_name = '' or object_format_name IS NULL") + return err +} + +func AdjustDBForSha256(x *xorm.Engine) error { + if err := expandHashReferencesToSha256(x); err != nil { + return err + } + return addObjectFormatNameToRepository(x) +} diff --git a/models/migrations/v1_22/v286_test.go b/models/migrations/v1_22/v286_test.go new file mode 100644 index 0000000000..e36a18a116 --- /dev/null +++ b/models/migrations/v1_22/v286_test.go @@ -0,0 +1,62 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_22 //nolint + +import ( + "testing" + + "code.gitea.io/gitea/models/migrations/base" + + "github.com/stretchr/testify/assert" + "xorm.io/xorm" +) + +func PrepareOldRepository(t *testing.T) (*xorm.Engine, func()) { + type Repository struct { // old struct + ID int64 `xorm:"pk autoincr"` + } + + // Prepare and load the testing database + return base.PrepareTestEnv(t, 0, new(Repository)) +} + +func Test_RepositoryFormat(t *testing.T) { + x, deferable := PrepareOldRepository(t) + defer deferable() + + type Repository struct { + ID int64 `xorm:"pk autoincr"` + ObjectFormatName string `xorg:"not null default('sha1')"` + } + + repo := new(Repository) + + // check we have some records to migrate + count, err := x.Count(new(Repository)) + assert.NoError(t, err) + assert.EqualValues(t, 4, count) + + assert.NoError(t, AdjustDBForSha256(x)) + + repo.ID = 20 + repo.ObjectFormatName = "sha256" + _, err = x.Insert(repo) + assert.NoError(t, err) + + count, err = x.Count(new(Repository)) + assert.NoError(t, err) + assert.EqualValues(t, 5, count) + + repo = new(Repository) + ok, err := x.ID(2).Get(repo) + assert.NoError(t, err) + assert.EqualValues(t, true, ok) + assert.EqualValues(t, "sha1", repo.ObjectFormatName) + + repo = new(Repository) + ok, err = x.ID(20).Get(repo) + assert.NoError(t, err) + assert.EqualValues(t, true, ok) + assert.EqualValues(t, "sha256", repo.ObjectFormatName) +} diff --git a/models/pull/review_state.go b/models/pull/review_state.go index 1a2b1e165f..e46a22a49d 100644 --- a/models/pull/review_state.go +++ b/models/pull/review_state.go @@ -39,7 +39,7 @@ type ReviewState struct { ID int64 `xorm:"pk autoincr"` UserID int64 `xorm:"NOT NULL UNIQUE(pull_commit_user)"` PullID int64 `xorm:"NOT NULL INDEX UNIQUE(pull_commit_user) DEFAULT 0"` // Which PR was the review on? - CommitSHA string `xorm:"NOT NULL VARCHAR(40) UNIQUE(pull_commit_user)"` // Which commit was the head commit for the review? + CommitSHA string `xorm:"NOT NULL VARCHAR(64) UNIQUE(pull_commit_user)"` // Which commit was the head commit for the review? UpdatedFiles map[string]ViewedState `xorm:"NOT NULL LONGTEXT JSON"` // Stores for each of the changed files of a PR whether they have been viewed, changed since last viewed, or not viewed UpdatedUnix timeutil.TimeStamp `xorm:"updated"` // Is an accurate indicator of the order of commits as we do not expect it to be possible to make reviews on previous commits } diff --git a/models/repo/archiver.go b/models/repo/archiver.go index d9520c670c..14ffa1d89b 100644 --- a/models/repo/archiver.go +++ b/models/repo/archiver.go @@ -33,7 +33,7 @@ type RepoArchiver struct { //revive:disable-line:exported RepoID int64 `xorm:"index unique(s)"` Type git.ArchiveType `xorm:"unique(s)"` Status ArchiverStatus - CommitID string `xorm:"VARCHAR(40) unique(s)"` + CommitID string `xorm:"VARCHAR(64) unique(s)"` CreatedUnix timeutil.TimeStamp `xorm:"INDEX NOT NULL created"` } diff --git a/models/repo/release.go b/models/repo/release.go index 72a73f8e80..1f37f11b2e 100644 --- a/models/repo/release.go +++ b/models/repo/release.go @@ -75,7 +75,7 @@ type Release struct { Target string TargetBehind string `xorm:"-"` // to handle non-existing or empty target Title string - Sha1 string `xorm:"VARCHAR(40)"` + Sha1 string `xorm:"VARCHAR(64)"` NumCommits int64 NumCommitsBehind int64 `xorm:"-"` Note string `xorm:"TEXT"` diff --git a/models/repo/repo.go b/models/repo/repo.go index 3695e1f78b..4401041cdd 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -180,7 +180,7 @@ type Repository struct { IsFsckEnabled bool `xorm:"NOT NULL DEFAULT true"` CloseIssuesViaCommitInAnyBranch bool `xorm:"NOT NULL DEFAULT false"` Topics []string `xorm:"TEXT JSON"` - ObjectFormatName string `xorm:"-"` + ObjectFormatName string `xorm:"VARCHAR(6) NOT NULL DEFAULT 'sha1'"` TrustModel TrustModelType @@ -276,10 +276,6 @@ func (repo *Repository) AfterLoad() { repo.NumOpenMilestones = repo.NumMilestones - repo.NumClosedMilestones repo.NumOpenProjects = repo.NumProjects - repo.NumClosedProjects repo.NumOpenActionRuns = repo.NumActionRuns - repo.NumClosedActionRuns - - // this is a temporary behaviour to support old repos, next step is to store the object format in the database - // and read from database so this line could be removed. To not depend on git module, we use a constant variable here - repo.ObjectFormatName = "sha1" } // LoadAttributes loads attributes of the repository. diff --git a/models/repo/repo_indexer.go b/models/repo/repo_indexer.go index bad1248b40..6e19d8f937 100644 --- a/models/repo/repo_indexer.go +++ b/models/repo/repo_indexer.go @@ -27,7 +27,7 @@ const ( type RepoIndexerStatus struct { //revive:disable-line:exported ID int64 `xorm:"pk autoincr"` RepoID int64 `xorm:"INDEX(s)"` - CommitSha string `xorm:"VARCHAR(40)"` + CommitSha string `xorm:"VARCHAR(64)"` IndexerType RepoIndexerType `xorm:"INDEX(s) NOT NULL DEFAULT 0"` } diff --git a/modules/git/blame_sha256_test.go b/modules/git/blame_sha256_test.go new file mode 100644 index 0000000000..01de0454a3 --- /dev/null +++ b/modules/git/blame_sha256_test.go @@ -0,0 +1,144 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package git + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestReadingBlameOutputSha256(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + t.Run("Without .git-blame-ignore-revs", func(t *testing.T) { + repo, err := OpenRepository(ctx, "./tests/repos/repo5_pulls_sha256") + assert.NoError(t, err) + defer repo.Close() + + commit, err := repo.GetCommit("0b69b7bb649b5d46e14cabb6468685e5dd721290acc7ffe604d37cde57927345") + assert.NoError(t, err) + + parts := []*BlamePart{ + { + Sha: "1e35a51dc00fd7de730344c07061acfe80e8117e075ac979b6a29a3a045190ca", + Lines: []string{ + "# test_repo", + "Test repository for testing migration from github to gitea", + }, + }, + { + Sha: "0b69b7bb649b5d46e14cabb6468685e5dd721290acc7ffe604d37cde57927345", + Lines: []string{"", "Do not make any changes to this repo it is used for unit testing"}, + PreviousSha: "1e35a51dc00fd7de730344c07061acfe80e8117e075ac979b6a29a3a045190ca", + PreviousPath: "README.md", + }, + } + + for _, bypass := range []bool{false, true} { + blameReader, err := CreateBlameReader(ctx, Sha256ObjectFormat, "./tests/repos/repo5_pulls_sha256", commit, "README.md", bypass) + assert.NoError(t, err) + assert.NotNil(t, blameReader) + defer blameReader.Close() + + assert.False(t, blameReader.UsesIgnoreRevs()) + + for _, part := range parts { + actualPart, err := blameReader.NextPart() + assert.NoError(t, err) + assert.Equal(t, part, actualPart) + } + + // make sure all parts have been read + actualPart, err := blameReader.NextPart() + assert.Nil(t, actualPart) + assert.NoError(t, err) + } + }) + + t.Run("With .git-blame-ignore-revs", func(t *testing.T) { + repo, err := OpenRepository(ctx, "./tests/repos/repo6_blame_sha256") + assert.NoError(t, err) + defer repo.Close() + + full := []*BlamePart{ + { + Sha: "ab2b57a4fa476fb2edb74dafa577caf918561abbaa8fba0c8dc63c412e17a7cc", + Lines: []string{"line", "line"}, + }, + { + Sha: "9347b0198cd1f25017579b79d0938fa89dba34ad2514f0dd92f6bc975ed1a2fe", + Lines: []string{"changed line"}, + PreviousSha: "ab2b57a4fa476fb2edb74dafa577caf918561abbaa8fba0c8dc63c412e17a7cc", + PreviousPath: "blame.txt", + }, + { + Sha: "ab2b57a4fa476fb2edb74dafa577caf918561abbaa8fba0c8dc63c412e17a7cc", + Lines: []string{"line", "line", ""}, + }, + } + + cases := []struct { + CommitID string + UsesIgnoreRevs bool + Bypass bool + Parts []*BlamePart + }{ + { + CommitID: "e2f5660e15159082902960af0ed74fc144921d2b0c80e069361853b3ece29ba3", + UsesIgnoreRevs: true, + Bypass: false, + Parts: []*BlamePart{ + { + Sha: "ab2b57a4fa476fb2edb74dafa577caf918561abbaa8fba0c8dc63c412e17a7cc", + Lines: []string{"line", "line", "changed line", "line", "line", ""}, + }, + }, + }, + { + CommitID: "e2f5660e15159082902960af0ed74fc144921d2b0c80e069361853b3ece29ba3", + UsesIgnoreRevs: false, + Bypass: true, + Parts: full, + }, + { + CommitID: "9347b0198cd1f25017579b79d0938fa89dba34ad2514f0dd92f6bc975ed1a2fe", + UsesIgnoreRevs: false, + Bypass: false, + Parts: full, + }, + { + CommitID: "9347b0198cd1f25017579b79d0938fa89dba34ad2514f0dd92f6bc975ed1a2fe", + UsesIgnoreRevs: false, + Bypass: false, + Parts: full, + }, + } + + for _, c := range cases { + commit, err := repo.GetCommit(c.CommitID) + assert.NoError(t, err) + + blameReader, err := CreateBlameReader(ctx, repo.objectFormat, "./tests/repos/repo6_blame_sha256", commit, "blame.txt", c.Bypass) + assert.NoError(t, err) + assert.NotNil(t, blameReader) + defer blameReader.Close() + + assert.Equal(t, c.UsesIgnoreRevs, blameReader.UsesIgnoreRevs()) + + for _, part := range c.Parts { + actualPart, err := blameReader.NextPart() + assert.NoError(t, err) + assert.Equal(t, part, actualPart) + } + + // make sure all parts have been read + actualPart, err := blameReader.NextPart() + assert.Nil(t, actualPart) + assert.NoError(t, err) + } + }) +} diff --git a/modules/git/commit_reader.go b/modules/git/commit_reader.go index d74bcffed8..4809d6c7ed 100644 --- a/modules/git/commit_reader.go +++ b/modules/git/commit_reader.go @@ -85,6 +85,8 @@ readLoop: commit.Committer.Decode(data) _, _ = payloadSB.Write(line) case "gpgsig": + fallthrough + case "gpgsig-sha256": // FIXME: no intertop, so only 1 exists at present. _, _ = signatureSB.Write(data) _ = signatureSB.WriteByte('\n') pgpsig = true diff --git a/modules/git/commit_sha256_test.go b/modules/git/commit_sha256_test.go new file mode 100644 index 0000000000..82112cb409 --- /dev/null +++ b/modules/git/commit_sha256_test.go @@ -0,0 +1,195 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +//go:build !gogit + +package git + +import ( + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCommitsCountSha256(t *testing.T) { + bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256") + + commitsCount, err := CommitsCount(DefaultContext, + CommitsCountOptions{ + RepoPath: bareRepo1Path, + Revision: []string{"f004f41359117d319dedd0eaab8c5259ee2263da839dcba33637997458627fdc"}, + }) + + assert.NoError(t, err) + assert.Equal(t, int64(3), commitsCount) +} + +func TestCommitsCountWithoutBaseSha256(t *testing.T) { + bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256") + + commitsCount, err := CommitsCount(DefaultContext, + CommitsCountOptions{ + RepoPath: bareRepo1Path, + Not: "main", + Revision: []string{"branch1"}, + }) + + assert.NoError(t, err) + assert.Equal(t, int64(2), commitsCount) +} + +func TestGetFullCommitIDSha256(t *testing.T) { + bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256") + + id, err := GetFullCommitID(DefaultContext, bareRepo1Path, "f004f4") + assert.NoError(t, err) + assert.Equal(t, "f004f41359117d319dedd0eaab8c5259ee2263da839dcba33637997458627fdc", id) +} + +func TestGetFullCommitIDErrorSha256(t *testing.T) { + bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256") + + id, err := GetFullCommitID(DefaultContext, bareRepo1Path, "unknown") + assert.Empty(t, id) + if assert.Error(t, err) { + assert.EqualError(t, err, "object does not exist [id: unknown, rel_path: ]") + } +} + +func TestCommitFromReaderSha256(t *testing.T) { + commitString := `9433b2a62b964c17a4485ae180f45f595d3e69d31b786087775e28c6b6399df0 commit 1114 +tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e +parent 26e9ccc29fad747e9c5d9f4c9ddeb7eff61cc45ef6a8dc258cbeb181afc055e8 +author Adam Majer 1698676906 +0100 +committer Adam Majer 1698676906 +0100 +gpgsig-sha256 -----BEGIN PGP SIGNATURE----- +` + " " + ` + iQIrBAABCgAtFiEES+fB08xlgTrzSdQvhkUIsBsmec8FAmU/wKoPHGFtYWplckBz + dXNlLmRlAAoJEIZFCLAbJnnP4s4PQIJATa++WPzR6/H4etT7bsOGoMyguEJYyWOd + aTybplzT7QAL7h2to0QszGabtzMJPIA39xSFZNYNN30voK5YyyYibXluPKgjemfK + WNXwF+gkwgZI38gSvKf+vlqI+EYyIFe19wOhiju0m8SIlB5NEPiWHa17q2mqmqqx + 1FWa2JdqLPYjAtSLFXeSZegrY5V1FxdemyMUONkg8YO9OSIMZiE0GsnnOXQ3xcT4 + JTCnmlUxIKw689UiEY80JopUIq+Wl7+qq9507IYYSUCyB6JazL42AKMzVCbD+qBP + oOzh/hafYgk9H9qCQXaLbmvs17zXRpicig1bAzqgAy1FDelvpERyRTydEajSLIG6 + U1cRCkgXCZ0NfsYNPPmBa8b3+rnstypXYTbyMwTln7FfUAaGo6o9JYiPMkzxlmsy + zfp/tcaY8+LlBL9aOJjtv+a0p+HrpCGd6CCa4ARfphTLq8QRSSh8uzlB9N+6HnRI + VAEUo6ecdDxSpyt2naeg9pKus/BRi7P6g4B1hkk/zZstUX/QP4IQuAJbXjkvsC+X + HKRr3NlRM/DygzTyj0gN74uoa0goCIbyAQhiT42nm0cuhM7uN/W0ayrlZjGF1cbR + 8NCJUL2Nwj0ywKIavC99Ipkb8AsFwpVT6U6effs6 + =xybZ + -----END PGP SIGNATURE----- + +signed commit` + + sha := &Sha256Hash{ + 0x94, 0x33, 0xb2, 0xa6, 0x2b, 0x96, 0x4c, 0x17, 0xa4, 0x48, 0x5a, 0xe1, 0x80, 0xf4, 0x5f, 0x59, + 0x5d, 0x3e, 0x69, 0xd3, 0x1b, 0x78, 0x60, 0x87, 0x77, 0x5e, 0x28, 0xc6, 0xb6, 0x39, 0x9d, 0xf0, + } + gitRepo, err := openRepositoryWithDefaultContext(filepath.Join(testReposDir, "repo1_bare_sha256")) + assert.NoError(t, err) + assert.NotNil(t, gitRepo) + defer gitRepo.Close() + + commitFromReader, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString)) + assert.NoError(t, err) + if !assert.NotNil(t, commitFromReader) { + return + } + assert.EqualValues(t, sha, commitFromReader.ID) + assert.EqualValues(t, `-----BEGIN PGP SIGNATURE----- + +iQIrBAABCgAtFiEES+fB08xlgTrzSdQvhkUIsBsmec8FAmU/wKoPHGFtYWplckBz +dXNlLmRlAAoJEIZFCLAbJnnP4s4PQIJATa++WPzR6/H4etT7bsOGoMyguEJYyWOd +aTybplzT7QAL7h2to0QszGabtzMJPIA39xSFZNYNN30voK5YyyYibXluPKgjemfK +WNXwF+gkwgZI38gSvKf+vlqI+EYyIFe19wOhiju0m8SIlB5NEPiWHa17q2mqmqqx +1FWa2JdqLPYjAtSLFXeSZegrY5V1FxdemyMUONkg8YO9OSIMZiE0GsnnOXQ3xcT4 +JTCnmlUxIKw689UiEY80JopUIq+Wl7+qq9507IYYSUCyB6JazL42AKMzVCbD+qBP +oOzh/hafYgk9H9qCQXaLbmvs17zXRpicig1bAzqgAy1FDelvpERyRTydEajSLIG6 +U1cRCkgXCZ0NfsYNPPmBa8b3+rnstypXYTbyMwTln7FfUAaGo6o9JYiPMkzxlmsy +zfp/tcaY8+LlBL9aOJjtv+a0p+HrpCGd6CCa4ARfphTLq8QRSSh8uzlB9N+6HnRI +VAEUo6ecdDxSpyt2naeg9pKus/BRi7P6g4B1hkk/zZstUX/QP4IQuAJbXjkvsC+X +HKRr3NlRM/DygzTyj0gN74uoa0goCIbyAQhiT42nm0cuhM7uN/W0ayrlZjGF1cbR +8NCJUL2Nwj0ywKIavC99Ipkb8AsFwpVT6U6effs6 +=xybZ +-----END PGP SIGNATURE----- +`, commitFromReader.Signature.Signature) + assert.EqualValues(t, `tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e +parent 26e9ccc29fad747e9c5d9f4c9ddeb7eff61cc45ef6a8dc258cbeb181afc055e8 +author Adam Majer 1698676906 +0100 +committer Adam Majer 1698676906 +0100 + +signed commit`, commitFromReader.Signature.Payload) + assert.EqualValues(t, "Adam Majer ", commitFromReader.Author.String()) + + commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n")) + assert.NoError(t, err) + commitFromReader.CommitMessage += "\n\n" + commitFromReader.Signature.Payload += "\n\n" + assert.EqualValues(t, commitFromReader, commitFromReader2) +} + +func TestHasPreviousCommitSha256(t *testing.T) { + bareRepo1Path := filepath.Join(testReposDir, "repo1_bare_sha256") + + repo, err := openRepositoryWithDefaultContext(bareRepo1Path) + assert.NoError(t, err) + defer repo.Close() + + commit, err := repo.GetCommit("f004f41359117d319dedd0eaab8c5259ee2263da839dcba33637997458627fdc") + assert.NoError(t, err) + + parentSHA := MustIDFromString("b0ec7af4547047f12d5093e37ef8f1b3b5415ed8ee17894d43a34d7d34212e9c") + notParentSHA := MustIDFromString("42e334efd04cd36eea6da0599913333c26116e1a537ca76e5b6e4af4dda00236") + assert.Equal(t, repo.objectFormat, parentSHA.Type()) + assert.Equal(t, repo.objectFormat.Name(), "sha256") + + haz, err := commit.HasPreviousCommit(parentSHA) + assert.NoError(t, err) + assert.True(t, haz) + + hazNot, err := commit.HasPreviousCommit(notParentSHA) + assert.NoError(t, err) + assert.False(t, hazNot) + + selfNot, err := commit.HasPreviousCommit(commit.ID) + assert.NoError(t, err) + assert.False(t, selfNot) +} + +func TestGetCommitFileStatusMergesSha256(t *testing.T) { + bareRepo1Path := filepath.Join(testReposDir, "repo6_merge_sha256") + + commitFileStatus, err := GetCommitFileStatus(DefaultContext, bareRepo1Path, "d2e5609f630dd8db500f5298d05d16def282412e3e66ed68cc7d0833b29129a1") + assert.NoError(t, err) + + expected := CommitFileStatus{ + []string{ + "add_file.txt", + }, + []string{}, + []string{ + "to_modify.txt", + }, + } + + assert.Equal(t, expected.Added, commitFileStatus.Added) + assert.Equal(t, expected.Removed, commitFileStatus.Removed) + assert.Equal(t, expected.Modified, commitFileStatus.Modified) + + expected = CommitFileStatus{ + []string{}, + []string{ + "to_remove.txt", + }, + []string{}, + } + + commitFileStatus, err = GetCommitFileStatus(DefaultContext, bareRepo1Path, "da1ded40dc8e5b7c564171f4bf2fc8370487decfb1cb6a99ef28f3ed73d09172") + assert.NoError(t, err) + + assert.Equal(t, expected.Added, commitFileStatus.Added) + assert.Equal(t, expected.Removed, commitFileStatus.Removed) + assert.Equal(t, expected.Modified, commitFileStatus.Modified) +} diff --git a/modules/git/git.go b/modules/git/git.go index 24eff05afc..89c23ff230 100644 --- a/modules/git/git.go +++ b/modules/git/git.go @@ -185,7 +185,13 @@ func InitFull(ctx context.Context) (err error) { globalCommandArgs = append(globalCommandArgs, "-c", "credential.helper=") } SupportProcReceive = CheckGitVersionAtLeast("2.29") == nil - SupportHashSha256 = CheckGitVersionAtLeast("2.42") == nil + SupportHashSha256 = CheckGitVersionAtLeast("2.42") == nil && !isGogit + if SupportHashSha256 { + SupportedObjectFormats = append(SupportedObjectFormats, Sha256ObjectFormat) + } else { + log.Warn("sha256 hash support is disabled - requires Git >= 2.42. Gogit is currently unsupported") + } + if setting.LFS.StartServer { if CheckGitVersionAtLeast("2.1.2") != nil { return errors.New("LFS server support requires Git >= 2.1.2") diff --git a/modules/git/object_format.go b/modules/git/object_format.go index 27771e7459..a056b20e8a 100644 --- a/modules/git/object_format.go +++ b/modules/git/object_format.go @@ -5,6 +5,7 @@ package git import ( "crypto/sha1" + "crypto/sha256" "regexp" "strconv" ) @@ -12,6 +13,9 @@ import ( // sha1Pattern can be used to determine if a string is an valid sha var sha1Pattern = regexp.MustCompile(`^[0-9a-f]{4,40}$`) +// sha256Pattern can be used to determine if a string is an valid sha +var sha256Pattern = regexp.MustCompile(`^[0-9a-f]{4,64}$`) + type ObjectFormat interface { // Name returns the name of the object format Name() string @@ -29,11 +33,12 @@ type ObjectFormat interface { ComputeHash(t ObjectType, content []byte) ObjectID } +/* SHA1 Type */ type Sha1ObjectFormatImpl struct{} var ( - emptyObjectID = &Sha1Hash{} - emptyTree = &Sha1Hash{ + emptySha1ObjectID = &Sha1Hash{} + emptySha1Tree = &Sha1Hash{ 0x4b, 0x82, 0x5d, 0xc6, 0x42, 0xcb, 0x6e, 0xb9, 0xa0, 0x60, 0xe5, 0x4b, 0xf8, 0xd6, 0x92, 0x88, 0xfb, 0xee, 0x49, 0x04, } @@ -41,11 +46,11 @@ var ( func (Sha1ObjectFormatImpl) Name() string { return "sha1" } func (Sha1ObjectFormatImpl) EmptyObjectID() ObjectID { - return emptyObjectID + return emptySha1ObjectID } func (Sha1ObjectFormatImpl) EmptyTree() ObjectID { - return emptyTree + return emptySha1Tree } func (Sha1ObjectFormatImpl) FullLength() int { return 40 } func (Sha1ObjectFormatImpl) IsValid(input string) bool { @@ -72,11 +77,59 @@ func (h Sha1ObjectFormatImpl) ComputeHash(t ObjectType, content []byte) ObjectID return &sha1 } -var Sha1ObjectFormat ObjectFormat = Sha1ObjectFormatImpl{} +/* SHA256 Type */ +type Sha256ObjectFormatImpl struct{} + +var ( + emptySha256ObjectID = &Sha256Hash{} + emptySha256Tree = &Sha256Hash{ + 0x6e, 0xf1, 0x9b, 0x41, 0x22, 0x5c, 0x53, 0x69, 0xf1, 0xc1, + 0x04, 0xd4, 0x5d, 0x8d, 0x85, 0xef, 0xa9, 0xb0, 0x57, 0xb5, + 0x3b, 0x14, 0xb4, 0xb9, 0xb9, 0x39, 0xdd, 0x74, 0xde, 0xcc, + 0x53, 0x21, + } +) + +func (Sha256ObjectFormatImpl) Name() string { return "sha256" } +func (Sha256ObjectFormatImpl) EmptyObjectID() ObjectID { + return emptySha256ObjectID +} + +func (Sha256ObjectFormatImpl) EmptyTree() ObjectID { + return emptySha256Tree +} +func (Sha256ObjectFormatImpl) FullLength() int { return 64 } +func (Sha256ObjectFormatImpl) IsValid(input string) bool { + return sha256Pattern.MatchString(input) +} + +func (Sha256ObjectFormatImpl) MustID(b []byte) ObjectID { + var id Sha256Hash + copy(id[0:32], b) + return &id +} + +// ComputeHash compute the hash for a given ObjectType and content +func (h Sha256ObjectFormatImpl) ComputeHash(t ObjectType, content []byte) ObjectID { + hasher := sha256.New() + _, _ = hasher.Write(t.Bytes()) + _, _ = hasher.Write([]byte(" ")) + _, _ = hasher.Write([]byte(strconv.FormatInt(int64(len(content)), 10))) + _, _ = hasher.Write([]byte{0}) + + // HashSum generates a SHA256 for the provided hash + var sha256 Sha1Hash + copy(sha256[:], hasher.Sum(nil)) + return &sha256 +} + +var ( + Sha1ObjectFormat ObjectFormat = Sha1ObjectFormatImpl{} + Sha256ObjectFormat ObjectFormat = Sha256ObjectFormatImpl{} +) var SupportedObjectFormats = []ObjectFormat{ Sha1ObjectFormat, - // TODO: add sha256 } func ObjectFormatFromName(name string) ObjectFormat { diff --git a/modules/git/object_id.go b/modules/git/object_id.go index 01c23ed3da..4f8c39ee1d 100644 --- a/modules/git/object_id.go +++ b/modules/git/object_id.go @@ -16,6 +16,7 @@ type ObjectID interface { Type() ObjectFormat } +/* SHA1 */ type Sha1Hash [20]byte func (h *Sha1Hash) String() string { @@ -39,6 +40,21 @@ func MustIDFromString(hexHash string) ObjectID { return id } +/* SHA256 */ +type Sha256Hash [32]byte + +func (h *Sha256Hash) String() string { + return hex.EncodeToString(h[:]) +} + +func (h *Sha256Hash) IsZero() bool { + empty := Sha256Hash{} + return bytes.Equal(empty[:], h[:]) +} +func (h *Sha256Hash) RawValue() []byte { return h[:] } +func (*Sha256Hash) Type() ObjectFormat { return Sha256ObjectFormat } + +/* utility */ func NewIDFromString(hexHash string) (ObjectID, error) { var theObjectFormat ObjectFormat for _, objectFormat := range SupportedObjectFormats { diff --git a/modules/git/object_id_gogit.go b/modules/git/object_id_gogit.go index 0cebb0d50b..db4c4ae0bd 100644 --- a/modules/git/object_id_gogit.go +++ b/modules/git/object_id_gogit.go @@ -13,6 +13,8 @@ func ParseGogitHash(h plumbing.Hash) ObjectID { switch hash.Size { case 20: return Sha1ObjectFormat.MustID(h[:]) + case 32: + return Sha256ObjectFormat.MustID(h[:]) } return nil diff --git a/modules/git/repo.go b/modules/git/repo.go index 7ccce0ba20..c3de2eb0ad 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -97,15 +97,12 @@ func InitRepository(ctx context.Context, repoPath string, bare bool, objectForma } cmd := NewCommand(ctx, "init") - if SupportHashSha256 { - if objectFormatName == "" { - objectFormatName = Sha1ObjectFormat.Name() - } - if !IsValidObjectFormat(objectFormatName) { - return fmt.Errorf("invalid object format: %s", objectFormatName) - } - cmd.AddOptionValues("--object-format", objectFormatName) + + if !IsValidObjectFormat(objectFormatName) { + return fmt.Errorf("invalid object format: %s", objectFormatName) } + cmd.AddOptionValues("--object-format", objectFormatName) + if bare { cmd.AddArguments("--bare") } diff --git a/modules/git/repo_base.go b/modules/git/repo_base.go index 2c6df8b9c4..a9d91d2deb 100644 --- a/modules/git/repo_base.go +++ b/modules/git/repo_base.go @@ -8,6 +8,8 @@ import ( "io" ) +var isGogit bool + // contextKey is a value for use with context.WithValue. type contextKey struct { name string diff --git a/modules/git/repo_base_gogit.go b/modules/git/repo_base_gogit.go index d0b8e79368..90123ee84b 100644 --- a/modules/git/repo_base_gogit.go +++ b/modules/git/repo_base_gogit.go @@ -21,6 +21,10 @@ import ( "github.com/go-git/go-git/v5/storage/filesystem" ) +func init() { + isGogit = true +} + // Repository represents a Git repository. type Repository struct { Path string diff --git a/modules/git/repo_base_nogogit.go b/modules/git/repo_base_nogogit.go index a783366cc1..d5a350a926 100644 --- a/modules/git/repo_base_nogogit.go +++ b/modules/git/repo_base_nogogit.go @@ -15,6 +15,10 @@ import ( "code.gitea.io/gitea/modules/log" ) +func init() { + isGogit = false +} + // Repository represents a Git repository. type Repository struct { Path string diff --git a/modules/git/tests/repos/repo1_bare_sha256/HEAD b/modules/git/tests/repos/repo1_bare_sha256/HEAD new file mode 100644 index 0000000000..b870d82622 --- /dev/null +++ b/modules/git/tests/repos/repo1_bare_sha256/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/modules/git/tests/repos/repo1_bare_sha256/config b/modules/git/tests/repos/repo1_bare_sha256/config new file mode 100644 index 0000000000..2388a50b2f --- /dev/null +++ b/modules/git/tests/repos/repo1_bare_sha256/config @@ -0,0 +1,6 @@ +[core] + repositoryformatversion = 1 + filemode = true + bare = true +[extensions] + objectformat = sha256 diff --git a/modules/git/tests/repos/repo1_bare_sha256/description b/modules/git/tests/repos/repo1_bare_sha256/description new file mode 100644 index 0000000000..498b267a8c --- /dev/null +++ b/modules/git/tests/repos/repo1_bare_sha256/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/modules/git/tests/repos/repo1_bare_sha256/info/exclude b/modules/git/tests/repos/repo1_bare_sha256/info/exclude new file mode 100644 index 0000000000..a5196d1be8 --- /dev/null +++ b/modules/git/tests/repos/repo1_bare_sha256/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/modules/git/tests/repos/repo1_bare_sha256/info/refs b/modules/git/tests/repos/repo1_bare_sha256/info/refs new file mode 100644 index 0000000000..b4de954582 --- /dev/null +++ b/modules/git/tests/repos/repo1_bare_sha256/info/refs @@ -0,0 +1,7 @@ +42e334efd04cd36eea6da0599913333c26116e1a537ca76e5b6e4af4dda00236 refs/heads/branch1 +5bc2249e32e0ba40a08879fba2bd4e97a13cb345831549f4bc5649525da8f6cc refs/heads/branch2 +9433b2a62b964c17a4485ae180f45f595d3e69d31b786087775e28c6b6399df0 refs/heads/main +29a82d4fc02e19190fb489cc90d5730ed91970b49f4e39acda2798b3dd4f814e refs/tags/signed-tag +9433b2a62b964c17a4485ae180f45f595d3e69d31b786087775e28c6b6399df0 refs/tags/signed-tag^{} +171822a62559f3aa28a00aa3785dbe915d6a8eb02712682740db44fc8bd2187a refs/tags/test +6aae864a3d1d0d6a5be0cc64028c1e7021e2632b031fd8eb82afc5a283d1c3d1 refs/tags/test^{} diff --git a/modules/git/tests/repos/repo1_bare_sha256/objects/info/commit-graph b/modules/git/tests/repos/repo1_bare_sha256/objects/info/commit-graph new file mode 100644 index 0000000000000000000000000000000000000000..2985d3e4361fa5d2453795c1d2fa235bc162232b GIT binary patch literal 2048 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 V03y}m<@UOrf!d;j&yBtl{0h7u+fV=i literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo1_bare_sha256/objects/pack/pack-c01aa121b9c5e345fe0da2f9be78665970b0c38c6b495d5fc034bc7a7b95334b.pack b/modules/git/tests/repos/repo1_bare_sha256/objects/pack/pack-c01aa121b9c5e345fe0da2f9be78665970b0c38c6b495d5fc034bc7a7b95334b.pack new file mode 100644 index 0000000000000000000000000000000000000000..c77bf2024c8938b19faa05798afe14293fd5f6f5 GIT binary patch literal 5656 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 literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo5_pulls_sha256/objects/pack/pack-bfe8f09d42ef5dd1610bf42641fe145d4a02b788eb26c31022a362312660a29d.pack b/modules/git/tests/repos/repo5_pulls_sha256/objects/pack/pack-bfe8f09d42ef5dd1610bf42641fe145d4a02b788eb26c31022a362312660a29d.pack new file mode 100644 index 0000000000000000000000000000000000000000..689318da321ce6cb4091760f4be5f2685cf60f73 GIT binary patch literal 3140 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 aDGs4tLBeR86E?+rfTCp%3gUL91^)#Odn{D| literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo5_pulls_sha256/objects/pack/pack-bfe8f09d42ef5dd1610bf42641fe145d4a02b788eb26c31022a362312660a29d.rev b/modules/git/tests/repos/repo5_pulls_sha256/objects/pack/pack-bfe8f09d42ef5dd1610bf42641fe145d4a02b788eb26c31022a362312660a29d.rev new file mode 100644 index 0000000000000000000000000000000000000000..c0bac95376c0e5e72e9cbc01721d452b92ab9e02 GIT binary patch literal 140 zcmWIYbctYKU|E5Aa}QVqx(2ba7*V02d(J2f}1=advSGfwGslyEqy_*sLZH8bq=>AlRd<(GZ|G z1Q>xP&=NBN%^$9q8R$2<b`x%G_ue+2{i=dIN3a1%EmS>As>{0< zx?3!*KNT#}7gLXCb8eY_znbeug}=G`!PN4S=w+E&UqA*!)$;(&w*c{BU}?F^W$U?@ fSGM`8IGj_y`_=S^WU;~5MrY2gkE27o$`=Cw{U?2W literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo6_blame_sha256/objects/info/packs b/modules/git/tests/repos/repo6_blame_sha256/objects/info/packs new file mode 100644 index 0000000000..73744cf8f7 --- /dev/null +++ b/modules/git/tests/repos/repo6_blame_sha256/objects/info/packs @@ -0,0 +1,2 @@ +P pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.pack + diff --git a/modules/git/tests/repos/repo6_blame_sha256/objects/pack/pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.bitmap b/modules/git/tests/repos/repo6_blame_sha256/objects/pack/pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.bitmap new file mode 100644 index 0000000000000000000000000000000000000000..c34487c53ad7ebe36637dc0c14255794fa88c940 GIT binary patch literal 318 zcmZ?r4Dn@PWME}rU|{~UW0B(a1l7MSqL+^*Z4+FhVyG4W$JU(r`q48JvTwcX1E~RG zCMX6{V89NgIe;{}+zF^0C#D>u0aOk|F(R=+OpsX&3=TkyW+LN%kOUBbT!LN2Gq4N; z*iYD1w18C1YDj`AM5SgtU)=+fTmC9#b!BC7?(>PMfB)nwe3ldXTA%nM>U!w;$E?$G Hw5c_8Mr59|BS^{cZ;RGbGL1ceRyr_30?6|uFee#i`=4Sc5Kx0ySn6R$o~(M z-8V?~T>KOu9zMJB!sPxHb9b4nRTcSgcha{#)8j5K`Zu|5%hrq+ajeWyEZpoj&gyO8 zvzu^hyZ5&F>{k`!If4yVYlkoS<(|Lk?RMYwOUqCFln9gBy{dl~Pwz1sM?LZ7XATOy zcy|6-n3?dam3R3>(*vfg+SHhQ`_RJVcQN0}_-A~&)GfT&Ow`!>V}Q~ot>i~5cR#T7 zzPP7!BHLSYtzWnHPkZz=jZai`Lem7zg!O#a{SUfKlGWyEc#vr(5xn`$quGmRYVMJ? zY0IDSwED>&Tk!z(+uhritGjzH{IpW*&WZAGZZEUWUIu2vJwObMJEq&fI6MQ)3gW=x zuo1|w1F}PbVmyC#EK=N_p!&B(^zzZ9ZGvl547K9_*qSq6KYC_D_N{k){yr>6_wBeC fyHsyR{c@fO!gKTHKfUbx?NZi?t_J}tFM0z2T;9!# literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo6_blame_sha256/objects/pack/pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.pack b/modules/git/tests/repos/repo6_blame_sha256/objects/pack/pack-fcb8a221b76025fd8415d3c562b611ac24312a5ffc3d3703d7c5cc906bdaee8e.pack new file mode 100644 index 0000000000000000000000000000000000000000..626f081398c8859462e1323ed5907ca9202772e3 GIT binary patch literal 904 zcmV;319$vTK|@Ob00062000S<5qO-Hj!ACAFbn|ieueIZ11*#&0zr{HppT$TGIdeM zg{LS5n_5m|eLlRG^8ds9W30PtdU|xixm9`LOmB7(-;>Y;hySoZ+?t{Oy zyEAWpyc~~1PonQG6e9mR@ZjEj@P1nMZCl6Ce`eEF#GP*InAe< zlTb&S5O|!G%S%o}F$@LJc~+4*QWd9mJ`$=xj9J8W>`)M|MX#yE@_{8VI-|38_t?pe zyqgvkF(>E!Y~kq;eAe#y->b1KTSZy z9>7D)bf%~n3TX-+Up<1Wck%G{rfQ3ylmo|$q=F&tWmF|qJ%+ELr!n+R=aPh8)i40^=y7x zB5^b8jITq8r0x=q`_EWR0oIu=vatksoCU$b0l**#1HgZ$0TdzQfRX)2=pELM7DZm_ zn2Ux7IzYk7sRX;$E}H8eAz^d+BK%Ry=6ydgI1!+-0(hLu$;?aT$^j9{8Hsu6sVNFM za1k)U1pv~I3vZzVc$_mdFfcPQQAo;3%uUrRsVHF()R5ELyVdSn>W0}3XFZ#rmPp*p zI^*jQBB{HC2&l<)ca41lOn- zYQ_JtHD|tl^vs0pTkrb%+w8Ase{`OHW!*)lj;F4!+Kdk`{F9#E*zn*LXWVbinE=vf BBLx5e literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo6_blame_sha256/packed-refs b/modules/git/tests/repos/repo6_blame_sha256/packed-refs new file mode 100644 index 0000000000..644269299f --- /dev/null +++ b/modules/git/tests/repos/repo6_blame_sha256/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled fully-peeled sorted +e2f5660e15159082902960af0ed74fc144921d2b0c80e069361853b3ece29ba3 refs/heads/main diff --git a/modules/git/tests/repos/repo6_blame_sha256/refs/refs/main b/modules/git/tests/repos/repo6_blame_sha256/refs/refs/main new file mode 100644 index 0000000000..829662cdf5 --- /dev/null +++ b/modules/git/tests/repos/repo6_blame_sha256/refs/refs/main @@ -0,0 +1 @@ +e2f5660e15159082902960af0ed74fc144921d2b0c80e069361853b3ece29ba3 diff --git a/modules/git/tests/repos/repo6_merge_sha256/HEAD b/modules/git/tests/repos/repo6_merge_sha256/HEAD new file mode 100644 index 0000000000..b870d82622 --- /dev/null +++ b/modules/git/tests/repos/repo6_merge_sha256/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/modules/git/tests/repos/repo6_merge_sha256/config b/modules/git/tests/repos/repo6_merge_sha256/config new file mode 100644 index 0000000000..2388a50b2f --- /dev/null +++ b/modules/git/tests/repos/repo6_merge_sha256/config @@ -0,0 +1,6 @@ +[core] + repositoryformatversion = 1 + filemode = true + bare = true +[extensions] + objectformat = sha256 diff --git a/modules/git/tests/repos/repo6_merge_sha256/description b/modules/git/tests/repos/repo6_merge_sha256/description new file mode 100644 index 0000000000..498b267a8c --- /dev/null +++ b/modules/git/tests/repos/repo6_merge_sha256/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/modules/git/tests/repos/repo6_merge_sha256/info/exclude b/modules/git/tests/repos/repo6_merge_sha256/info/exclude new file mode 100644 index 0000000000..a5196d1be8 --- /dev/null +++ b/modules/git/tests/repos/repo6_merge_sha256/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/modules/git/tests/repos/repo6_merge_sha256/info/refs b/modules/git/tests/repos/repo6_merge_sha256/info/refs new file mode 100644 index 0000000000..7dae8a1be7 --- /dev/null +++ b/modules/git/tests/repos/repo6_merge_sha256/info/refs @@ -0,0 +1,4 @@ +d2e5609f630dd8db500f5298d05d16def282412e3e66ed68cc7d0833b29129a1 refs/heads/main +b45258e9823233edea2d40d183742f29630e1e69300479fb4a55eabfe9b1d8bf refs/heads/merge/add_file +ff2b996e2fa366146300e4c9e51ccb6818147b360e46fa1437334f4a690955ce refs/heads/merge/modify_file +da1ded40dc8e5b7c564171f4bf2fc8370487decfb1cb6a99ef28f3ed73d09172 refs/heads/merge/remove_file diff --git a/modules/git/tests/repos/repo6_merge_sha256/objects/info/commit-graph b/modules/git/tests/repos/repo6_merge_sha256/objects/info/commit-graph new file mode 100644 index 0000000000000000000000000000000000000000..98068475e872f046ba11bdf7d5893f98a0255cbd GIT binary patch literal 1564 zcmZ>E5Aa}QVrB66ba7*VfB+!d2f}0taCUJFfwDiiyEqy_*sKp+UEE!v>@N@+M6&)t zut!;=Auwn|fD!02Vlfj??Lc5=puPAo3s8QrVb+yNp`Ta$%IUmzrTIr&uPbcTdTwHcq=FA;NNf3Hl=&~tO@Z9|rHJ&ByM z$1bh)kj8sy`5Y6@U#FknsM*VK`ova~0$`wmFc7e$x_k`uU6Z@~;FgW2oVPH|ty*RH zI<-O6m}%jx_IWGS7hk`%{X0k@R6Pe!ecdmolM|PPRGoHz`{A~dgbj)KN$0`tzYZ=r15S<>akrf&3`B|<|MSo zCocdgM412Gyp(Hui@tEgmb!Wm@8hRiQ@%`?ih@GWLtd*)S><;PIfe|rq#V*xA; p!1P~weV_M+rsQYMxi5NVEoC)LPOF`?mG!`vkhdpx@4k987XbIX&9eXi literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo6_merge_sha256/objects/info/packs b/modules/git/tests/repos/repo6_merge_sha256/objects/info/packs new file mode 100644 index 0000000000..f3cf8197ce --- /dev/null +++ b/modules/git/tests/repos/repo6_merge_sha256/objects/info/packs @@ -0,0 +1,3 @@ +P pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.pack +P pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.pack + diff --git a/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.bitmap b/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.bitmap new file mode 100644 index 0000000000000000000000000000000000000000..d1624a0780e2ec1c910e845302f8baed9867beba GIT binary patch literal 410 zcmZ?r4Dn@PWME}rU|`k%&*Aao#;YCQCup6N+O}ZY@nHV&+8D0NW45ynZSgM^0I30D zCMX6{U?2~r`G7Q?*JsxOsxM8mSJGv#-$=w2&w|) z9tH*nAVxEzTm&Qm1RP+}0Z5{$2;BjeVPIg#sR9%lU@&X4Q38lDt6}*OFx|ldqTpaw u^V$V44ooeGU%OUD;lo|_NHzYiEy~CCZS$UdE=^oJbZwhC=R2Oy9o7JVEii=u literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.idx b/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-2fff0848f8d8eab8f7902ac91ab6a096c7530f577d5c0a79c63d9ac2b44f7510.idx new file mode 100644 index 0000000000000000000000000000000000000000..09b897d2db2804e585f2fdb78ed661ea4570427f GIT binary patch literal 1696 zcmexg;-AdGz`z8=qk!}fU<7I*7lXna7iI>^5rbKP>hNJ!pgg&l4XBrvm>p<7sh9(( zhgi%BREv(efMT@9+(0|B9} z^vc_pelX@=Tff%#N#os!)ML9|n*UH_%t>gEPhOB4e`(@w{&W|=nX5hZr9b|;AA5@P z)+V3Nh7SS-x12w?xRh&qi@tEgmb!Wm@8hRiQ@%`?ih@GWLtd*)S><;PlVwh0~G z_4-@6e&sv06U#5}sGNJPGNLEY`KqMy^zKPcbLwqFmUKOdoU+F*t@V(`dujO`6V6|! zpWmq2%W(R{R+E)Up`Ta$%IUmzrvpJURJP z=5&UHNVOTC+b=`kN;ZUKg``&^!A7Q zW&NW+b1#3qAZqHi>%X$>g%y_{h4kDNKJ@rjsFysjD7p(QW_|;U5)B}I9Y}it>6buS z3@8^0EXGy<*$*MI?|b$>RGl$~P6V727VZs;iiVye0(vc6E3`~vcyI`oqC}=1 zp(WobSDxN@=(;;$5Eb;&tEN_Z$_NDvn+5AN7LT=vc5BdEW+JsvEvl3#o}h#;k6CC$ zS%Y!R88Aoh6+3Byel#moz|vwqmf09EmKf2HGkHp>>zAit3aKj95JNofD2MBJaJ+)S z0v%oj&2;FokTv9#l$$9vklJkG_x-#L_bj})7k<^@9(lRWpO^QG-itmt$V48fRPSy* zct7=RS>}D$|Ex_fI!@|_F59km`{4e2UQezKUi(=u?q(bFXVff{-ZZP zzOiMK**-p*<5j+47Wrh;KM0ALu9gsZoR!PLO$0FvK+$`u$Q=pUldcmimDbIQ`4}Yr1DHJxXu2Halz!0pu{&P}|LSK{FDj&WCy{HDtqI(HW#ta8XEC zo&L45Hr|M$sDyHtW^7#wKp@*u(Qz|lA`(Jq-mB^EozU>8mDDZieZ8MEznYHxrXN1@ zla9Z>-0nAjG=I*>tpN%V<_AE4)Xy<4YxzI7G<}@kp5yZA=?7DLOxTtXc$}5XO-cqa z3;@u5Ptm;~%}n!C5YYp8h%`xY#5yuxzlFCKkKpR9-nt?(W6{o1w*fm!uN*w8)NX8D zkm^7X1Cgx`rZNakLztT5UX_i~w_fqJvNqZf$F4GzOq!FM?4=AK?+gK(J0YSVlorOW zH4MR_Goywly|4H4%CD|7zv)L@`AO%WFSq+G9zC8jP-_LG66c2kr6fD&Jl2YTwlq&a z#!nu{XQW?yaZCb}5O|!G%Rx?rAq)o4J*QxAVp^aS5@YlL9^!+RIL6;G|1kGgkKpR9 z-ag%9G0bYv$)gOOD0vi0-4sA(A5|K$o3CEu=xBJZ>&7ULJ z-iei3jSs{`VP22pvbX=U1(?Nk`SkDuiBwCblMHyAmCH*C0x=8#(0xyly&&l{{eg%c zz(b^IiX)bhY3Kgp5nR31o4YDxiOp3{Oo^3z&Q!!{2+7N`ByG0X7Q_+e#!@ua6s1%| zDUynJWcZlRZHIg14iA3m4j1k}Z{rwxu6hLb{g&=yJ!Ong7ocjVsFRKh;X( z5SofobMwm}F55X_E@%4k+o?tAj|&6V^Tj`&%UEfwT_ZYS2D667EBmPcXMtBZ=K_F4 zc$@(z0NDS|0hs}ic_3VF?d;=S217#l3){UXwd9tlP(i_@@YYZ;u=@ymG9I}EWf;?a_+Ut zh@L>_tCGsoyC*prLe!V!$LHp!WTsVuHO1t;ee*b$&DrS(_wBvvTc1o@5#V@m$%ktJ z22aF&1ZzSNnu=0$^UG4fns!c@%bC9Xc4|@j!&CM@MQrW(I)taSI^RTmIwVgBo(9KXjc cQL)uig}NGx3>y~(MEy@)IH%pMujOYR01j|Sm;e9( literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.mtimes b/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.mtimes new file mode 100644 index 0000000000000000000000000000000000000000..a669a06e2741e4eb21149dab64899024ca52aa37 GIT binary patch literal 84 zcmV-a0IUB^R82(y000310007IMEVS6MEB)o7AuCY+pIiRW|q{4=6kZFrBEE9`ZXx} q*r`WPx_(dwPSy=szZh0sjm=`$s5CF9=`yxB+tqXRT`xw-u;fjXFeVEC literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.pack b/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.pack new file mode 100644 index 0000000000000000000000000000000000000000..a28808ee11835d7525339f6aae7e862364567183 GIT binary patch literal 447 zcmV;w0YLsxK|@Ob000620007*Bb7cK=)c znBloy;Av^2{`}$L7t5iUu<8bZHh7%-!+f22gF7ROg_()zWN${}NDxCo+rZGkfQ!pF zwJ1GRA*m=aFF7N%SV27(#Me(uNr_L(%t=+(fr%8Q=H{2BLIf2O^HN~qx%nxXX_XLh pE&$6xA~9taD~7MztUOj`mehyld$OdZP#mH9H7NSnsYg$`eo(!B)C~Xt literal 0 HcmV?d00001 diff --git a/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.rev b/modules/git/tests/repos/repo6_merge_sha256/objects/pack/pack-65162b86afdbac3c566696d487e67bb2a4a5501ca1fa3528fad8a9474fba7e50.rev new file mode 100644 index 0000000000000000000000000000000000000000..c09bb3203ba74067d70d94bad6ae9ec9b7ac8469 GIT binary patch literal 84 zcmWIYbctYKU|Choose a license. +object_format = Object Format +object_format_helper = Object format of the repository. Cannot be changed later. SHA1 is most compatible. readme = README readme_helper = Select a README file template. readme_helper_desc = This is the place where you can write a complete description for your project. @@ -1038,6 +1040,7 @@ desc.public = Public desc.template = Template desc.internal = Internal desc.archived = Archived +desc.sha256 = SHA256 template.items = Template Items template.git_content = Git Content (Default Branch) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 8ce03cf29c..9810e461de 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -253,7 +253,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *user_model.User, opt api.Cre DefaultBranch: opt.DefaultBranch, TrustModel: repo_model.ToTrustModel(opt.TrustModel), IsTemplate: opt.Template, - ObjectFormatName: git.Sha1ObjectFormat.Name(), + ObjectFormatName: opt.ObjectFormatName, }) if err != nil { if repo_model.IsErrRepoAlreadyExist(err) { diff --git a/routers/web/githttp.go b/routers/web/githttp.go index 8d0d1ce03a..ab74e9a333 100644 --- a/routers/web/githttp.go +++ b/routers/web/githttp.go @@ -36,8 +36,8 @@ func gitHTTPRouters(m *web.Route) { m.Methods("GET,OPTIONS", "/objects/info/http-alternates", repo.GetTextFile("objects/info/http-alternates")) m.Methods("GET,OPTIONS", "/objects/info/packs", repo.GetInfoPacks) m.Methods("GET,OPTIONS", "/objects/info/{file:[^/]*}", repo.GetTextFile("")) - m.Methods("GET,OPTIONS", "/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38}}", repo.GetLooseObject) - m.Methods("GET,OPTIONS", "/objects/pack/pack-{file:[0-9a-f]{40}}.pack", repo.GetPackFile) - m.Methods("GET,OPTIONS", "/objects/pack/pack-{file:[0-9a-f]{40}}.idx", repo.GetIdxFile) + m.Methods("GET,OPTIONS", "/objects/{head:[0-9a-f]{2}}/{hash:[0-9a-f]{38,62}}", repo.GetLooseObject) + m.Methods("GET,OPTIONS", "/objects/pack/pack-{file:[0-9a-f]{40,64}}.pack", repo.GetPackFile) + m.Methods("GET,OPTIONS", "/objects/pack/pack-{file:[0-9a-f]{40,64}}.idx", repo.GetIdxFile) }, ignSignInAndCsrf, requireSignIn, repo.HTTPGitEnabledHandler, repo.CorsHandler(), context_service.UserAssignmentWeb()) } diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index b5c550ae45..b64db91406 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -159,7 +159,6 @@ func Create(ctx *context.Context) { ctx.Data["private"] = getRepoPrivate(ctx) ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate ctx.Data["default_branch"] = setting.Repository.DefaultBranch - ctx.Data["hash_type"] = "sha1" ctxUser := checkContextUser(ctx, ctx.FormInt64("org")) if ctx.Written() { @@ -179,6 +178,8 @@ func Create(ctx *context.Context) { ctx.Data["CanCreateRepo"] = ctx.Doer.CanCreateRepo() ctx.Data["MaxCreationLimit"] = ctx.Doer.MaxCreationLimit() + ctx.Data["SupportedObjectFormats"] = git.SupportedObjectFormats + ctx.Data["DefaultObjectFormat"] = git.Sha1ObjectFormat ctx.HTML(http.StatusOK, tplCreate) } diff --git a/routers/web/web.go b/routers/web/web.go index 22f98d95de..ff0ce0c258 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1235,7 +1235,7 @@ func registerRoutes(m *web.Route) { Post(web.Bind(forms.UploadRepoFileForm{}), repo.UploadFilePost) m.Combo("/_diffpatch/*").Get(repo.NewDiffPatch). Post(web.Bind(forms.EditRepoFileForm{}), repo.NewDiffPatchPost) - m.Combo("/_cherrypick/{sha:([a-f0-9]{7,40})}/*").Get(repo.CherryPick). + m.Combo("/_cherrypick/{sha:([a-f0-9]{7,64})}/*").Get(repo.CherryPick). Post(web.Bind(forms.CherryPickForm{}), repo.CherryPickPost) }, repo.MustBeEditable) m.Group("", func() { @@ -1377,8 +1377,8 @@ func registerRoutes(m *web.Route) { m.Combo("/*"). Get(repo.Wiki). Post(context.RepoMustNotBeArchived(), reqSignIn, reqRepoWikiWriter, web.Bind(forms.NewWikiForm{}), repo.WikiPost) - m.Get("/commit/{sha:[a-f0-9]{7,40}}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.Diff) - m.Get("/commit/{sha:[a-f0-9]{7,40}}.{ext:patch|diff}", repo.RawDiff) + m.Get("/commit/{sha:[a-f0-9]{7,64}}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.Diff) + m.Get("/commit/{sha:[a-f0-9]{7,64}}.{ext:patch|diff}", repo.RawDiff) }, repo.MustEnableWiki, func(ctx *context.Context) { ctx.Data["PageIsWiki"] = true ctx.Data["CloneButtonOriginLink"] = ctx.Repo.Repository.WikiCloneLink() @@ -1498,9 +1498,9 @@ func registerRoutes(m *web.Route) { m.Group("", func() { m.Get("/graph", repo.Graph) - m.Get("/commit/{sha:([a-f0-9]{7,40})$}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.Diff) - m.Get("/commit/{sha:([a-f0-9]{7,40})$}/load-branches-and-tags", repo.LoadBranchesAndTags) - m.Get("/cherry-pick/{sha:([a-f0-9]{7,40})$}", repo.SetEditorconfigIfExists, repo.CherryPick) + m.Get("/commit/{sha:([a-f0-9]{7,64})$}", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.Diff) + m.Get("/commit/{sha:([a-f0-9]{7,64})$}/load-branches-and-tags", repo.LoadBranchesAndTags) + m.Get("/cherry-pick/{sha:([a-f0-9]{7,64})$}", repo.SetEditorconfigIfExists, repo.CherryPick) }, repo.MustBeNotEmpty, context.RepoRef(), reqRepoCodeReader) m.Get("/rss/branch/*", context.RepoRefByType(context.RepoRefBranch), feedEnabled, feed.RenderBranchFeed) @@ -1517,7 +1517,7 @@ func registerRoutes(m *web.Route) { m.Group("", func() { m.Get("/forks", repo.Forks) }, context.RepoRef(), reqRepoCodeReader) - m.Get("/commit/{sha:([a-f0-9]{7,40})}.{ext:patch|diff}", repo.MustBeNotEmpty, reqRepoCodeReader, repo.RawDiff) + m.Get("/commit/{sha:([a-f0-9]{7,64})}.{ext:patch|diff}", repo.MustBeNotEmpty, reqRepoCodeReader, repo.RawDiff) }, ignSignIn, context.RepoAssignment, context.UnitTypes()) m.Post("/{username}/{reponame}/lastcommit/*", ignSignInAndCsrf, context.RepoAssignment, context.UnitTypes(), context.RepoRefByType(context.RepoRefCommit), reqRepoCodeReader, repo.LastCommit) diff --git a/services/repository/create.go b/services/repository/create.go index bcf2c85c21..0e89573343 100644 --- a/services/repository/create.go +++ b/services/repository/create.go @@ -217,6 +217,10 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt } } + if opts.ObjectFormatName == "" { + opts.ObjectFormatName = git.Sha1ObjectFormat.Name() + } + repo := &repo_model.Repository{ OwnerID: u.ID, Owner: u, diff --git a/services/repository/fork.go b/services/repository/fork.go index 851a69c80f..a8ff2717b0 100644 --- a/services/repository/fork.go +++ b/services/repository/fork.go @@ -76,17 +76,18 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork defaultBranch = opts.SingleBranch } repo := &repo_model.Repository{ - OwnerID: owner.ID, - Owner: owner, - OwnerName: owner.Name, - Name: opts.Name, - LowerName: strings.ToLower(opts.Name), - Description: opts.Description, - DefaultBranch: defaultBranch, - IsPrivate: opts.BaseRepo.IsPrivate || opts.BaseRepo.Owner.Visibility == structs.VisibleTypePrivate, - IsEmpty: opts.BaseRepo.IsEmpty, - IsFork: true, - ForkID: opts.BaseRepo.ID, + OwnerID: owner.ID, + Owner: owner, + OwnerName: owner.Name, + Name: opts.Name, + LowerName: strings.ToLower(opts.Name), + Description: opts.Description, + DefaultBranch: defaultBranch, + IsPrivate: opts.BaseRepo.IsPrivate || opts.BaseRepo.Owner.Visibility == structs.VisibleTypePrivate, + IsEmpty: opts.BaseRepo.IsEmpty, + IsFork: true, + ForkID: opts.BaseRepo.ID, + ObjectFormatName: opts.BaseRepo.ObjectFormatName, } oldRepoPath := opts.BaseRepo.RepoPath() diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index 7102f73305..fdba0734a2 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -67,6 +67,9 @@ {{if .IsTemplate}} {{ctx.Locale.Tr "repo.desc.template"}} {{end}} + {{if eq .ObjectFormatName "sha256"}} + {{ctx.Locale.Tr "repo.desc.sha256"}} + {{end}} {{if .IsMirror}} {{svg "octicon-mirror"}} {{else if .IsFork}} diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index b28aa02c1e..c51dcaa3ff 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -25,6 +25,9 @@ {{if .IsTemplate}} {{ctx.Locale.Tr "repo.desc.template"}} {{end}} + {{if eq .ObjectFormatName "sha256"}} + {{ctx.Locale.Tr "repo.desc.sha256"}} + {{end}}
diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 7bfed53124..7702770c40 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -3,7 +3,7 @@ {{ctx.Locale.Tr "repo.commits.author"}} - SHA1 + {{StringUtils.ToUpper $.Repository.ObjectFormatName}} {{ctx.Locale.Tr "repo.commits.message"}} {{ctx.Locale.Tr "repo.commits.date"}} diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 3b4b994be7..66f73fb398 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -185,6 +185,19 @@ {{ctx.Locale.Tr "repo.default_branch_helper"}}
+
+ + + {{ctx.Locale.Tr "repo.object_format_helper"}} +
diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index a5ef8daa9a..dac30af600 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -27,6 +27,9 @@ {{ctx.Locale.Tr "repo.desc.template"}}
{{svg "octicon-repo-template" 18}}
{{end}} + {{if eq .ObjectFormatName "sha256"}} + {{ctx.Locale.Tr "repo.desc.sha256"}} + {{end}}
{{if not (or .IsBeingCreated .IsBroken)}} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 094a0e9aec..dc04a97b83 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -18370,6 +18370,15 @@ "uniqueItems": true, "x-go-name": "Name" }, + "object_format_name": { + "description": "ObjectFormatName of the underlying git repository", + "type": "string", + "enum": [ + "sha1", + "sha256" + ], + "x-go-name": "ObjectFormatName" + }, "private": { "description": "Whether the repository is private", "type": "boolean", @@ -22185,6 +22194,15 @@ "type": "string", "x-go-name": "Name" }, + "object_format_name": { + "description": "ObjectFormatName of the underlying git repository", + "type": "string", + "enum": [ + "sha1", + "sha256" + ], + "x-go-name": "ObjectFormatName" + }, "open_issues_count": { "type": "integer", "format": "int64", From 62f995203ab3397a6d995afb80767b33b1f00a1f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 20 Jan 2024 10:07:31 +0800 Subject: [PATCH 27/76] Move doctor package from modules to services (#28856) --- cmd/doctor.go | 2 +- cmd/doctor_test.go | 2 +- {modules => services}/doctor/authorizedkeys.go | 0 {modules => services}/doctor/breaking.go | 0 {modules => services}/doctor/checkOldArchives.go | 0 {modules => services}/doctor/dbconsistency.go | 0 {modules => services}/doctor/dbversion.go | 0 {modules => services}/doctor/doctor.go | 0 {modules => services}/doctor/fix16961.go | 0 {modules => services}/doctor/fix16961_test.go | 0 {modules => services}/doctor/fix8312.go | 0 {modules => services}/doctor/heads.go | 0 {modules => services}/doctor/lfs.go | 0 {modules => services}/doctor/mergebase.go | 0 {modules => services}/doctor/misc.go | 0 {modules => services}/doctor/paths.go | 0 {modules => services}/doctor/repository.go | 0 {modules => services}/doctor/storage.go | 0 {modules => services}/doctor/usertype.go | 0 19 files changed, 2 insertions(+), 2 deletions(-) rename {modules => services}/doctor/authorizedkeys.go (100%) rename {modules => services}/doctor/breaking.go (100%) rename {modules => services}/doctor/checkOldArchives.go (100%) rename {modules => services}/doctor/dbconsistency.go (100%) rename {modules => services}/doctor/dbversion.go (100%) rename {modules => services}/doctor/doctor.go (100%) rename {modules => services}/doctor/fix16961.go (100%) rename {modules => services}/doctor/fix16961_test.go (100%) rename {modules => services}/doctor/fix8312.go (100%) rename {modules => services}/doctor/heads.go (100%) rename {modules => services}/doctor/lfs.go (100%) rename {modules => services}/doctor/mergebase.go (100%) rename {modules => services}/doctor/misc.go (100%) rename {modules => services}/doctor/paths.go (100%) rename {modules => services}/doctor/repository.go (100%) rename {modules => services}/doctor/storage.go (100%) rename {modules => services}/doctor/usertype.go (100%) diff --git a/cmd/doctor.go b/cmd/doctor.go index f891b12608..e433f4adc5 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -15,9 +15,9 @@ import ( "code.gitea.io/gitea/models/migrations" migrate_base "code.gitea.io/gitea/models/migrations/base" "code.gitea.io/gitea/modules/container" - "code.gitea.io/gitea/modules/doctor" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/services/doctor" "github.com/urfave/cli/v2" "xorm.io/xorm" diff --git a/cmd/doctor_test.go b/cmd/doctor_test.go index 75376a567e..3e1ff299c5 100644 --- a/cmd/doctor_test.go +++ b/cmd/doctor_test.go @@ -7,8 +7,8 @@ import ( "context" "testing" - "code.gitea.io/gitea/modules/doctor" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/services/doctor" "github.com/stretchr/testify/assert" "github.com/urfave/cli/v2" diff --git a/modules/doctor/authorizedkeys.go b/services/doctor/authorizedkeys.go similarity index 100% rename from modules/doctor/authorizedkeys.go rename to services/doctor/authorizedkeys.go diff --git a/modules/doctor/breaking.go b/services/doctor/breaking.go similarity index 100% rename from modules/doctor/breaking.go rename to services/doctor/breaking.go diff --git a/modules/doctor/checkOldArchives.go b/services/doctor/checkOldArchives.go similarity index 100% rename from modules/doctor/checkOldArchives.go rename to services/doctor/checkOldArchives.go diff --git a/modules/doctor/dbconsistency.go b/services/doctor/dbconsistency.go similarity index 100% rename from modules/doctor/dbconsistency.go rename to services/doctor/dbconsistency.go diff --git a/modules/doctor/dbversion.go b/services/doctor/dbversion.go similarity index 100% rename from modules/doctor/dbversion.go rename to services/doctor/dbversion.go diff --git a/modules/doctor/doctor.go b/services/doctor/doctor.go similarity index 100% rename from modules/doctor/doctor.go rename to services/doctor/doctor.go diff --git a/modules/doctor/fix16961.go b/services/doctor/fix16961.go similarity index 100% rename from modules/doctor/fix16961.go rename to services/doctor/fix16961.go diff --git a/modules/doctor/fix16961_test.go b/services/doctor/fix16961_test.go similarity index 100% rename from modules/doctor/fix16961_test.go rename to services/doctor/fix16961_test.go diff --git a/modules/doctor/fix8312.go b/services/doctor/fix8312.go similarity index 100% rename from modules/doctor/fix8312.go rename to services/doctor/fix8312.go diff --git a/modules/doctor/heads.go b/services/doctor/heads.go similarity index 100% rename from modules/doctor/heads.go rename to services/doctor/heads.go diff --git a/modules/doctor/lfs.go b/services/doctor/lfs.go similarity index 100% rename from modules/doctor/lfs.go rename to services/doctor/lfs.go diff --git a/modules/doctor/mergebase.go b/services/doctor/mergebase.go similarity index 100% rename from modules/doctor/mergebase.go rename to services/doctor/mergebase.go diff --git a/modules/doctor/misc.go b/services/doctor/misc.go similarity index 100% rename from modules/doctor/misc.go rename to services/doctor/misc.go diff --git a/modules/doctor/paths.go b/services/doctor/paths.go similarity index 100% rename from modules/doctor/paths.go rename to services/doctor/paths.go diff --git a/modules/doctor/repository.go b/services/doctor/repository.go similarity index 100% rename from modules/doctor/repository.go rename to services/doctor/repository.go diff --git a/modules/doctor/storage.go b/services/doctor/storage.go similarity index 100% rename from modules/doctor/storage.go rename to services/doctor/storage.go diff --git a/modules/doctor/usertype.go b/services/doctor/usertype.go similarity index 100% rename from modules/doctor/usertype.go rename to services/doctor/usertype.go From b9d91694afc4b2b52220450927107e6f44f9a7bd Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sat, 20 Jan 2024 03:12:20 +0100 Subject: [PATCH 28/76] In administration documentation about environment variables, point to those for the Go runtime instead of Go compiler (#28859) The previous variables are used by the compiler and aren't too useful for non-developers. The newly listed variables are more likely to be of interest. Apologies for this drive-by PR, I probably missed instructions from the contributors guide. The patch can be regarded as a simple way to explain the problem and solution. Feel free to close and possibly create a new PR that does adhere to the contributors guide. --- .../administration/environment-variables.en-us.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/content/administration/environment-variables.en-us.md b/docs/content/administration/environment-variables.en-us.md index f910cf060e..2c6fcbe681 100644 --- a/docs/content/administration/environment-variables.en-us.md +++ b/docs/content/administration/environment-variables.en-us.md @@ -27,14 +27,15 @@ GITEA_CUSTOM=/home/gitea/custom ./gitea web ## From Go language -As Gitea is written in Go, it uses some Go variables, such as: +As Gitea is written in Go, it uses some variables that influence the behaviour of Go's runtime, such as: -- `GOOS` -- `GOARCH` -- [`GOPATH`](https://golang.org/cmd/go/#hdr-GOPATH_environment_variable) +- `GOMEMLIMIT` +- `GOGC` +- `GOMAXPROCS` +- `GODEBUG` For documentation about each of the variables available, refer to the -[official Go documentation](https://golang.org/cmd/go/#hdr-Environment_variables). +[official Go documentation on runtime environment variables](https://pkg.go.dev/runtime#hdr-Environment_Variables). ## Gitea files From 5574968ecbc34908dfa17b28bfc79c3490eaa685 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 20 Jan 2024 04:38:16 +0200 Subject: [PATCH 29/76] Set the `isPermaLink` attribute to `false` in the `guid` sub-element (#28860) Our `guid` is not a valid URL so according to the RSS spec the `isPermaLink` attribute needs to be set to `false`. Example: ```diff yardenshoham opened issue <a href="https://3000-yardenshoham-gitea-jqlxjixsez9.ws-us107.gitpod.io/yardenshoham/test/issues/2">yardenshoham/test#2</a> https://3000-yardenshoham-gitea-jqlxjixsez9.ws-us107.gitpod.io/yardenshoham/test/issues/2 2#hey yardenshoham - 355: https://3000-yardenshoham-gitea-jqlxjixsez9.ws-us107.gitpod.io/yardenshoham/test/issues/2 + 355: https://3000-yardenshoham-gitea-jqlxjixsez9.ws-us107.gitpod.io/yardenshoham/test/issues/2 Tue, 16 Jan 2024 18:54:36 +0000 ``` References: - https://www.rssboard.org/rss-specification#ltguidgtSubelementOfLtitemgt - Fixes https://github.com/go-gitea/gitea/issues/28734 - https://github.com/gorilla/feeds/issues/78 - https://github.com/go-gitea/gitea/pull/21550 - https://github.com/gorilla/feeds/pull/107 Signed-off-by: Yarden Shoham --- go.mod | 2 ++ go.sum | 4 ++-- routers/web/feed/convert.go | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index e1b37c65f6..7bf0804871 100644 --- a/go.mod +++ b/go.mod @@ -306,6 +306,8 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142 replace github.com/nektos/act => gitea.com/gitea/act v0.2.51 +replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5 + exclude github.com/gofrs/uuid v3.2.0+incompatible exclude github.com/gofrs/uuid v4.0.0+incompatible diff --git a/go.sum b/go.sum index ae6c91f902..52aeabfeac 100644 --- a/go.sum +++ b/go.sum @@ -501,8 +501,6 @@ github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8 github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= -github.com/gorilla/feeds v1.1.2 h1:pxzZ5PD3RJdhFH2FsJJ4x6PqMqbgFk1+Vez4XWBW8Iw= -github.com/gorilla/feeds v1.1.2/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y= github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= @@ -904,6 +902,8 @@ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMx github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI= github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= +github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5 h1:3seWKGVhGoc66Ht5QlhQsr4xT2caDnFegsnh2NqvENU= +github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y= github.com/yohcop/openid-go v1.0.1 h1:DPRd3iPO5F6O5zX2e62XpVAbPT6wV51cuucH0z9g3js= github.com/yohcop/openid-go v1.0.1/go.mod h1:b/AvD03P0KHj4yuihb+VtLD6bYYgsy0zqBzPCRjkCNs= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= diff --git a/routers/web/feed/convert.go b/routers/web/feed/convert.go index 95b1062253..6dbc2c2cbc 100644 --- a/routers/web/feed/convert.go +++ b/routers/web/feed/convert.go @@ -244,6 +244,7 @@ func feedActionsToFeedItems(ctx *context.Context, actions activities_model.Actio Title: title, Link: link, Description: desc, + IsPermaLink: "false", Author: &feeds.Author{ Name: act.ActUser.DisplayName(), Email: act.ActUser.GetEmail(), From 7711db0a7138a063a36a412d9780328795a9cea2 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 20 Jan 2024 23:27:31 +0800 Subject: [PATCH 30/76] Fix migrate storage bug (#28830) --- cmd/migrate_storage.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/migrate_storage.go b/cmd/migrate_storage.go index acc3ba16ba..aa49445a89 100644 --- a/cmd/migrate_storage.go +++ b/cmd/migrate_storage.go @@ -110,6 +110,9 @@ func migrateLFS(ctx context.Context, dstStorage storage.ObjectStorage) error { func migrateAvatars(ctx context.Context, dstStorage storage.ObjectStorage) error { return db.Iterate(ctx, nil, func(ctx context.Context, user *user_model.User) error { + if user.CustomAvatarRelativePath() == "" { + return nil + } _, err := storage.Copy(dstStorage, user.CustomAvatarRelativePath(), storage.Avatars, user.CustomAvatarRelativePath()) return err }) @@ -117,6 +120,9 @@ func migrateAvatars(ctx context.Context, dstStorage storage.ObjectStorage) error func migrateRepoAvatars(ctx context.Context, dstStorage storage.ObjectStorage) error { return db.Iterate(ctx, nil, func(ctx context.Context, repo *repo_model.Repository) error { + if repo.CustomAvatarRelativePath() == "" { + return nil + } _, err := storage.Copy(dstStorage, repo.CustomAvatarRelativePath(), storage.RepoAvatars, repo.CustomAvatarRelativePath()) return err }) From 6c771a311b09c511d837dda79c84264dcf4abb47 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 20 Jan 2024 17:37:32 +0200 Subject: [PATCH 31/76] Run `npm audit fix` (#28866) --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5f4dc9bc2b..b299967eba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11160,9 +11160,9 @@ } }, "node_modules/vite": { - "version": "5.0.10", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.10.tgz", - "integrity": "sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==", + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz", + "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==", "dev": true, "dependencies": { "esbuild": "^0.19.3", From 80d48621cdf484247f70ddd653fb4c47a640317a Mon Sep 17 00:00:00 2001 From: sdvcrx Date: Sun, 21 Jan 2024 00:04:47 +0800 Subject: [PATCH 32/76] Fix incorrect PostgreSQL connection string for Unix sockets (#28865) Fix #28864 --- modules/setting/database.go | 4 ++-- modules/setting/database_test.go | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/setting/database.go b/modules/setting/database.go index 0b0488ce85..e200b15b2e 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -169,8 +169,8 @@ func getPostgreSQLConnectionString(dbHost, dbUser, dbPasswd, dbName, dbsslMode s RawQuery: dbParam, } query := connURL.Query() - if strings.HasPrefix(dbHost, "/") { // looks like a unix socket - query.Add("host", dbHost) + if strings.HasPrefix(host, "/") { // looks like a unix socket + query.Add("host", host) connURL.Host = ":" + port } query.Set("sslmode", dbsslMode) diff --git a/modules/setting/database_test.go b/modules/setting/database_test.go index 14e0a6ac02..a742d54f8c 100644 --- a/modules/setting/database_test.go +++ b/modules/setting/database_test.go @@ -77,6 +77,14 @@ func Test_getPostgreSQLConnectionString(t *testing.T) { SSLMode: "false", Output: "postgres://testuser:space%20space%20%21%23$%25%5E%5E%25%5E%60%60%60-=%3F=@:5432/gitea?host=%2Ftmp%2Fpg.sock&sslmode=false", }, + { + Host: "/tmp/pg.sock:6432", + User: "testuser", + Passwd: "pass", + Name: "gitea", + SSLMode: "false", + Output: "postgres://testuser:pass@:6432/gitea?host=%2Ftmp%2Fpg.sock&sslmode=false", + }, { Host: "localhost", User: "pgsqlusername", From 14f6fcf4481cedc2cd9d5ea5aaff88e109089e1f Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 20 Jan 2024 21:44:51 +0200 Subject: [PATCH 33/76] Don't do a full page load when clicking the subscribe button (#28871) - Refactor the form around the subscribe button into its own template - Use htmx to perform the form submission - `hx-boost="true"` to prevent the default form submission behavior of a full page load - `hx-sync="this:replace"` to replace the current request (in case the button is clicked again before the response is returned) - `hx-target="this"` to replace the form tag with the new form tag - `hx-push-url="false"` to disable a change to the URL - `hx-swap="show:no-scroll"` to preserve the scroll position - Change the backend response to return a `
` tag instead of a redirect to the issue page - Include `htmx.org` in javascript imports This change introduces htmx with the hope we could use it to make Gitea more reactive while keeping our "HTML rendered on the server" approach. # Before ![before](https://github.com/go-gitea/gitea/assets/20454870/4ec3e81e-4dbf-4338-9968-b0655c276d4c) # After ![after](https://github.com/go-gitea/gitea/assets/20454870/8c8841af-9bfe-40b2-b1cd-cd1f3c90ba4d) --------- Signed-off-by: Yarden Shoham --- package-lock.json | 6 ++++++ package.json | 1 + routers/web/repo/issue_watch.go | 9 ++++++++- templates/repo/issue/view_content/sidebar.tmpl | 14 +------------- templates/repo/issue/view_content/watching.tmpl | 13 +++++++++++++ web_src/js/features/common-global.js | 1 + webpack.config.js | 1 + 7 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 templates/repo/issue/view_content/watching.tmpl diff --git a/package-lock.json b/package-lock.json index b299967eba..d73fc5df5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "esbuild-loader": "4.0.2", "escape-goat": "4.0.0", "fast-glob": "3.3.2", + "htmx.org": "1.9.10", "jquery": "3.7.1", "katex": "0.16.9", "license-checker-webpack-plugin": "0.2.1", @@ -6158,6 +6159,11 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/htmx.org": { + "version": "1.9.10", + "resolved": "https://registry.npmjs.org/htmx.org/-/htmx.org-1.9.10.tgz", + "integrity": "sha512-UgchasltTCrTuU2DQLom3ohHrBvwr7OqpwyAVJ9VxtNBng4XKkVsqrv0Qr3srqvM9ZNI3f1MmvVQQqK7KW/bTA==" + }, "node_modules/http-proxy-agent": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", diff --git a/package.json b/package.json index 801e85db83..5c6de1dd62 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "esbuild-loader": "4.0.2", "escape-goat": "4.0.0", "fast-glob": "3.3.2", + "htmx.org": "1.9.10", "jquery": "3.7.1", "katex": "0.16.9", "license-checker-webpack-plugin": "0.2.1", diff --git a/routers/web/repo/issue_watch.go b/routers/web/repo/issue_watch.go index 1cb5cc7162..1f51ceba5e 100644 --- a/routers/web/repo/issue_watch.go +++ b/routers/web/repo/issue_watch.go @@ -8,10 +8,15 @@ import ( "strconv" issues_model "code.gitea.io/gitea/models/issues" + "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" ) +const ( + tplWatching base.TplName = "repo/issue/view_content/watching" +) + // IssueWatch sets issue watching func IssueWatch(ctx *context.Context) { issue := GetActionIssue(ctx) @@ -52,5 +57,7 @@ func IssueWatch(ctx *context.Context) { return } - ctx.Redirect(issue.Link()) + ctx.Data["Issue"] = issue + ctx.Data["IssueWatch"] = &issues_model.IssueWatch{IsWatching: watch} + ctx.HTML(http.StatusOK, tplWatching) } diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 4334e4bcbd..6c13eef023 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -270,19 +270,7 @@
{{ctx.Locale.Tr "notification.notifications"}}
- - - {{$.CsrfTokenHtml}} - - + {{template "repo/issue/view_content/watching" .}}
{{end}} diff --git a/templates/repo/issue/view_content/watching.tmpl b/templates/repo/issue/view_content/watching.tmpl new file mode 100644 index 0000000000..06b9d9af33 --- /dev/null +++ b/templates/repo/issue/view_content/watching.tmpl @@ -0,0 +1,13 @@ +
+ + {{$.CsrfTokenHtml}} + +
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js index 0b00eb8e8e..ffa0434cff 100644 --- a/web_src/js/features/common-global.js +++ b/web_src/js/features/common-global.js @@ -12,6 +12,7 @@ import {showTemporaryTooltip} from '../modules/tippy.js'; import {confirmModal} from './comp/ConfirmModal.js'; import {showErrorToast} from '../modules/toast.js'; import {request, POST} from '../modules/fetch.js'; +import 'htmx.org'; const {appUrl, appSubUrl, csrfToken, i18n} = window.config; diff --git a/webpack.config.js b/webpack.config.js index 448dc64003..0d8418938f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -214,6 +214,7 @@ export default { }, override: { 'khroma@*': {licenseName: 'MIT'}, // https://github.com/fabiospampinato/khroma/pull/33 + 'htmx.org@1.9.10': {licenseName: 'BSD-2-Clause'}, // "BSD 2-Clause" -> "BSD-2-Clause" }, emitError: true, allow: '(Apache-2.0 OR BSD-2-Clause OR BSD-3-Clause OR MIT OR ISC OR CPAL-1.0 OR Unlicense OR EPL-1.0 OR EPL-2.0)', From 1df06e3f399307c14b60a2b88e1b26cedc1ae2f9 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sun, 21 Jan 2024 00:37:22 +0200 Subject: [PATCH 34/76] Don't do a full page load when clicking the follow button (#28872) - Use htmx to perform the button request - `hx-headers='{"x-csrf-token": "{{.CsrfToken}}"}'` to authenticate (we should probably learn to reuse this) - `hx-post="{{.ContextUser.HomeLink}}?action=follow"` to send a POST request to follow the user - `hx-target="#profile-avatar-card"` to target the card div for replacement - `hx-swap="outerHTML"` to replace the card (as opposed to its inner content) with the new card that shows the new follower count and button color - Change the backend response to return a `
` tag (the card) instead of a redirect to the user page # Before ![before](https://github.com/go-gitea/gitea/assets/20454870/86899d15-41c9-42ed-bd85-253b9caac7f8) # After ![after](https://github.com/go-gitea/gitea/assets/20454870/59455d96-548c-4a81-a5b0-fab1dc1e87ef) Signed-off-by: Yarden Shoham --- routers/web/user/profile.go | 11 +++++++++-- templates/shared/user/profile_big_avatar.tmpl | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index c5305ebcd9..73ab93caed 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" + "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" @@ -26,6 +27,10 @@ import ( shared_user "code.gitea.io/gitea/routers/web/shared/user" ) +const ( + tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar" +) + // OwnerProfile render profile page for a user or a organization (aka, repo owner) func OwnerProfile(ctx *context.Context) { if strings.Contains(ctx.Req.Header.Get("Accept"), "application/rss+xml") { @@ -309,8 +314,10 @@ func Action(ctx *context.Context) { if err != nil { log.Error("Failed to apply action %q: %v", ctx.FormString("action"), err) - ctx.JSONError(fmt.Sprintf("Action %q failed", ctx.FormString("action"))) + ctx.Error(http.StatusBadRequest, fmt.Sprintf("Action %q failed", ctx.FormString("action"))) return } - ctx.JSONOK() + + shared_user.PrepareContextForProfileBigAvatar(ctx) + ctx.HTML(http.StatusOK, tplProfileBigAvatar) } diff --git a/templates/shared/user/profile_big_avatar.tmpl b/templates/shared/user/profile_big_avatar.tmpl index a637a9a5f9..7afc852d1b 100644 --- a/templates/shared/user/profile_big_avatar.tmpl +++ b/templates/shared/user/profile_big_avatar.tmpl @@ -1,4 +1,4 @@ -
+
{{if eq .SignedUserID .ContextUser.ID}} @@ -110,13 +110,13 @@ {{end}} {{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}} - {{end}} {{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}} -
{{if .IsNothingToCompare}} - {{if and $.IsSigned $.AllowEmptyPr (not .Repository.IsArchived)}} + {{if and $.IsSigned $.AllowEmptyPr (not .Repository.IsArchived) .PageIsComparePull}}
{{ctx.Locale.Tr "repo.pulls.nothing_to_compare_and_allow_empty_pr"}}
@@ -185,8 +185,10 @@
{{template "repo/issue/new_form" .}}
- {{else}} + {{else if and .HeadIsBranch .BaseIsBranch}}
{{ctx.Locale.Tr "repo.pulls.nothing_to_compare"}}
+ {{else}} +
{{ctx.Locale.Tr "repo.pulls.nothing_to_compare_have_tag"}}
{{end}} {{else if and .PageIsComparePull (gt .CommitCount 0)}} {{if .HasPullRequest}} @@ -229,7 +231,7 @@ {{end}} {{$showDiffBox = true}} {{end}} - {{else}} + {{else if not .IsNothingToCompare}} {{$showDiffBox = true}} {{end}}
From caad931385687a06cac73a168a46c00728ed14b6 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sun, 21 Jan 2024 17:31:29 +0100 Subject: [PATCH 39/76] Prevent anonymous container access if `RequireSignInView` is enabled (#28877) Fixes #28875 If `RequireSignInView` is enabled, the ghost user has no access rights. --- modules/context/package.go | 2 +- routers/api/packages/container/container.go | 19 ++++++++++++++----- .../api_packages_container_test.go | 9 +++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/context/package.go b/modules/context/package.go index 87e817c1cd..c452c657e7 100644 --- a/modules/context/package.go +++ b/modules/context/package.go @@ -93,7 +93,7 @@ func packageAssignment(ctx *packageAssignmentCtx, errCb func(int, string, any)) } func determineAccessMode(ctx *Base, pkg *Package, doer *user_model.User) (perm.AccessMode, error) { - if setting.Service.RequireSignInView && doer == nil { + if setting.Service.RequireSignInView && (doer == nil || doer.IsGhost()) { return perm.AccessModeNone, nil } diff --git a/routers/api/packages/container/container.go b/routers/api/packages/container/container.go index dce3809264..8621242da4 100644 --- a/routers/api/packages/container/container.go +++ b/routers/api/packages/container/container.go @@ -114,11 +114,15 @@ func apiErrorDefined(ctx *context.Context, err *namedError) { }) } -// ReqContainerAccess is a middleware which checks the current user valid (real user or ghost for anonymous access) +func apiUnauthorizedError(ctx *context.Context) { + ctx.Resp.Header().Add("WWW-Authenticate", `Bearer realm="`+setting.AppURL+`v2/token",service="container_registry",scope="*"`) + apiErrorDefined(ctx, errUnauthorized) +} + +// ReqContainerAccess is a middleware which checks the current user valid (real user or ghost if anonymous access is enabled) func ReqContainerAccess(ctx *context.Context) { - if ctx.Doer == nil { - ctx.Resp.Header().Add("WWW-Authenticate", `Bearer realm="`+setting.AppURL+`v2/token",service="container_registry",scope="*"`) - apiErrorDefined(ctx, errUnauthorized) + if ctx.Doer == nil || (setting.Service.RequireSignInView && ctx.Doer.IsGhost()) { + apiUnauthorizedError(ctx) } } @@ -138,10 +142,15 @@ func DetermineSupport(ctx *context.Context) { } // Authenticate creates a token for the current user -// If the current user is anonymous, the ghost user is used +// If the current user is anonymous, the ghost user is used unless RequireSignInView is enabled. func Authenticate(ctx *context.Context) { u := ctx.Doer if u == nil { + if setting.Service.RequireSignInView { + apiUnauthorizedError(ctx) + return + } + u = user_model.NewGhostUser() } diff --git a/tests/integration/api_packages_container_test.go b/tests/integration/api_packages_container_test.go index f32d33888b..509ad424e6 100644 --- a/tests/integration/api_packages_container_test.go +++ b/tests/integration/api_packages_container_test.go @@ -21,6 +21,7 @@ import ( container_module "code.gitea.io/gitea/modules/packages/container" "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/minio/sha256-simd" @@ -106,6 +107,14 @@ func TestPackageContainer(t *testing.T) { req = NewRequest(t, "GET", fmt.Sprintf("%sv2", setting.AppURL)). AddTokenAuth(anonymousToken) MakeRequest(t, req, http.StatusOK) + + defer test.MockVariableValue(&setting.Service.RequireSignInView, true)() + + req = NewRequest(t, "GET", fmt.Sprintf("%sv2", setting.AppURL)) + MakeRequest(t, req, http.StatusUnauthorized) + + req = NewRequest(t, "GET", fmt.Sprintf("%sv2/token", setting.AppURL)) + MakeRequest(t, req, http.StatusUnauthorized) }) t.Run("User", func(t *testing.T) { From 692929b628da20258f9f46279142287eb72a843f Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Mon, 22 Jan 2024 00:26:33 +0000 Subject: [PATCH 40/76] [skip ci] Updated licenses and gitignores --- options/license/BSD-Source-beginning-file | 23 +++ options/license/Caldera-no-preamble | 35 +++++ options/license/HPND-MIT-disclaimer | 18 +++ options/license/LPD-document | 8 + options/license/TGPPL-1.0 | 181 ++++++++++++++++++++++ 5 files changed, 265 insertions(+) create mode 100644 options/license/BSD-Source-beginning-file create mode 100644 options/license/Caldera-no-preamble create mode 100644 options/license/HPND-MIT-disclaimer create mode 100644 options/license/LPD-document create mode 100644 options/license/TGPPL-1.0 diff --git a/options/license/BSD-Source-beginning-file b/options/license/BSD-Source-beginning-file new file mode 100644 index 0000000000..6265f97608 --- /dev/null +++ b/options/license/BSD-Source-beginning-file @@ -0,0 +1,23 @@ +Copyright (c) 1997 Justin T. Gibbs. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions, and the following disclaimer, + without modification, immediately at the beginning of the file. +2. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 THE AUTHOR OR CONTRIBUTORS 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/Caldera-no-preamble b/options/license/Caldera-no-preamble new file mode 100644 index 0000000000..f70f34b32b --- /dev/null +++ b/options/license/Caldera-no-preamble @@ -0,0 +1,35 @@ +Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code and documentation must retain the above +copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +All advertising materials mentioning features or use of this software +must display the following acknowledgement: + + This product includes software developed or owned by Caldera + International, Inc. + +Neither the name of Caldera International, Inc. nor the names of other +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA +INTERNATIONAL, INC. AND CONTRIBUTORS ``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 CALDERA INTERNATIONAL, INC. 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/HPND-MIT-disclaimer b/options/license/HPND-MIT-disclaimer new file mode 100644 index 0000000000..bf035915cf --- /dev/null +++ b/options/license/HPND-MIT-disclaimer @@ -0,0 +1,18 @@ + LICENSE + ======= + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided +that the original copyright notices appear in all copies and that both +copyright notice and this permission notice appear in supporting +documentation, and that the name of the author not be used in advertising +or publicity pertaining to distribution of the software without specific +prior written permission. + +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/LPD-document b/options/license/LPD-document new file mode 100644 index 0000000000..0b46392e2f --- /dev/null +++ b/options/license/LPD-document @@ -0,0 +1,8 @@ +Copyright (c) 1996 L. Peter Deutsch + +Permission is granted to copy and distribute this +document for any purpose and without charge, including +translations into other languages and incorporation +into compilations, provided that the copyright notice +and this notice are preserved, and that any substantive +changes or deletions from the original are clearly marked. diff --git a/options/license/TGPPL-1.0 b/options/license/TGPPL-1.0 new file mode 100644 index 0000000000..fbafe92c82 --- /dev/null +++ b/options/license/TGPPL-1.0 @@ -0,0 +1,181 @@ +======================================================= +Transitive Grace Period Public Licence ("TGPPL") v. 1.0 +======================================================= + +This Transitive Grace Period Public Licence (the "License") applies to any +original work of authorship (the "Original Work") whose owner (the +"Licensor") has placed the following licensing notice adjacent to the +copyright notice for the Original Work: + + *Licensed under the Transitive Grace Period Public Licence version 1.0* + +1. **Grant of Copyright License.** Licensor grants You a worldwide, + royalty-free, non-exclusive, sublicensable license, for the duration of + the copyright, to do the following: + + a. to reproduce the Original Work in copies, either alone or as part of a + collective work; + + b. to translate, adapt, alter, transform, modify, or arrange the Original + Work, thereby creating derivative works ("Derivative Works") based upon + the Original Work; + + c. to distribute or communicate copies of the Original Work and Derivative + Works to the public, with the proviso that copies of Original Work or + Derivative Works that You distribute or communicate shall be licensed + under this Transitive Grace Period Public Licence no later than 12 + months after You distributed or communicated said copies; + + d. to perform the Original Work publicly; and + + e. to display the Original Work publicly. + +2. **Grant of Patent License.** Licensor grants You a worldwide, + royalty-free, non-exclusive, sublicensable license, under patent claims + owned or controlled by the Licensor that are embodied in the Original + Work as furnished by the Licensor, for the duration of the patents, to + make, use, sell, offer for sale, have made, and import the Original Work + and Derivative Works. + +3. **Grant of Source Code License.** The term "Source Code" means the + preferred form of the Original Work for making modifications to it and + all available documentation describing how to modify the Original + Work. Licensor agrees to provide a machine-readable copy of the Source + Code of the Original Work along with each copy of the Original Work that + Licensor distributes. Licensor reserves the right to satisfy this + obligation by placing a machine-readable copy of the Source Code in an + information repository reasonably calculated to permit inexpensive and + convenient access by You for as long as Licensor continues to distribute + the Original Work. + +4. **Exclusions From License Grant.** Neither the names of Licensor, nor the + names of any contributors to the Original Work, nor any of their + trademarks or service marks, may be used to endorse or promote products + derived from this Original Work without express prior permission of the + Licensor. Except as expressly stated herein, nothing in this License + grants any license to Licensor's trademarks, copyrights, patents, trade + secrets or any other intellectual property. No patent license is granted + to make, use, sell, offer for sale, have made, or import embodiments of + any patent claims other than the licensed claims defined in Section 2. No + license is granted to the trademarks of Licensor even if such marks are + included in the Original Work. Nothing in this License shall be + interpreted to prohibit Licensor from licensing under terms different + from this License any Original Work that Licensor otherwise would have a + right to license. + +5. **External Deployment.** The term "External Deployment" means the use, + distribution, or communication of the Original Work or Derivative Works + in any way such that the Original Work or Derivative Works may be used by + anyone other than You, whether those works are distributed or + communicated to those persons or made available as an application + intended for use over a network. As an express condition for the grants + of license hereunder, You must treat any External Deployment by You of + the Original Work or a Derivative Work as a distribution under section + 1(c). + +6. **Attribution Rights.** You must retain, in the Source Code of any + Derivative Works that You create, all copyright, patent, or trademark + notices from the Source Code of the Original Work, as well as any notices + of licensing and any descriptive text identified therein as an + "Attribution Notice." You must cause the Source Code for any Derivative + Works that You create to carry a prominent Attribution Notice reasonably + calculated to inform recipients that You have modified the Original Work. + +7. **Warranty of Provenance and Disclaimer of Warranty.** Licensor warrants + that the copyright in and to the Original Work and the patent rights + granted herein by Licensor are owned by the Licensor or are sublicensed + to You under the terms of this License with the permission of the + contributor(s) of those copyrights and patent rights. Except as expressly + stated in the immediately preceding sentence, the Original Work is + provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, + either express or implied, including, without limitation, the warranties + of non-infringement, merchantability or fitness for a particular + purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH + YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this + License. No license to the Original Work is granted by this License + except under this disclaimer. + +8. **Limitation of Liability.** Under no circumstances and under no legal + theory, whether in tort (including negligence), contract, or otherwise, + shall the Licensor be liable to anyone for any indirect, special, + incidental, or consequential damages of any character arising as a result + of this License or the use of the Original Work including, without + limitation, damages for loss of goodwill, work stoppage, computer failure + or malfunction, or any and all other commercial damages or losses. This + limitation of liability shall not apply to the extent applicable law + prohibits such limitation. + +9. **Acceptance and Termination.** If, at any time, You expressly assented + to this License, that assent indicates your clear and irrevocable + acceptance of this License and all of its terms and conditions. If You + distribute or communicate copies of the Original Work or a Derivative + Work, You must make a reasonable effort under the circumstances to obtain + the express assent of recipients to the terms of this License. This + License conditions your rights to undertake the activities listed in + Section 1, including your right to create Derivative Works based upon the + Original Work, and doing so without honoring these terms and conditions + is prohibited by copyright law and international treaty. Nothing in this + License is intended to affect copyright exceptions and limitations + (including 'fair use' or 'fair dealing'). This License shall terminate + immediately and You may no longer exercise any of the rights granted to + You by this License upon your failure to honor the conditions in Section + 1(c). + +10. **Termination for Patent Action.** This License shall terminate + automatically and You may no longer exercise any of the rights granted to + You by this License as of the date You commence an action, including a + cross-claim or counterclaim, against Licensor or any licensee alleging + that the Original Work infringes a patent. This termination provision + shall not apply for an action alleging patent infringement by + combinations of the Original Work with other software or hardware. + +11. **Jurisdiction, Venue and Governing Law.** Any action or suit relating to + this License may be brought only in the courts of a jurisdiction wherein + the Licensor resides or in which Licensor conducts its primary business, + and under the laws of that jurisdiction excluding its conflict-of-law + provisions. The application of the United Nations Convention on Contracts + for the International Sale of Goods is expressly excluded. Any use of the + Original Work outside the scope of this License or after its termination + shall be subject to the requirements and penalties of copyright or patent + law in the appropriate jurisdiction. This section shall survive the + termination of this License. + +12. **Attorneys' Fees.** In any action to enforce the terms of this License + or seeking damages relating thereto, the prevailing party shall be + entitled to recover its costs and expenses, including, without + limitation, reasonable attorneys' fees and costs incurred in connection + with such action, including any appeal of such action. This section shall + survive the termination of this License. + +13. **Miscellaneous.** If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. + +14. **Definition of "You" in This License.** "You" throughout this License, + whether in upper or lower case, means an individual or a legal entity + exercising rights under, and complying with all of the terms of, this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with you. For purposes of this + definition, "control" means (i) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + +15. **Right to Use.** You may use the Original Work in all ways not otherwise + restricted or conditioned by this License or by law, and Licensor + promises not to interfere with or be responsible for such uses by You. + +16. **Modification of This License.** This License is Copyright © 2007 Zooko + Wilcox-O'Hearn. Permission is granted to copy, distribute, or communicate + this License without modification. Nothing in this License permits You to + modify this License as applied to the Original Work or to Derivative + Works. However, You may modify the text of this License and copy, + distribute or communicate your modified version (the "Modified License") + and apply it to other original works of authorship subject to the + following conditions: (i) You may not indicate in any way that your + Modified License is the "Transitive Grace Period Public Licence" or + "TGPPL" and you may not use those names in the name of your Modified + License; and (ii) You must replace the notice specified in the first + paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to + the notice in this License. From 23efd9d2781c2ac22594a83afa75182d276b1571 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 22 Jan 2024 10:13:24 +0800 Subject: [PATCH 41/76] Fix schedule not trigger bug because matching full ref name with short ref name (#28874) Fix #28533 Caused by #28691 --- services/actions/notifier_helper.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 0618f15602..2a3ffb76f3 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -159,24 +159,28 @@ func notify(ctx context.Context, input *notifyInput) error { workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit, input.Event, input.Payload, - input.Event == webhook_module.HookEventPush && input.Ref == input.Repo.DefaultBranch, + input.Event == webhook_module.HookEventPush && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch, ) if err != nil { return fmt.Errorf("DetectWorkflows: %w", err) } - if len(workflows) == 0 { - log.Trace("repo %s with commit %s couldn't find workflows", input.Repo.RepoPath(), commit.ID) - } else { - for _, wf := range workflows { - if actionsConfig.IsWorkflowDisabled(wf.EntryName) { - log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName) - continue - } + log.Trace("repo %s with commit %s event %s find %d workflows and %d schedules", + input.Repo.RepoPath(), + commit.ID, + input.Event, + len(workflows), + len(schedules), + ) - if wf.TriggerEvent.Name != actions_module.GithubEventPullRequestTarget { - detectedWorkflows = append(detectedWorkflows, wf) - } + for _, wf := range workflows { + if actionsConfig.IsWorkflowDisabled(wf.EntryName) { + log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName) + continue + } + + if wf.TriggerEvent.Name != actions_module.GithubEventPullRequestTarget { + detectedWorkflows = append(detectedWorkflows, wf) } } From 8e9b6817bc2032c5af607b63d70ffc7e6599ebbb Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Mon, 22 Jan 2024 08:19:56 +0100 Subject: [PATCH 42/76] Fix `DeleteCollaboration` transaction behaviour (#28886) The method can't be called with an outer transaction because if the user is not a collaborator the outer transaction will be rolled back even if the inner transaction uses the no-error path. `has == 0` leads to `return nil` which cancels the transaction. A standalone call of this method does nothing but if used with an outer transaction, that will be canceled. --- services/repository/collaboration.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/repository/collaboration.go b/services/repository/collaboration.go index eff33c71f3..dccc124748 100644 --- a/services/repository/collaboration.go +++ b/services/repository/collaboration.go @@ -26,9 +26,12 @@ func DeleteCollaboration(ctx context.Context, repo *repo_model.Repository, uid i } defer committer.Close() - if has, err := db.GetEngine(ctx).Delete(collaboration); err != nil || has == 0 { + if has, err := db.GetEngine(ctx).Delete(collaboration); err != nil { return err - } else if err = access_model.RecalculateAccesses(ctx, repo); err != nil { + } else if has == 0 { + return committer.Commit() + } + if err = access_model.RecalculateAccesses(ctx, repo); err != nil { return err } From 77506c6f6cbfa5c15d8373743415f47b2adb404d Mon Sep 17 00:00:00 2001 From: Luca Zulberti Date: Mon, 22 Jan 2024 08:56:17 +0100 Subject: [PATCH 43/76] Add missing exclusive in advanced label options (#28322) Hi, I think these changes could be useful for default labels when creating new repos. The PR includes the following changes: - Add missing exclusive flag for Kind/ scope in labels. - Move Breaking label into new Compat/ scope. --- options/label/Advanced.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/options/label/Advanced.yaml b/options/label/Advanced.yaml index 27b2c14637..b1ecdd6d93 100644 --- a/options/label/Advanced.yaml +++ b/options/label/Advanced.yaml @@ -14,12 +14,12 @@ labels: - name: "Kind/Testing" color: 795548 description: Issue or pull request related to testing - - name: "Kind/Breaking" - color: c62828 - description: Breaking change that won't be backward compatible - name: "Kind/Documentation" color: 37474f description: Documentation changes + - name: "Compat/Breaking" + color: c62828 + description: Breaking change that won't be backward compatible - name: "Reviewed/Duplicate" exclusive: true color: 616161 From 4abd63d3784ab5e374b9efcf16a7b20a951f00dc Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 22 Jan 2024 18:24:55 +0800 Subject: [PATCH 44/76] Upgrade xorm to v1.3.7 to fix a resource leak problem caused by Iterate (#28891) Mainly fix an error https://gitea.com/xorm/xorm/issues/2393 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7bf0804871..59278324d4 100644 --- a/go.mod +++ b/go.mod @@ -121,7 +121,7 @@ require ( mvdan.cc/xurls/v2 v2.5.0 strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 xorm.io/builder v0.3.13 - xorm.io/xorm v1.3.7-0.20240101024435-4992cba040fe + xorm.io/xorm v1.3.7 ) require ( diff --git a/go.sum b/go.sum index 52aeabfeac..bf1ae82b8e 100644 --- a/go.sum +++ b/go.sum @@ -1380,5 +1380,5 @@ strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 h1:mUcz5b3 strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:FJGmPh3vz9jSos1L/F91iAgnC/aejc0wIIrF2ZwJxdY= xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo= xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= -xorm.io/xorm v1.3.7-0.20240101024435-4992cba040fe h1:c+IGxoesJV3s4QZb55feZIb1sqFEUluAYHpe5uJIO6U= -xorm.io/xorm v1.3.7-0.20240101024435-4992cba040fe/go.mod h1:/PjYRKEcJ67WtOnb6DXEMb2Y0uWFaZSoDlhJUebWbXw= +xorm.io/xorm v1.3.7 h1:mLceAGu0b87r9pD4qXyxGHxifOXIIrAdVcA6k95/osw= +xorm.io/xorm v1.3.7/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw= From c4cdebacfeeecac259273f3ff62c0139131ba490 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 23 Jan 2024 09:17:42 +0800 Subject: [PATCH 45/76] Fix sort bug on repository issues list (#28897) Fix #28896 --- modules/indexer/issues/db/options.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/indexer/issues/db/options.go b/modules/indexer/issues/db/options.go index b827a24589..5406715bbc 100644 --- a/modules/indexer/issues/db/options.go +++ b/modules/indexer/issues/db/options.go @@ -38,7 +38,7 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m sortType = "leastupdate" case internal.SortByCommentsAsc: sortType = "leastcomment" - case internal.SortByDeadlineAsc: + case internal.SortByDeadlineDesc: sortType = "farduedate" case internal.SortByCreatedDesc: sortType = "newest" @@ -46,7 +46,7 @@ func ToDBOptions(ctx context.Context, options *internal.SearchOptions) (*issue_m sortType = "recentupdate" case internal.SortByCommentsDesc: sortType = "mostcomment" - case internal.SortByDeadlineDesc: + case internal.SortByDeadlineAsc: sortType = "nearduedate" default: sortType = "newest" From 82acf22d9c09f3c1bed35a63410ee82853ff9484 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 23 Jan 2024 13:40:00 +0800 Subject: [PATCH 46/76] Update go dependencies and fix go-git (#28893) More details are in the comment of repo_base_gogit.go And ref: https://github.com/go-git/go-git/issues/1006 --- assets/go-licenses.json | 7 +- go.mod | 96 ++++++------- go.sum | 200 +++++++++++++------------- modules/git/repo_base_gogit.go | 11 +- modules/git/repo_commitgraph_gogit.go | 4 +- 5 files changed, 158 insertions(+), 160 deletions(-) diff --git a/assets/go-licenses.json b/assets/go-licenses.json index 846cd55276..2aa60780c4 100644 --- a/assets/go-licenses.json +++ b/assets/go-licenses.json @@ -734,15 +734,10 @@ "path": "github.com/mattn/go-runewidth/LICENSE", "licenseText": "The MIT License (MIT)\n\nCopyright (c) 2016 Yasuhiro Matsumoto\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" }, - { - "name": "github.com/matttproud/golang_protobuf_extensions/v2/pbutil", - "path": "github.com/matttproud/golang_protobuf_extensions/v2/pbutil/LICENSE", - "licenseText": " Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"{}\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright {yyyy} {name of copyright owner}\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n" - }, { "name": "github.com/meilisearch/meilisearch-go", "path": "github.com/meilisearch/meilisearch-go/LICENSE", - "licenseText": "MIT License\n\nCopyright (c) 2020-2022 Meili SAS\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" + "licenseText": "MIT License\n\nCopyright (c) 2020-2024 Meili SAS\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" }, { "name": "github.com/mholt/acmez", diff --git a/go.mod b/go.mod index 59278324d4..3268b81e66 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( code.gitea.io/actions-proto-go v0.3.1 code.gitea.io/gitea-vet v0.2.3 - code.gitea.io/sdk/gitea v0.17.0 + code.gitea.io/sdk/gitea v0.17.1 codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570 gitea.com/go-chi/binding v0.0.0-20230415142243-04b515c6d669 gitea.com/go-chi/cache v0.2.0 @@ -21,7 +21,7 @@ require ( github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb github.com/blevesearch/bleve/v2 v2.3.10 github.com/bufbuild/connect-go v1.10.0 - github.com/buildkite/terminal-to-html/v3 v3.10.0 + github.com/buildkite/terminal-to-html/v3 v3.10.1 github.com/caddyserver/certmagic v0.20.0 github.com/chi-middleware/proxy v1.1.1 github.com/denisenkom/go-mssqldb v0.12.3 @@ -36,27 +36,27 @@ require ( github.com/ethantkoenig/rupture v1.0.1 github.com/felixge/fgprof v0.9.3 github.com/fsnotify/fsnotify v1.7.0 - github.com/gliderlabs/ssh v0.3.6-0.20230927171611-ece6c7995e46 + github.com/gliderlabs/ssh v0.3.6 github.com/go-ap/activitypub v0.0.0-20231114162308-e219254dc5c9 github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73 - github.com/go-chi/chi/v5 v5.0.10 + github.com/go-chi/chi/v5 v5.0.11 github.com/go-chi/cors v1.2.1 github.com/go-co-op/gocron v1.37.0 github.com/go-enry/go-enry/v2 v2.8.6 github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e github.com/go-git/go-billy/v5 v5.5.0 - github.com/go-git/go-git/v5 v5.9.0 + github.com/go-git/go-git/v5 v5.11.0 github.com/go-ldap/ldap/v3 v3.4.6 github.com/go-sql-driver/mysql v1.7.1 github.com/go-swagger/go-swagger v0.30.5 github.com/go-testfixtures/testfixtures/v3 v3.9.0 - github.com/go-webauthn/webauthn v0.9.4 + github.com/go-webauthn/webauthn v0.10.0 github.com/gobwas/glob v0.2.3 github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85 github.com/golang-jwt/jwt/v5 v5.2.0 github.com/google/go-github/v57 v57.0.0 - github.com/google/pprof v0.0.0-20231212022811-ec68065c825e + github.com/google/pprof v0.0.0-20240117000934-35fc243c5815 github.com/google/uuid v1.5.0 github.com/gorilla/feeds v1.1.2 github.com/gorilla/sessions v1.2.2 @@ -74,7 +74,7 @@ require ( github.com/markbates/goth v1.78.0 github.com/mattn/go-isatty v0.0.20 github.com/mattn/go-sqlite3 v1.14.19 - github.com/meilisearch/meilisearch-go v0.26.0 + github.com/meilisearch/meilisearch-go v0.26.1 github.com/mholt/archiver/v3 v3.5.1 github.com/microcosm-cc/bluemonday v1.0.26 github.com/minio/minio-go/v7 v7.0.66 @@ -84,12 +84,12 @@ require ( github.com/niklasfasching/go-org v1.7.0 github.com/olivere/elastic/v7 v7.0.32 github.com/opencontainers/go-digest v1.0.0 - github.com/opencontainers/image-spec v1.1.0-rc5 + github.com/opencontainers/image-spec v1.1.0-rc6 github.com/pkg/errors v0.9.1 github.com/pquerna/otp v1.4.0 - github.com/prometheus/client_golang v1.17.0 + github.com/prometheus/client_golang v1.18.0 github.com/quasoft/websspi v1.1.2 - github.com/redis/go-redis/v9 v9.3.0 + github.com/redis/go-redis/v9 v9.4.0 github.com/robfig/cron/v3 v3.0.1 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/sassoftware/go-rpmutils v0.2.0 @@ -99,22 +99,22 @@ require ( github.com/syndtr/goleveldb v1.0.0 github.com/tstranex/u2f v1.0.0 github.com/ulikunitz/xz v0.5.11 - github.com/urfave/cli/v2 v2.26.0 - github.com/xanzy/go-gitlab v0.95.2 + github.com/urfave/cli/v2 v2.27.1 + github.com/xanzy/go-gitlab v0.96.0 github.com/xeipuuv/gojsonschema v1.2.0 github.com/yohcop/openid-go v1.0.1 github.com/yuin/goldmark v1.6.0 github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc github.com/yuin/goldmark-meta v1.1.0 - golang.org/x/crypto v0.17.0 - golang.org/x/image v0.14.0 - golang.org/x/net v0.19.0 - golang.org/x/oauth2 v0.15.0 - golang.org/x/sys v0.15.0 + golang.org/x/crypto v0.18.0 + golang.org/x/image v0.15.0 + golang.org/x/net v0.20.0 + golang.org/x/oauth2 v0.16.0 + golang.org/x/sys v0.16.0 golang.org/x/text v0.14.0 - golang.org/x/tools v0.16.1 - google.golang.org/grpc v1.60.0 - google.golang.org/protobuf v1.31.0 + golang.org/x/tools v0.17.0 + google.golang.org/grpc v1.60.1 + google.golang.org/protobuf v1.32.0 gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/ini.v1 v1.67.0 gopkg.in/yaml.v3 v3.0.1 @@ -129,29 +129,28 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect dario.cat/mergo v1.0.0 // indirect git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect - github.com/ClickHouse/ch-go v0.61.0 // indirect - github.com/ClickHouse/clickhouse-go/v2 v2.16.0 // indirect + github.com/ClickHouse/ch-go v0.61.1 // indirect + github.com/ClickHouse/clickhouse-go/v2 v2.17.1 // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect + github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/RoaringBitmap/roaring v1.7.0 // indirect - github.com/acomagu/bufpipe v1.0.4 // indirect - github.com/andybalholm/brotli v1.0.6 // indirect + github.com/andybalholm/brotli v1.1.0 // indirect github.com/andybalholm/cascadia v1.3.2 // indirect github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.12.0 // indirect - github.com/blevesearch/bleve_index_api v1.1.4 // indirect - github.com/blevesearch/geo v0.1.18 // indirect + github.com/bits-and-blooms/bitset v1.13.0 // indirect + github.com/blevesearch/bleve_index_api v1.1.5 // indirect + github.com/blevesearch/geo v0.1.19 // indirect github.com/blevesearch/go-porterstemmer v1.0.3 // indirect github.com/blevesearch/gtreap v0.1.1 // indirect github.com/blevesearch/mmap-go v1.0.4 // indirect - github.com/blevesearch/scorch_segment_api/v2 v2.2.5 // indirect + github.com/blevesearch/scorch_segment_api/v2 v2.2.6 // indirect github.com/blevesearch/segment v0.9.1 // indirect github.com/blevesearch/snowballstem v0.9.0 // indirect github.com/blevesearch/upsidedown_store_api v1.0.2 // indirect @@ -185,18 +184,18 @@ require ( github.com/go-faster/city v1.0.1 // indirect github.com/go-faster/errors v0.7.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-openapi/analysis v0.21.5 // indirect + github.com/go-openapi/analysis v0.22.2 // indirect github.com/go-openapi/errors v0.21.0 // indirect github.com/go-openapi/inflect v0.19.0 // indirect - github.com/go-openapi/jsonpointer v0.20.1 // indirect - github.com/go-openapi/jsonreference v0.20.3 // indirect - github.com/go-openapi/loads v0.21.3 // indirect + github.com/go-openapi/jsonpointer v0.20.2 // indirect + github.com/go-openapi/jsonreference v0.20.4 // indirect + github.com/go-openapi/loads v0.21.5 // indirect github.com/go-openapi/runtime v0.26.2 // indirect - github.com/go-openapi/spec v0.20.12 // indirect - github.com/go-openapi/strfmt v0.21.10 // indirect - github.com/go-openapi/swag v0.22.5 // indirect - github.com/go-openapi/validate v0.22.4 // indirect - github.com/go-webauthn/x v0.1.5 // indirect + github.com/go-openapi/spec v0.20.14 // indirect + github.com/go-openapi/strfmt v0.22.0 // indirect + github.com/go-openapi/swag v0.22.7 // indirect + github.com/go-openapi/validate v0.22.6 // indirect + github.com/go-webauthn/x v0.1.6 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect @@ -228,9 +227,8 @@ require ( github.com/markbates/going v1.0.3 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/mholt/acmez v1.2.0 // indirect - github.com/miekg/dns v1.1.57 // indirect + github.com/miekg/dns v1.1.58 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -243,13 +241,13 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onsi/ginkgo v1.16.5 // indirect - github.com/paulmach/orb v0.10.0 // indirect + github.com/paulmach/orb v0.11.0 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect - github.com/pierrec/lz4/v4 v4.1.19 // indirect + github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/common v0.46.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rhysd/actionlint v1.6.26 // indirect github.com/rivo/uniseg v0.4.4 // indirect @@ -284,17 +282,17 @@ require ( github.com/zeebo/blake3 v0.2.3 // indirect go.etcd.io/bbolt v1.3.8 // indirect go.mongodb.org/mongo-driver v1.13.1 // indirect - go.opentelemetry.io/otel v1.21.0 // indirect - go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/otel v1.22.0 // indirect + go.opentelemetry.io/otel/trace v1.22.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 // indirect + golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/sync v0.6.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index bf1ae82b8e..f13026c6bb 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ code.gitea.io/actions-proto-go v0.3.1 h1:PMyiQtBKb8dNnpEO2R5rcZdXSis+UQZVo/SciMt code.gitea.io/actions-proto-go v0.3.1/go.mod h1:00ys5QDo1iHN1tHNvvddAcy2W/g+425hQya1cCSvq9A= code.gitea.io/gitea-vet v0.2.3 h1:gdFmm6WOTM65rE8FUBTRzeQZYzXePKSSB1+r574hWwI= code.gitea.io/gitea-vet v0.2.3/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE= -code.gitea.io/sdk/gitea v0.17.0 h1:8JPBss4+Jf7AE1YcfyiGrngTXE8dFSG3si/bypsTH34= -code.gitea.io/sdk/gitea v0.17.0/go.mod h1:ndkDk99BnfiUCCYEUhpNzi0lpmApXlwRFqClBlOlEBg= +code.gitea.io/sdk/gitea v0.17.1 h1:3jCPOG2ojbl8AcfaUCRYLT5MUcBMFwS0OSK2mA5Zok8= +code.gitea.io/sdk/gitea v0.17.1/go.mod h1:aCnBqhHpoEWA180gMbaCtdX9Pl6BWBAuuP2miadoTNM= codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570 h1:TXbikPqa7YRtfU9vS6QJBg77pUvbEb6StRdZO8t1bEY= codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsijsd8q1isWX8MACefDEgTQslQ4stk2AeeTt3kM= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= @@ -76,10 +76,10 @@ github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+ github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ClickHouse/ch-go v0.61.0 h1:22JYeFJoFNAU/Vod4etAeUEY28cYt7Ixnwqj1+EUfro= -github.com/ClickHouse/ch-go v0.61.0/go.mod h1:POJBl0MxEMS91Zd0uTgDDt05KfXEjf5KIwW6lNhje9Y= -github.com/ClickHouse/clickhouse-go/v2 v2.16.0 h1:rhMfnPewXPnY4Q4lQRGdYuTLRBRKJEIEYHtbUMrzmvI= -github.com/ClickHouse/clickhouse-go/v2 v2.16.0/go.mod h1:J7SPfIxwR+x4mQ+o8MLSe0oY50NNntEqCIjFe/T1VPM= +github.com/ClickHouse/ch-go v0.61.1 h1:j5rx3qnvcnYjhnP1IdXE/vdIRQiqgwAzyqOaasA6QCw= +github.com/ClickHouse/ch-go v0.61.1/go.mod h1:myxt/JZgy2BYHFGQqzmaIpbfr5CMbs3YHVULaWQj5YU= +github.com/ClickHouse/clickhouse-go/v2 v2.17.1 h1:ZCmAYWpu75IyEi7+Yrs/uaAjiCGY5wfW5kXo64exkX4= +github.com/ClickHouse/clickhouse-go/v2 v2.17.1/go.mod h1:rkGTvFDTLqLIm0ma+13xmcCfr/08Gvs7KmFt1tgiWHQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -96,16 +96,14 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= -github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c h1:kMFnB0vCcX7IL/m9Y5LO+KQYv+t1CQOiFe6+SV2J7bE= -github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= +github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ= github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I= github.com/RoaringBitmap/roaring v1.7.0 h1:OZF303tJCER1Tj3x+aArx/S5X7hrT186ri6JjrGvG68= github.com/RoaringBitmap/roaring v1.7.0/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90= -github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= -github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink= github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs= @@ -118,8 +116,8 @@ github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3Uu github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4= github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI= -github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= @@ -136,18 +134,19 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.1.10/go.mod h1:w0XsmFg8qg6cmpTtJ0z3pKgjTDBMMnI/+I2syrE6XBE= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA= github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE= +github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb h1:m935MPodAbYS46DG4pJSv7WO+VECIWUQ7OJYSoTrMh4= github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI= github.com/blevesearch/bleve/v2 v2.0.5/go.mod h1:ZjWibgnbRX33c+vBRgla9QhPb4QOjD6fdVJ+R1Bk8LM= github.com/blevesearch/bleve/v2 v2.3.10 h1:z8V0wwGoL4rp7nG/O3qVVLYxUqCbEwskMt4iRJsPLgg= github.com/blevesearch/bleve/v2 v2.3.10/go.mod h1:RJzeoeHC+vNHsoLR54+crS1HmOWpnH87fL70HAUCzIA= github.com/blevesearch/bleve_index_api v1.0.0/go.mod h1:fiwKS0xLEm+gBRgv5mumf0dhgFr2mDgZah1pqv1c1M4= -github.com/blevesearch/bleve_index_api v1.1.4 h1:n9Ilxlb80g9DAhchR95IcVrzohamDSri0wPnkKnva50= -github.com/blevesearch/bleve_index_api v1.1.4/go.mod h1:PbcwjIcRmjhGbkS/lJCpfgVSMROV6TRubGGAODaK1W8= -github.com/blevesearch/geo v0.1.18 h1:Np8jycHTZ5scFe7VEPLrDoHnnb9C4j636ue/CGrhtDw= -github.com/blevesearch/geo v0.1.18/go.mod h1:uRMGWG0HJYfWfFJpK3zTdnnr1K+ksZTuWKhXeSokfnM= +github.com/blevesearch/bleve_index_api v1.1.5 h1:0q05mzu6GT/kebzqKywCpou/eUea9wTKa7kfqX7QX+k= +github.com/blevesearch/bleve_index_api v1.1.5/go.mod h1:PbcwjIcRmjhGbkS/lJCpfgVSMROV6TRubGGAODaK1W8= +github.com/blevesearch/geo v0.1.19 h1:hlX1YpBZ+X+xfjS8hEpmM/tdPUFbqBME3mdAWKHo2s0= +github.com/blevesearch/geo v0.1.19/go.mod h1:EPyr3iJCcESYa830PnkFhqzJkOP7/daHT/ocun43WRY= github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo= github.com/blevesearch/go-porterstemmer v1.0.3/go.mod h1:angGc5Ht+k2xhJdZi511LtmxuEf0OVpvUUNrwmM1P7M= github.com/blevesearch/gtreap v0.1.1 h1:2JWigFrzDMR+42WGIN/V2p0cUvn4UP3C4Q5nmaZGW8Y= @@ -156,8 +155,8 @@ github.com/blevesearch/mmap-go v1.0.2/go.mod h1:ol2qBqYaOUsGdm7aRMRrYGgPvnwLe6Y+ github.com/blevesearch/mmap-go v1.0.4 h1:OVhDhT5B/M1HNPpYPBKIEJaD0F3Si+CrEKULGCDPWmc= github.com/blevesearch/mmap-go v1.0.4/go.mod h1:EWmEAOmdAS9z/pi/+Toxu99DnsbhG1TIxUoRmJw/pSs= github.com/blevesearch/scorch_segment_api/v2 v2.0.1/go.mod h1:lq7yK2jQy1yQjtjTfU931aVqz7pYxEudHaDwOt1tXfU= -github.com/blevesearch/scorch_segment_api/v2 v2.2.5 h1:5SsNQmR8v1bojtGQ1zFhZravcMg5rdiX8AVu6LwlVtc= -github.com/blevesearch/scorch_segment_api/v2 v2.2.5/go.mod h1:8N2ytOlBCdurlxDgbqsfeR1oTKRN0ZVIKdUUP1VFZNc= +github.com/blevesearch/scorch_segment_api/v2 v2.2.6 h1:rewrzgFaCEjjfWovAB9NubMAd4+aCLxD3RaQcPDaoNo= +github.com/blevesearch/scorch_segment_api/v2 v2.2.6/go.mod h1:0rv+k/OIjtYCT/g7Z45pCOVweFyta+0AdXO8keKfZxo= github.com/blevesearch/segment v0.9.0/go.mod h1:9PfHYUdQCgHktBgvtUOF4x+pc4/l8rdH0u5spnW85UQ= github.com/blevesearch/segment v0.9.1 h1:+dThDy+Lvgj5JMxhmOVlgFfkUtZV2kw49xax4+jTfSU= github.com/blevesearch/segment v0.9.1/go.mod h1:zN21iLm7+GnBHWTao9I+Au/7MBiL8pPFtJBJTsk6kQw= @@ -197,8 +196,8 @@ github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/bufbuild/connect-go v1.10.0 h1:QAJ3G9A1OYQW2Jbk3DeoJbkCxuKArrvZgDt47mjdTbg= github.com/bufbuild/connect-go v1.10.0/go.mod h1:CAIePUgkDR5pAFaylSMtNK45ANQjp9JvpluG20rhpV8= -github.com/buildkite/terminal-to-html/v3 v3.10.0 h1:mW1PSgDdUvmQMHOfXEOJDPGfqGWaskJfnGzdaQuJvsE= -github.com/buildkite/terminal-to-html/v3 v3.10.0/go.mod h1:qtuRyYs6/Sw3FS9jUyVEaANHgHGqZsGqMknPLyau5cQ= +github.com/buildkite/terminal-to-html/v3 v3.10.1 h1:znT9eD26LQ59dDJJEpMCwkP4wEptEAPi74hsTBuHdEo= +github.com/buildkite/terminal-to-html/v3 v3.10.1/go.mod h1:qtuRyYs6/Sw3FS9jUyVEaANHgHGqZsGqMknPLyau5cQ= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/caddyserver/certmagic v0.20.0 h1:bTw7LcEZAh9ucYCRXyCpIrSAGplplI0vGYJ4BpCQ/Fc= github.com/caddyserver/certmagic v0.20.0/go.mod h1:N4sXgpICQUskEWpj7zVzvWD41p3NYacrNoZYiRM2jTg= @@ -307,8 +306,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= -github.com/gliderlabs/ssh v0.3.6-0.20230927171611-ece6c7995e46 h1:fYiA820jw7wmAvdXrHwMItxjJkra7dT9y8yiXhtzb94= -github.com/gliderlabs/ssh v0.3.6-0.20230927171611-ece6c7995e46/go.mod h1:i/TCLcdiX9Up/vs+Rp8c3yMbqp2Y4Y7Nh9uzGFCa5pM= +github.com/gliderlabs/ssh v0.3.6 h1:ZzjlDa05TcFRICb3anf/dSPN3ewz1Zx6CMLPWgkm3b8= +github.com/gliderlabs/ssh v0.3.6/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-ap/activitypub v0.0.0-20231114162308-e219254dc5c9 h1:j2TrkUG/NATGi/EQS+MvEoF79CxiRUmT16ErFroNcKI= @@ -321,8 +320,8 @@ github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-chi/chi/v5 v5.0.1/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/chi/v5 v5.0.4/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= -github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= -github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA= +github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0= @@ -342,37 +341,37 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f h1:Pz0DHeFij3XFhoBRGUDPzSJ+w2UcK5/0JvF8DRI58r8= -github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20230305113008-0c11038e723f/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= -github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= -github.com/go-git/go-git/v5 v5.9.0/go.mod h1:RKIqga24sWdMGZF+1Ekv9kylsDz6LzdTSI2s/OsZWE0= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= +github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= +github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4= +github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A= github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc= -github.com/go-openapi/analysis v0.21.5 h1:3tHfEBh6Ia8eKc4M7khOGjPOAlWKJ10d877Cr9teujI= -github.com/go-openapi/analysis v0.21.5/go.mod h1:25YcZosX9Lwz2wBsrFrrsL8bmjjXdlyP6zsr2AMy29M= +github.com/go-openapi/analysis v0.22.2 h1:ZBmNoP2h5omLKr/srIC9bfqrUGzT6g6gNv03HE9Vpj0= +github.com/go-openapi/analysis v0.22.2/go.mod h1:pDF4UbZsQTo/oNuRfAWWd4dAh4yuYf//LYorPTjrpvo= github.com/go-openapi/errors v0.21.0 h1:FhChC/duCnfoLj1gZ0BgaBmzhJC2SL/sJr8a2vAobSY= github.com/go-openapi/errors v0.21.0/go.mod h1:jxNTMUxRCKj65yb/okJGEtahVd7uvWnuWfj53bse4ho= github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= -github.com/go-openapi/jsonpointer v0.20.1 h1:MkK4VEIEZMj4wT9PmjaUmGflVBr9nvud4Q4UVFbDoBE= -github.com/go-openapi/jsonpointer v0.20.1/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= -github.com/go-openapi/jsonreference v0.20.3 h1:EjGcjTW8pD1mRis6+w/gmoBdqv5+RbE9B85D1NgDOVQ= -github.com/go-openapi/jsonreference v0.20.3/go.mod h1:FviDZ46i9ivh810gqzFLl5NttD5q3tSlMLqLr6okedM= -github.com/go-openapi/loads v0.21.3 h1:8sSH2FIm/SnbDUGv572md4YqVMFne/a9Eubvcd3anew= -github.com/go-openapi/loads v0.21.3/go.mod h1:Y3aMR24iHbKHppOj91nQ/SHc0cuPbAr4ndY4a02xydc= +github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= +github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= +github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdXSSgNeAhojU= +github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= +github.com/go-openapi/loads v0.21.5 h1:jDzF4dSoHw6ZFADCGltDb2lE4F6De7aWSpe+IcsRzT0= +github.com/go-openapi/loads v0.21.5/go.mod h1:PxTsnFBoBe+z89riT+wYt3prmSBP6GDAQh2l9H1Flz8= github.com/go-openapi/runtime v0.26.2 h1:elWyB9MacRzvIVgAZCBJmqTi7hBzU0hlKD4IvfX0Zl0= github.com/go-openapi/runtime v0.26.2/go.mod h1:O034jyRZ557uJKzngbMDJXkcKJVzXJiymdSfgejrcRw= -github.com/go-openapi/spec v0.20.12 h1:cgSLbrsmziAP2iais+Vz7kSazwZ8rsUZd6TUzdDgkVI= -github.com/go-openapi/spec v0.20.12/go.mod h1:iSCgnBcwbMW9SfzJb8iYynXvcY6C/QFrI7otzF7xGM4= -github.com/go-openapi/strfmt v0.21.10 h1:JIsly3KXZB/Qf4UzvzJpg4OELH/0ASDQsyk//TTBDDk= -github.com/go-openapi/strfmt v0.21.10/go.mod h1:vNDMwbilnl7xKiO/Ve/8H8Bb2JIInBnH+lqiw6QWgis= -github.com/go-openapi/swag v0.22.5 h1:fVS63IE3M0lsuWRzuom3RLwUMVI2peDH01s6M70ugys= -github.com/go-openapi/swag v0.22.5/go.mod h1:Gl91UqO+btAM0plGGxHqJcQZ1ZTy6jbmridBTsDy8A0= -github.com/go-openapi/validate v0.22.4 h1:5v3jmMyIPKTR8Lv9syBAIRxG6lY0RqeBPB1LKEijzk8= -github.com/go-openapi/validate v0.22.4/go.mod h1:qm6O8ZIcPVdSY5219468Jv7kBdGvkiZLPOmqnqTUZ2A= +github.com/go-openapi/spec v0.20.14 h1:7CBlRnw+mtjFGlPDRZmAMnq35cRzI91xj03HVyUi/Do= +github.com/go-openapi/spec v0.20.14/go.mod h1:8EOhTpBoFiask8rrgwbLC3zmJfz4zsCUueRuPM6GNkw= +github.com/go-openapi/strfmt v0.22.0 h1:Ew9PnEYc246TwrEspvBdDHS4BVKXy/AOVsfqGDgAcaI= +github.com/go-openapi/strfmt v0.22.0/go.mod h1:HzJ9kokGIju3/K6ap8jL+OlGAbjpSv27135Yr9OivU4= +github.com/go-openapi/swag v0.22.7 h1:JWrc1uc/P9cSomxfnsFSVWoE1FW6bNbrVPmpQYpCcR8= +github.com/go-openapi/swag v0.22.7/go.mod h1:Gl91UqO+btAM0plGGxHqJcQZ1ZTy6jbmridBTsDy8A0= +github.com/go-openapi/validate v0.22.6 h1:+NhuwcEYpWdO5Nm4bmvhGLW0rt1Fcc532Mu3wpypXfo= +github.com/go-openapi/validate v0.22.6/go.mod h1:eaddXSqKeTg5XpSmj1dYyFTK/95n/XHwcOY+BMxKMyM= github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-redis/redis/v8 v8.4.0/go.mod h1:A1tbYoHSa1fXwN+//ljcCYYJeLmVrwL9hbQN45Jdy0M= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -387,10 +386,10 @@ github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg= github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/go-testfixtures/testfixtures/v3 v3.9.0 h1:938g5V+GWLVejm3Hc+nWCuEXRlcglZDDlN/t1gWzcSY= github.com/go-testfixtures/testfixtures/v3 v3.9.0/go.mod h1:cdsKD2ApFBjdog9jRsz6EJqF+LClq/hrwE9K/1Dzo4s= -github.com/go-webauthn/webauthn v0.9.4 h1:YxvHSqgUyc5AK2pZbqkWWR55qKeDPhP8zLDr6lpIc2g= -github.com/go-webauthn/webauthn v0.9.4/go.mod h1:LqupCtzSef38FcxzaklmOn7AykGKhAhr9xlRbdbgnTw= -github.com/go-webauthn/x v0.1.5 h1:V2TCzDU2TGLd0kSZOXdrqDVV5JB9ILnKxA9S53CSBw0= -github.com/go-webauthn/x v0.1.5/go.mod h1:qbzWwcFcv4rTwtCLOZd+icnr6B7oSsAGZJqlt8cukqY= +github.com/go-webauthn/webauthn v0.10.0 h1:yuW2e1tXnRAwAvKrR4q4LQmc6XtCMH639/ypZGhZCwk= +github.com/go-webauthn/webauthn v0.10.0/go.mod h1:l0NiauXhL6usIKqNLCUM3Qir43GK7ORg8ggold0Uv/Y= +github.com/go-webauthn/x v0.1.6 h1:QNAX+AWeqRt9loE8mULeWJCqhVG5D/jvdmJ47fIWCkQ= +github.com/go-webauthn/x v0.1.6/go.mod h1:W8dFVZ79o4f+nY1eOUICy/uq5dhrRl7mxQkYhXTo0FA= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/goccy/go-json v0.9.5/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= @@ -483,8 +482,8 @@ github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200905233945-acf8798be1f7/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= -github.com/google/pprof v0.0.0-20231212022811-ec68065c825e h1:bwOy7hAFd0C91URzMIEBfr6BAz29yk7Qj0cy6S7DJlU= -github.com/google/pprof v0.0.0-20231212022811-ec68065c825e/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240117000934-35fc243c5815 h1:WzfWbQz/Ze8v6l++GGbGNFZnUShVpP/0xffCPLL+ax8= +github.com/google/pprof v0.0.0-20240117000934-35fc243c5815/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -635,8 +634,6 @@ github.com/markbates/going v1.0.3 h1:mY45T5TvW+Xz5A6jY7lf4+NLg9D8+iuStIHyR7M8qsE github.com/markbates/going v1.0.3/go.mod h1:fQiT6v6yQar9UD6bd/D4Z5Afbk9J6BBVBtLiyY4gp2o= github.com/markbates/goth v1.78.0 h1:7VEIFDycJp9deyVv3YraGBPdD0ZYQW93Y3Aw1eVP3BY= github.com/markbates/goth v1.78.0/go.mod h1:X6xdNgpapSENS0O35iTBBcMHoJDQDfI9bJl+APCkYMc= -github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -648,18 +645,16 @@ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI= github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= -github.com/meilisearch/meilisearch-go v0.26.0 h1:6IdFC9S53gEp7FMkt99swIFyEZE+4TwJAgen3eQdw40= -github.com/meilisearch/meilisearch-go v0.26.0/go.mod h1:SxuSqDcPBIykjWz1PX+KzsYzArNLSCadQodWs8extS0= +github.com/meilisearch/meilisearch-go v0.26.1 h1:3bmo2uLijX7kvBmiZ9LupVfC95TFcRJDgrRTzbOoE4A= +github.com/meilisearch/meilisearch-go v0.26.1/go.mod h1:SxuSqDcPBIykjWz1PX+KzsYzArNLSCadQodWs8extS0= github.com/mholt/acmez v1.2.0 h1:1hhLxSgY5FvH5HCnGUuwbKY2VQVo8IU7rxXKSnZ7F30= github.com/mholt/acmez v1.2.0/go.mod h1:VT9YwH1xgNX1kmYY89gY8xPJC84BFAisjo8Egigt4kE= github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo= github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4= github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58= github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= -github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM= -github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk= +github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= +github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/minio-go/v7 v7.0.66 h1:bnTOXOHjOqv/gcMuiVbN9o2ngRItvqE774dG9nq0Dzw= @@ -721,10 +716,10 @@ github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= -github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= -github.com/paulmach/orb v0.10.0 h1:guVYVqzxHE/CQ1KpfGO077TR0ATHSNjp4s6XGLn3W9s= -github.com/paulmach/orb v0.10.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= +github.com/opencontainers/image-spec v1.1.0-rc6 h1:XDqvyKsJEbRtATzkgItUqBA7QHk58yxX1Ov9HERHNqU= +github.com/opencontainers/image-spec v1.1.0-rc6/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/paulmach/orb v0.11.0 h1:JfVXJUBeH9ifc/OrhBY0lL16QsmPgpCHMlqSSYhcgAA= +github.com/paulmach/orb v0.11.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= @@ -732,8 +727,8 @@ github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOS github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pierrec/lz4/v4 v4.1.19 h1:tYLzDnjDXh9qIxSTKHwXwOYmm9d887Y7Y1ZkyXYHAN4= -github.com/pierrec/lz4/v4 v4.1.19/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= +github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= @@ -745,20 +740,20 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pquerna/otp v1.4.0 h1:wZvl1TIVxKRThZIBiwOOHOGP/1+nZyWBil9Y2XNEDzg= github.com/pquerna/otp v1.4.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg= -github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= -github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= -github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= +github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/quasoft/websspi v1.1.2 h1:/mA4w0LxWlE3novvsoEL6BBA1WnjJATbjkh1kFrTidw= github.com/quasoft/websspi v1.1.2/go.mod h1:HmVdl939dQ0WIXZhyik+ARdI03M6bQzaSEKcgpFmewk= github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/redis/go-redis/v9 v9.3.0 h1:RiVDjmig62jIWp7Kk4XVLs0hzV6pI3PyTnnL0cnn0u0= -github.com/redis/go-redis/v9 v9.3.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/redis/go-redis/v9 v9.4.0 h1:Yzoz33UZw9I/mFhx4MNrB6Fk+XHO1VukNcCa1+lwyKk= +github.com/redis/go-redis/v9 v9.4.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rhysd/actionlint v1.6.26 h1:zi7jPZf3Ks14gCXYAAL47uBziyFlX7+Xwilqhexct9g= @@ -868,8 +863,8 @@ github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs= github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= -github.com/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI= -github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= +github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.37.1-0.20220607072126-8a320890c08d/go.mod h1:t/G+3rLek+CyY9bnIE+YlMRddxVAAGjhxndDB4i4C0I= @@ -881,8 +876,8 @@ github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7Fw github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/xanzy/go-gitlab v0.95.2 h1:4p0IirHqEp5f0baK/aQqr4TR57IsD+8e4fuyAA1yi88= -github.com/xanzy/go-gitlab v0.95.2/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI= +github.com/xanzy/go-gitlab v0.96.0 h1:LGkZ+wSNMRtHIBaYE4Hq3dZVjprwHv3Y1+rhKU3WETs= +github.com/xanzy/go-gitlab v0.96.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= @@ -937,10 +932,10 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/otel v0.14.0/go.mod h1:vH5xEuwy7Rts0GNtsCW3HYQoZDY+OmBJ6t1bFGGlxgw= -go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= -go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= -go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= -go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= +go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= +go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= +go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0= +go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= @@ -962,15 +957,14 @@ golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -981,12 +975,12 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= -golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4= -golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= +golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8= +golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1052,16 +1046,16 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= -golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= +golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= +golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1074,8 +1068,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1134,8 +1128,9 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1145,8 +1140,9 @@ golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1218,8 +1214,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1281,8 +1277,8 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200929141702-51c3e5b607fe/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1297,8 +1293,8 @@ google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= -google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1312,8 +1308,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/modules/git/repo_base_gogit.go b/modules/git/repo_base_gogit.go index 90123ee84b..9270bb70f0 100644 --- a/modules/git/repo_base_gogit.go +++ b/modules/git/repo_base_gogit.go @@ -14,6 +14,7 @@ import ( gitealog "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "github.com/go-git/go-billy/v5" "github.com/go-git/go-billy/v5/osfs" gogit "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" @@ -62,7 +63,15 @@ func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) { return nil, err } } - storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true, LargeObjectThreshold: setting.Git.LargeObjectThreshold}) + // the "clone --shared" repo doesn't work well with go-git AlternativeFS, https://github.com/go-git/go-git/issues/1006 + // so use "/" for AlternatesFS, I guess it is the same behavior as current nogogit (no limitation or check for the "objects/info/alternates" paths), trust the "clone" command executed by the server. + var altFs billy.Filesystem + if setting.IsWindows { + altFs = osfs.New(filepath.VolumeName(setting.RepoRootPath) + "\\") // TODO: does it really work for Windows? Need some time to check. + } else { + altFs = osfs.New("/") + } + storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true, LargeObjectThreshold: setting.Git.LargeObjectThreshold, AlternatesFS: altFs}) gogitRepo, err := gogit.Open(storage, fs) if err != nil { return nil, err diff --git a/modules/git/repo_commitgraph_gogit.go b/modules/git/repo_commitgraph_gogit.go index c2d741daae..d3182f15c6 100644 --- a/modules/git/repo_commitgraph_gogit.go +++ b/modules/git/repo_commitgraph_gogit.go @@ -12,7 +12,7 @@ import ( gitealog "code.gitea.io/gitea/modules/log" - "github.com/go-git/go-git/v5/plumbing/format/commitgraph" + commitgraph "github.com/go-git/go-git/v5/plumbing/format/commitgraph/v2" cgobject "github.com/go-git/go-git/v5/plumbing/object/commitgraph" ) @@ -22,7 +22,7 @@ func (r *Repository) CommitNodeIndex() (cgobject.CommitNodeIndex, *os.File) { file, err := os.Open(indexPath) if err == nil { - var index commitgraph.Index // TODO: in newer go-git, it might need to use "github.com/go-git/go-git/v5/plumbing/format/commitgraph/v2" package to compile + var index commitgraph.Index index, err = commitgraph.OpenFileIndex(file) if err == nil { return cgobject.NewGraphCommitNodeIndex(index, r.gogitRepo.Storer), file From 1ca947baece4863a1af2c9114a1f67c81a351d0c Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Wed, 24 Jan 2024 00:25:44 +0000 Subject: [PATCH 47/76] [skip ci] Updated translations via Crowdin --- options/locale/locale_sk-SK.ini | 84 ++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_sk-SK.ini b/options/locale/locale_sk-SK.ini index aa02c701dd..f714d34d54 100644 --- a/options/locale/locale_sk-SK.ini +++ b/options/locale/locale_sk-SK.ini @@ -4,6 +4,7 @@ explore=Preskúmať help=Pomoc logo=Logo sign_in=Prihlásiť sa +sign_in_with_provider=Prihlásiť sa pomocou %s sign_in_or=alebo sign_out=Odhlásiť sa sign_up=Registrácia @@ -16,9 +17,11 @@ template=Šablóna language=Jazyk notifications=Upozornenia active_stopwatch=Sledovanie času aktivity +tracked_time_summary=Zhrnutie sledovaného času na základe filtrov zoznamu problémov create_new=Vytvoriť… user_profile_and_more=Profil a nastavenia… signed_in_as=Prihlásený ako +enable_javascript=Táto stránka vyžaduje JavaScript. toc=Obsah licenses=Licencie return_to_gitea=Naspäť do Gitea @@ -56,6 +59,7 @@ new_mirror=Nové zrkadlo new_fork=Nový fork repozitára new_org=Nová organizácia new_project=Nový projekt +new_project_column=Nový stĺpec manage_org=Spravovať organizácie admin_panel=Administrácia account_settings=Nastavenia účtu @@ -78,6 +82,8 @@ milestones=Míľniky ok=OK cancel=Zrušiť retry=Opakovať +rerun=Spustiť znovu +rerun_all=Spustiť znovu všetky činnosti save=Uložiť add=Pridať add_all=Pridať všetko @@ -85,11 +91,15 @@ remove=Odstrániť remove_all=Odstrániť všetko remove_label_str=Odstrániť položku „%s“ edit=Upraviť +view=Zobraziť enabled=Povolené +disabled=Zakázané +locked=Uzamknuté copy=Kopírovať copy_url=Kopírovať URL +copy_hash=Kopírovať hash copy_content=Kopírovať obsah copy_branch=Kopírovať meno vetvy copy_success=Skopírované! @@ -102,29 +112,70 @@ loading=Načítava sa… error=Chyba error404=Stránka, na ktorú sa pokúšate dostať, buď neexistuje, alebo nemáte oprávnenie na jej zobrazenie. +go_back=Naspäť never=Nikdy +unknown=Neznámy rss_feed=RSS kanál +pin=Pripnúť +unpin=Odopnúť +artifacts=Artefakty archived=Archivované +concept_system_global=Globálne +concept_user_individual=Individuálne +concept_code_repository=Repozitár +concept_user_organization=Organizácia +show_timestamps=Zobraziť časové značky +show_log_seconds=Zobraziť sekundy +show_full_screen=Zobraziť cez celú obrazovku +download_logs=Stiahnuť protokoly +confirm_delete_selected=Potvrdzujete zmazanie všetkých vybraných položiek? +name=Meno +value=Hodnota [aria] +navbar=Navigačná lišta +footer=Päta +footer.software=O softvéri +footer.links=Odkazy [heatmap] +number_of_contributions_in_the_last_12_months=%s príspevkov za posledných 12 mesiacov +no_contributions=Žiadne príspevky +less=Menej +more=Viac [editor] +buttons.heading.tooltip=Pridať hlavičku +buttons.bold.tooltip=Pridať tučný text +buttons.italic.tooltip=Pridať kurzívu +buttons.quote.tooltip=Citovať text +buttons.code.tooltip=Pridať kód +buttons.link.tooltip=Pridať odkaz +buttons.list.unordered.tooltip=Pridať zoznam +buttons.list.ordered.tooltip=Pridať číslovaný zoznam +buttons.list.task.tooltip=Pridať zoznam úloh +buttons.mention.tooltip=Spomenúť používateľa alebo tím +buttons.ref.tooltip=Odkázať na problém alebo žiadosť o natiahnutie +buttons.switch_to_legacy.tooltip=Použiť starší editor namiest toho +buttons.enable_monospace_font=Povoliť font s pevnou šírkou +buttons.disable_monospace_font=Zakázať font s pevnou šírkou [filter] +string.asc=A - Z +string.desc=Z - A [error] occurred=Vyskytla sa chyba +report_message=Ak si myslíte, že ide o chybu Gitea, vyhľadajte problémy na GitHub-e alebo v prípade potreby otvorte nový problém. missing_csrf=Nesprávna žiadosť: neprítomný CSFR token invalid_csrf=Nesprávna žiadosť: nesprávny CSFR token not_found=Nebolo možné nájsť cieľ. @@ -133,6 +184,7 @@ network_error=Chyba siete [startpage] app_desc=Jednoducho prístupný vlastný Git install=Jednoduchá inštalácia +install_desc=Jednoducho spustite binárku pre vašu platformu, pošlite ju ako Docker, alebo ju získajte ako balíček. platform=Multiplatformový platform_desc=Gitea beží všade kde je možné preložiť Go: Windows, macOS, Linux, ARM, a podobne. Vyberte si! lightweight=Ľahká @@ -215,6 +267,7 @@ openid_signup_popup=Povoliť používateľskú registráciu založenú na OpenID enable_captcha=Povoliť CAPTCHA pri registrácii enable_captcha_popup=Vyžadovať CAPTCHA validáciu pri registrácii používateľa. require_sign_in_view=Vyžadovať prihlásenie na prezeranie stránok +require_sign_in_view_popup=Povoliť prístup k stránkam iba pre prihlásených používateľov. Návštevníci uvidia iba prihlasovaciu a registračnú stránku. admin_setting_desc=Vytvorenie správcovského účtu je nepovinné. Prvý zaregistrovaný používateľ sa stane automaticky správcom. admin_title=Nastavenia administrátorského účtu admin_name=Používateľské meno administrátora @@ -242,6 +295,10 @@ default_enable_timetracking_popup=Predvolene povoliť sledovanie času pre nové no_reply_address=Skrytá e-mailová doména no_reply_address_helper=Doménové meno pre používateľov so skrytou e-mailovou adresou. Napríklad, používateľ s menom 'joe' bude zalogovaný v Git-e ako 'joe@noreply.example.org' ak je skrytá e-mailová doména nastavená na 'noreply.example.org'. password_algorithm=Hašovací algoritmus hesla +invalid_password_algorithm=Neplatný hash algoritmus hesla +password_algorithm_helper=Nastavte algoritmus hashovania hesla. Algoritmy majú rôzne požiadavky a silu. Algoritmus argon2 je pomerne bezpečný, ale využíva veľa pamäte a môže byť nevhodný pre malé systémy. +enable_update_checker=Povoliť kontrolu aktualizácií +enable_update_checker_helper=Pravidelne kontroluje nové verzie pripojením k gitea.io. [home] uname_holder=Používateľské meno alebo emailová adresa @@ -275,14 +332,19 @@ repos=Repozitáre users=Používatelia organizations=Organizácie search=Hľadať +go_to=Ísť na code=Zdrojový kód +search.type.tooltip=Typ vyhľadávania search.fuzzy=Fuzzy +search.fuzzy.tooltip=Zahrnúť iba výsledky, ktoré sa takmer zhodujú s hľadaným výrazom search.match=Zhoda +search.match.tooltip=Zahrnúť iba výsledky, ktoré sa presne zhodujú s hľadaným výrazom code_search_unavailable=Vyhľadávanie kódu momentálne nie je dostupné. Kontaktujte, prosím, správcu. repo_no_results=Nenašli sa zodpovedajúce repozitáre. user_no_results=Nenašli sa zodpovedajúci používatelia. org_no_results=Nenašli sa zodpovedajúce organizácie. code_no_results=Nenašiel sa žiaden zdrojový kód zodpovedajúci hľadanému výrazu. +code_search_results=`Výsledky hľadania pre "%s"` code_last_indexed_at=Naposledy indexované %s relevant_repositories_tooltip=Repozitáre, ktoré sú forkami alebo ktoré nemajú tému, žiadnu ikonu ani popis, sú skryté. relevant_repositories=Zobrazujú sa iba relevantné repozitáre, zobraziť nefiltrované výsledky. @@ -299,7 +361,6 @@ forgot_password_title=Zabudnuté heslo forgot_password=Zabudli ste heslo? sign_up_now=Potrebujete účet? Zaregistrujte sa teraz. confirmation_mail_sent_prompt=Na adresu %s bol odoslaný nový potvrdzovací e-mail. Skontrolujte si, prosím, vašu doručenú poštu počas najbližších %s pre dokončenie procesu registrácie. -must_change_password=Aktualizácia vášho hesla allow_password_change=Vyžiadať od používateľa zmenu hesla (doporučuje sa) reset_password_mail_sent_prompt=Na adresu %s bol odoslaný potvrdzovací e-mail. Skontrolujte si, prosím, vašu doručenú poštu počas najbližších %s pre dokončenie procesu obnovenia účtu. active_your_account=Aktivovať účet @@ -312,6 +373,7 @@ email_not_associate=Táto e-mailová adresa nie je priradená k žiadnemu účtu send_reset_mail=Odoslať e-mail pre obnovenie účtu reset_password=Obnovenie účtu invalid_code=Váš potvrdzovací kód je chybný alebo vypršala jeho platnosť. +invalid_password=Vaše heslo sa nezhoduje s heslom, ktoré bolo použité na vytvorenie účtu. reset_password_helper=Obnoviť účet password_too_short=Heslo nemôže obsahovať menej ako %d znakov. non_local_account=Externe overovaní používatelia nemôžu aktualizovať svoje heslo prostredníctvom webového rozhrania Gitea. @@ -351,6 +413,7 @@ password_pwned_err=Nie je možné dokončiť žiadosť na HaveIBeenPwned [mail] view_it_on=Zobraziť na %s +reply=alebo odpovedzte priamo na tento e-mail link_not_working_do_paste=Nefunguje? Skúste ho skopírovať a vložiť do svojho prehliadača. hi_user_x=Ahoj %s, @@ -408,10 +471,15 @@ repo.transfer.body=Ak to chcete prijať alebo odmietnuť, navštívte %s alebo t repo.collaborator.added.subject=%s vás pridal do %s repo.collaborator.added.text=Boli ste pridaný ako spolupracovník repozitára: +team_invite.subject=%[1]s vás pozval/a, aby ste sa pripojili k organizácii %[2]s +team_invite.text_1=%[1]s vás pozval/a, aby ste sa pripojili k tímu %[2]s v organizácii %[3]s. +team_invite.text_2=Ak sa chcete pripojiť k tímu, kliknite na nasledujúci odkaz: +team_invite.text_3=Poznámka: Táto pozvánka bola určená pre %[1]s. Ak ste túto pozvánku nečakali, môžete tento e-mail ignorovať. [modal] yes=Áno no=Nie +confirm=Potvrdiť cancel=Zrušiť modify=Aktualizovať @@ -448,6 +516,8 @@ max_size_error=` musí obsahovať maximálne %s znakov.` email_error=` nie je platná e-mailová adresa.` glob_pattern_error=` glob vzor je neplatný: %s.` regex_pattern_error=` regex vzor je neplatný: %s.` +username_error=` môže obsahovať iba alfanumerické znaky ('0-9', 'a-z', 'A-Z'), pomlčku ('-'), podčiarkovník ('_') a bodku ('.'). Nemôže začínať ani končiť nealfanumerickými znakmi a po sebe idúce nealfanumerické znaky sú tiež zakázané.` +invalid_group_team_map_error=`mapovanie je neplatné: %s` unknown_error=Neznáma chyba: captcha_incorrect=Overovací kód CAPTCHA je nesprávny. password_not_match=Heslá sa nezhodujú. @@ -482,10 +552,14 @@ user_not_exist=Tento používateľ neexistuje. team_not_exist=Tento tím neexistuje. last_org_owner=Nemôžete odstrániť posledného používateľa z tímu 'vlastníkov'. Musí existovať aspoň jeden vlastník pre organizáciu. cannot_add_org_to_team=Organizácia nemôže byť pridaná ako člen tímu. +duplicate_invite_to_team=Používateľ už bol pozvaný ako člen tímu. +organization_leave_success=Úspešne ste opustili organizáciu %s. invalid_ssh_key=Nie je možné overiť váš SSH kľúč: %s invalid_gpg_key=Nie je možné overiť váš GPG kľúč: %s invalid_ssh_principal=Neplatná identita: %s +must_use_public_key=Zadaný kľúč je súkromný kľúč. Nikde neodovzdávajte svoj súkromný kľúč. Namiesto toho použite svoj verejný kľúč. +unable_verify_ssh_key=Nie je možné overiť kľúč SSH, skontrolujte, či neobsahuje chyby. auth_failed=Overenie zlyhalo: %v @@ -493,12 +567,15 @@ target_branch_not_exist=Cieľová vetva neexistuje. [user] change_avatar=Zmeniť svoj avatar… +joined_on=Pripojil/a sa %s repositories=Repozitáre activity=Verejná aktivita followers=Sledujúci starred=Obľúbené repozitáre watched=Sledované repozitáre +code=Kód projects=Projekty +overview=Prehľad following=Sledovaní follow=Sledovať unfollow=Zrušiť sledovanie @@ -962,6 +1039,7 @@ projects.edit=Upraviť projekty projects.modify=Aktualizovať projekt projects.type.none=Žiadny projects.template.desc=Šablóna +projects.column.new=Nový stĺpec projects.open=Otvoriť projects.close=Zavrieť @@ -1074,8 +1152,11 @@ activity.git_stats_commit_1=%d commit activity.git_stats_commit_n=%d commity search=Hľadať +search.type.tooltip=Typ vyhľadávania search.fuzzy=Fuzzy +search.fuzzy.tooltip=Zahrnúť iba výsledky, ktoré sa takmer zhodujú s hľadaným výrazom search.match=Zhoda +search.match.tooltip=Zahrnúť iba výsledky, ktoré sa presne zhodujú s hľadaným výrazom search.code_no_results=Nenašiel sa žiaden zdrojový kód zodpovedajúci hľadanému výrazu. search.code_search_unavailable=Vyhľadávanie kódu momentálne nie je dostupné. Kontaktujte, prosím, správcu. @@ -1173,6 +1254,7 @@ release.cancel=Zrušiť [org] +code=Kód lower_repositories=repozitáre From fd97613b655f370b92eab8af9a26fe8006c891bd Mon Sep 17 00:00:00 2001 From: wackbyte Date: Tue, 23 Jan 2024 20:07:13 -0500 Subject: [PATCH 48/76] Fix hardcoded GitHub icon used as migrated release avatar (#28910) --- templates/repo/release/list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index f7d2025733..ccea14c4e2 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -55,7 +55,7 @@

{{if .OriginalAuthor}} - {{svg "octicon-mark-github" 20 "gt-mr-2"}}{{.OriginalAuthor}} + {{svg (MigrationIcon .Repo.GetOriginalURLHostname) 20 "gt-mr-2"}}{{.OriginalAuthor}} {{else if .Publisher}} {{ctx.AvatarUtils.Avatar .Publisher 20 "gt-mr-2"}} {{.Publisher.GetDisplayName}} From 1af45689f9bdac7267400a8c9d77c23676b33935 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Wed, 24 Jan 2024 03:09:08 +0100 Subject: [PATCH 49/76] Only migrate the first 255 chars of a Github issue title (#28902) Fixes #28846 --- services/migrations/gitea_uploader.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index 23d855d615..5a4392c667 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -19,6 +19,7 @@ import ( issues_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" + base_module "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/label" "code.gitea.io/gitea/modules/log" @@ -397,7 +398,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error { RepoID: g.repo.ID, Repo: g.repo, Index: issue.Number, - Title: issue.Title, + Title: base_module.TruncateString(issue.Title, 255), Content: issue.Content, Ref: issue.Ref, IsClosed: issue.State == "closed", From f3ba3e922dde7d12999a90d6cee15805a56cc7ff Mon Sep 17 00:00:00 2001 From: JakobDev Date: Wed, 24 Jan 2024 03:32:57 +0100 Subject: [PATCH 50/76] Don't run push mirrors for archived repos (#27140) Fixes https://codeberg.org/forgejo/forgejo/issues/612 At the moment push mirrors are still run if a repo is archived. This PR fixes this. --- models/repo/pushmirror.go | 7 +- options/locale/locale_en-US.ini | 1 + routers/api/v1/api.go | 8 +- routers/web/repo/setting/setting.go | 10 +- templates/repo/settings/options.tmpl | 346 ++++++++++++++------------- 5 files changed, 191 insertions(+), 181 deletions(-) diff --git a/models/repo/pushmirror.go b/models/repo/pushmirror.go index 24c58faf84..bf134abfb1 100644 --- a/models/repo/pushmirror.go +++ b/models/repo/pushmirror.go @@ -121,8 +121,11 @@ func GetPushMirrorsSyncedOnCommit(ctx context.Context, repoID int64) ([]*PushMir // PushMirrorsIterate iterates all push-mirror repositories. func PushMirrorsIterate(ctx context.Context, limit int, f func(idx int, bean any) error) error { sess := db.GetEngine(ctx). - Where("last_update + (`interval` / ?) <= ?", time.Second, time.Now().Unix()). - And("`interval` != 0"). + Table("push_mirror"). + Join("INNER", "`repository`", "`repository`.id = `push_mirror`.repo_id"). + Where("`push_mirror`.last_update + (`push_mirror`.`interval` / ?) <= ?", time.Second, time.Now().Unix()). + And("`push_mirror`.`interval` != 0"). + And("`repository`.is_archived = ?", false). OrderBy("last_update ASC") if limit > 0 { sess = sess.Limit(limit) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 9a06bb0952..3bf8aa3845 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2377,6 +2377,7 @@ settings.archive.error = An error occurred while trying to archive the repo. See settings.archive.error_ismirror = You cannot archive a mirrored repo. settings.archive.branchsettings_unavailable = Branch settings are not available if the repo is archived. settings.archive.tagsettings_unavailable = Tag settings are not available if the repo is archived. +settings.archive.mirrors_unavailable = Mirrors are not available if the repo is archived. settings.unarchive.button = Unarchive repo settings.unarchive.header = Unarchive this repo settings.unarchive.text = Unarchiving the repo will restore its ability to receive commits and pushes, as well as new issues and pull-requests. diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 8d7669762b..cb1803f7c6 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1181,13 +1181,13 @@ func Routes() *web.Route { Delete(reqToken(), reqRepoWriter(unit.TypeReleases), repo.DeleteReleaseByTag) }) }, reqRepoReader(unit.TypeReleases)) - m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), repo.MirrorSync) - m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), repo.PushMirrorSync) + m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.MirrorSync) + m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), mustNotBeArchived, repo.PushMirrorSync) m.Group("/push_mirrors", func() { m.Combo("").Get(repo.ListPushMirrors). - Post(bind(api.CreatePushMirrorOption{}), repo.AddPushMirror) + Post(mustNotBeArchived, bind(api.CreatePushMirrorOption{}), repo.AddPushMirror) m.Combo("/{name}"). - Delete(repo.DeletePushMirrorByRemoteName). + Delete(mustNotBeArchived, repo.DeletePushMirrorByRemoteName). Get(repo.GetPushMirrorByName) }, reqAdmin(), reqToken()) diff --git a/routers/web/repo/setting/setting.go b/routers/web/repo/setting/setting.go index e721b7c739..fc1403b3cc 100644 --- a/routers/web/repo/setting/setting.go +++ b/routers/web/repo/setting/setting.go @@ -185,7 +185,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "mirror": - if !setting.Mirror.Enabled || !repo.IsMirror { + if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived { ctx.NotFound("", nil) return } @@ -278,7 +278,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "mirror-sync": - if !setting.Mirror.Enabled || !repo.IsMirror { + if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived { ctx.NotFound("", nil) return } @@ -306,7 +306,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "push-mirror-update": - if !setting.Mirror.Enabled { + if !setting.Mirror.Enabled || repo.IsArchived { ctx.NotFound("", nil) return } @@ -343,7 +343,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "push-mirror-remove": - if !setting.Mirror.Enabled { + if !setting.Mirror.Enabled || repo.IsArchived { ctx.NotFound("", nil) return } @@ -372,7 +372,7 @@ func SettingsPost(ctx *context.Context) { ctx.Redirect(repo.Link() + "/settings") case "push-mirror-add": - if setting.Mirror.DisableNewPush { + if setting.Mirror.DisableNewPush || repo.IsArchived { ctx.NotFound("", nil) return } diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 8456bb409b..07b2f58d53 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -79,206 +79,212 @@ {{ctx.Locale.Tr "repo.settings.mirror_settings"}}

- {{if $newMirrorsEntirelyEnabled}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}

- {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.pull_mirror_instructions"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_pull_section"}}
- {{else if $onlyNewPushMirrorsEnabled}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_pull_mirror.instructions"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}
- {{else if $onlyNewPullMirrorsEnabled}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.instructions"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.pull_mirror_warning"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}

- {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.info"}} - {{if $existingPushMirror}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}} - {{end}} + {{if .Repository.IsArchived}} +
+ {{ctx.Locale.Tr "repo.settings.archive.mirrors_unavailable"}} +
{{else}} - {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.no_new_mirrors"}} {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}}
- {{end}} - - {{if $existingPushMirror}} - - - - - - - - + {{if $newMirrorsEntirelyEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}

+ {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.pull_mirror_instructions"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_pull_section"}}
+ {{else if $onlyNewPushMirrorsEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_pull_mirror.instructions"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}
+ {{else if $onlyNewPullMirrorsEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.instructions"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.pull_mirror_warning"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}

+ {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.info"}} + {{if $existingPushMirror}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}} + {{end}} + {{else}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.no_new_mirrors"}} {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}}
{{end}} - {{if $modifyBrokenPullMirror}} - {{/* even if a repo is a pull mirror (IsMirror=true), the PullMirror might still be nil if the mirror migration is broken */}} +
{{ctx.Locale.Tr "repo.settings.mirror_settings.mirrored_repository"}}{{ctx.Locale.Tr "repo.settings.mirror_settings.direction"}}{{ctx.Locale.Tr "repo.settings.mirror_settings.last_update"}}
+ {{if $existingPushMirror}} + + + + + + + + + {{end}} + {{if $modifyBrokenPullMirror}} + {{/* even if a repo is a pull mirror (IsMirror=true), the PullMirror might still be nil if the mirror migration is broken */}} + + + + + + {{else if $isWorkingPullMirror}} - + + + - - {{else if $isWorkingPullMirror}} - - - - - - - - - - - - - {{end}}{{/* end if: IsMirror */}} - - {{range .PushMirrors}} - - - - - - - {{else}} - - - - {{end}} - {{if (not .DisableNewPushMirrors)}} - {{end}} - -
{{ctx.Locale.Tr "repo.settings.mirror_settings.mirrored_repository"}}{{ctx.Locale.Tr "repo.settings.mirror_settings.direction"}}{{ctx.Locale.Tr "repo.settings.mirror_settings.last_update"}}
+
{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}: {{ctx.Locale.Tr "error.occurred"}}
+
-
{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}: {{ctx.Locale.Tr "error.occurred"}}
+
{{.PullMirror.RemoteAddress}}{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}{{DateTime "full" .PullMirror.UpdatedUnix}} +
+ {{.CsrfTokenHtml}} + + +
{{.PullMirror.RemoteAddress}}{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}{{DateTime "full" .PullMirror.UpdatedUnix}} -
- {{.CsrfTokenHtml}} - - -
-
-
- {{template "base/disable_form_autofill"}} - {{.CsrfTokenHtml}} - -
- -
- - -
-
-
- - -
- {{$address := MirrorRemoteAddress $.Context .Repository .PullMirror.GetRemoteName false}} -
- - -

{{ctx.Locale.Tr "repo.mirror_address_desc"}}

-
-
- - {{ctx.Locale.Tr "repo.need_auth"}} - -
-
- - -
-
- - -
-

{{ctx.Locale.Tr "repo.mirror_password_help"}}

-
-
- - {{if .LFSStartServer}} -
- -
- - -
-
-
- - -

{{ctx.Locale.Tr "repo.mirror_lfs_endpoint_desc" "https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md#server-discovery" | Str2html}}

-
- {{end}} -
- -
-
-
{{.RemoteAddress}}{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.push"}}{{if .LastUpdateUnix}}{{DateTime "full" .LastUpdateUnix}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} {{if .LastError}}
{{ctx.Locale.Tr "error"}}
{{end}}
- -
- {{$.CsrfTokenHtml}} - - - -
-
- {{$.CsrfTokenHtml}} - - - -
-
{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.none"}}
{{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}} - -
- - + +
+ +
+ + +
+
+
+ + +
+ {{$address := MirrorRemoteAddress $.Context .Repository .PullMirror.GetRemoteName false}} +
+ +

{{ctx.Locale.Tr "repo.mirror_address_desc"}}

-
+
{{ctx.Locale.Tr "repo.need_auth"}}
-
- - +
+ +
-
- - +
+ +
+

{{ctx.Locale.Tr "repo.mirror_password_help"}}

-
+ + {{if .LFSStartServer}} +
+
- - + +
-
- - +
+ + +

{{ctx.Locale.Tr "repo.mirror_lfs_endpoint_desc" "https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md#server-discovery" | Str2html}}

+ {{end}}
- +
+ + + {{end}}{{/* end if: IsMirror */}} + + {{range .PushMirrors}} + + {{.RemoteAddress}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.direction.push"}} + {{if .LastUpdateUnix}}{{DateTime "full" .LastUpdateUnix}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} {{if .LastError}}
{{ctx.Locale.Tr "error"}}
{{end}} + + +
+ {{$.CsrfTokenHtml}} + + + +
+
+ {{$.CsrfTokenHtml}} + + + +
+ + + {{else}} + + {{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.none"}} + + {{end}} + {{if (not .DisableNewPushMirrors)}} + + +
+ {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + +
+ + +

{{ctx.Locale.Tr "repo.mirror_address_desc"}}

+
+
+ + {{ctx.Locale.Tr "repo.need_auth"}} + +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+ + +
+
+ +
+
+ + + {{end}} + + + {{end}}
{{end}} From 4567a3a1ad0490d9077102e0e7b5de35790e5803 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Wed, 24 Jan 2024 04:02:04 +0100 Subject: [PATCH 51/76] Allow to sync tags from admin dashboard (#28045) Inspired by #28043 This PR adds a option to the Admin Dashboard to sync all tags to the database. ![grafik](https://github.com/go-gitea/gitea/assets/15185051/26ac51ef-82a4-4fd9-a6a6-5aefec612ff6) --- modules/repository/repo.go | 16 +++++++++ options/locale/locale_en-US.ini | 2 ++ routers/init.go | 3 ++ routers/web/admin/admin.go | 8 +++++ services/release/release.go | 6 ++++ services/release/tag.go | 61 +++++++++++++++++++++++++++++++++ templates/admin/dashboard.tmpl | 4 +++ 7 files changed, 100 insertions(+) create mode 100644 services/release/tag.go diff --git a/modules/repository/repo.go b/modules/repository/repo.go index 33363e4689..5af69763d1 100644 --- a/modules/repository/repo.go +++ b/modules/repository/repo.go @@ -284,6 +284,22 @@ func CleanUpMigrateInfo(ctx context.Context, repo *repo_model.Repository) (*repo return repo, UpdateRepository(ctx, repo, false) } +// SyncRepoTags synchronizes releases table with repository tags +func SyncRepoTags(ctx context.Context, repoID int64) error { + repo, err := repo_model.GetRepositoryByID(ctx, repoID) + if err != nil { + return err + } + + gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + if err != nil { + return err + } + defer gitRepo.Close() + + return SyncReleasesWithTags(ctx, repo, gitRepo) +} + // SyncReleasesWithTags synchronizes release table with repository tags func SyncReleasesWithTags(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository) error { log.Debug("SyncReleasesWithTags: in Repo[%d:%s/%s]", repo.ID, repo.OwnerName, repo.Name) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 3bf8aa3845..26734f2dd6 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2748,6 +2748,7 @@ dashboard.delete_missing_repos = Delete all repositories missing their Git files dashboard.delete_missing_repos.started = Delete all repositories missing their Git files task started. dashboard.delete_generated_repository_avatars = Delete generated repository avatars dashboard.sync_repo_branches = Sync missed branches from git data to databases +dashboard.sync_repo_tags = Sync tags from git data to database dashboard.update_mirrors = Update Mirrors dashboard.repo_health_check = Health check all repositories dashboard.check_repo_stats = Check all repository statistics @@ -2802,6 +2803,7 @@ dashboard.stop_endless_tasks = Stop endless tasks dashboard.cancel_abandoned_jobs = Cancel abandoned jobs dashboard.start_schedule_tasks = Start schedule tasks dashboard.sync_branch.started = Branches Sync started +dashboard.sync_tag.started = Tags Sync started dashboard.rebuild_issue_indexer = Rebuild issue indexer users.user_manage_panel = User Account Management diff --git a/routers/init.go b/routers/init.go index ee98aedb16..e0a7150ba3 100644 --- a/routers/init.go +++ b/routers/init.go @@ -45,6 +45,7 @@ import ( repo_migrations "code.gitea.io/gitea/services/migrations" mirror_service "code.gitea.io/gitea/services/mirror" pull_service "code.gitea.io/gitea/services/pull" + release_service "code.gitea.io/gitea/services/release" repo_service "code.gitea.io/gitea/services/repository" "code.gitea.io/gitea/services/repository/archiver" "code.gitea.io/gitea/services/task" @@ -138,6 +139,8 @@ func InitWebInstalled(ctx context.Context) { mustInit(system.Init) mustInitCtx(ctx, oauth2.Init) + mustInit(release_service.Init) + mustInitCtx(ctx, models.Init) mustInitCtx(ctx, authmodel.Init) mustInitCtx(ctx, repo_service.Init) diff --git a/routers/web/admin/admin.go b/routers/web/admin/admin.go index 5559b6af88..d31cb1cd25 100644 --- a/routers/web/admin/admin.go +++ b/routers/web/admin/admin.go @@ -23,6 +23,7 @@ import ( "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/cron" "code.gitea.io/gitea/services/forms" + release_service "code.gitea.io/gitea/services/release" repo_service "code.gitea.io/gitea/services/repository" ) @@ -157,6 +158,13 @@ func DashboardPost(ctx *context.Context) { } }() ctx.Flash.Success(ctx.Tr("admin.dashboard.sync_branch.started")) + case "sync_repo_tags": + go func() { + if err := release_service.AddAllRepoTagsToSyncQueue(graceful.GetManager().ShutdownContext()); err != nil { + log.Error("AddAllRepoTagsToSyncQueue: %v: %v", ctx.Doer.ID, err) + } + }() + ctx.Flash.Success(ctx.Tr("admin.dashboard.sync_tag.started")) default: task := cron.GetTask(form.Op) if task != nil { diff --git a/services/release/release.go b/services/release/release.go index ddfb11fa47..f17682ae0f 100644 --- a/services/release/release.go +++ b/services/release/release.go @@ -16,6 +16,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/storage" @@ -370,3 +371,8 @@ func DeleteReleaseByID(ctx context.Context, repo *repo_model.Repository, rel *re return nil } + +// Init start release service +func Init() error { + return initTagSyncQueue(graceful.GetManager().ShutdownContext()) +} diff --git a/services/release/tag.go b/services/release/tag.go new file mode 100644 index 0000000000..dae2b70f76 --- /dev/null +++ b/services/release/tag.go @@ -0,0 +1,61 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package release + +import ( + "context" + "errors" + "fmt" + + "code.gitea.io/gitea/models/db" + repo_model "code.gitea.io/gitea/models/repo" + "code.gitea.io/gitea/modules/graceful" + "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/queue" + repo_module "code.gitea.io/gitea/modules/repository" + + "xorm.io/builder" +) + +type TagSyncOptions struct { + RepoID int64 +} + +// tagSyncQueue represents a queue to handle tag sync jobs. +var tagSyncQueue *queue.WorkerPoolQueue[*TagSyncOptions] + +func handlerTagSync(items ...*TagSyncOptions) []*TagSyncOptions { + for _, opts := range items { + err := repo_module.SyncRepoTags(graceful.GetManager().ShutdownContext(), opts.RepoID) + if err != nil { + log.Error("syncRepoTags [%d] failed: %v", opts.RepoID, err) + } + } + return nil +} + +func addRepoToTagSyncQueue(repoID int64) error { + return tagSyncQueue.Push(&TagSyncOptions{ + RepoID: repoID, + }) +} + +func initTagSyncQueue(ctx context.Context) error { + tagSyncQueue = queue.CreateUniqueQueue(ctx, "tag_sync", handlerTagSync) + if tagSyncQueue == nil { + return errors.New("unable to create tag_sync queue") + } + go graceful.GetManager().RunWithCancel(tagSyncQueue) + + return nil +} + +func AddAllRepoTagsToSyncQueue(ctx context.Context) error { + if err := db.Iterate(ctx, builder.Eq{"is_empty": false}, func(ctx context.Context, repo *repo_model.Repository) error { + return addRepoToTagSyncQueue(repo.ID) + }); err != nil { + return fmt.Errorf("run sync all tags failed: %v", err) + } + return nil +} diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index 65d9c370f3..f43b4c5385 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -63,6 +63,10 @@ {{ctx.Locale.Tr "admin.dashboard.sync_repo_branches"}} + + {{ctx.Locale.Tr "admin.dashboard.sync_repo_tags"}} + + From ee3e83eec154c906e8668a126bb39c56a053d49a Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Wed, 24 Jan 2024 04:26:28 +0100 Subject: [PATCH 52/76] Don't reload timeline page when (un)resolving or replying conversation (#28654) Fixes #15981 --- routers/web/repo/pull_review.go | 32 ++--- .../repo/issue/view_content/comments.tmpl | 134 +----------------- .../repo/issue/view_content/conversation.tmpl | 133 +++++++++++++++++ web_src/css/review.css | 2 +- 4 files changed, 151 insertions(+), 150 deletions(-) create mode 100644 templates/repo/issue/view_content/conversation.tmpl diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go index 1359af9d3b..156b70a999 100644 --- a/routers/web/repo/pull_review.go +++ b/routers/web/repo/pull_review.go @@ -21,8 +21,9 @@ import ( ) const ( - tplConversation base.TplName = "repo/diff/conversation" - tplNewComment base.TplName = "repo/diff/new_comment" + tplDiffConversation base.TplName = "repo/diff/conversation" + tplTimelineConversation base.TplName = "repo/issue/view_content/conversation" + tplNewComment base.TplName = "repo/diff/new_comment" ) // RenderNewCodeCommentForm will render the form for creating a new review comment @@ -97,11 +98,7 @@ func CreateCodeComment(ctx *context.Context) { log.Trace("Comment created: %-v #%d[%d] Comment[%d]", ctx.Repo.Repository, issue.Index, issue.ID, comment.ID) - if form.Origin == "diff" { - renderConversation(ctx, comment) - return - } - ctx.Redirect(comment.Link(ctx)) + renderConversation(ctx, comment, form.Origin) } // UpdateResolveConversation add or remove an Conversation resolved mark @@ -152,22 +149,21 @@ func UpdateResolveConversation(ctx *context.Context) { return } - if origin == "diff" { - renderConversation(ctx, comment) - return - } - ctx.JSONOK() + renderConversation(ctx, comment, origin) } -func renderConversation(ctx *context.Context, comment *issues_model.Comment) { +func renderConversation(ctx *context.Context, comment *issues_model.Comment, origin string) { 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 } - ctx.Data["PageIsPullFiles"] = true + ctx.Data["PageIsPullFiles"] = (origin == "diff") ctx.Data["comments"] = comments - ctx.Data["CanMarkConversation"] = true + if ctx.Data["CanMarkConversation"], err = issues_model.CanMarkConversation(ctx, comment.Issue, ctx.Doer); err != nil { + ctx.ServerError("CanMarkConversation", err) + return + } ctx.Data["Issue"] = comment.Issue if err = comment.Issue.LoadPullRequest(ctx); err != nil { ctx.ServerError("comment.Issue.LoadPullRequest", err) @@ -179,7 +175,11 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment) { return } ctx.Data["AfterCommitID"] = pullHeadCommitID - ctx.HTML(http.StatusOK, tplConversation) + if origin == "diff" { + ctx.HTML(http.StatusOK, tplDiffConversation) + } else if origin == "timeline" { + ctx.HTML(http.StatusOK, tplTimelineConversation) + } } // SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 817f20af20..ad7b836e9c 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -460,139 +460,7 @@
{{range $filename, $lines := .Review.CodeComments}} {{range $line, $comms := $lines}} -
-
- {{$invalid := (index $comms 0).Invalidated}} - {{$resolved := (index $comms 0).IsResolved}} - {{$resolveDoer := (index $comms 0).ResolveDoer}} - {{$isNotPending := (not (eq (index $comms 0).Review.Type 0))}} -
- {{$filename}} - {{if $invalid}} - - {{ctx.Locale.Tr "repo.issues.review.outdated"}} - - {{end}} -
-
- {{if or $invalid $resolved}} - - - {{end}} -
-
- {{$diff := (CommentMustAsDiff ctx (index $comms 0))}} - {{if $diff}} - {{$file := (index $diff.Files 0)}} -
-
-
- - - {{template "repo/diff/section_unified" dict "file" $file "root" $}} - -
-
-
-
- {{end}} -
-
- {{range $comms}} - {{$createdSubStr:= TimeSinceUnix .CreatedUnix ctx.Locale}} -
-
-
-
- {{if not .OriginalAuthor}} - - {{ctx.AvatarUtils.Avatar .Poster 20}} - - {{end}} - - {{if .OriginalAuthor}} - - {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} - {{.OriginalAuthor}} - - {{if $.Repository.OriginalURL}} - ({{ctx.Locale.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe}}){{end}} - {{else}} - {{template "shared/user/authorlink" .Poster}} - {{end}} - {{ctx.Locale.Tr "repo.issues.commented_at" (.HashTag|Escape) $createdSubStr | Safe}} - -
-
- {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}} - {{if not $.Repository.IsArchived}} - {{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}} - {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} - {{end}} -
-
-
-
- {{if .RenderedContent}} - {{.RenderedContent|Str2html}} - {{else}} - {{ctx.Locale.Tr "repo.issues.no_content"}} - {{end}} -
-
{{.Content}}
-
-
- {{$reactions := .Reactions.GroupByType}} - {{if $reactions}} - {{template "repo/issue/view_content/reactions" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} - {{end}} -
-
- {{end}} -
-
-
- {{if $resolved}} -
- {{svg "octicon-check" 16 "gt-mr-2"}} - {{$resolveDoer.Name}} {{ctx.Locale.Tr "repo.issues.review.resolved_by"}} -
- {{end}} -
-
- {{if and $.CanMarkConversation $isNotPending}} - - {{end}} - {{if and $.SignedUserID (not $.Repository.IsArchived)}} - - {{end}} -
-
- {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $comms 0).ReviewID "root" $ "comment" (index $comms 0)}} -
-
+ {{template "repo/issue/view_content/conversation" dict "." $ "comments" $comms}} {{end}} {{end}}
diff --git a/templates/repo/issue/view_content/conversation.tmpl b/templates/repo/issue/view_content/conversation.tmpl new file mode 100644 index 0000000000..c9e5ee6275 --- /dev/null +++ b/templates/repo/issue/view_content/conversation.tmpl @@ -0,0 +1,133 @@ +{{$invalid := (index .comments 0).Invalidated}} +{{$resolved := (index .comments 0).IsResolved}} +{{$resolveDoer := (index .comments 0).ResolveDoer}} +{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}} +
+
+
+ {{(index .comments 0).TreePath}} + {{if $invalid}} + + {{ctx.Locale.Tr "repo.issues.review.outdated"}} + + {{end}} +
+
+ {{if or $invalid $resolved}} + + + {{end}} +
+
+ {{$diff := (CommentMustAsDiff ctx (index .comments 0))}} + {{if $diff}} + {{$file := (index $diff.Files 0)}} +
+
+
+ + + {{template "repo/diff/section_unified" dict "file" $file "root" $}} + +
+
+
+
+ {{end}} +
+
+ {{range .comments}} + {{$createdSubStr:= TimeSinceUnix .CreatedUnix ctx.Locale}} +
+
+
+
+ {{if not .OriginalAuthor}} + + {{ctx.AvatarUtils.Avatar .Poster 20}} + + {{end}} + + {{if .OriginalAuthor}} + + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} + {{.OriginalAuthor}} + + {{if $.Repository.OriginalURL}} + ({{ctx.Locale.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe}}){{end}} + {{else}} + {{template "shared/user/authorlink" .Poster}} + {{end}} + {{ctx.Locale.Tr "repo.issues.commented_at" (.HashTag|Escape) $createdSubStr | Safe}} + +
+
+ {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}} + {{if not $.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{end}} +
+
+
+
+ {{if .RenderedContent}} + {{.RenderedContent|Str2html}} + {{else}} + {{ctx.Locale.Tr "repo.issues.no_content"}} + {{end}} +
+
{{.Content}}
+
+
+ {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} + {{template "repo/issue/view_content/reactions" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} + {{end}} +
+
+ {{end}} +
+
+
+ {{if $resolved}} +
+ {{svg "octicon-check" 16 "gt-mr-2"}} + {{$resolveDoer.Name}} {{ctx.Locale.Tr "repo.issues.review.resolved_by"}} +
+ {{end}} +
+
+ {{if and $.CanMarkConversation $isNotPending}} + + {{end}} + {{if and $.SignedUserID (not $.Repository.IsArchived)}} + + {{end}} +
+
+ {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index .comments 0).ReviewID "root" $ "comment" (index .comments 0)}} +
+
diff --git a/web_src/css/review.css b/web_src/css/review.css index c831f38976..5336775547 100644 --- a/web_src/css/review.css +++ b/web_src/css/review.css @@ -67,7 +67,7 @@ position: relative; } -.conversation-holder .comment-code-cloud { +.code-diff .conversation-holder .comment-code-cloud { max-width: 820px; } From 7ed18566e10b298309dcc99d97447cb1932ae09a Mon Sep 17 00:00:00 2001 From: JakobDev Date: Wed, 24 Jan 2024 06:51:37 +0100 Subject: [PATCH 53/76] Show in Web UI if file is vendored and generated (#28620) This simple shows in the Web UI is a file is vendored and/or generated. ![grafik](https://github.com/go-gitea/gitea/assets/15185051/bfe45fcc-cfec-4ba1-8d93-c0a262c3ae1c) ![grafik](https://github.com/go-gitea/gitea/assets/15185051/9f222a49-e7bf-4540-ba64-43dcc5767b76) --------- Co-authored-by: delvh Co-authored-by: Lunny Xiao --- options/locale/locale_en-US.ini | 2 ++ routers/web/repo/view.go | 15 +++++++++++++++ templates/repo/file_info.tmpl | 10 ++++++++++ 3 files changed, 27 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 26734f2dd6..effb3896c2 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1191,6 +1191,8 @@ audio_not_supported_in_browser = Your browser does not support the HTML5 'audio' stored_lfs = Stored with Git LFS symbolic_link = Symbolic link executable_file = Executable File +vendored = Vendored +generated = Generated commit_graph = Commit Graph commit_graph.select = Select branches commit_graph.hide_pr_refs = Hide Pull Requests diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index aa07d5939d..00fd47b650 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -647,6 +647,21 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) { } } + if ctx.Repo.GitRepo != nil { + checker, deferable := ctx.Repo.GitRepo.CheckAttributeReader(ctx.Repo.CommitID) + if checker != nil { + defer deferable() + attrs, err := checker.CheckPath(ctx.Repo.TreePath) + if err == nil { + vendored, has := attrs["linguist-vendored"] + ctx.Data["IsVendored"] = has && (vendored == "set" || vendored == "true") + + generated, has := attrs["linguist-generated"] + ctx.Data["IsGenerated"] = has && (generated == "set" || generated == "true") + } + } + } + if fInfo.st.IsImage() && !fInfo.st.IsSvgImage() { img, _, err := image.DecodeConfig(bytes.NewReader(buf)) if err == nil { diff --git a/templates/repo/file_info.tmpl b/templates/repo/file_info.tmpl index 3003fbbdb6..33f0f87d61 100644 --- a/templates/repo/file_info.tmpl +++ b/templates/repo/file_info.tmpl @@ -30,6 +30,16 @@ {{ctx.Locale.Tr "repo.executable_file"}}
{{end}} + {{if .IsVendored}} +
+ {{ctx.Locale.Tr "repo.vendored"}} +
+ {{end}} + {{if .IsGenerated}} +
+ {{ctx.Locale.Tr "repo.generated"}} +
+ {{end}} {{if .ImageSize}}
{{.ImageSize}} From eaab89c46b77902b70bb8da2f1643a7f909daf45 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Thu, 25 Jan 2024 00:25:21 +0000 Subject: [PATCH 54/76] [skip ci] Updated translations via Crowdin --- options/locale/locale_sk-SK.ini | 147 +++++++++++++++----------------- 1 file changed, 70 insertions(+), 77 deletions(-) diff --git a/options/locale/locale_sk-SK.ini b/options/locale/locale_sk-SK.ini index f714d34d54..1c3ca5ae43 100644 --- a/options/locale/locale_sk-SK.ini +++ b/options/locale/locale_sk-SK.ini @@ -76,7 +76,6 @@ forks=Forky activities=Aktivity pull_requests=Pull requesty -issues=Úkoly milestones=Míľniky ok=OK @@ -438,7 +437,6 @@ reset_password.text=Pre obnovenie vašeho účtu kliknite, prosím, na nasledovn register_success=Registrácia prebehla úspešne issue_assigned.pull=@%[1]s vám pridelil pull request %[2]s repozitári %[3]s. -issue_assigned.issue=@%[1]s vám pridelil úkol %[2]s v repozitári %[3]s. issue.x_mentioned_you=@%s vás zmienil: issue.action.force_push=%[1]s vynútil nahranie %[2]s z %[3]s do %[4]s. @@ -620,7 +618,6 @@ hidden_comment_types=Skryté typy komentárov comment_type_group_reference=Referencia comment_type_group_label=Štítok comment_type_group_milestone=Míľnik -comment_type_group_assignee=Príjemca comment_type_group_title=Názov comment_type_group_branch=Vetva comment_type_group_time_tracking=Sledovanie času @@ -630,7 +627,6 @@ comment_type_group_lock=Stav zámku comment_type_group_review_request=Žiadosť o revíziu comment_type_group_pull_request_push=Pridané commity comment_type_group_project=Projekt -comment_type_group_issue_ref=Referenčné číslo úkolu saved_successfully=Nastavenia úspešne uložené. privacy=Súkromie keep_activity_private_popup=Nastaviť aktivitu viditeľnú iba pre vás a administrátorov @@ -736,7 +732,7 @@ gpg_key_deletion_desc=Odstránením GPG kľúča zneplatníte overenie commitov, ssh_principal_deletion_desc=Odstránenie SSH certifikátu identity zruší jeho prístup k vašemu účtu. Pokračovať? ssh_key_deletion_success=SSH kľúč bol odstránený. gpg_key_deletion_success=GPG kľúč bol odstránený. -ssh_principal_deletion_success=Identita bola odstránená. +ssh_principal_deletion_success=Zabezpečenie bolo odstránené. valid_forever=Platný navždy last_used=Naposledy použité no_activity=Žiadna nedávna aktivita @@ -775,6 +771,7 @@ remove_oauth2_application_success=Aplikácia bola odstránená. create_oauth2_application=Vytvoriť novú aplikáciu OAuth2 create_oauth2_application_button=Vytvoriť aplikáciu oauth2_application_name=Názov aplikácie +oauth2_confidential_client=Dôverný klient. Vyberte aplikácie, ktoré uchovávajú tajomstvo v tajnosti, ako sú webové aplikácie. Nevyberajte pre natívne aplikácie vrátane aplikácií pre počítače a mobilné aplikácie. save_application=Uložiť oauth2_client_id=ID klienta oauth2_client_secret=Tajný klientsky kľúč @@ -805,6 +802,7 @@ passcode_invalid=Prístupový kód je nesprávny. Skúste to znova. twofa_enrolled=Váš účet bol zaregistrovaný do dvojfaktorovej autentifikácie. Uložte si token (%s) na bezpečnom mieste, pretože sa zobrazuje iba raz! twofa_failed_get_secret=Nepodarilo sa získať tajomstvo. +webauthn_desc=Bezpečnostné kľúče sú hardvérové ​​zariadenia obsahujúce kryptografické kľúče. Môžu byť použité na dvojfaktorovú autentifikáciu. Bezpečnostné kľúče musia podporovať štandard WebAuthn Authenticator. webauthn_register_key=Pridať bezpečnostný kľúč webauthn_nickname=Prezývka webauthn_delete_key=Odstrániť bezpečnostný kľúč @@ -812,12 +810,17 @@ webauthn_delete_key_desc=Ak odstránite bezpečnostný kľúč, už sa s ním ne manage_account_links=Spravovať prepojené kontá manage_account_links_desc=Tieto externé účty sú prepojené s vaším účtom Gitea. +account_links_not_available=V súčasnosti nie sú s vaším účtom Gitea prepojené žiadne externé účty. link_account=Pripojiť účet +remove_account_link=Odstrániť prepojený účet +remove_account_link_desc=Odstránenie prepojeného účtu zruší jeho prístup k vášmu účtu Gitea. Pokračovať? +remove_account_link_success=Prepojený účet bol odstránený. orgs_none=Nieste členom žiadnej organizácie. delete_account=Odstrániť môj účet +delete_prompt=Táto operácia natrvalo odstráni váš používateľský účet. NEDÁ SA vrátiť späť. confirm_delete_account=Potvrdiť odstránenie delete_account_title=Odstrániť používateľský účet delete_account_desc=Naozaj chcete natrvalo odstrániť tento účet? @@ -826,6 +829,7 @@ email_notifications.enable=Povoliť e-mailové upozornenia email_notifications.onmention=E-mail iba pri zmienke email_notifications.disable=Vypnúť e-mailové upozornenia email_notifications.submit=Nastaviť predvoľby e-mailu +email_notifications.andyourown=A vaše vlastné upozornenia visibility=Viditeľnosť používateľa visibility.public=Verejný @@ -846,22 +850,16 @@ visibility=Viditeľnosť visibility_description=Vidieť ho bude iba vlastník alebo členovia organizácie, ak majú práva. visibility_helper_forced=Váš správca vynucuje že nové repozitáre musia byť súkromné. visibility_fork_helper=(Zmena ovplyvní všetky forky.) -fork_repo=Forknúť repozitár -fork_from=Forknúť z -already_forked=Už ste forkli %s -fork_to_different_account=Fork na iný účet -fork_visibility_helper=Viditeľnosť forknutého repozitára nemožno zmeniť. -download_zip=Stiahnuť ZIP -download_tar=Stiahnuť TAR.GZ -download_bundle=Stiahnuť BUNDLE +clone_helper=Potrebujete pomoc s klonovaním? Navštívte Pomocníka. +use_template=Použiť túto šablónu +clone_in_vsc=Klonovať vo VS Code generate_repo=Generovať repozitár generate_from=Generovať z repo_desc=Popis +repo_desc_helper=Zadajte krátky popis (voliteľné) repo_lang=Jazyk repo_gitignore_helper=Vyberte .gitignore šablóny. repo_gitignore_helper_desc=Zo zoznamu šablón pre bežné jazyky vyberte, ktoré súbory sa nemajú sledovať. Typické artefakty generované nástrojmi na vytváranie jednotlivých jazykov sú štandardne zahrnuté v .gitignore. -issue_labels=Štítky úkolov -issue_labels_helper=Vyberte skupinu štítkov úkolov. license=Licencia license_helper=Vybrať súbor s licenciou. license_helper_desc=Licencia určuje, čo ostatní môžu a nemôžu robiť s vaším kódom. Nie ste si istí, ktorý z nich je vhodný pre váš projekt? Pozrite si výber licencie. @@ -875,13 +873,14 @@ trust_model_helper_committer=Prispievateľ: Dôverovať podpisom, ktoré zodpove trust_model_helper_collaborator_committer=Spolupracovník+Prispievateľ: Dôverovať podpisom spolupracovníkov, ktorí zodpovedajú prispievateľovi trust_model_helper_default=Predvolené: Pre túto inštaláciu použiť predvolený model dôvery create_repo=Vytvoriť repozitár -default_branch=Východzia vetva -default_branch_helper=Predvolená vetva je základná vetva pre pull requesty a commity. mirror_prune=Vyčistiť +mirror_prune_desc=Odstráňte zastarané referencie vzdialeného sledovania mirror_interval=Interval zrkadlenia (platné sú 'h', 'm', 's'). 0 na vypnutie periodickej synchronizácie. (Minimálny interval: %s) mirror_interval_invalid=Interval zrkadlenia nie je platný. mirror_sync_on_commit=Synchronizovať, keď sú odovzdané commity mirror_address=Klonovať z URL +mirror_lfs=Úložisko veľkých súborov (LFS) +mirror_lfs_desc=Aktivovať zrkadlenie dát LFS. mirror_lfs_endpoint=Koncový bod LFS mirror_lfs_endpoint_desc=Synchronizácia sa pokúsi použiť klonovaciu adresu URL na určenie servera LFS. Môžete tiež zadať vlastný koncový bod, ak sú dáta repozitára LFS uložené niekde inde. mirror_last_synced=Posledná synchronizácia @@ -917,42 +916,60 @@ desc.internal=Interný desc.archived=Archivovaný template.items=Položky šablóny +template.git_content=Obsah Gitu (predvolená vetva) template.git_hooks=Git hooky template.webhooks=Webhooky +template.topics=Témy template.avatar=Avatar -template.issue_labels=Štítky úkolov +template.one_item=Musíte vybrať aspoň jednu položku šablóny template.invalid=Vyberte šablónu repozitára -archive.issue.nocomment=Tento repozitár je archivovaný. Nemôžete komentovať úkoly. form.reach_limit_of_creation_1=Už ste dosiahli svoj limit pre %d repozitár. form.reach_limit_of_creation_n=Už ste dosiahli svoj limit pre %d repozitáre. +need_auth=Autorizácia +migrate_options=Možnosti migrácie +migrate_service=Migračná služba migrate_options_mirror_helper=Tento repozitár bude zrkadlom +migrate_options_lfs=Migrovať LFS súbory migrate_options_lfs_endpoint.label=Koncový bod LFS migrate_options_lfs_endpoint.description=Migrácia sa pokúsi použiť váš vzdialený Git na určenie servera LFS. Môžete tiež zadať vlastný koncový bod, ak sú dáta repozitára LFS uložené niekde inde. +migrate_options_lfs_endpoint.description.local=Podporovaná je aj cesta k lokálnemu serveru. +migrate_items=Položky migrácie +migrate_items_wiki=Wiki migrate_items_milestones=Míľniky -migrate_items_issues=Úkoly +migrate_items_labels=Štítky migrate_items_pullrequests=Pull requesty migrate_repo=Migrovať repozitár migrate.clone_address_desc=HTTP(S) alebo Git 'clone' URL pre klonovanie existujúceho repozitára migrate.github_token_desc=Sem môžete vložiť jeden alebo viac tokenov oddelených čiarkami, aby sa migrácia zrýchlila z dôvodu limitu rýchlosti rozhrania GitHub API. UPOZORNENIE: Zneužitie tejto funkcie môže porušiť zásady poskytovateľa služieb a viesť k zablokovaniu účtu. +migrate.clone_local_path=alebo cestu k lokálnemu serveru migrate.permission_denied=Nemáte povolené importovať miestne repozitáre. +migrate.invalid_lfs_endpoint=Koncový bod LFS nie je platný. +migrate.failed=Migrácia zlyhala: %v migrate.migrate_items_options=Na migráciu ďalších položiek je potrebný prístupový token +migrated_from=Migrované z %[2]s +migrated_from_fake=Migrované z %[1]s +migrate.migrate=Migrovať z %s +migrate.migrating_failed=Migrácia z %s zlyhala. migrate.migrating_failed_no_addr=Migrácia zlyhala. -migrate.git.description=Migrujte repozitár iba z akejkoľvek služby Git. -migrate.migrating_issues=Migrovanie úkolov +migrate.gitlab.description=Migrovať dáta z gitlab.com alebo iných inštancií GitLab. +migrate.gitea.description=Migrovať dáta z gitea.com alebo iných inštancií Gitea. +migrate.gogs.description=Migrovať dáta z notabug.org alebo iných inštancií Gogs. +migrate.onedev.description=Migrovať dáta z code.onedev.io alebo iných inštancií OneDev. +migrate.codebase.description=Migrovať dáta z codebasehq.com. +migrate.gitbucket.description=Migrovať dáta z inštancií GitBucket. -forked_from=forknuté z -fork_from_self=Repozitár, ktorý vlastníte, nemôžete forknúť. -fork_guest_user=Prihláste sa, aby ste forkli repozitár. +mirror_from=zrkadlo z +generated_from=generované z watch_guest_user=Pre sledovanie tohoto repozitára sa prihláste. unwatch=Už nesledovať watch=Sledovať unstar=Zrušiť hviezdičku star=Hviezdička -fork=Forknúť download_archive=Stiahnuť repozitár +more_operations=Viac operácií no_desc=Bez popisu quick_guide=Rýchly sprievodca @@ -971,13 +988,20 @@ filter_branch_and_tag=Filter vetvy alebo tagu find_tag=Hľadať tag branches=Vetvy tags=Tagy -issues=Úkoly pulls=Pull requesty project_board=Projekty +packages=Balíčky +actions=Akcie +labels=Štítky +org_labels_desc=Štítky na úrovni organizácie, ktoré možno použiť so všetkými repozitármi v rámci tejto organizácie +org_labels_desc_manage=spravovať milestones=Míľniky commits=Commitov -commit=Commit +release=Vydanie +releases=Vydania +file_history=História +file_view_source=Zobraziť zdrojový kód escape_control_characters=Ošetriť file_copy_permalink=Kopírovať trvalý odkaz @@ -987,10 +1011,17 @@ audio_not_supported_in_browser=Váš prehliadač nepodporuje HTML5 tag 'audio'. stored_lfs=Uložené pomocou Git LFS symbolic_link=Symbolický odkaz commit_graph=Graf commitov +line=riadok +lines=riadky +from_comment=(komentár) +editor.add_file=Pridať súbor +editor.new_file=Nový súbor +editor.upload_file=Nahrať súbor +editor.edit_file=Upraviť súbor editor.preview_changes=Náhľad zmien editor.edit_this_file=Upraviť súbor -editor.fork_before_edit=Musíte forknúť tento repozitár pre vytvorenie alebo navrhnutie zmeny tohoto súboru. +editor.this_file_locked=Súbor je uzamknutý editor.delete_this_file=Vymazať súbor editor.or=alebo editor.cancel_lower=Zrušiť @@ -1005,7 +1036,6 @@ editor.no_commit_to_branch=Nedá sa odoslať priamo do vetvy, pretože: editor.require_signed_commit=Vetva vyžaduje podpísaný commit commits.commits=Commity -commits.search=Hľadanie commitov… commits.find=Hľadať commits.search_all=Všetky vetvy commits.author=Autor @@ -1028,8 +1058,6 @@ commit.cherry-pick-content=Vyberte vetvu pre cherry-pick na: commitstatus.error=Chyba -ext_issues=Prístup k externým úkolom -ext_issues.desc=Odkaz na externé sledovanie úkolov. projects=Projekty projects.title=Názov @@ -1039,41 +1067,30 @@ projects.edit=Upraviť projekty projects.modify=Aktualizovať projekt projects.type.none=Žiadny projects.template.desc=Šablóna +projects.column.edit_title=Meno +projects.column.new_title=Meno projects.column.new=Nový stĺpec +projects.column.set_default=Nastaviť ako predvolené +projects.column.color=Farba projects.open=Otvoriť projects.close=Zavrieť issues.filter_reviewers=Filtrovať revidentov -issues.new=Nový úkol +issues.new.labels=Štítky issues.new.projects=Projekty issues.new.milestone=Míľnik issues.new.no_reviewers=Žiadni revidenti issues.choose.open_external_link=Otvoriť -issues.choose.blank_about=Vytvoriť úkol z predvolenej šablóny. issues.create=Vytvoriť úkol issues.filter_label=Štítok issues.filter_milestone=Míľnik issues.filter_project=Projekt -issues.filter_assignee=Príjemca -issues.filter_type.all_issues=Všetky úkoly issues.filter_type.review_requested=Požiadané o revíziu -issues.filter_sort.mostforks=Najviac forkov -issues.filter_sort.fewestforks=Najmenej forkov issues.action_open=Otvoriť issues.action_close=Zavrieť issues.action_label=Štítok issues.action_milestone=Míľnik -issues.action_assignee=Príjemca issues.open_title=Otvoriť -issues.context.reference_issue=Odkázať v novom úkole -issues.closed_at=`uzavrel/a tento úkol %[2]s` -issues.reopened_at=`znovuotvoril/a tento úkol %[2]s` -issues.commit_ref_at=`odkázal na tento úkol z commitu %[2]s` -issues.ref_issue_from=`odkazoval/a na tento úkol %[4]s %[2]s` -issues.ref_closing_from=`odkazoval/a na pull request %[4]s, ktorý uzavrie tento úkol %[2]s` -issues.ref_reopening_from=`odkazoval/a na pull request %[4]s, ktorý znovu otvorí tento úkol %[2]s` -issues.ref_closed_from=`uzavrel/a tento úkol %[4]s %[2]s` -issues.ref_reopened_from=`znovu otvoril/a tento úkol %[4]s %[2]s` issues.role.owner=Vlastník issues.re_request_review=Znovu požiadať o revíziu issues.is_stale=Od tejto kontroly došlo k zmenám v tomto pull requeste @@ -1083,32 +1100,9 @@ issues.dismiss_review=Zamietnuť revíziu issues.dismiss_review_warning=Naozaj chcete zrušiť túto revíziu? issues.cancel=Zrušiť issues.save=Uložiť -issues.label_open_issues=%d otvorených úkolov -issues.label_deletion_desc=Odstránenie štítka ho odstráni zo všetkých úkolov. Ďalej? -issues.lock.unknown_reason=Nie je možné uzamknúť úkol bez dôvodu. -issues.lock_duplicate=Úkol nie je možné uzamknúť dvakrát. -issues.unlock_error=Nie je možné odomknúť úkol, ktorý nie je uzamknutý. -issues.lock.notice_1=- Ostatní používatelia nemôžu komentovať tento úkol. -issues.lock.notice_3=- Tento úkol môžete v budúcnosti kedykoľvek znova odomknúť. -issues.unlock.notice_1=- Všetci budú môcť znovu komentovať tento úkol. -issues.unlock.notice_2=- Tento úkol môžete v budúcnosti kedykoľvek znova zamknúť. -issues.lock.title=Uzamknúť konverzáciu o tomto úkole. -issues.unlock.title=Odomknúť konverzáciu o tomto úkole. -issues.comment_on_locked=Nemôžete komentovať zamknutý úkol. -issues.delete.title=Vymazať tento úkol? -issues.delete.text=Naozaj chcete odstrániť tento úkol? (Týmto natrvalo odstránite všetok obsah. Ak ho chcete ponechať archivovaný, zvážte radšej jeho zatvorenie.) -issues.tracker_auto_close=Po vyriešení tohto úkolu sa časovač automaticky zastaví -issues.tracking_already_started=`Už ste spustili sledovanie času v inom úkole!` issues.cancel_tracking=Zahodiť issues.add_time_cancel=Zrušiť -issues.push_commit_1=pridal/a %d commit %s -issues.push_commits_n=pridal/a %d commity %s issues.dependency.cancel=Zrušiť -issues.dependency.pr_closing_blockedby=Zatvorenie tohto pull requestu je blokované nasledujúcimi úkolmi -issues.dependency.issue_closing_blockedby=Zatvorenie tohto úkolu je blokované nasledujúcimi úkolmi -issues.dependency.issue_close_blocks=Tento úkol blokuje uzavretie nasledujúcich úkolov -issues.dependency.pr_close_blocks=Tento pull request blokuje uzavretie nasledujúcich úkolov -issues.dependency.issue_close_blocked=Pred zatvorením tohto úkolu musíte zatvoriť všetky úkoly, ktoré blokujú tento úkol. issues.review.comment=revidoval %s issues.review.dismissed=zamietol revíziu od %s %s issues.review.wait=bol požiadaný o revidovanie %s @@ -1119,7 +1113,6 @@ issues.review.review=Revízia issues.review.reviewers=Revidenti -pulls.desc=Povoliť pull requesty a revízie kódu. pulls.tab_commits=Commity pulls.data_broken=Tento pull request je nefunkčný z dôvodu chýbajúcich informácií o forku. pulls.waiting_count_1=%d čakajúca revízia @@ -1143,10 +1136,10 @@ milestones.cancel=Zrušiť +wiki=Wiki wiki.page=Stránka wiki.new_page=Stránka -activity.new_issues_count_1=Nový úkol activity.unresolved_conv_label=Otvoriť activity.git_stats_commit_1=%d commit activity.git_stats_commit_n=%d commity @@ -1165,7 +1158,6 @@ settings.hooks=Webhooky settings.githooks=Git hooky settings.mirror_settings.mirrored_repository=Zrkadlený repozitár -settings.admin_enable_close_issues_via_commit_in_any_branch=Zavrieť úkol pomocou commitu v inej ako východzej vetve settings.new_owner_has_same_repo=Nový vlastník už repozitár s rovnakým názvom má. Vyberte, prosím, iné meno. settings.convert_fork=Konvertovať na bežný repozitár settings.convert_fork_desc=Tento fork môžete previesť na bežný repozitár. To nie je možné vrátiť späť. @@ -1190,7 +1182,6 @@ settings.wiki_delete_notices_1=- Natrvalo odstráni a zakáže wiki pre %s. settings.wiki_deletion_success=Údaje wiki boli vymazané. settings.delete=Odstrániť tento repozitár settings.delete_desc=Odstránenie repozitára je trvalé a nemožno ho vrátiť späť. -settings.delete_notices_2=- Táto operácia natrvalo odstráni repozitár %s vrátane kódu, úkolov, komentárov, wiki a nastavení spolupracovníkov. settings.delete_notices_fork_1=- Forky tohto repozitára sa po vymazaní stanú nezávislými. settings.deletion_success=Repozitár bol vymazaný. settings.update_settings_success=Nastavenia repozitára boli aktualizované. @@ -1215,6 +1206,8 @@ settings.add_webhook_desc=Gitea odošle požiadavky POST so špecif settings.event_header_repository=Udalosti repozitára settings.event_fork=Fork settings.event_fork_desc=Repozitár forknutý +settings.event_wiki=Wiki +settings.event_release=Vydanie settings.event_repository=Repozitár settings.event_repository_desc=Repozitár vytvorený alebo odstránený. settings.event_pull_request_review=Pull request bol revidovaný @@ -1355,6 +1348,7 @@ error.not_signed_commit=Nie je podpísaný commit [packages] alpine.repository.repositories=Repozitáre conan.details.repository=Repozitár +container.labels=Štítky owner.settings.cleanuprules.enabled=Povolené [secrets] @@ -1363,9 +1357,8 @@ owner.settings.cleanuprules.enabled=Povolené -runners.task_list.commit=Commit +runners.labels=Štítky -runs.commit=Commit From c46316f7aec1a00b3db74a3565008c44c0b0807f Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Thu, 25 Jan 2024 09:54:44 +0100 Subject: [PATCH 55/76] Respect branch info for relative links (#28909) Fix #28904 Co-authored-by: Giteabot --- modules/markup/markdown/goldmark.go | 2 ++ modules/markup/markdown/markdown_test.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/markup/markdown/goldmark.go b/modules/markup/markdown/goldmark.go index b92b90561b..1db3cbad7e 100644 --- a/modules/markup/markdown/goldmark.go +++ b/modules/markup/markdown/goldmark.go @@ -137,6 +137,8 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa var base string if ctx.IsWiki { base = ctx.Links.WikiLink() + } else if ctx.Links.HasBranchInfo() { + base = ctx.Links.SrcLink() } else { base = ctx.Links.Base } diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 957d773acd..1edfb3e664 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -765,7 +765,7 @@ space

Expected: `

space @mention-user
/just/a/path.bin
https://example.com/file.bin
-local link
+local link
remote link
local link
remote link
@@ -878,7 +878,7 @@ space

Expected: `

space @mention-user
/just/a/path.bin
https://example.com/file.bin
-local link
+local link
remote link
local link
remote link
From 071b7b2a0308d3b65f2deafc0a004a340e6ead86 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Thu, 25 Jan 2024 20:06:29 +0800 Subject: [PATCH 56/76] Implement `MigrateRepository` for the actions notifier (#28920) Fixes #28699 This PR implements the `MigrateRepository` method for `actionsNotifier` to detect the schedules from the workflow files in the migrated repository. --- services/actions/notifier.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/actions/notifier.go b/services/actions/notifier.go index 5a71d1cd79..0b4fed5db1 100644 --- a/services/actions/notifier.go +++ b/services/actions/notifier.go @@ -565,3 +565,15 @@ func (n *actionsNotifier) DeleteWikiPage(ctx context.Context, doer *user_model.U Page: page, }).Notify(ctx) } + +// MigrateRepository is used to detect workflows after a repository has been migrated +func (n *actionsNotifier) MigrateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) { + ctx = withMethod(ctx, "MigrateRepository") + + newNotifyInput(repo, doer, webhook_module.HookEventRepository).WithPayload(&api.RepositoryPayload{ + Action: api.HookRepoCreated, + Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm_model.AccessModeOwner}), + Organization: convert.ToUser(ctx, u, nil), + Sender: convert.ToUser(ctx, doer, nil), + }).Notify(ctx) +} From 3084c990b04aea16278f012da38152ada1290a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Qu=C3=A9r=C3=A9?= <47711333+Anthony-Jhoiro@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:51:32 +0100 Subject: [PATCH 57/76] fix: update enable_prune even if mirror_interval is not provided (#28905) Currently, the `updateMirror` function which update the mirror interval and enable prune properties is only executed by the `Edit` function. But it is only triggered if `opts.MirrorInterval` is not null, even if `opts.EnablePrune` is not null. With this patch, it is now possible to update the enable_prune property with a patch request without modifying the mirror_interval. ## Example request with httpie ### Currently: **Does nothing** ```bash http PATCH https://gitea.your-server/api/v1/repos/myOrg/myRepo "enable_prune:=false" -A bearer -a $gitea_token ``` **Updates both properties** ```bash http PATCH https://gitea.your-server/api/v1/repos/myOrg/myRepo "enable_prune:=false" "mirror_interval=10m" -A bearer -a $gitea_token ``` ### With the patch **Updates enable_prune only** ```bash http PATCH https://gitea.your-server/api/v1/repos/myOrg/myRepo "enable_prune:=false" -A bearer -a $gitea_token ``` --- routers/api/v1/repo/repo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 9810e461de..436b83adf2 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -637,7 +637,7 @@ func Edit(ctx *context.APIContext) { } } - if opts.MirrorInterval != nil { + if opts.MirrorInterval != nil || opts.EnablePrune != nil { if err := updateMirror(ctx, opts); err != nil { return } From 76bbad4e746af977fea66c719d38048869de36c4 Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Thu, 25 Jan 2024 12:04:50 -0600 Subject: [PATCH 58/76] Check for sha256 support to use --object-format flag (#28928) This should fix https://github.com/go-gitea/gitea/issues/28927 Technically older versions of Git would support this flag as well, but per https://github.com/go-gitea/gitea/pull/28466 that's the version where using it (object-format=sha256) left "experimental" state. `sha1` is (currently) the default, so older clients should be unaffected in either case. Signed-off-by: jolheiser --- modules/git/repo.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/git/repo.go b/modules/git/repo.go index c3de2eb0ad..db99d285a8 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -101,7 +101,9 @@ func InitRepository(ctx context.Context, repoPath string, bare bool, objectForma if !IsValidObjectFormat(objectFormatName) { return fmt.Errorf("invalid object format: %s", objectFormatName) } - cmd.AddOptionValues("--object-format", objectFormatName) + if SupportHashSha256 { + cmd.AddOptionValues("--object-format", objectFormatName) + } if bare { cmd.AddArguments("--bare") From ba24e0ba61b1b66f58c8448f27272d1d6d14f60c Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Thu, 25 Jan 2024 22:40:24 +0100 Subject: [PATCH 59/76] Use new RPM constants (#28931) https://github.com/sassoftware/go-rpmutils/pull/24 got merged. --- go.mod | 2 +- go.sum | 4 ++-- modules/packages/rpm/metadata.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 3268b81e66..7a752ec874 100644 --- a/go.mod +++ b/go.mod @@ -92,7 +92,7 @@ require ( github.com/redis/go-redis/v9 v9.4.0 github.com/robfig/cron/v3 v3.0.1 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 - github.com/sassoftware/go-rpmutils v0.2.0 + github.com/sassoftware/go-rpmutils v0.2.1-0.20240124161140-277b154961dd github.com/sergi/go-diff v1.3.1 github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index f13026c6bb..b3b8ad8ce4 100644 --- a/go.sum +++ b/go.sum @@ -781,8 +781,8 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= -github.com/sassoftware/go-rpmutils v0.2.0 h1:pKW0HDYMFWQ5b4JQPiI3WI12hGsVoW0V8+GMoZiI/JE= -github.com/sassoftware/go-rpmutils v0.2.0/go.mod h1:TJJQYtLe/BeEmEjelI3b7xNZjzAukEkeWKmoakvaOoI= +github.com/sassoftware/go-rpmutils v0.2.1-0.20240124161140-277b154961dd h1:KpbqRPDwcAQTyaP+L+YudTRb3CnJlQ64Hfn1SF/zHBA= +github.com/sassoftware/go-rpmutils v0.2.1-0.20240124161140-277b154961dd/go.mod h1:TJJQYtLe/BeEmEjelI3b7xNZjzAukEkeWKmoakvaOoI= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs= diff --git a/modules/packages/rpm/metadata.go b/modules/packages/rpm/metadata.go index 7fc47a53e6..f4f78c2cab 100644 --- a/modules/packages/rpm/metadata.go +++ b/modules/packages/rpm/metadata.go @@ -140,7 +140,7 @@ func ParsePackage(r io.Reader) (*Package, error) { Provides: getEntries(rpm.Header, rpmutils.PROVIDENAME, rpmutils.PROVIDEVERSION, rpmutils.PROVIDEFLAGS), Requires: getEntries(rpm.Header, rpmutils.REQUIRENAME, rpmutils.REQUIREVERSION, rpmutils.REQUIREFLAGS), - Conflicts: getEntries(rpm.Header, 1054 /*rpmutils.CONFLICTNAME*/, 1055 /*rpmutils.CONFLICTVERSION*/, 1053 /*rpmutils.CONFLICTFLAGS*/), // https://github.com/sassoftware/go-rpmutils/pull/24 + Conflicts: getEntries(rpm.Header, rpmutils.CONFLICTNAME, rpmutils.CONFLICTVERSION, rpmutils.CONFLICTFLAGS), Obsoletes: getEntries(rpm.Header, rpmutils.OBSOLETENAME, rpmutils.OBSOLETEVERSION, rpmutils.OBSOLETEFLAGS), Files: getFiles(rpm.Header), Changelogs: getChangelogs(rpm.Header), From 534917d57670d82703567131e2b33fd945e6f8cb Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 26 Jan 2024 14:18:19 +0800 Subject: [PATCH 60/76] Don't remove all mirror repository's releases when mirroring (#28817) Fix #22066 # Purpose This PR fix the releases will be deleted when mirror repository sync the tags. # The problem In the previous implementation of #19125. All releases record in databases of one mirror repository will be deleted before sync. Ref: https://github.com/go-gitea/gitea/pull/19125/files#diff-2aa04998a791c30e5a02b49a97c07fcd93d50e8b31640ce2ddb1afeebf605d02R481 # The Pros This PR introduced a new method which will load all releases from databases and all tags on git data into memory. And detect which tags needs to be inserted, which tags need to be updated or deleted. Only tags releases(IsTag=true) which are not included in git data will be deleted, only tags which sha1 changed will be updated. So it will not delete any real releases include drafts. # The Cons The drawback is the memory usage will be higher than before if there are many tags on this repository. This PR defined a special release struct to reduce columns loaded from database to memory. --- modules/repository/repo.go | 76 ++++++++++++++++++++++++++++++--- modules/repository/repo_test.go | 76 +++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 modules/repository/repo_test.go diff --git a/modules/repository/repo.go b/modules/repository/repo.go index 5af69763d1..5352da0378 100644 --- a/modules/repository/repo.go +++ b/modules/repository/repo.go @@ -508,6 +508,18 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re return nil } +// shortRelease to reduce load memory, this struct can replace repo_model.Release +type shortRelease struct { + ID int64 + TagName string + Sha1 string + IsTag bool +} + +func (shortRelease) TableName() string { + return "release" +} + // pullMirrorReleaseSync is a pull-mirror specific tag<->release table // synchronization which overwrites all Releases from the repository tags. This // can be relied on since a pull-mirror is always identical to its @@ -521,16 +533,20 @@ func pullMirrorReleaseSync(ctx context.Context, repo *repo_model.Repository, git return fmt.Errorf("unable to GetTagInfos in pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err) } err = db.WithTx(ctx, func(ctx context.Context) error { - // - // clear out existing releases - // - if _, err := db.DeleteByBean(ctx, &repo_model.Release{RepoID: repo.ID}); err != nil { - return fmt.Errorf("unable to clear releases for pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err) + dbReleases, err := db.Find[shortRelease](ctx, repo_model.FindReleasesOptions{ + RepoID: repo.ID, + IncludeDrafts: true, + IncludeTags: true, + }) + if err != nil { + return fmt.Errorf("unable to FindReleases in pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err) } + + inserts, deletes, updates := calcSync(tags, dbReleases) // // make release set identical to upstream tags // - for _, tag := range tags { + for _, tag := range inserts { release := repo_model.Release{ RepoID: repo.ID, TagName: tag.Name, @@ -547,6 +563,25 @@ func pullMirrorReleaseSync(ctx context.Context, repo *repo_model.Repository, git return fmt.Errorf("unable insert tag %s for pull-mirror Repo[%d:%s/%s]: %w", tag.Name, repo.ID, repo.OwnerName, repo.Name, err) } } + + // only delete tags releases + if len(deletes) > 0 { + if _, err := db.GetEngine(ctx).Where("repo_id=?", repo.ID). + In("id", deletes). + Delete(&repo_model.Release{}); err != nil { + return fmt.Errorf("unable to delete tags for pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err) + } + } + + for _, tag := range updates { + if _, err := db.GetEngine(ctx).Where("repo_id = ? AND lower_tag_name = ?", repo.ID, strings.ToLower(tag.Name)). + Cols("sha1"). + Update(&repo_model.Release{ + Sha1: tag.Object.String(), + }); err != nil { + return fmt.Errorf("unable to update tag %s for pull-mirror Repo[%d:%s/%s]: %w", tag.Name, repo.ID, repo.OwnerName, repo.Name, err) + } + } return nil }) if err != nil { @@ -556,3 +591,32 @@ func pullMirrorReleaseSync(ctx context.Context, repo *repo_model.Repository, git log.Trace("pullMirrorReleaseSync: done rebuilding %d releases", numTags) return nil } + +func calcSync(destTags []*git.Tag, dbTags []*shortRelease) ([]*git.Tag, []int64, []*git.Tag) { + destTagMap := make(map[string]*git.Tag) + for _, tag := range destTags { + destTagMap[tag.Name] = tag + } + dbTagMap := make(map[string]*shortRelease) + for _, rel := range dbTags { + dbTagMap[rel.TagName] = rel + } + + inserted := make([]*git.Tag, 0, 10) + updated := make([]*git.Tag, 0, 10) + for _, tag := range destTags { + rel := dbTagMap[tag.Name] + if rel == nil { + inserted = append(inserted, tag) + } else if rel.Sha1 != tag.Object.String() { + updated = append(updated, tag) + } + } + deleted := make([]int64, 0, 10) + for _, tag := range dbTags { + if destTagMap[tag.TagName] == nil && tag.IsTag { + deleted = append(deleted, tag.ID) + } + } + return inserted, deleted, updated +} diff --git a/modules/repository/repo_test.go b/modules/repository/repo_test.go new file mode 100644 index 0000000000..68980f92f9 --- /dev/null +++ b/modules/repository/repo_test.go @@ -0,0 +1,76 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package repository + +import ( + "testing" + + "code.gitea.io/gitea/modules/git" + + "github.com/stretchr/testify/assert" +) + +func Test_calcSync(t *testing.T) { + gitTags := []*git.Tag{ + /*{ + Name: "v0.1.0-beta", //deleted tag + Object: git.MustIDFromString(""), + }, + { + Name: "v0.1.1-beta", //deleted tag but release should not be deleted because it's a release + Object: git.MustIDFromString(""), + }, + */ + { + Name: "v1.0.0", // keep as before + Object: git.MustIDFromString("1006e6e13c73ad3d9e2d5682ad266b5016523485"), + }, + { + Name: "v1.1.0", // retagged with new commit id + Object: git.MustIDFromString("bbdb7df30248e7d4a26a909c8d2598a152e13868"), + }, + { + Name: "v1.2.0", // new tag + Object: git.MustIDFromString("a5147145e2f24d89fd6d2a87826384cc1d253267"), + }, + } + + dbReleases := []*shortRelease{ + { + ID: 1, + TagName: "v0.1.0-beta", + Sha1: "244758d7da8dd1d9e0727e8cb7704ed4ba9a17c3", + IsTag: true, + }, + { + ID: 2, + TagName: "v0.1.1-beta", + Sha1: "244758d7da8dd1d9e0727e8cb7704ed4ba9a17c3", + IsTag: false, + }, + { + ID: 3, + TagName: "v1.0.0", + Sha1: "1006e6e13c73ad3d9e2d5682ad266b5016523485", + }, + { + ID: 4, + TagName: "v1.1.0", + Sha1: "53ab18dcecf4152b58328d1f47429510eb414d50", + }, + } + + inserts, deletes, updates := calcSync(gitTags, dbReleases) + if assert.EqualValues(t, 1, len(inserts), "inserts") { + assert.EqualValues(t, *gitTags[2], *inserts[0], "inserts equal") + } + + if assert.EqualValues(t, 1, len(deletes), "deletes") { + assert.EqualValues(t, 1, deletes[0], "deletes equal") + } + + if assert.EqualValues(t, 1, len(updates), "updates") { + assert.EqualValues(t, *gitTags[1], *updates[0], "updates equal") + } +} From a240d5dfa7e261f2fb703cf24b1ba4dc6aa47bfd Mon Sep 17 00:00:00 2001 From: wackbyte Date: Fri, 26 Jan 2024 09:15:57 -0500 Subject: [PATCH 61/76] Fix non-alphabetic sorting of repo topics (#28938) --- models/repo/topic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/repo/topic.go b/models/repo/topic.go index b71f43bc88..79b13e320d 100644 --- a/models/repo/topic.go +++ b/models/repo/topic.go @@ -366,7 +366,7 @@ func syncTopicsInRepository(sess db.Engine, repoID int64) error { topicNames := make([]string, 0, 25) if err := sess.Table("topic").Cols("name"). Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id"). - Where("repo_topic.repo_id = ?", repoID).Desc("topic.repo_count").Find(&topicNames); err != nil { + Where("repo_topic.repo_id = ?", repoID).Asc("topic.name").Find(&topicNames); err != nil { return err } From 01acd1eea38f25d2b21f56ec15dd162ca6005fbf Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 27 Jan 2024 04:36:01 +0100 Subject: [PATCH 62/76] Strip `/` from relative links (#28932) Fixes #28915 Restores the old behaviour: https://github.com/go-gitea/gitea/pull/26745/files#diff-d78a9d361b1fddc12218e4dd42f42d39d6be1fda184041e06bb6fb30f0d94c59L96 --- modules/markup/markdown/goldmark.go | 10 +++++---- modules/markup/markdown/markdown_test.go | 26 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/modules/markup/markdown/goldmark.go b/modules/markup/markdown/goldmark.go index 1db3cbad7e..3dc5530e00 100644 --- a/modules/markup/markdown/goldmark.go +++ b/modules/markup/markdown/goldmark.go @@ -85,9 +85,11 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa // 2. If they're not wrapped with a link they need a link wrapper // Check if the destination is a real link - link := v.Destination - if len(link) > 0 && !markup.IsLink(link) { - v.Destination = []byte(giteautil.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsWiki), string(link))) + if len(v.Destination) > 0 && !markup.IsLink(v.Destination) { + v.Destination = []byte(giteautil.URLJoin( + ctx.Links.ResolveMediaLink(ctx.IsWiki), + strings.TrimLeft(string(v.Destination), "/"), + )) } parent := n.Parent() @@ -103,7 +105,7 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa // Duplicate the current image node image := ast.NewImage(ast.NewLink()) - image.Destination = link + image.Destination = v.Destination image.Title = v.Title for _, attr := range v.Attributes() { image.SetAttribute(attr.Name, attr.Value) diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index 1edfb3e664..bdf4011fa2 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -580,6 +580,8 @@ https://example.com/file.bin [[local link|file.bin]] [[remote link|https://example.com]] ![local image](image.jpg) +![local image](path/file) +![local image](/path/file) ![remote image](https://example.com/image.jpg) [[local image|image.jpg]] [[remote link|https://example.com/image.jpg]] @@ -609,6 +611,8 @@ mail@domain.com local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -634,6 +638,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -661,6 +667,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -688,6 +696,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -715,6 +725,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -742,6 +754,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -770,6 +784,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -798,6 +814,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -826,6 +844,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -854,6 +874,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -883,6 +905,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
@@ -912,6 +936,8 @@ space

local link
remote link
local image
+local image
+local image
remote image
local image
remote link
From fc1bae00a4cc07d832eb9405ec8fd8f4e52c0197 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 27 Jan 2024 10:27:34 +0100 Subject: [PATCH 63/76] Fix SSPI user creation (#28948) Fixes #28945 Setting the avatar is wrong and creating a random password is equal to leave it empty. --- services/auth/sspi.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/services/auth/sspi.go b/services/auth/sspi.go index 57ba0462c5..0e974fde8f 100644 --- a/services/auth/sspi.go +++ b/services/auth/sspi.go @@ -11,7 +11,6 @@ import ( "sync" "code.gitea.io/gitea/models/auth" - "code.gitea.io/gitea/models/avatars" "code.gitea.io/gitea/models/db" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/base" @@ -167,12 +166,9 @@ func (s *SSPI) shouldAuthenticate(req *http.Request) (shouldAuth bool) { func (s *SSPI) newUser(ctx context.Context, username string, cfg *sspi.Source) (*user_model.User, error) { email := gouuid.New().String() + "@localhost.localdomain" user := &user_model.User{ - Name: username, - Email: email, - Passwd: gouuid.New().String(), - Language: cfg.DefaultLanguage, - UseCustomAvatar: true, - Avatar: avatars.DefaultAvatarLink(), + Name: username, + Email: email, + Language: cfg.DefaultLanguage, } emailNotificationPreference := user_model.EmailNotificationsDisabled overwriteDefault := &user_model.CreateUserOverwriteOptions{ From 0e650dca3076bbf8e1a4d1a80cef3275a51af658 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sat, 27 Jan 2024 14:27:37 +0200 Subject: [PATCH 64/76] Make loading animation less aggressive (#28955) The current animation loops in a very fast manner, causing a slight feeling of uncomfortableness. This change slows it a bit for a smoother experience. # Before ![before](https://github.com/go-gitea/gitea/assets/20454870/215a722d-feb4-4643-819d-c37a620c5e48) # After ![after](https://github.com/go-gitea/gitea/assets/20454870/7acb1fab-9157-4f4d-8cc7-45fea0234b47) Signed-off-by: Yarden Shoham --- web_src/css/modules/animations.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/css/modules/animations.css b/web_src/css/modules/animations.css index cac824d87d..87eb6a75cf 100644 --- a/web_src/css/modules/animations.css +++ b/web_src/css/modules/animations.css @@ -22,7 +22,7 @@ height: min(4em, 66.6%); aspect-ratio: 1; transform: translate(-50%, -50%); - animation: isloadingspin 500ms infinite linear; + animation: isloadingspin 1000ms infinite linear; border-width: 4px; border-style: solid; border-color: var(--color-secondary) var(--color-secondary) var(--color-secondary-dark-8) var(--color-secondary-dark-8); From 60e4a98ab07dcf3bd86cf630c79e6433c3ef3e84 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 27 Jan 2024 19:02:51 +0100 Subject: [PATCH 65/76] Preserve BOM in web editor (#28935) The `ToUTF8*` functions were stripping BOM, while BOM is actually valid in UTF8, so the stripping must be optional depending on use case. This does: - Add a options struct to all `ToUTF8*` functions, that by default will strip BOM to preserve existing behaviour - Remove `ToUTF8` function, it was dead code - Rename `ToUTF8WithErr` to `ToUTF8` - Preserve BOM in Monaco Editor - Remove a unnecessary newline in the textarea value. Browsers did ignore it, it seems but it's better not to rely on this behaviour. Fixes: https://github.com/go-gitea/gitea/issues/28743 Related: https://github.com/go-gitea/gitea/issues/6716 which seems to have once introduced a mechanism that strips and re-adds the BOM, but from what I can tell, this mechanism was removed at some point after that PR. --- modules/charset/charset.go | 43 +++--- modules/charset/charset_test.go | 133 +++++------------- modules/indexer/code/bleve/bleve.go | 2 +- .../code/elasticsearch/elasticsearch.go | 2 +- routers/web/repo/commit.go | 2 +- routers/web/repo/compare.go | 2 +- routers/web/repo/editor.go | 4 +- routers/web/repo/render.go | 2 +- routers/web/repo/setting/lfs.go | 2 +- routers/web/repo/view.go | 4 +- templates/repo/editor/edit.tmpl | 3 +- .../migration-test/migration_test.go | 2 +- web_src/js/features/codeeditor.js | 2 +- 13 files changed, 69 insertions(+), 134 deletions(-) diff --git a/modules/charset/charset.go b/modules/charset/charset.go index 51152142a5..1855446a98 100644 --- a/modules/charset/charset.go +++ b/modules/charset/charset.go @@ -22,17 +22,21 @@ import ( // UTF8BOM is the utf-8 byte-order marker var UTF8BOM = []byte{'\xef', '\xbb', '\xbf'} +type ConvertOpts struct { + KeepBOM bool +} + // ToUTF8WithFallbackReader detects the encoding of content and converts to UTF-8 reader if possible -func ToUTF8WithFallbackReader(rd io.Reader) io.Reader { +func ToUTF8WithFallbackReader(rd io.Reader, opts ConvertOpts) io.Reader { buf := make([]byte, 2048) n, err := util.ReadAtMost(rd, buf) if err != nil { - return io.MultiReader(bytes.NewReader(RemoveBOMIfPresent(buf[:n])), rd) + return io.MultiReader(bytes.NewReader(MaybeRemoveBOM(buf[:n], opts)), rd) } charsetLabel, err := DetectEncoding(buf[:n]) if err != nil || charsetLabel == "UTF-8" { - return io.MultiReader(bytes.NewReader(RemoveBOMIfPresent(buf[:n])), rd) + return io.MultiReader(bytes.NewReader(MaybeRemoveBOM(buf[:n], opts)), rd) } encoding, _ := charset.Lookup(charsetLabel) @@ -42,20 +46,20 @@ func ToUTF8WithFallbackReader(rd io.Reader) io.Reader { return transform.NewReader( io.MultiReader( - bytes.NewReader(RemoveBOMIfPresent(buf[:n])), + bytes.NewReader(MaybeRemoveBOM(buf[:n], opts)), rd, ), encoding.NewDecoder(), ) } -// ToUTF8WithErr converts content to UTF8 encoding -func ToUTF8WithErr(content []byte) (string, error) { +// ToUTF8 converts content to UTF8 encoding +func ToUTF8(content []byte, opts ConvertOpts) (string, error) { charsetLabel, err := DetectEncoding(content) if err != nil { return "", err } else if charsetLabel == "UTF-8" { - return string(RemoveBOMIfPresent(content)), nil + return string(MaybeRemoveBOM(content, opts)), nil } encoding, _ := charset.Lookup(charsetLabel) @@ -70,28 +74,22 @@ func ToUTF8WithErr(content []byte) (string, error) { result = append(result, content[n:]...) } - result = RemoveBOMIfPresent(result) + result = MaybeRemoveBOM(result, opts) return string(result), err } // ToUTF8WithFallback detects the encoding of content and converts to UTF-8 if possible -func ToUTF8WithFallback(content []byte) []byte { - bs, _ := io.ReadAll(ToUTF8WithFallbackReader(bytes.NewReader(content))) +func ToUTF8WithFallback(content []byte, opts ConvertOpts) []byte { + bs, _ := io.ReadAll(ToUTF8WithFallbackReader(bytes.NewReader(content), opts)) return bs } -// ToUTF8 converts content to UTF8 encoding and ignore error -func ToUTF8(content string) string { - res, _ := ToUTF8WithErr([]byte(content)) - return res -} - // ToUTF8DropErrors makes sure the return string is valid utf-8; attempts conversion if possible -func ToUTF8DropErrors(content []byte) []byte { +func ToUTF8DropErrors(content []byte, opts ConvertOpts) []byte { charsetLabel, err := DetectEncoding(content) if err != nil || charsetLabel == "UTF-8" { - return RemoveBOMIfPresent(content) + return MaybeRemoveBOM(content, opts) } encoding, _ := charset.Lookup(charsetLabel) @@ -117,11 +115,14 @@ func ToUTF8DropErrors(content []byte) []byte { } } - return RemoveBOMIfPresent(decoded) + return MaybeRemoveBOM(decoded, opts) } -// RemoveBOMIfPresent removes a UTF-8 BOM from a []byte -func RemoveBOMIfPresent(content []byte) []byte { +// MaybeRemoveBOM removes a UTF-8 BOM from a []byte when opts.KeepBOM is false +func MaybeRemoveBOM(content []byte, opts ConvertOpts) []byte { + if opts.KeepBOM { + return content + } if len(content) > 2 && bytes.Equal(content[0:3], UTF8BOM) { return content[3:] } diff --git a/modules/charset/charset_test.go b/modules/charset/charset_test.go index fc56799b47..829844a976 100644 --- a/modules/charset/charset_test.go +++ b/modules/charset/charset_test.go @@ -30,15 +30,15 @@ func resetDefaultCharsetsOrder() { } } -func TestRemoveBOMIfPresent(t *testing.T) { - res := RemoveBOMIfPresent([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}) +func TestMaybeRemoveBOM(t *testing.T) { + res := MaybeRemoveBOM([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, ConvertOpts{}) assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, res) - res = RemoveBOMIfPresent([]byte{0xef, 0xbb, 0xbf, 0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}) + res = MaybeRemoveBOM([]byte{0xef, 0xbb, 0xbf, 0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, ConvertOpts{}) assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, res) } -func TestToUTF8WithErr(t *testing.T) { +func TestToUTF8(t *testing.T) { resetDefaultCharsetsOrder() var res string var err error @@ -47,53 +47,53 @@ func TestToUTF8WithErr(t *testing.T) { // locale, so some conversions might behave differently. For that reason, we don't // depend on particular conversions but in expected behaviors. - res, err = ToUTF8WithErr([]byte{0x41, 0x42, 0x43}) + res, err = ToUTF8([]byte{0x41, 0x42, 0x43}, ConvertOpts{}) assert.NoError(t, err) assert.Equal(t, "ABC", res) // "áéíóú" - res, err = ToUTF8WithErr([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}) + res, err = ToUTF8([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, ConvertOpts{}) assert.NoError(t, err) assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, []byte(res)) // "áéíóú" - res, err = ToUTF8WithErr([]byte{ + res, err = ToUTF8([]byte{ 0xef, 0xbb, 0xbf, 0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba, - }) + }, ConvertOpts{}) assert.NoError(t, err) assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, []byte(res)) - res, err = ToUTF8WithErr([]byte{ + res, err = ToUTF8([]byte{ 0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0xF1, 0x6F, 0x73, 0x41, 0x41, 0x41, 0x2e, - }) + }, ConvertOpts{}) assert.NoError(t, err) stringMustStartWith(t, "Hola,", res) stringMustEndWith(t, "AAA.", res) - res, err = ToUTF8WithErr([]byte{ + res, err = ToUTF8([]byte{ 0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x07, 0xA4, 0x6F, 0x73, 0x41, 0x41, 0x41, 0x2e, - }) + }, ConvertOpts{}) assert.NoError(t, err) stringMustStartWith(t, "Hola,", res) stringMustEndWith(t, "AAA.", res) - res, err = ToUTF8WithErr([]byte{ + res, err = ToUTF8([]byte{ 0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x81, 0xA4, 0x6F, 0x73, 0x41, 0x41, 0x41, 0x2e, - }) + }, ConvertOpts{}) assert.NoError(t, err) stringMustStartWith(t, "Hola,", res) stringMustEndWith(t, "AAA.", res) // Japanese (Shift-JIS) // 日属秘ぞしちゅ。 - res, err = ToUTF8WithErr([]byte{ + res, err = ToUTF8([]byte{ 0x93, 0xFA, 0x91, 0xAE, 0x94, 0xE9, 0x82, 0xBC, 0x82, 0xB5, 0x82, 0xBF, 0x82, 0xE3, 0x81, 0x42, - }) + }, ConvertOpts{}) assert.NoError(t, err) assert.Equal(t, []byte{ 0xE6, 0x97, 0xA5, 0xE5, 0xB1, 0x9E, 0xE7, 0xA7, 0x98, 0xE3, @@ -101,7 +101,7 @@ func TestToUTF8WithErr(t *testing.T) { }, []byte(res)) - res, err = ToUTF8WithErr([]byte{0x00, 0x00, 0x00, 0x00}) + res, err = ToUTF8([]byte{0x00, 0x00, 0x00, 0x00}, ConvertOpts{}) assert.NoError(t, err) assert.Equal(t, []byte{0x00, 0x00, 0x00, 0x00}, []byte(res)) } @@ -109,22 +109,22 @@ func TestToUTF8WithErr(t *testing.T) { func TestToUTF8WithFallback(t *testing.T) { resetDefaultCharsetsOrder() // "ABC" - res := ToUTF8WithFallback([]byte{0x41, 0x42, 0x43}) + res := ToUTF8WithFallback([]byte{0x41, 0x42, 0x43}, ConvertOpts{}) assert.Equal(t, []byte{0x41, 0x42, 0x43}, res) // "áéíóú" - res = ToUTF8WithFallback([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}) + res = ToUTF8WithFallback([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, ConvertOpts{}) assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, res) // UTF8 BOM + "áéíóú" - res = ToUTF8WithFallback([]byte{0xef, 0xbb, 0xbf, 0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}) + res = ToUTF8WithFallback([]byte{0xef, 0xbb, 0xbf, 0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, ConvertOpts{}) assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, res) // "Hola, así cómo ños" res = ToUTF8WithFallback([]byte{ 0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0xF1, 0x6F, 0x73, - }) + }, ConvertOpts{}) assert.Equal(t, []byte{ 0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xC3, 0xAD, 0x20, 0x63, 0xC3, 0xB3, 0x6D, 0x6F, 0x20, 0xC3, 0xB1, 0x6F, 0x73, @@ -133,126 +133,65 @@ func TestToUTF8WithFallback(t *testing.T) { // "Hola, así cómo " minmatch := []byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xC3, 0xAD, 0x20, 0x63, 0xC3, 0xB3, 0x6D, 0x6F, 0x20} - res = ToUTF8WithFallback([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x07, 0xA4, 0x6F, 0x73}) + res = ToUTF8WithFallback([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x07, 0xA4, 0x6F, 0x73}, ConvertOpts{}) // Do not fail for differences in invalid cases, as the library might change the conversion criteria for those assert.Equal(t, minmatch, res[0:len(minmatch)]) - res = ToUTF8WithFallback([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x81, 0xA4, 0x6F, 0x73}) + res = ToUTF8WithFallback([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x81, 0xA4, 0x6F, 0x73}, ConvertOpts{}) // Do not fail for differences in invalid cases, as the library might change the conversion criteria for those assert.Equal(t, minmatch, res[0:len(minmatch)]) // Japanese (Shift-JIS) // "日属秘ぞしちゅ。" - res = ToUTF8WithFallback([]byte{0x93, 0xFA, 0x91, 0xAE, 0x94, 0xE9, 0x82, 0xBC, 0x82, 0xB5, 0x82, 0xBF, 0x82, 0xE3, 0x81, 0x42}) + res = ToUTF8WithFallback([]byte{0x93, 0xFA, 0x91, 0xAE, 0x94, 0xE9, 0x82, 0xBC, 0x82, 0xB5, 0x82, 0xBF, 0x82, 0xE3, 0x81, 0x42}, ConvertOpts{}) assert.Equal(t, []byte{ 0xE6, 0x97, 0xA5, 0xE5, 0xB1, 0x9E, 0xE7, 0xA7, 0x98, 0xE3, 0x81, 0x9E, 0xE3, 0x81, 0x97, 0xE3, 0x81, 0xA1, 0xE3, 0x82, 0x85, 0xE3, 0x80, 0x82, }, res) - res = ToUTF8WithFallback([]byte{0x00, 0x00, 0x00, 0x00}) + res = ToUTF8WithFallback([]byte{0x00, 0x00, 0x00, 0x00}, ConvertOpts{}) assert.Equal(t, []byte{0x00, 0x00, 0x00, 0x00}, res) } -func TestToUTF8(t *testing.T) { - resetDefaultCharsetsOrder() - // Note: golang compiler seems so behave differently depending on the current - // locale, so some conversions might behave differently. For that reason, we don't - // depend on particular conversions but in expected behaviors. - - res := ToUTF8(string([]byte{0x41, 0x42, 0x43})) - assert.Equal(t, "ABC", res) - - // "áéíóú" - res = ToUTF8(string([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba})) - assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, []byte(res)) - - // BOM + "áéíóú" - res = ToUTF8(string([]byte{ - 0xef, 0xbb, 0xbf, 0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, - 0xc3, 0xba, - })) - assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, []byte(res)) - - // Latin1 - // Hola, así cómo ños - res = ToUTF8(string([]byte{ - 0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, - 0xF3, 0x6D, 0x6F, 0x20, 0xF1, 0x6F, 0x73, - })) - assert.Equal(t, []byte{ - 0x48, 0x6f, 0x6c, 0x61, 0x2c, 0x20, 0x61, 0x73, 0xc3, 0xad, 0x20, 0x63, - 0xc3, 0xb3, 0x6d, 0x6f, 0x20, 0xc3, 0xb1, 0x6f, 0x73, - }, []byte(res)) - - // Latin1 - // Hola, así cómo \x07ños - res = ToUTF8(string([]byte{ - 0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, - 0xF3, 0x6D, 0x6F, 0x20, 0x07, 0xA4, 0x6F, 0x73, - })) - // Hola, - bytesMustStartWith(t, []byte{0x48, 0x6F, 0x6C, 0x61, 0x2C}, []byte(res)) - - // This test FAILS - // res = ToUTF8("Hola, así cómo \x81ños") - // Do not fail for differences in invalid cases, as the library might change the conversion criteria for those - // assert.Regexp(t, "^Hola, así cómo", res) - - // Japanese (Shift-JIS) - // 日属秘ぞしちゅ。 - res = ToUTF8(string([]byte{ - 0x93, 0xFA, 0x91, 0xAE, 0x94, 0xE9, 0x82, 0xBC, 0x82, 0xB5, 0x82, - 0xBF, 0x82, 0xE3, 0x81, 0x42, - })) - assert.Equal(t, []byte{ - 0xE6, 0x97, 0xA5, 0xE5, 0xB1, 0x9E, 0xE7, 0xA7, 0x98, 0xE3, - 0x81, 0x9E, 0xE3, 0x81, 0x97, 0xE3, 0x81, 0xA1, 0xE3, 0x82, 0x85, 0xE3, 0x80, 0x82, - }, - []byte(res)) - - res = ToUTF8("\x00\x00\x00\x00") - assert.Equal(t, []byte{0x00, 0x00, 0x00, 0x00}, []byte(res)) -} - func TestToUTF8DropErrors(t *testing.T) { resetDefaultCharsetsOrder() // "ABC" - res := ToUTF8DropErrors([]byte{0x41, 0x42, 0x43}) + res := ToUTF8DropErrors([]byte{0x41, 0x42, 0x43}, ConvertOpts{}) assert.Equal(t, []byte{0x41, 0x42, 0x43}, res) // "áéíóú" - res = ToUTF8DropErrors([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}) + res = ToUTF8DropErrors([]byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, ConvertOpts{}) assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, res) // UTF8 BOM + "áéíóú" - res = ToUTF8DropErrors([]byte{0xef, 0xbb, 0xbf, 0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}) + res = ToUTF8DropErrors([]byte{0xef, 0xbb, 0xbf, 0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, ConvertOpts{}) assert.Equal(t, []byte{0xc3, 0xa1, 0xc3, 0xa9, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba}, res) // "Hola, así cómo ños" - res = ToUTF8DropErrors([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0xF1, 0x6F, 0x73}) + res = ToUTF8DropErrors([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0xF1, 0x6F, 0x73}, ConvertOpts{}) assert.Equal(t, []byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73}, res[:8]) assert.Equal(t, []byte{0x73}, res[len(res)-1:]) // "Hola, así cómo " minmatch := []byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xC3, 0xAD, 0x20, 0x63, 0xC3, 0xB3, 0x6D, 0x6F, 0x20} - res = ToUTF8DropErrors([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x07, 0xA4, 0x6F, 0x73}) + res = ToUTF8DropErrors([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x07, 0xA4, 0x6F, 0x73}, ConvertOpts{}) // Do not fail for differences in invalid cases, as the library might change the conversion criteria for those assert.Equal(t, minmatch, res[0:len(minmatch)]) - res = ToUTF8DropErrors([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x81, 0xA4, 0x6F, 0x73}) + res = ToUTF8DropErrors([]byte{0x48, 0x6F, 0x6C, 0x61, 0x2C, 0x20, 0x61, 0x73, 0xED, 0x20, 0x63, 0xF3, 0x6D, 0x6F, 0x20, 0x81, 0xA4, 0x6F, 0x73}, ConvertOpts{}) // Do not fail for differences in invalid cases, as the library might change the conversion criteria for those assert.Equal(t, minmatch, res[0:len(minmatch)]) // Japanese (Shift-JIS) // "日属秘ぞしちゅ。" - res = ToUTF8DropErrors([]byte{0x93, 0xFA, 0x91, 0xAE, 0x94, 0xE9, 0x82, 0xBC, 0x82, 0xB5, 0x82, 0xBF, 0x82, 0xE3, 0x81, 0x42}) + res = ToUTF8DropErrors([]byte{0x93, 0xFA, 0x91, 0xAE, 0x94, 0xE9, 0x82, 0xBC, 0x82, 0xB5, 0x82, 0xBF, 0x82, 0xE3, 0x81, 0x42}, ConvertOpts{}) assert.Equal(t, []byte{ 0xE6, 0x97, 0xA5, 0xE5, 0xB1, 0x9E, 0xE7, 0xA7, 0x98, 0xE3, 0x81, 0x9E, 0xE3, 0x81, 0x97, 0xE3, 0x81, 0xA1, 0xE3, 0x82, 0x85, 0xE3, 0x80, 0x82, }, res) - res = ToUTF8DropErrors([]byte{0x00, 0x00, 0x00, 0x00}) + res = ToUTF8DropErrors([]byte{0x00, 0x00, 0x00, 0x00}, ConvertOpts{}) assert.Equal(t, []byte{0x00, 0x00, 0x00, 0x00}, res) } @@ -302,10 +241,6 @@ func stringMustEndWith(t *testing.T, expected, value string) { assert.Equal(t, expected, value[len(value)-len(expected):]) } -func bytesMustStartWith(t *testing.T, expected, value []byte) { - assert.Equal(t, expected, value[:len(expected)]) -} - func TestToUTF8WithFallbackReader(t *testing.T) { resetDefaultCharsetsOrder() @@ -317,7 +252,7 @@ func TestToUTF8WithFallbackReader(t *testing.T) { } input = input[:testLen] input += "// Выключаем" - rd := ToUTF8WithFallbackReader(bytes.NewReader([]byte(input))) + rd := ToUTF8WithFallbackReader(bytes.NewReader([]byte(input)), ConvertOpts{}) r, _ := io.ReadAll(rd) assert.EqualValuesf(t, input, string(r), "testing string len=%d", testLen) } diff --git a/modules/indexer/code/bleve/bleve.go b/modules/indexer/code/bleve/bleve.go index 0bfd85cb3f..8ba50ed77c 100644 --- a/modules/indexer/code/bleve/bleve.go +++ b/modules/indexer/code/bleve/bleve.go @@ -174,7 +174,7 @@ func (b *Indexer) addUpdate(ctx context.Context, batchWriter git.WriteCloserErro return batch.Index(id, &RepoIndexerData{ RepoID: repo.ID, CommitID: commitSha, - Content: string(charset.ToUTF8DropErrors(fileContents)), + Content: string(charset.ToUTF8DropErrors(fileContents, charset.ConvertOpts{})), Language: analyze.GetCodeLanguage(update.Filename, fileContents), UpdatedAt: time.Now().UTC(), }) diff --git a/modules/indexer/code/elasticsearch/elasticsearch.go b/modules/indexer/code/elasticsearch/elasticsearch.go index e7e3429a39..2fadbfeb06 100644 --- a/modules/indexer/code/elasticsearch/elasticsearch.go +++ b/modules/indexer/code/elasticsearch/elasticsearch.go @@ -135,7 +135,7 @@ func (b *Indexer) addUpdate(ctx context.Context, batchWriter git.WriteCloserErro Id(id). Doc(map[string]any{ "repo_id": repo.ID, - "content": string(charset.ToUTF8DropErrors(fileContents)), + "content": string(charset.ToUTF8DropErrors(fileContents, charset.ConvertOpts{})), "commit_id": sha, "language": analyze.GetCodeLanguage(update.Filename, fileContents), "updated_at": timeutil.TimeStampNow(), diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index abb39caa57..00157d44c9 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -384,7 +384,7 @@ func Diff(ctx *context.Context) { Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, Ctx: ctx, - }, template.HTMLEscapeString(string(charset.ToUTF8WithFallback(note.Message)))) + }, template.HTMLEscapeString(string(charset.ToUTF8WithFallback(note.Message, charset.ConvertOpts{})))) if err != nil { ctx.ServerError("RenderCommitMessage", err) return diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 042b8ed692..5ae48e1ce8 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -142,7 +142,7 @@ func setCsvCompareContext(ctx *context.Context) { return nil, nil, err } - csvReader, err := csv_module.CreateReaderAndDetermineDelimiter(ctx, charset.ToUTF8WithFallbackReader(reader)) + csvReader, err := csv_module.CreateReaderAndDetermineDelimiter(ctx, charset.ToUTF8WithFallbackReader(reader, charset.ConvertOpts{})) return csvReader, reader, err } diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index 5e7cd1caa3..85d40e7820 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -166,8 +166,8 @@ func editFile(ctx *context.Context, isNewFile bool) { } buf = append(buf, d...) - if content, err := charset.ToUTF8WithErr(buf); err != nil { - log.Error("ToUTF8WithErr: %v", err) + if content, err := charset.ToUTF8(buf, charset.ConvertOpts{KeepBOM: true}); err != nil { + log.Error("ToUTF8: %v", err) ctx.Data["FileContent"] = string(buf) } else { ctx.Data["FileContent"] = content diff --git a/routers/web/repo/render.go b/routers/web/repo/render.go index f2c6ab3f8f..7eb5a42aa4 100644 --- a/routers/web/repo/render.go +++ b/routers/web/repo/render.go @@ -43,7 +43,7 @@ func RenderFile(ctx *context.Context) { st := typesniffer.DetectContentType(buf) isTextFile := st.IsText() - rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc)) + rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{}) if markupType := markup.Type(blob.Name()); markupType == "" { if isTextFile { diff --git a/routers/web/repo/setting/lfs.go b/routers/web/repo/setting/lfs.go index edf1298c20..cd0f11d548 100644 --- a/routers/web/repo/setting/lfs.go +++ b/routers/web/repo/setting/lfs.go @@ -303,7 +303,7 @@ func LFSFileGet(ctx *context.Context) { break } - rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc)) + rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{}) // Building code view blocks with line number on server side. escapedContent := &bytes.Buffer{} diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 00fd47b650..af3021da11 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -303,7 +303,7 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr return } - rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc)) + rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{}) if markupType := markup.Type(readmeFile.Name()); markupType != "" { ctx.Data["IsMarkup"] = true @@ -492,7 +492,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) { break } - rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc)) + rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{}) shouldRenderSource := ctx.FormString("display") == "source" readmeExist := util.IsReadmeFileName(blob.Name()) diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index 58ed6f356e..cfc266731b 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -38,8 +38,7 @@ data-url="{{.Repository.Link}}/markup" data-context="{{.RepoLink}}" data-previewable-extensions="{{.PreviewableExtensions}}" - data-line-wrap-extensions="{{.LineWrapExtensions}}"> -{{.FileContent}} + data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}
diff --git a/tests/integration/migration-test/migration_test.go b/tests/integration/migration-test/migration_test.go index 556a54015b..40fcf95705 100644 --- a/tests/integration/migration-test/migration_test.go +++ b/tests/integration/migration-test/migration_test.go @@ -141,7 +141,7 @@ func readSQLFromFile(version string) (string, error) { if err != nil { return "", err } - return string(charset.RemoveBOMIfPresent(bytes)), nil + return string(charset.MaybeRemoveBOM(bytes, charset.ConvertOpts{})), nil } func restoreOldDB(t *testing.T, version string) bool { diff --git a/web_src/js/features/codeeditor.js b/web_src/js/features/codeeditor.js index ae54268d56..fceb2f7620 100644 --- a/web_src/js/features/codeeditor.js +++ b/web_src/js/features/codeeditor.js @@ -114,7 +114,7 @@ export async function createMonaco(textarea, filename, editorOpts) { const model = editor.getModel(); model.onDidChangeContent(() => { - textarea.value = editor.getValue(); + textarea.value = editor.getValue({preserveBOM: true}); textarea.dispatchEvent(new Event('change')); // seems to be needed for jquery-are-you-sure }); From 5f82ead13cb7706d3f660271d94de6101cef4119 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 28 Jan 2024 04:09:51 +0800 Subject: [PATCH 66/76] Simplify how git repositories are opened (#28937) ## Purpose This is a refactor toward building an abstraction over managing git repositories. Afterwards, it does not matter anymore if they are stored on the local disk or somewhere remote. ## What this PR changes We used `git.OpenRepository` everywhere previously. Now, we should split them into two distinct functions: Firstly, there are temporary repositories which do not change: ```go git.OpenRepository(ctx, diskPath) ``` Gitea managed repositories having a record in the database in the `repository` table are moved into the new package `gitrepo`: ```go gitrepo.OpenRepository(ctx, repo_model.Repo) ``` Why is `repo_model.Repository` the second parameter instead of file path? Because then we can easily adapt our repository storage strategy. The repositories can be stored locally, however, they could just as well be stored on a remote server. ## Further changes in other PRs - A Git Command wrapper on package `gitrepo` could be created. i.e. `NewCommand(ctx, repo_model.Repository, commands...)`. `git.RunOpts{Dir: repo.RepoPath()}`, the directory should be empty before invoking this method and it can be filled in the function only. #28940 - Remove the `RepoPath()`/`WikiPath()` functions to reduce the possibility of mistakes. --------- Co-authored-by: delvh --- cmd/admin.go | 3 +- models/activities/repo_activity.go | 5 +- models/issues/comment.go | 5 +- models/issues/pull.go | 3 +- models/repo/repo.go | 8 ++ modules/context/api.go | 9 +- modules/context/context.go | 4 +- modules/context/repo.go | 10 +- modules/contexttest/context_tests.go | 6 +- modules/git/repo_base.go | 44 -------- modules/git/repo_branch.go | 23 ---- modules/git/repo_branch_gogit.go | 29 ----- modules/git/repo_branch_nogogit.go | 13 +-- modules/gitrepo/branch.go | 32 ++++++ modules/gitrepo/gitrepo.go | 103 ++++++++++++++++++ modules/gitrepo/walk_gogit.go | 40 +++++++ modules/gitrepo/walk_nogogit.go | 17 +++ modules/indexer/stats/db.go | 3 +- modules/repository/branch.go | 5 +- modules/repository/generate.go | 3 +- modules/repository/repo.go | 3 +- routers/api/v1/repo/branch.go | 5 +- routers/api/v1/repo/file.go | 4 +- routers/api/v1/repo/pull.go | 9 +- routers/api/v1/repo/pull_review.go | 5 +- routers/api/v1/repo/repo.go | 3 +- routers/api/v1/repo/wiki.go | 3 +- routers/api/v1/utils/git.go | 3 +- routers/private/internal_repo.go | 4 +- routers/web/repo/commit.go | 5 +- routers/web/repo/compare.go | 7 +- routers/web/repo/editor_test.go | 3 +- routers/web/repo/pull.go | 17 +-- routers/web/repo/wiki.go | 3 +- routers/web/repo/wiki_test.go | 3 +- routers/web/shared/user/header.go | 3 +- services/actions/notifier_helper.go | 3 +- services/asymkey/sign.go | 7 +- services/automerge/automerge.go | 7 +- services/convert/pull.go | 9 +- services/doctor/misc.go | 3 +- services/migrations/gitea_uploader.go | 3 +- services/migrations/gitea_uploader_test.go | 5 +- services/mirror/mirror_pull.go | 7 +- services/mirror/mirror_push.go | 21 +++- services/pull/check.go | 3 +- services/pull/comment.go | 5 +- services/pull/commit_status.go | 3 +- services/pull/merge_rebase.go | 3 +- services/pull/merge_squash.go | 3 +- services/pull/patch.go | 3 +- services/pull/pull.go | 17 +-- services/pull/pull_test.go | 5 +- services/pull/review.go | 3 +- services/release/release.go | 3 +- services/release/release_test.go | 10 +- services/repository/adopt.go | 3 +- services/repository/archiver/archiver.go | 3 +- services/repository/branch.go | 9 +- services/repository/create.go | 3 +- services/repository/files/commit.go | 3 +- services/repository/files/content.go | 5 +- services/repository/files/content_test.go | 5 +- services/repository/files/file_test.go | 4 +- services/repository/files/patch.go | 3 +- services/repository/files/update.go | 3 +- services/repository/fork.go | 5 +- services/repository/hooks.go | 6 +- services/repository/lfs.go | 3 +- services/repository/push.go | 9 +- services/wiki/wiki.go | 4 +- services/wiki/wiki_test.go | 9 +- tests/integration/api_packages_cargo_test.go | 4 +- tests/integration/api_releases_test.go | 5 +- .../integration/api_repo_file_create_test.go | 6 +- .../integration/api_repo_file_update_test.go | 4 +- .../integration/api_repo_files_change_test.go | 4 +- .../api_repo_get_contents_list_test.go | 3 +- .../integration/api_repo_get_contents_test.go | 3 +- tests/integration/api_repo_git_tags_test.go | 3 +- tests/integration/mirror_pull_test.go | 3 +- tests/integration/mirror_push_test.go | 5 +- tests/integration/pull_merge_test.go | 5 +- tests/integration/repofiles_change_test.go | 9 +- 84 files changed, 426 insertions(+), 273 deletions(-) create mode 100644 modules/gitrepo/branch.go create mode 100644 modules/gitrepo/gitrepo.go create mode 100644 modules/gitrepo/walk_gogit.go create mode 100644 modules/gitrepo/walk_nogogit.go diff --git a/cmd/admin.go b/cmd/admin.go index 74bfa5a6c6..6c9480e76e 100644 --- a/cmd/admin.go +++ b/cmd/admin.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" @@ -122,7 +123,7 @@ func runRepoSyncReleases(_ *cli.Context) error { log.Trace("Processing next %d repos of %d", len(repos), count) for _, repo := range repos { log.Trace("Synchronizing repo %s with path %s", repo.FullName(), repo.RepoPath()) - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { log.Warn("OpenRepository: %v", err) continue diff --git a/models/activities/repo_activity.go b/models/activities/repo_activity.go index 91f5ac12bd..ba5e4959f0 100644 --- a/models/activities/repo_activity.go +++ b/models/activities/repo_activity.go @@ -14,6 +14,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "xorm.io/xorm" ) @@ -65,7 +66,7 @@ func GetActivityStats(ctx context.Context, repo *repo_model.Repository, timeFrom return nil, fmt.Errorf("FillUnresolvedIssues: %w", err) } if code { - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return nil, fmt.Errorf("OpenRepository: %w", err) } @@ -82,7 +83,7 @@ func GetActivityStats(ctx context.Context, repo *repo_model.Repository, timeFrom // GetActivityStatsTopAuthors returns top author stats for git commits for all branches func GetActivityStatsTopAuthors(ctx context.Context, repo *repo_model.Repository, timeFrom time.Time, count int) ([]*ActivityAuthorData, error) { - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return nil, fmt.Errorf("OpenRepository: %w", err) } diff --git a/models/issues/comment.go b/models/issues/comment.go index 8a3bae5b88..c63fcab894 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -18,7 +18,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/container" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/references" @@ -762,8 +762,7 @@ func (c *Comment) LoadPushCommits(ctx context.Context) (err error) { c.OldCommit = data.CommitIDs[0] c.NewCommit = data.CommitIDs[1] } else { - repoPath := c.Issue.Repo.RepoPath() - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repoPath) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, c.Issue.Repo) if err != nil { return err } diff --git a/models/issues/pull.go b/models/issues/pull.go index 4ae6e38ae1..2cb1e1b971 100644 --- a/models/issues/pull.go +++ b/models/issues/pull.go @@ -19,6 +19,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" @@ -865,7 +866,7 @@ func PullRequestCodeOwnersReview(ctx context.Context, pull *Issue, pr *PullReque return err } - repo, err := git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + repo, err := gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { return err } diff --git a/models/repo/repo.go b/models/repo/repo.go index 4401041cdd..13493ba6e8 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -196,6 +196,14 @@ func init() { db.RegisterModel(new(Repository)) } +func (repo *Repository) GetName() string { + return repo.Name +} + +func (repo *Repository) GetOwnerName() string { + return repo.OwnerName +} + // SanitizedOriginalURL returns a sanitized OriginalURL func (repo *Repository) SanitizedOriginalURL() string { if repo.OriginalURL == "" { diff --git a/modules/context/api.go b/modules/context/api.go index f41228ad76..e226264a87 100644 --- a/modules/context/api.go +++ b/modules/context/api.go @@ -11,11 +11,11 @@ import ( "net/url" "strings" - repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" mc "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/httpcache" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -224,7 +224,7 @@ func APIContexter() func(http.Handler) http.Handler { defer baseCleanUp() ctx.Base.AppendContextValue(apiContextKey, ctx) - ctx.Base.AppendContextValueFunc(git.RepositoryContextKey, func() any { return ctx.Repo.GitRepo }) + ctx.Base.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo }) // If request sends files, parse them here otherwise the Query() can't be parsed and the CsrfToken will be invalid. if ctx.Req.Method == "POST" && strings.Contains(ctx.Req.Header.Get("Content-Type"), "multipart/form-data") { @@ -278,10 +278,9 @@ func ReferencesGitRepo(allowEmpty ...bool) func(ctx *APIContext) (cancel context // For API calls. if ctx.Repo.GitRepo == nil { - repoPath := repo_model.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) - gitRepo, err := git.OpenRepository(ctx, repoPath) + gitRepo, err := gitrepo.OpenRepository(ctx, ctx.Repo.Repository) if err != nil { - ctx.Error(http.StatusInternalServerError, "RepoRef Invalid repo "+repoPath, err) + ctx.Error(http.StatusInternalServerError, fmt.Sprintf("Open Repository %v failed", ctx.Repo.Repository.FullName()), err) return cancel } ctx.Repo.GitRepo = gitRepo diff --git a/modules/context/context.go b/modules/context/context.go index 8a94e958b5..d19c5d1198 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -17,7 +17,7 @@ import ( "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" mc "code.gitea.io/gitea/modules/cache" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/httpcache" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/templates" @@ -163,7 +163,7 @@ func Contexter() func(next http.Handler) http.Handler { ctx.Data["PageData"] = ctx.PageData ctx.Base.AppendContextValue(WebContextKey, ctx) - ctx.Base.AppendContextValueFunc(git.RepositoryContextKey, func() any { return ctx.Repo.GitRepo }) + ctx.Base.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo }) ctx.Csrf = PrepareCSRFProtector(csrfOpts, ctx) diff --git a/modules/context/repo.go b/modules/context/repo.go index 8d82be1990..75ebfec705 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -23,6 +23,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" code_indexer "code.gitea.io/gitea/modules/indexer/code" "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" @@ -633,7 +634,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc { return nil } - gitRepo, err := git.OpenRepository(ctx, repo_model.RepoPath(userName, repoName)) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { if strings.Contains(err.Error(), "repository does not exist") || strings.Contains(err.Error(), "no such file or directory") { log.Error("Repository %-v has a broken repository on the file system: %s Error: %v", ctx.Repo.Repository, ctx.Repo.Repository.RepoPath(), err) @@ -645,7 +646,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc { } return nil } - ctx.ServerError("RepoAssignment Invalid repo "+repo_model.RepoPath(userName, repoName), err) + ctx.ServerError("RepoAssignment Invalid repo "+repo.FullName(), err) return nil } if ctx.Repo.GitRepo != nil { @@ -920,10 +921,9 @@ func RepoRefByType(refType RepoRefType, ignoreNotExistErr ...bool) func(*Context ) if ctx.Repo.GitRepo == nil { - repoPath := repo_model.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) - ctx.Repo.GitRepo, err = git.OpenRepository(ctx, repoPath) + ctx.Repo.GitRepo, err = gitrepo.OpenRepository(ctx, ctx.Repo.Repository) if err != nil { - ctx.ServerError("RepoRef Invalid repo "+repoPath, err) + ctx.ServerError(fmt.Sprintf("Open Repository %v failed", ctx.Repo.Repository.FullName()), err) return nil } // We opened it, we should close it diff --git a/modules/contexttest/context_tests.go b/modules/contexttest/context_tests.go index 8994c1e451..9ca028bb6e 100644 --- a/modules/contexttest/context_tests.go +++ b/modules/contexttest/context_tests.go @@ -18,7 +18,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/translation" "code.gitea.io/gitea/modules/web/middleware" @@ -107,7 +107,7 @@ func LoadRepoCommit(t *testing.T, ctx gocontext.Context) { assert.FailNow(t, "context is not *context.Context or *context.APIContext") } - gitRepo, err := git.OpenRepository(ctx, repo.Repository.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo.Repository) assert.NoError(t, err) defer gitRepo.Close() branch, err := gitRepo.GetHEADBranch() @@ -137,7 +137,7 @@ func LoadUser(t *testing.T, ctx gocontext.Context, userID int64) { func LoadGitRepo(t *testing.T, ctx *context.Context) { assert.NoError(t, ctx.Repo.Repository.LoadOwner(ctx)) var err error - ctx.Repo.GitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.RepoPath()) + ctx.Repo.GitRepo, err = gitrepo.OpenRepository(ctx, ctx.Repo.Repository) assert.NoError(t, err) } diff --git a/modules/git/repo_base.go b/modules/git/repo_base.go index a9d91d2deb..6c148d9af5 100644 --- a/modules/git/repo_base.go +++ b/modules/git/repo_base.go @@ -3,48 +3,4 @@ package git -import ( - "context" - "io" -) - var isGogit bool - -// contextKey is a value for use with context.WithValue. -type contextKey struct { - name string -} - -// RepositoryContextKey is a context key. It is used with context.Value() to get the current Repository for the context -var RepositoryContextKey = &contextKey{"repository"} - -// RepositoryFromContext attempts to get the repository from the context -func RepositoryFromContext(ctx context.Context, path string) *Repository { - value := ctx.Value(RepositoryContextKey) - if value == nil { - return nil - } - - if repo, ok := value.(*Repository); ok && repo != nil { - if repo.Path == path { - return repo - } - } - - return nil -} - -type nopCloser func() - -func (nopCloser) Close() error { return nil } - -// RepositoryFromContextOrOpen attempts to get the repository from the context or just opens it -func RepositoryFromContextOrOpen(ctx context.Context, path string) (*Repository, io.Closer, error) { - gitRepo := RepositoryFromContext(ctx, path) - if gitRepo != nil { - return gitRepo, nopCloser(nil), nil - } - - gitRepo, err := OpenRepository(ctx, path) - return gitRepo, gitRepo, err -} diff --git a/modules/git/repo_branch.go b/modules/git/repo_branch.go index 5958093975..979c5dec91 100644 --- a/modules/git/repo_branch.go +++ b/modules/git/repo_branch.go @@ -86,29 +86,6 @@ func (repo *Repository) GetBranch(branch string) (*Branch, error) { }, nil } -// GetBranchesByPath returns a branch by it's path -// if limit = 0 it will not limit -func GetBranchesByPath(ctx context.Context, path string, skip, limit int) ([]*Branch, int, error) { - gitRepo, err := OpenRepository(ctx, path) - if err != nil { - return nil, 0, err - } - defer gitRepo.Close() - - return gitRepo.GetBranches(skip, limit) -} - -// GetBranchCommitID returns a branch commit ID by its name -func GetBranchCommitID(ctx context.Context, path, branch string) (string, error) { - gitRepo, err := OpenRepository(ctx, path) - if err != nil { - return "", err - } - defer gitRepo.Close() - - return gitRepo.GetBranchCommitID(branch) -} - // GetBranches returns a slice of *git.Branch func (repo *Repository) GetBranches(skip, limit int) ([]*Branch, int, error) { brs, countAll, err := repo.GetBranchNames(skip, limit) diff --git a/modules/git/repo_branch_gogit.go b/modules/git/repo_branch_gogit.go index 1c0d9a18aa..d1ec14d811 100644 --- a/modules/git/repo_branch_gogit.go +++ b/modules/git/repo_branch_gogit.go @@ -7,7 +7,6 @@ package git import ( - "context" "sort" "strings" @@ -95,34 +94,6 @@ func (repo *Repository) GetBranchNames(skip, limit int) ([]string, int, error) { return branchNames, len(branchData), nil } -// WalkReferences walks all the references from the repository -// refType should be empty, ObjectTag or ObjectBranch. All other values are equivalent to empty. -func WalkReferences(ctx context.Context, repoPath string, walkfn func(sha1, refname string) error) (int, error) { - repo := RepositoryFromContext(ctx, repoPath) - if repo == nil { - var err error - repo, err = OpenRepository(ctx, repoPath) - if err != nil { - return 0, err - } - defer repo.Close() - } - - i := 0 - iter, err := repo.gogitRepo.References() - if err != nil { - return i, err - } - defer iter.Close() - - err = iter.ForEach(func(ref *plumbing.Reference) error { - err := walkfn(ref.Hash().String(), string(ref.Name())) - i++ - return err - }) - return i, err -} - // WalkReferences walks all the references from the repository func (repo *Repository) WalkReferences(arg ObjectType, skip, limit int, walkfn func(sha1, refname string) error) (int, error) { i := 0 diff --git a/modules/git/repo_branch_nogogit.go b/modules/git/repo_branch_nogogit.go index b1e7c8b73e..470faebe25 100644 --- a/modules/git/repo_branch_nogogit.go +++ b/modules/git/repo_branch_nogogit.go @@ -65,11 +65,6 @@ func (repo *Repository) GetBranchNames(skip, limit int) ([]string, int, error) { return callShowRef(repo.Ctx, repo.Path, BranchPrefix, TrustedCmdArgs{BranchPrefix, "--sort=-committerdate"}, skip, limit) } -// WalkReferences walks all the references from the repository -func WalkReferences(ctx context.Context, repoPath string, walkfn func(sha1, refname string) error) (int, error) { - return walkShowRef(ctx, repoPath, nil, 0, 0, walkfn) -} - // WalkReferences walks all the references from the repository // refType should be empty, ObjectTag or ObjectBranch. All other values are equivalent to empty. func (repo *Repository) WalkReferences(refType ObjectType, skip, limit int, walkfn func(sha1, refname string) error) (int, error) { @@ -81,12 +76,12 @@ func (repo *Repository) WalkReferences(refType ObjectType, skip, limit int, walk args = TrustedCmdArgs{BranchPrefix, "--sort=-committerdate"} } - return walkShowRef(repo.Ctx, repo.Path, args, skip, limit, walkfn) + return WalkShowRef(repo.Ctx, repo.Path, args, skip, limit, walkfn) } // callShowRef return refs, if limit = 0 it will not limit func callShowRef(ctx context.Context, repoPath, trimPrefix string, extraArgs TrustedCmdArgs, skip, limit int) (branchNames []string, countAll int, err error) { - countAll, err = walkShowRef(ctx, repoPath, extraArgs, skip, limit, func(_, branchName string) error { + countAll, err = WalkShowRef(ctx, repoPath, extraArgs, skip, limit, func(_, branchName string) error { branchName = strings.TrimPrefix(branchName, trimPrefix) branchNames = append(branchNames, branchName) @@ -95,7 +90,7 @@ func callShowRef(ctx context.Context, repoPath, trimPrefix string, extraArgs Tru return branchNames, countAll, err } -func walkShowRef(ctx context.Context, repoPath string, extraArgs TrustedCmdArgs, skip, limit int, walkfn func(sha1, refname string) error) (countAll int, err error) { +func WalkShowRef(ctx context.Context, repoPath string, extraArgs TrustedCmdArgs, skip, limit int, walkfn func(sha1, refname string) error) (countAll int, err error) { stdoutReader, stdoutWriter := io.Pipe() defer func() { _ = stdoutReader.Close() @@ -189,7 +184,7 @@ func walkShowRef(ctx context.Context, repoPath string, extraArgs TrustedCmdArgs, // GetRefsBySha returns all references filtered with prefix that belong to a sha commit hash func (repo *Repository) GetRefsBySha(sha, prefix string) ([]string, error) { var revList []string - _, err := walkShowRef(repo.Ctx, repo.Path, nil, 0, 0, func(walkSha, refname string) error { + _, err := WalkShowRef(repo.Ctx, repo.Path, nil, 0, 0, func(walkSha, refname string) error { if walkSha == sha && strings.HasPrefix(refname, prefix) { revList = append(revList, refname) } diff --git a/modules/gitrepo/branch.go b/modules/gitrepo/branch.go new file mode 100644 index 0000000000..dcaf92668d --- /dev/null +++ b/modules/gitrepo/branch.go @@ -0,0 +1,32 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package gitrepo + +import ( + "context" + + "code.gitea.io/gitea/modules/git" +) + +// GetBranchesByPath returns a branch by its path +// if limit = 0 it will not limit +func GetBranchesByPath(ctx context.Context, repo Repository, skip, limit int) ([]*git.Branch, int, error) { + gitRepo, err := OpenRepository(ctx, repo) + if err != nil { + return nil, 0, err + } + defer gitRepo.Close() + + return gitRepo.GetBranches(skip, limit) +} + +func GetBranchCommitID(ctx context.Context, repo Repository, branch string) (string, error) { + gitRepo, err := OpenRepository(ctx, repo) + if err != nil { + return "", err + } + defer gitRepo.Close() + + return gitRepo.GetBranchCommitID(branch) +} diff --git a/modules/gitrepo/gitrepo.go b/modules/gitrepo/gitrepo.go new file mode 100644 index 0000000000..d89f8f9c0c --- /dev/null +++ b/modules/gitrepo/gitrepo.go @@ -0,0 +1,103 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package gitrepo + +import ( + "context" + "io" + "path/filepath" + "strings" + + "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/setting" +) + +type Repository interface { + GetName() string + GetOwnerName() string +} + +func repoPath(repo Repository) string { + return filepath.Join(setting.RepoRootPath, strings.ToLower(repo.GetOwnerName()), strings.ToLower(repo.GetName())+".git") +} + +func wikiPath(repo Repository) string { + return filepath.Join(setting.RepoRootPath, strings.ToLower(repo.GetOwnerName()), strings.ToLower(repo.GetName())+".wiki.git") +} + +// OpenRepository opens the repository at the given relative path with the provided context. +func OpenRepository(ctx context.Context, repo Repository) (*git.Repository, error) { + return git.OpenRepository(ctx, repoPath(repo)) +} + +func OpenWikiRepository(ctx context.Context, repo Repository) (*git.Repository, error) { + return git.OpenRepository(ctx, wikiPath(repo)) +} + +// contextKey is a value for use with context.WithValue. +type contextKey struct { + name string +} + +// RepositoryContextKey is a context key. It is used with context.Value() to get the current Repository for the context +var RepositoryContextKey = &contextKey{"repository"} + +// RepositoryFromContext attempts to get the repository from the context +func repositoryFromContext(ctx context.Context, repo Repository) *git.Repository { + value := ctx.Value(RepositoryContextKey) + if value == nil { + return nil + } + + if gitRepo, ok := value.(*git.Repository); ok && gitRepo != nil { + if gitRepo.Path == repoPath(repo) { + return gitRepo + } + } + + return nil +} + +type nopCloser func() + +func (nopCloser) Close() error { return nil } + +// RepositoryFromContextOrOpen attempts to get the repository from the context or just opens it +func RepositoryFromContextOrOpen(ctx context.Context, repo Repository) (*git.Repository, io.Closer, error) { + gitRepo := repositoryFromContext(ctx, repo) + if gitRepo != nil { + return gitRepo, nopCloser(nil), nil + } + + gitRepo, err := OpenRepository(ctx, repo) + return gitRepo, gitRepo, err +} + +// repositoryFromContextPath attempts to get the repository from the context +func repositoryFromContextPath(ctx context.Context, path string) *git.Repository { + value := ctx.Value(RepositoryContextKey) + if value == nil { + return nil + } + + if repo, ok := value.(*git.Repository); ok && repo != nil { + if repo.Path == path { + return repo + } + } + + return nil +} + +// RepositoryFromContextOrOpenPath attempts to get the repository from the context or just opens it +// Deprecated: Use RepositoryFromContextOrOpen instead +func RepositoryFromContextOrOpenPath(ctx context.Context, path string) (*git.Repository, io.Closer, error) { + gitRepo := repositoryFromContextPath(ctx, path) + if gitRepo != nil { + return gitRepo, nopCloser(nil), nil + } + + gitRepo, err := git.OpenRepository(ctx, path) + return gitRepo, gitRepo, err +} diff --git a/modules/gitrepo/walk_gogit.go b/modules/gitrepo/walk_gogit.go new file mode 100644 index 0000000000..6370faf08e --- /dev/null +++ b/modules/gitrepo/walk_gogit.go @@ -0,0 +1,40 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +//go:build gogit + +package gitrepo + +import ( + "context" + + "github.com/go-git/go-git/v5/plumbing" +) + +// WalkReferences walks all the references from the repository +// refname is empty, ObjectTag or ObjectBranch. All other values should be treated as equivalent to empty. +func WalkReferences(ctx context.Context, repo Repository, walkfn func(sha1, refname string) error) (int, error) { + gitRepo := repositoryFromContext(ctx, repo) + if gitRepo == nil { + var err error + gitRepo, err = OpenRepository(ctx, repo) + if err != nil { + return 0, err + } + defer gitRepo.Close() + } + + i := 0 + iter, err := gitRepo.GoGitRepo().References() + if err != nil { + return i, err + } + defer iter.Close() + + err = iter.ForEach(func(ref *plumbing.Reference) error { + err := walkfn(ref.Hash().String(), string(ref.Name())) + i++ + return err + }) + return i, err +} diff --git a/modules/gitrepo/walk_nogogit.go b/modules/gitrepo/walk_nogogit.go new file mode 100644 index 0000000000..ff9555996d --- /dev/null +++ b/modules/gitrepo/walk_nogogit.go @@ -0,0 +1,17 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +//go:build !gogit + +package gitrepo + +import ( + "context" + + "code.gitea.io/gitea/modules/git" +) + +// WalkReferences walks all the references from the repository +func WalkReferences(ctx context.Context, repo Repository, walkfn func(sha1, refname string) error) (int, error) { + return git.WalkShowRef(ctx, repoPath(repo), nil, 0, 0, walkfn) +} diff --git a/modules/indexer/stats/db.go b/modules/indexer/stats/db.go index 163843b47f..98a977c700 100644 --- a/modules/indexer/stats/db.go +++ b/modules/indexer/stats/db.go @@ -8,6 +8,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -35,7 +36,7 @@ func (db *DBIndexer) Index(id int64) error { return err } - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { if err.Error() == "no such file or directory" { return nil diff --git a/modules/repository/branch.go b/modules/repository/branch.go index cd45f16227..e448490f4a 100644 --- a/modules/repository/branch.go +++ b/modules/repository/branch.go @@ -11,6 +11,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" ) @@ -24,9 +25,9 @@ func SyncRepoBranches(ctx context.Context, repoID, doerID int64) (int64, error) log.Debug("SyncRepoBranches: in Repo[%d:%s]", repo.ID, repo.FullName()) - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { - log.Error("OpenRepository[%s]: %w", repo.RepoPath(), err) + log.Error("OpenRepository[%s]: %w", repo.FullName(), err) return 0, err } defer gitRepo.Close() diff --git a/modules/repository/generate.go b/modules/repository/generate.go index f8478b8c18..b32c4e058e 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -19,6 +19,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/util" @@ -271,7 +272,7 @@ func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *r repo.DefaultBranch = templateRepo.DefaultBranch } - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { return fmt.Errorf("openRepository: %w", err) } diff --git a/modules/repository/repo.go b/modules/repository/repo.go index 5352da0378..fc3af04071 100644 --- a/modules/repository/repo.go +++ b/modules/repository/repo.go @@ -19,6 +19,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/migration" @@ -291,7 +292,7 @@ func SyncRepoTags(ctx context.Context, repoID int64) error { return err } - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { return err } diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index edbfbcc568..bd02a8afc4 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -16,6 +16,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" repo_module "code.gitea.io/gitea/modules/repository" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" @@ -643,7 +644,7 @@ func CreateBranchProtection(ctx *context.APIContext) { } else { if !isPlainRule { if ctx.Repo.GitRepo == nil { - ctx.Repo.GitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.RepoPath()) + ctx.Repo.GitRepo, err = gitrepo.OpenRepository(ctx, ctx.Repo.Repository) if err != nil { ctx.Error(http.StatusInternalServerError, "OpenRepository", err) return @@ -920,7 +921,7 @@ func EditBranchProtection(ctx *context.APIContext) { } else { if !isPlainRule { if ctx.Repo.GitRepo == nil { - ctx.Repo.GitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.RepoPath()) + ctx.Repo.GitRepo, err = gitrepo.OpenRepository(ctx, ctx.Repo.Repository) if err != nil { ctx.Error(http.StatusInternalServerError, "OpenRepository", err) return diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 94e634461c..065d6bf8b2 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/httpcache" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" @@ -279,9 +280,8 @@ func GetArchive(ctx *context.APIContext) { // "404": // "$ref": "#/responses/notFound" - repoPath := repo_model.RepoPath(ctx.Params(":username"), ctx.Params(":reponame")) if ctx.Repo.GitRepo == nil { - gitRepo, err := git.OpenRepository(ctx, repoPath) + gitRepo, err := gitrepo.OpenRepository(ctx, ctx.Repo.Repository) if err != nil { ctx.Error(http.StatusInternalServerError, "OpenRepository", err) return diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index b1cb7011f1..eaf406e64d 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -23,6 +23,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -906,9 +907,9 @@ func MergePullRequest(ctx *context.APIContext) { if ctx.Repo != nil && ctx.Repo.Repository != nil && ctx.Repo.Repository.ID == pr.HeadRepoID && ctx.Repo.GitRepo != nil { headRepo = ctx.Repo.GitRepo } else { - headRepo, err = git.OpenRepository(ctx, pr.HeadRepo.RepoPath()) + headRepo, err = gitrepo.OpenRepository(ctx, pr.HeadRepo) if err != nil { - ctx.ServerError(fmt.Sprintf("OpenRepository[%s]", pr.HeadRepo.RepoPath()), err) + ctx.ServerError(fmt.Sprintf("OpenRepository[%s]", pr.HeadRepo.FullName()), err) return } defer headRepo.Close() @@ -1004,7 +1005,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption) headRepo = ctx.Repo.Repository headGitRepo = ctx.Repo.GitRepo } else { - headGitRepo, err = git.OpenRepository(ctx, repo_model.RepoPath(headUser.Name, headRepo.Name)) + headGitRepo, err = gitrepo.OpenRepository(ctx, headRepo) if err != nil { ctx.Error(http.StatusInternalServerError, "OpenRepository", err) return nil, nil, nil, nil, "", "" @@ -1308,7 +1309,7 @@ func GetPullRequestCommits(ctx *context.APIContext) { } var prInfo *git.CompareInfo - baseGitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.BaseRepo.RepoPath()) + baseGitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.BaseRepo) if err != nil { ctx.ServerError("OpenRepository", err) return diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go index 7b9445be4c..07d8f4877b 100644 --- a/routers/api/v1/repo/pull_review.go +++ b/routers/api/v1/repo/pull_review.go @@ -13,7 +13,7 @@ import ( access_model "code.gitea.io/gitea/models/perm/access" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/routers/api/v1/utils" @@ -329,8 +329,7 @@ func CreatePullReview(ctx *context.APIContext) { // if CommitID is empty, set it as lastCommitID if opts.CommitID == "" { - - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.Issue.Repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.Issue.Repo) if err != nil { ctx.Error(http.StatusInternalServerError, "git.OpenRepository", err) return diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 436b83adf2..2efdccb569 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -21,6 +21,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/label" "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" @@ -718,7 +719,7 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err if ctx.Repo.GitRepo == nil && !repo.IsEmpty { var err error - ctx.Repo.GitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.RepoPath()) + ctx.Repo.GitRepo, err = gitrepo.OpenRepository(ctx, ctx.Repo.Repository) if err != nil { ctx.Error(http.StatusInternalServerError, "Unable to OpenRepository", err) return err diff --git a/routers/api/v1/repo/wiki.go b/routers/api/v1/repo/wiki.go index 8e5ecce310..ba3e978a83 100644 --- a/routers/api/v1/repo/wiki.go +++ b/routers/api/v1/repo/wiki.go @@ -12,6 +12,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" @@ -475,7 +476,7 @@ func findEntryForFile(commit *git.Commit, target string) (*git.TreeEntry, error) // findWikiRepoCommit opens the wiki repo and returns the latest commit, writing to context on error. // The caller is responsible for closing the returned repo again func findWikiRepoCommit(ctx *context.APIContext) (*git.Repository, *git.Commit) { - wikiRepo, err := git.OpenRepository(ctx, ctx.Repo.Repository.WikiPath()) + wikiRepo, err := gitrepo.OpenWikiRepository(ctx, ctx.Repo.Repository) if err != nil { if git.IsErrNotExist(err) || err.Error() == "no such file or directory" { diff --git a/routers/api/v1/utils/git.go b/routers/api/v1/utils/git.go index 39714e343f..2299cdc247 100644 --- a/routers/api/v1/utils/git.go +++ b/routers/api/v1/utils/git.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" ) @@ -79,7 +80,7 @@ func ConvertToObjectID(ctx gocontext.Context, repo *context.Repository, commitID } } - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.Repository.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo.Repository) if err != nil { return objectFormat.EmptyObjectID(), fmt.Errorf("RepositoryFromContextOrOpen: %w", err) } diff --git a/routers/private/internal_repo.go b/routers/private/internal_repo.go index 5e7e82b03c..615239d479 100644 --- a/routers/private/internal_repo.go +++ b/routers/private/internal_repo.go @@ -10,7 +10,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" gitea_context "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/private" ) @@ -28,7 +28,7 @@ func RepoAssignment(ctx *gitea_context.PrivateContext) context.CancelFunc { return nil } - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { log.Error("Failed to open repository: %s/%s Error: %v", ownerName, repoName, err) ctx.JSON(http.StatusInternalServerError, private.Response{ diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 00157d44c9..32fa973ef6 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -22,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/gitgraph" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/setting" @@ -279,7 +280,7 @@ func Diff(ctx *context.Context) { ) if ctx.Data["PageIsWiki"] != nil { - gitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.WikiPath()) + gitRepo, err = gitrepo.OpenWikiRepository(ctx, ctx.Repo.Repository) if err != nil { ctx.ServerError("Repo.GitRepo.GetCommit", err) return @@ -404,7 +405,7 @@ func Diff(ctx *context.Context) { func RawDiff(ctx *context.Context) { var gitRepo *git.Repository if ctx.Data["PageIsWiki"] != nil { - wikiRepo, err := git.OpenRepository(ctx, ctx.Repo.Repository.WikiPath()) + wikiRepo, err := gitrepo.OpenWikiRepository(ctx, ctx.Repo.Repository) if err != nil { ctx.ServerError("OpenRepository", err) return diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 5ae48e1ce8..a3593815b8 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -28,6 +28,7 @@ import ( "code.gitea.io/gitea/modules/context" csv_module "code.gitea.io/gitea/modules/csv" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/setting" @@ -408,7 +409,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo { ci.HeadRepo = ctx.Repo.Repository ci.HeadGitRepo = ctx.Repo.GitRepo } else if has { - ci.HeadGitRepo, err = git.OpenRepository(ctx, ci.HeadRepo.RepoPath()) + ci.HeadGitRepo, err = gitrepo.OpenRepository(ctx, ci.HeadRepo) if err != nil { ctx.ServerError("OpenRepository", err) return nil @@ -688,7 +689,7 @@ func PrepareCompareDiff( } func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repository) (branches, tags []string, err error) { - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { return nil, nil, err } @@ -876,7 +877,7 @@ func ExcerptBlob(ctx *context.Context) { gitRepo := ctx.Repo.GitRepo if ctx.FormBool("wiki") { var err error - gitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.WikiPath()) + gitRepo, err = gitrepo.OpenWikiRepository(ctx, ctx.Repo.Repository) if err != nil { ctx.ServerError("OpenRepository", err) return diff --git a/routers/web/repo/editor_test.go b/routers/web/repo/editor_test.go index 67fb277d5c..c28c3ef1d6 100644 --- a/routers/web/repo/editor_test.go +++ b/routers/web/repo/editor_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/contexttest" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "github.com/stretchr/testify/assert" ) @@ -66,7 +67,7 @@ func TestGetClosestParentWithFiles(t *testing.T) { repo := ctx.Repo.Repository branch := repo.DefaultBranch - gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(git.DefaultContext, repo) defer gitRepo.Close() commit, _ := gitRepo.GetBranchCommit(branch) var expectedTreePath string // Should return the root dir, empty string, since there are no subdirs in this repo diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index e36d7092af..b265cf4754 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -29,6 +29,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" issue_template "code.gitea.io/gitea/modules/issue/template" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -530,7 +531,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C if pull.BaseRepoID == ctx.Repo.Repository.ID && ctx.Repo.GitRepo != nil { baseGitRepo = ctx.Repo.GitRepo } else { - baseGitRepo, err := git.OpenRepository(ctx, pull.BaseRepo.RepoPath()) + baseGitRepo, err := gitrepo.OpenRepository(ctx, pull.BaseRepo) if err != nil { ctx.ServerError("OpenRepository", err) return nil @@ -582,7 +583,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C var headBranchSha string // HeadRepo may be missing if pull.HeadRepo != nil { - headGitRepo, err := git.OpenRepository(ctx, pull.HeadRepo.RepoPath()) + headGitRepo, err := gitrepo.OpenRepository(ctx, pull.HeadRepo) if err != nil { ctx.ServerError("OpenRepository", err) return nil @@ -1314,9 +1315,9 @@ func MergePullRequest(ctx *context.Context) { if ctx.Repo != nil && ctx.Repo.Repository != nil && pr.HeadRepoID == ctx.Repo.Repository.ID && ctx.Repo.GitRepo != nil { headRepo = ctx.Repo.GitRepo } else { - headRepo, err = git.OpenRepository(ctx, pr.HeadRepo.RepoPath()) + headRepo, err = gitrepo.OpenRepository(ctx, pr.HeadRepo) if err != nil { - ctx.ServerError(fmt.Sprintf("OpenRepository[%s]", pr.HeadRepo.RepoPath()), err) + ctx.ServerError(fmt.Sprintf("OpenRepository[%s]", pr.HeadRepo.FullName()), err) return } defer headRepo.Close() @@ -1537,9 +1538,9 @@ func CleanUpPullRequest(ctx *context.Context) { gitBaseRepo = ctx.Repo.GitRepo } else { // If not just open it - gitBaseRepo, err = git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + gitBaseRepo, err = gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { - ctx.ServerError(fmt.Sprintf("OpenRepository[%s]", pr.BaseRepo.RepoPath()), err) + ctx.ServerError(fmt.Sprintf("OpenRepository[%s]", pr.BaseRepo.FullName()), err) return } defer gitBaseRepo.Close() @@ -1552,9 +1553,9 @@ func CleanUpPullRequest(ctx *context.Context) { gitRepo = ctx.Repo.GitRepo } else if pr.BaseRepoID != pr.HeadRepoID { // Otherwise just load it up - gitRepo, err = git.OpenRepository(ctx, pr.HeadRepo.RepoPath()) + gitRepo, err = gitrepo.OpenRepository(ctx, pr.HeadRepo) if err != nil { - ctx.ServerError(fmt.Sprintf("OpenRepository[%s]", pr.HeadRepo.RepoPath()), err) + ctx.ServerError(fmt.Sprintf("OpenRepository[%s]", pr.HeadRepo.FullName()), err) return } defer gitRepo.Close() diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go index 4e09f046cf..5e7b971e67 100644 --- a/routers/web/repo/wiki.go +++ b/routers/web/repo/wiki.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/modules/charset" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" @@ -92,7 +93,7 @@ func findEntryForFile(commit *git.Commit, target string) (*git.TreeEntry, error) } func findWikiRepoCommit(ctx *context.Context) (*git.Repository, *git.Commit, error) { - wikiRepo, err := git.OpenRepository(ctx, ctx.Repo.Repository.WikiPath()) + wikiRepo, err := gitrepo.OpenWikiRepository(ctx, ctx.Repo.Repository) if err != nil { ctx.ServerError("OpenRepository", err) return nil, nil, err diff --git a/routers/web/repo/wiki_test.go b/routers/web/repo/wiki_test.go index ae050df967..d3decdae2d 100644 --- a/routers/web/repo/wiki_test.go +++ b/routers/web/repo/wiki_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/contexttest" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/services/forms" wiki_service "code.gitea.io/gitea/services/wiki" @@ -26,7 +27,7 @@ const ( ) func wikiEntry(t *testing.T, repo *repo_model.Repository, wikiName wiki_service.WebPath) *git.TreeEntry { - wikiRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) + wikiRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo) assert.NoError(t, err) defer wikiRepo.Close() commit, err := wikiRepo.GetBranchCommit("master") diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go index 0f8d64e7b2..a2c0abb47e 100644 --- a/routers/web/shared/user/header.go +++ b/routers/web/shared/user/header.go @@ -13,6 +13,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" @@ -90,7 +91,7 @@ func FindUserProfileReadme(ctx *context.Context, doer *user_model.User) (profile if err == nil { perm, err := access_model.GetUserRepoPermission(ctx, profileDbRepo, doer) if err == nil && !profileDbRepo.IsEmpty && perm.CanRead(unit.TypeCode) { - if profileGitRepo, err = git.OpenRepository(ctx, profileDbRepo.RepoPath()); err != nil { + if profileGitRepo, err = gitrepo.OpenRepository(ctx, profileDbRepo); err != nil { log.Error("FindUserProfileReadme failed to OpenRepository: %v", err) } else { if commit, err := profileGitRepo.GetBranchCommit(profileDbRepo.DefaultBranch); err != nil { diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 2a3ffb76f3..9900de3d2e 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -20,6 +20,7 @@ import ( user_model "code.gitea.io/gitea/models/user" actions_module "code.gitea.io/gitea/modules/actions" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -128,7 +129,7 @@ func notify(ctx context.Context, input *notifyInput) error { return nil } - gitRepo, err := git.OpenRepository(context.Background(), input.Repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(context.Background(), input.Repo) if err != nil { return fmt.Errorf("git.OpenRepository: %w", err) } diff --git a/services/asymkey/sign.go b/services/asymkey/sign.go index 0c4aac8156..2f5d76a293 100644 --- a/services/asymkey/sign.go +++ b/services/asymkey/sign.go @@ -13,8 +13,10 @@ import ( "code.gitea.io/gitea/models/db" git_model "code.gitea.io/gitea/models/git" issues_model "code.gitea.io/gitea/models/issues" + repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" @@ -167,7 +169,8 @@ Loop: } // SignWikiCommit determines if we should sign the commits to this repository wiki -func SignWikiCommit(ctx context.Context, repoWikiPath string, u *user_model.User) (bool, string, *git.Signature, error) { +func SignWikiCommit(ctx context.Context, repo *repo_model.Repository, u *user_model.User) (bool, string, *git.Signature, error) { + repoWikiPath := repo.WikiPath() rules := signingModeFromStrings(setting.Repository.Signing.Wiki) signingKey, sig := SigningKey(ctx, repoWikiPath) if signingKey == "" { @@ -201,7 +204,7 @@ Loop: return false, "", nil, &ErrWontSign{twofa} } case parentSigned: - gitRepo, err := git.OpenRepository(ctx, repoWikiPath) + gitRepo, err := gitrepo.OpenWikiRepository(ctx, repo) if err != nil { return false, "", nil, err } diff --git a/services/automerge/automerge.go b/services/automerge/automerge.go index bf713c4431..bd427bef9f 100644 --- a/services/automerge/automerge.go +++ b/services/automerge/automerge.go @@ -17,6 +17,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -111,7 +112,7 @@ func MergeScheduledPullRequest(ctx context.Context, sha string, repo *repo_model } func getPullRequestsByHeadSHA(ctx context.Context, sha string, repo *repo_model.Repository, filter func(*issues_model.PullRequest) bool) (map[int64]*issues_model.PullRequest, error) { - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { return nil, err } @@ -190,7 +191,7 @@ func handlePull(pullID int64, sha string) { return } - headGitRepo, err := git.OpenRepository(ctx, pr.HeadRepo.RepoPath()) + headGitRepo, err := gitrepo.OpenRepository(ctx, pr.HeadRepo) if err != nil { log.Error("OpenRepository %-v: %v", pr.HeadRepo, err) return @@ -246,7 +247,7 @@ func handlePull(pullID int64, sha string) { return } - baseGitRepo, err = git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + baseGitRepo, err = gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { log.Error("OpenRepository %-v: %v", pr.BaseRepo, err) return diff --git a/services/convert/pull.go b/services/convert/pull.go index 7eebe20426..6d98121ed5 100644 --- a/services/convert/pull.go +++ b/services/convert/pull.go @@ -12,6 +12,7 @@ import ( access_model "code.gitea.io/gitea/models/perm/access" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" api "code.gitea.io/gitea/modules/structs" ) @@ -101,7 +102,7 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u apiPullRequest.Closed = pr.Issue.ClosedUnix.AsTimePtr() } - gitRepo, err := git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { log.Error("OpenRepository[%s]: %v", pr.BaseRepo.RepoPath(), err) return nil @@ -127,7 +128,7 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u } if pr.Flow == issues_model.PullRequestFlowAGit { - gitRepo, err := git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { log.Error("OpenRepository[%s]: %v", pr.GetGitRefName(), err) return nil @@ -154,7 +155,7 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u apiPullRequest.Head.RepoID = pr.HeadRepo.ID apiPullRequest.Head.Repository = ToRepo(ctx, pr.HeadRepo, p) - headGitRepo, err := git.OpenRepository(ctx, pr.HeadRepo.RepoPath()) + headGitRepo, err := gitrepo.OpenRepository(ctx, pr.HeadRepo) if err != nil { log.Error("OpenRepository[%s]: %v", pr.HeadRepo.RepoPath(), err) return nil @@ -190,7 +191,7 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u } if len(apiPullRequest.Head.Sha) == 0 && len(apiPullRequest.Head.Ref) != 0 { - baseGitRepo, err := git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + baseGitRepo, err := gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { log.Error("OpenRepository[%s]: %v", pr.BaseRepo.RepoPath(), err) return nil diff --git a/services/doctor/misc.go b/services/doctor/misc.go index f0b5966b54..9300c3a25c 100644 --- a/services/doctor/misc.go +++ b/services/doctor/misc.go @@ -16,6 +16,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" @@ -91,7 +92,7 @@ func checkEnablePushOptions(ctx context.Context, logger log.Logger, autofix bool if err := iterateRepositories(ctx, func(repo *repo_model.Repository) error { numRepos++ - r, err := git.OpenRepository(ctx, repo.RepoPath()) + r, err := gitrepo.OpenRepository(ctx, repo) if err != nil { return err } diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index 5a4392c667..7b21d9f4d2 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -21,6 +21,7 @@ import ( user_model "code.gitea.io/gitea/models/user" base_module "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/label" "code.gitea.io/gitea/modules/log" base "code.gitea.io/gitea/modules/migration" @@ -139,7 +140,7 @@ func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.Migrate if err != nil { return err } - g.gitRepo, err = git.OpenRepository(g.ctx, r.RepoPath()) + g.gitRepo, err = gitrepo.OpenRepository(g.ctx, r) return err } diff --git a/services/migrations/gitea_uploader_test.go b/services/migrations/gitea_uploader_test.go index 4ec0361dfb..c8102c6b8b 100644 --- a/services/migrations/gitea_uploader_test.go +++ b/services/migrations/gitea_uploader_test.go @@ -19,6 +19,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" base "code.gitea.io/gitea/modules/migration" @@ -249,7 +250,7 @@ func TestGiteaUploadUpdateGitForPullRequest(t *testing.T) { Author: &signature, Message: "Initial Commit", })) - fromGitRepo, err := git.OpenRepository(git.DefaultContext, fromRepo.RepoPath()) + fromGitRepo, err := gitrepo.OpenRepository(git.DefaultContext, fromRepo) assert.NoError(t, err) defer fromGitRepo.Close() baseSHA, err := fromGitRepo.GetBranchCommitID(baseRef) @@ -292,7 +293,7 @@ func TestGiteaUploadUpdateGitForPullRequest(t *testing.T) { Author: &signature, Message: "branch2 commit", })) - forkGitRepo, err := git.OpenRepository(git.DefaultContext, forkRepo.RepoPath()) + forkGitRepo, err := gitrepo.OpenRepository(git.DefaultContext, forkRepo) assert.NoError(t, err) defer forkGitRepo.Close() forkHeadSHA, err := forkGitRepo.GetBranchCommitID(forkHeadRef) diff --git a/services/mirror/mirror_pull.go b/services/mirror/mirror_pull.go index 6f03e14ab0..3418cf90df 100644 --- a/services/mirror/mirror_pull.go +++ b/services/mirror/mirror_pull.go @@ -13,6 +13,7 @@ import ( system_model "code.gitea.io/gitea/models/system" "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -300,7 +301,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo log.Error("SyncMirrors [repo: %-v]: %v", m.Repo, err) } - gitRepo, err := git.OpenRepository(ctx, repoPath) + gitRepo, err := gitrepo.OpenRepository(ctx, m.Repo) if err != nil { log.Error("SyncMirrors [repo: %-v]: failed to OpenRepository: %v", m.Repo, err) return nil, false @@ -396,7 +397,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo } log.Trace("SyncMirrors [repo: %-v]: invalidating mirror branch caches...", m.Repo) - branches, _, err := git.GetBranchesByPath(ctx, m.Repo.RepoPath(), 0, 0) + branches, _, err := gitrepo.GetBranchesByPath(ctx, m.Repo, 0, 0) if err != nil { log.Error("SyncMirrors [repo: %-v]: failed to GetBranches: %v", m.Repo, err) return nil, false @@ -453,7 +454,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool { log.Trace("SyncMirrors [repo: %-v]: no branches updated", m.Repo) } else { log.Trace("SyncMirrors [repo: %-v]: %d branches updated", m.Repo, len(results)) - gitRepo, err = git.OpenRepository(ctx, m.Repo.RepoPath()) + gitRepo, err = gitrepo.OpenRepository(ctx, m.Repo) if err != nil { log.Error("SyncMirrors [repo: %-v]: unable to OpenRepository: %v", m.Repo, err) return false diff --git a/services/mirror/mirror_push.go b/services/mirror/mirror_push.go index b117e79fac..21ba0afeff 100644 --- a/services/mirror/mirror_push.go +++ b/services/mirror/mirror_push.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -131,7 +132,11 @@ func SyncPushMirror(ctx context.Context, mirrorID int64) bool { func runPushSync(ctx context.Context, m *repo_model.PushMirror) error { timeout := time.Duration(setting.Git.Timeout.Mirror) * time.Second - performPush := func(path string) error { + performPush := func(repo *repo_model.Repository, isWiki bool) error { + path := repo.RepoPath() + if isWiki { + path = repo.WikiPath() + } remoteURL, err := git.GetRemoteURL(ctx, path, m.RemoteName) if err != nil { log.Error("GetRemoteAddress(%s) Error %v", path, err) @@ -141,7 +146,12 @@ func runPushSync(ctx context.Context, m *repo_model.PushMirror) error { if setting.LFS.StartServer { log.Trace("SyncMirrors [repo: %-v]: syncing LFS objects...", m.Repo) - gitRepo, err := git.OpenRepository(ctx, path) + var gitRepo *git.Repository + if isWiki { + gitRepo, err = gitrepo.OpenWikiRepository(ctx, repo) + } else { + gitRepo, err = gitrepo.OpenRepository(ctx, repo) + } if err != nil { log.Error("OpenRepository: %v", err) return errors.New("Unexpected error") @@ -171,16 +181,15 @@ func runPushSync(ctx context.Context, m *repo_model.PushMirror) error { return nil } - err := performPush(m.Repo.RepoPath()) + err := performPush(m.Repo, false) if err != nil { return err } if m.Repo.HasWiki() { - wikiPath := m.Repo.WikiPath() - _, err := git.GetRemoteAddress(ctx, wikiPath, m.RemoteName) + _, err := git.GetRemoteAddress(ctx, m.Repo.WikiPath(), m.RemoteName) if err == nil { - err := performPush(wikiPath) + err := performPush(m.Repo, true) if err != nil { return err } diff --git a/services/pull/check.go b/services/pull/check.go index ebe4c6d61b..dd6c3ed230 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -20,6 +20,7 @@ import ( "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/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -215,7 +216,7 @@ func getMergeCommit(ctx context.Context, pr *issues_model.PullRequest) (*git.Com return nil, fmt.Errorf("GetFullCommitID(%s) in %s: %w", prHeadRef, pr.BaseRepo.FullName(), err) } - gitRepo, err := git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { return nil, fmt.Errorf("%-v OpenRepository: %w", pr.BaseRepo, err) } diff --git a/services/pull/comment.go b/services/pull/comment.go index 14fba52f1e..d538b118d5 100644 --- a/services/pull/comment.go +++ b/services/pull/comment.go @@ -9,7 +9,7 @@ import ( issues_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/json" ) @@ -17,8 +17,7 @@ import ( // isForcePush will be true if oldCommit isn't on the branch // Commit on baseBranch will skip func getCommitIDsFromRepo(ctx context.Context, repo *repo_model.Repository, oldCommitID, newCommitID, baseBranch string) (commitIDs []string, isForcePush bool, err error) { - repoPath := repo.RepoPath() - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repoPath) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return nil, false, err } diff --git a/services/pull/commit_status.go b/services/pull/commit_status.go index 39d60380ff..b73816c7eb 100644 --- a/services/pull/commit_status.go +++ b/services/pull/commit_status.go @@ -11,6 +11,7 @@ import ( git_model "code.gitea.io/gitea/models/git" issues_model "code.gitea.io/gitea/models/issues" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/structs" @@ -116,7 +117,7 @@ func GetPullRequestCommitStatusState(ctx context.Context, pr *issues_model.PullR } // check if all required status checks are successful - headGitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.HeadRepo.RepoPath()) + headGitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.HeadRepo) if err != nil { return "", errors.Wrap(err, "OpenRepository") } diff --git a/services/pull/merge_rebase.go b/services/pull/merge_rebase.go index a88f805ef0..ecf376220e 100644 --- a/services/pull/merge_rebase.go +++ b/services/pull/merge_rebase.go @@ -9,6 +9,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" ) @@ -57,7 +58,7 @@ func doMergeRebaseFastForward(ctx *mergeContext) error { } // Original repo to read template from. - baseGitRepo, err := git.OpenRepository(ctx, ctx.pr.BaseRepo.RepoPath()) + baseGitRepo, err := gitrepo.OpenRepository(ctx, ctx.pr.BaseRepo) if err != nil { log.Error("Unable to get Git repo for rebase: %v", err) return err diff --git a/services/pull/merge_squash.go b/services/pull/merge_squash.go index f52a2301d9..197d8102dd 100644 --- a/services/pull/merge_squash.go +++ b/services/pull/merge_squash.go @@ -10,6 +10,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" ) @@ -24,7 +25,7 @@ func getAuthorSignatureSquash(ctx *mergeContext) (*git.Signature, error) { // Try to get an signature from the same user in one of the commits, as the // poster email might be private or commits might have a different signature // than the primary email address of the poster. - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, ctx.tmpBasePath) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpenPath(ctx, ctx.tmpBasePath) if err != nil { log.Error("%-v Unable to open base repository: %v", ctx.pr, err) return nil, err diff --git a/services/pull/patch.go b/services/pull/patch.go index acaff04bda..12b79a0625 100644 --- a/services/pull/patch.go +++ b/services/pull/patch.go @@ -19,6 +19,7 @@ import ( "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -35,7 +36,7 @@ func DownloadDiffOrPatch(ctx context.Context, pr *issues_model.PullRequest, w io return err } - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.BaseRepo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.BaseRepo) if err != nil { return fmt.Errorf("OpenRepository: %w", err) } diff --git a/services/pull/pull.go b/services/pull/pull.go index 930954bdfd..e1ea4357fc 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -23,6 +23,7 @@ import ( "code.gitea.io/gitea/modules/container" gitea_context "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" @@ -62,7 +63,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *iss assigneeCommentMap := make(map[int64]*issues_model.Comment) // add first push codes comment - baseGitRepo, err := git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + baseGitRepo, err := gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { return err } @@ -269,9 +270,9 @@ func checkForInvalidation(ctx context.Context, requests issues_model.PullRequest if err != nil { return fmt.Errorf("GetRepositoryByIDCtx: %w", err) } - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { - return fmt.Errorf("git.OpenRepository: %w", err) + return fmt.Errorf("gitrepo.OpenRepository: %w", err) } go func() { // FIXME: graceful: We need to tell the manager we're doing something... @@ -614,7 +615,7 @@ func CloseBranchPulls(ctx context.Context, doer *user_model.User, repoID int64, // CloseRepoBranchesPulls close all pull requests which head branches are in the given repository, but only whose base repo is not in the given repository func CloseRepoBranchesPulls(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) error { - branches, _, err := git.GetBranchesByPath(ctx, repo.RepoPath(), 0, 0) + branches, _, err := gitrepo.GetBranchesByPath(ctx, repo, 0, 0) if err != nil { return err } @@ -671,7 +672,7 @@ func GetSquashMergeCommitMessages(ctx context.Context, pr *issues_model.PullRequ } } - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.HeadRepo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.HeadRepo) if err != nil { log.Error("Unable to open head repository: Error: %v", err) return "" @@ -845,7 +846,7 @@ func GetIssuesAllCommitStatus(ctx context.Context, issues issues_model.IssueList } gitRepo, ok := gitRepos[issue.RepoID] if !ok { - gitRepo, err = git.OpenRepository(ctx, issue.Repo.RepoPath()) + gitRepo, err = gitrepo.OpenRepository(ctx, issue.Repo) if err != nil { log.Error("Cannot open git repository %-v for issue #%d[%d]. Error: %v", issue.Repo, issue.Index, issue.ID, err) continue @@ -882,7 +883,7 @@ func IsHeadEqualWithBranch(ctx context.Context, pr *issues_model.PullRequest, br if err = pr.LoadBaseRepo(ctx); err != nil { return false, err } - baseGitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.BaseRepo.RepoPath()) + baseGitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.BaseRepo) if err != nil { return false, err } @@ -902,7 +903,7 @@ func IsHeadEqualWithBranch(ctx context.Context, pr *issues_model.PullRequest, br } else { var closer io.Closer - headGitRepo, closer, err = git.RepositoryFromContextOrOpen(ctx, pr.HeadRepo.RepoPath()) + headGitRepo, closer, err = gitrepo.RepositoryFromContextOrOpen(ctx, pr.HeadRepo) if err != nil { return false, err } diff --git a/services/pull/pull_test.go b/services/pull/pull_test.go index d63227a7d5..787910bf76 100644 --- a/services/pull/pull_test.go +++ b/services/pull/pull_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "github.com/stretchr/testify/assert" ) @@ -41,7 +42,7 @@ func TestPullRequest_GetDefaultMergeMessage_InternalTracker(t *testing.T) { pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2}) assert.NoError(t, pr.LoadBaseRepo(db.DefaultContext)) - gitRepo, err := git.OpenRepository(git.DefaultContext, pr.BaseRepo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, pr.BaseRepo) assert.NoError(t, err) defer gitRepo.Close() @@ -71,7 +72,7 @@ func TestPullRequest_GetDefaultMergeMessage_ExternalTracker(t *testing.T) { pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2, BaseRepo: baseRepo}) assert.NoError(t, pr.LoadBaseRepo(db.DefaultContext)) - gitRepo, err := git.OpenRepository(git.DefaultContext, pr.BaseRepo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, pr.BaseRepo) assert.NoError(t, err) defer gitRepo.Close() diff --git a/services/pull/review.go b/services/pull/review.go index e48f380154..d4ea975612 100644 --- a/services/pull/review.go +++ b/services/pull/review.go @@ -16,6 +16,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" @@ -170,7 +171,7 @@ func createCodeComment(ctx context.Context, doer *user_model.User, repo *repo_mo if err := pr.LoadBaseRepo(ctx); err != nil { return nil, fmt.Errorf("LoadBaseRepo: %w", err) } - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, pr.BaseRepo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, pr.BaseRepo) if err != nil { return nil, fmt.Errorf("RepositoryFromContextOrOpen: %w", err) } diff --git a/services/release/release.go b/services/release/release.go index f17682ae0f..c1d13126f0 100644 --- a/services/release/release.go +++ b/services/release/release.go @@ -16,6 +16,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/repository" @@ -168,7 +169,7 @@ func CreateNewTag(ctx context.Context, doer *user_model.User, repo *repo_model.R } } - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return err } diff --git a/services/release/release_test.go b/services/release/release_test.go index 4b57262981..3d0681f1e1 100644 --- a/services/release/release_test.go +++ b/services/release/release_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/services/attachment" _ "code.gitea.io/gitea/models/actions" @@ -29,9 +30,8 @@ func TestRelease_Create(t *testing.T) { user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) - repoPath := repo_model.RepoPath(user.Name, repo.Name) - gitRepo, err := git.OpenRepository(git.DefaultContext, repoPath) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo) assert.NoError(t, err) defer gitRepo.Close() @@ -135,9 +135,8 @@ func TestRelease_Update(t *testing.T) { user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) - repoPath := repo_model.RepoPath(user.Name, repo.Name) - gitRepo, err := git.OpenRepository(git.DefaultContext, repoPath) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo) assert.NoError(t, err) defer gitRepo.Close() @@ -278,9 +277,8 @@ func TestRelease_createTag(t *testing.T) { user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) - repoPath := repo_model.RepoPath(user.Name, repo.Name) - gitRepo, err := git.OpenRepository(git.DefaultContext, repoPath) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo) assert.NoError(t, err) defer gitRepo.Close() diff --git a/services/repository/adopt.go b/services/repository/adopt.go index 2e9b0c822f..bfb965063f 100644 --- a/services/repository/adopt.go +++ b/services/repository/adopt.go @@ -17,6 +17,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" @@ -126,7 +127,7 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r repo.IsEmpty = false // Don't bother looking this repo in the context it won't be there - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { return fmt.Errorf("openRepository: %w", err) } diff --git a/services/repository/archiver/archiver.go b/services/repository/archiver/archiver.go index c2ad4d484a..01c58f0ce4 100644 --- a/services/repository/archiver/archiver.go +++ b/services/repository/archiver/archiver.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -209,7 +210,7 @@ func doArchive(ctx context.Context, r *ArchiveRequest) (*repo_model.RepoArchiver return nil, fmt.Errorf("archiver.LoadRepo failed: %w", err) } - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { return nil, err } diff --git a/services/repository/branch.go b/services/repository/branch.go index c1e6625ed4..e2e50297af 100644 --- a/services/repository/branch.go +++ b/services/repository/branch.go @@ -17,6 +17,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/queue" @@ -160,7 +161,7 @@ func loadOneBranch(ctx context.Context, repo *repo_model.Repository, dbBranch *g if pr.HasMerged { baseGitRepo, ok := repoIDToGitRepo[pr.BaseRepoID] if !ok { - baseGitRepo, err = git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) + baseGitRepo, err = gitrepo.OpenRepository(ctx, pr.BaseRepo) if err != nil { return nil, fmt.Errorf("OpenRepository: %v", err) } @@ -190,13 +191,9 @@ func loadOneBranch(ctx context.Context, repo *repo_model.Repository, dbBranch *g }, nil } -func GetBranchCommitID(ctx context.Context, repo *repo_model.Repository, branch string) (string, error) { - return git.GetBranchCommitID(ctx, repo.RepoPath(), branch) -} - // checkBranchName validates branch name with existing repository branches func checkBranchName(ctx context.Context, repo *repo_model.Repository, name string) error { - _, err := git.WalkReferences(ctx, repo.RepoPath(), func(_, refName string) error { + _, err := gitrepo.WalkReferences(ctx, repo, func(_, refName string) error { branchRefName := strings.TrimPrefix(refName, git.BranchPrefix) switch { case branchRefName == name: diff --git a/services/repository/create.go b/services/repository/create.go index 0e89573343..a648c0d816 100644 --- a/services/repository/create.go +++ b/services/repository/create.go @@ -16,6 +16,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/options" repo_module "code.gitea.io/gitea/modules/repository" @@ -175,7 +176,7 @@ func initRepository(ctx context.Context, repoPath string, u *user_model.User, re if len(opts.DefaultBranch) > 0 { repo.DefaultBranch = opts.DefaultBranch - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { return fmt.Errorf("openRepository: %w", err) } diff --git a/services/repository/files/commit.go b/services/repository/files/commit.go index 048e41e6fd..16a15e06a7 100644 --- a/services/repository/files/commit.go +++ b/services/repository/files/commit.go @@ -12,6 +12,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/services/automerge" ) @@ -23,7 +24,7 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, creato repoPath := repo.RepoPath() // confirm that commit is exist - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return fmt.Errorf("OpenRepository[%s]: %w", repoPath, err) } diff --git a/services/repository/files/content.go b/services/repository/files/content.go index 30d62fbcdf..c278d7f835 100644 --- a/services/repository/files/content.go +++ b/services/repository/files/content.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" @@ -58,7 +59,7 @@ func GetContentsOrList(ctx context.Context, repo *repo_model.Repository, treePat } treePath = cleanTreePath - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return nil, err } @@ -133,7 +134,7 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref } treePath = cleanTreePath - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return nil, err } diff --git a/services/repository/files/content_test.go b/services/repository/files/content_test.go index 3ad3e3ab98..d50847789a 100644 --- a/services/repository/files/content_test.go +++ b/services/repository/files/content_test.go @@ -6,10 +6,9 @@ package files import ( "testing" - repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/contexttest" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" api "code.gitea.io/gitea/modules/structs" _ "code.gitea.io/gitea/models/actions" @@ -235,7 +234,7 @@ func TestGetBlobBySHA(t *testing.T) { ctx.SetParams(":id", "1") ctx.SetParams(":sha", sha) - gitRepo, err := git.OpenRepository(ctx, repo_model.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)) + gitRepo, err := gitrepo.OpenRepository(ctx, ctx.Repo.Repository) if err != nil { t.Fail() } diff --git a/services/repository/files/file_test.go b/services/repository/files/file_test.go index 4e67ad1410..675ddbddb3 100644 --- a/services/repository/files/file_test.go +++ b/services/repository/files/file_test.go @@ -8,7 +8,7 @@ import ( "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/contexttest" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -109,7 +109,7 @@ func TestGetFileResponseFromCommit(t *testing.T) { repo := ctx.Repo.Repository branch := repo.DefaultBranch treePath := "README.md" - gitRepo, _ := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(ctx, repo) defer gitRepo.Close() commit, _ := gitRepo.GetBranchCommit(branch) expectedFileResponse := getExpectedFileResponse() diff --git a/services/repository/files/patch.go b/services/repository/files/patch.go index 14f8caaa8c..f6d5643dc9 100644 --- a/services/repository/files/patch.go +++ b/services/repository/files/patch.go @@ -13,6 +13,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/structs" asymkey_service "code.gitea.io/gitea/services/asymkey" @@ -42,7 +43,7 @@ func (opts *ApplyDiffPatchOptions) Validate(ctx context.Context, repo *repo_mode opts.NewBranch = opts.OldBranch } - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return err } diff --git a/services/repository/files/update.go b/services/repository/files/update.go index 1892043304..f223daf3a9 100644 --- a/services/repository/files/update.go +++ b/services/repository/files/update.go @@ -16,6 +16,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -78,7 +79,7 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use opts.NewBranch = opts.OldBranch } - gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath()) + gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, repo) if err != nil { return nil, err } diff --git a/services/repository/fork.go b/services/repository/fork.go index a8ff2717b0..f9c13a109e 100644 --- a/services/repository/fork.go +++ b/services/repository/fork.go @@ -14,6 +14,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/structs" @@ -167,7 +168,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork return fmt.Errorf("createDelegateHooks: %w", err) } - gitRepo, err := git.OpenRepository(txCtx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(txCtx, repo) if err != nil { return fmt.Errorf("OpenRepository: %w", err) } @@ -190,7 +191,7 @@ func ForkRepository(ctx context.Context, doer, owner *user_model.User, opts Fork log.Error("Copy language stat from oldRepo failed: %v", err) } - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { log.Error("Open created git repository failed: %v", err) } else { diff --git a/services/repository/hooks.go b/services/repository/hooks.go index 7b82f36b43..97e9e290a3 100644 --- a/services/repository/hooks.go +++ b/services/repository/hooks.go @@ -10,7 +10,7 @@ import ( "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/webhook" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" @@ -52,13 +52,13 @@ func SyncRepositoryHooks(ctx context.Context) error { // GenerateGitHooks generates git hooks from a template repository func GenerateGitHooks(ctx context.Context, templateRepo, generateRepo *repo_model.Repository) error { - generateGitRepo, err := git.OpenRepository(ctx, generateRepo.RepoPath()) + generateGitRepo, err := gitrepo.OpenRepository(ctx, generateRepo) if err != nil { return err } defer generateGitRepo.Close() - templateGitRepo, err := git.OpenRepository(ctx, templateRepo.RepoPath()) + templateGitRepo, err := gitrepo.OpenRepository(ctx, templateRepo) if err != nil { return err } diff --git a/services/repository/lfs.go b/services/repository/lfs.go index b437fda15d..4504f796bd 100644 --- a/services/repository/lfs.go +++ b/services/repository/lfs.go @@ -12,6 +12,7 @@ import ( git_model "code.gitea.io/gitea/models/git" repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/lfs" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -69,7 +70,7 @@ func GarbageCollectLFSMetaObjectsForRepo(ctx context.Context, repo *repo_model.R } }() - gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { log.Error("Unable to open git repository %-v: %v", repo, err) return err diff --git a/services/repository/push.go b/services/repository/push.go index e86eebde81..bedcf6f252 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -16,6 +16,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" @@ -86,17 +87,15 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { return fmt.Errorf("GetRepositoryByOwnerAndName failed: %w", err) } - repoPath := repo.RepoPath() - - gitRepo, err := git.OpenRepository(ctx, repoPath) + gitRepo, err := gitrepo.OpenRepository(ctx, repo) if err != nil { - return fmt.Errorf("OpenRepository[%s]: %w", repoPath, err) + return fmt.Errorf("OpenRepository[%s]: %w", repo.FullName(), err) } defer gitRepo.Close() objectFormat, err := gitRepo.GetObjectFormat() if err != nil { - return fmt.Errorf("unknown repository ObjectFormat [%s]: %w", repoPath, err) + return fmt.Errorf("unknown repository ObjectFormat [%s]: %w", repo.FullName(), err) } if err = repo_module.UpdateRepoSize(ctx, repo); err != nil { diff --git a/services/wiki/wiki.go b/services/wiki/wiki.go index ce54a00da7..50d52d3140 100644 --- a/services/wiki/wiki.go +++ b/services/wiki/wiki.go @@ -191,7 +191,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model committer := doer.NewGitSig() - sign, signingKey, signer, _ := asymkey_service.SignWikiCommit(ctx, repo.WikiPath(), doer) + sign, signingKey, signer, _ := asymkey_service.SignWikiCommit(ctx, repo, doer) if sign { commitTreeOpts.KeyID = signingKey if repo.GetTrustModel() == repo_model.CommitterTrustModel || repo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel { @@ -314,7 +314,7 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model committer := doer.NewGitSig() - sign, signingKey, signer, _ := asymkey_service.SignWikiCommit(ctx, repo.WikiPath(), doer) + sign, signingKey, signer, _ := asymkey_service.SignWikiCommit(ctx, repo, doer) if sign { commitTreeOpts.KeyID = signingKey if repo.GetTrustModel() == repo_model.CommitterTrustModel || repo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel { diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go index 277fa086ac..59c77060f2 100644 --- a/services/wiki/wiki_test.go +++ b/services/wiki/wiki_test.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" _ "code.gitea.io/gitea/models/actions" @@ -164,7 +165,7 @@ func TestRepository_AddWikiPage(t *testing.T) { webPath := UserTitleToWebPath("", userTitle) assert.NoError(t, AddWikiPage(git.DefaultContext, doer, repo, webPath, wikiContent, commitMsg)) // Now need to show that the page has been added: - gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) + gitRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo) if !assert.NoError(t, err) { return } @@ -212,7 +213,7 @@ func TestRepository_EditWikiPage(t *testing.T) { assert.NoError(t, EditWikiPage(git.DefaultContext, doer, repo, "Home", webPath, newWikiContent, commitMsg)) // Now need to show that the page has been added: - gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) + gitRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo) assert.NoError(t, err) masterTree, err := gitRepo.GetTree(DefaultBranch) assert.NoError(t, err) @@ -236,7 +237,7 @@ func TestRepository_DeleteWikiPage(t *testing.T) { assert.NoError(t, DeleteWikiPage(git.DefaultContext, doer, repo, "Home")) // Now need to show that the page has been added: - gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) + gitRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo) if !assert.NoError(t, err) { return } @@ -251,7 +252,7 @@ func TestRepository_DeleteWikiPage(t *testing.T) { func TestPrepareWikiFileName(t *testing.T) { unittest.PrepareTestEnv(t) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) - gitRepo, err := git.OpenRepository(git.DefaultContext, repo.WikiPath()) + gitRepo, err := gitrepo.OpenWikiRepository(git.DefaultContext, repo) if !assert.NoError(t, err) { return } diff --git a/tests/integration/api_packages_cargo_test.go b/tests/integration/api_packages_cargo_test.go index 6b8154af45..c0705e0de5 100644 --- a/tests/integration/api_packages_cargo_test.go +++ b/tests/integration/api_packages_cargo_test.go @@ -18,7 +18,7 @@ import ( repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/json" cargo_module "code.gitea.io/gitea/modules/packages/cargo" "code.gitea.io/gitea/modules/setting" @@ -78,7 +78,7 @@ func testPackageCargo(t *testing.T, _ *neturl.URL) { assert.NoError(t, err) readGitContent := func(t *testing.T, path string) string { - gitRepo, err := git.OpenRepository(db.DefaultContext, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(db.DefaultContext, repo) assert.NoError(t, err) defer gitRepo.Close() diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index e070bd05b5..5b1ab76ce9 100644 --- a/tests/integration/api_releases_test.go +++ b/tests/integration/api_releases_test.go @@ -18,6 +18,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/tests" @@ -109,7 +110,7 @@ func TestAPICreateAndUpdateRelease(t *testing.T) { session := loginUser(t, owner.LowerName) token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository) - gitRepo, err := git.OpenRepository(git.DefaultContext, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo) assert.NoError(t, err) defer gitRepo.Close() @@ -172,7 +173,7 @@ func TestAPICreateReleaseToDefaultBranchOnExistingTag(t *testing.T) { session := loginUser(t, owner.LowerName) token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository) - gitRepo, err := git.OpenRepository(git.DefaultContext, repo.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo) assert.NoError(t, err) defer gitRepo.Close() diff --git a/tests/integration/api_repo_file_create_test.go b/tests/integration/api_repo_file_create_test.go index f78909eb32..0d192a1fe8 100644 --- a/tests/integration/api_repo_file_create_test.go +++ b/tests/integration/api_repo_file_create_test.go @@ -18,7 +18,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -167,7 +167,7 @@ func TestAPICreateFile(t *testing.T) { req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath), &createFileOptions). AddTokenAuth(token2) resp := MakeRequest(t, req, http.StatusCreated) - gitRepo, _ := git.OpenRepository(stdCtx.Background(), repo1.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(stdCtx.Background(), repo1) commitID, _ := gitRepo.GetBranchCommitID(createFileOptions.NewBranchName) latestCommit, _ := gitRepo.GetCommitByPath(treePath) expectedFileResponse := getExpectedFileResponseForCreate("user2/repo1", commitID, treePath, latestCommit.ID.String()) @@ -285,7 +285,7 @@ func TestAPICreateFile(t *testing.T) { AddTokenAuth(token2) resp = MakeRequest(t, req, http.StatusCreated) emptyRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerName: "user2", Name: "empty-repo"}) // public repo - gitRepo, _ := git.OpenRepository(stdCtx.Background(), emptyRepo.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(stdCtx.Background(), emptyRepo) commitID, _ := gitRepo.GetBranchCommitID(createFileOptions.NewBranchName) latestCommit, _ := gitRepo.GetCommitByPath(treePath) expectedFileResponse := getExpectedFileResponseForCreate("user2/empty-repo", commitID, treePath, latestCommit.ID.String()) diff --git a/tests/integration/api_repo_file_update_test.go b/tests/integration/api_repo_file_update_test.go index 7e88f6cd80..195a1090c7 100644 --- a/tests/integration/api_repo_file_update_test.go +++ b/tests/integration/api_repo_file_update_test.go @@ -17,7 +17,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -135,7 +135,7 @@ func TestAPIUpdateFile(t *testing.T) { req := NewRequestWithJSON(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath), &updateFileOptions). AddTokenAuth(token2) resp := MakeRequest(t, req, http.StatusOK) - gitRepo, _ := git.OpenRepository(stdCtx.Background(), repo1.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(stdCtx.Background(), repo1) commitID, _ := gitRepo.GetBranchCommitID(updateFileOptions.NewBranchName) lasCommit, _ := gitRepo.GetCommitByPath(treePath) expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath, lasCommit.ID.String()) diff --git a/tests/integration/api_repo_files_change_test.go b/tests/integration/api_repo_files_change_test.go index d500d48b36..ab5cf19a9c 100644 --- a/tests/integration/api_repo_files_change_test.go +++ b/tests/integration/api_repo_files_change_test.go @@ -16,7 +16,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" - "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" @@ -96,7 +96,7 @@ func TestAPIChangeFiles(t *testing.T) { req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/contents", user2.Name, repo1.Name), &changeFilesOptions). AddTokenAuth(token2) resp := MakeRequest(t, req, http.StatusCreated) - gitRepo, _ := git.OpenRepository(stdCtx.Background(), repo1.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(stdCtx.Background(), repo1) commitID, _ := gitRepo.GetBranchCommitID(changeFilesOptions.NewBranchName) createLasCommit, _ := gitRepo.GetCommitByPath(createTreePath) updateLastCommit, _ := gitRepo.GetCommitByPath(updateTreePath) diff --git a/tests/integration/api_repo_get_contents_list_test.go b/tests/integration/api_repo_get_contents_list_test.go index 86313f5e3b..1ba74490a3 100644 --- a/tests/integration/api_repo_get_contents_list_test.go +++ b/tests/integration/api_repo_get_contents_list_test.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" repo_service "code.gitea.io/gitea/services/repository" @@ -71,7 +72,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) { token4 := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadRepository) // Get the commit ID of the default branch - gitRepo, err := git.OpenRepository(git.DefaultContext, repo1.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo1) assert.NoError(t, err) defer gitRepo.Close() diff --git a/tests/integration/api_repo_get_contents_test.go b/tests/integration/api_repo_get_contents_test.go index ffbdfcb0fa..68a8608117 100644 --- a/tests/integration/api_repo_get_contents_test.go +++ b/tests/integration/api_repo_get_contents_test.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" repo_service "code.gitea.io/gitea/services/repository" @@ -73,7 +74,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) { token4 := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeReadRepository) // Get the commit ID of the default branch - gitRepo, err := git.OpenRepository(git.DefaultContext, repo1.RepoPath()) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo1) assert.NoError(t, err) defer gitRepo.Close() diff --git a/tests/integration/api_repo_git_tags_test.go b/tests/integration/api_repo_git_tags_test.go index 2e8510ab1b..937f6a829c 100644 --- a/tests/integration/api_repo_git_tags_test.go +++ b/tests/integration/api_repo_git_tags_test.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/tests" @@ -32,7 +33,7 @@ func TestAPIGitTags(t *testing.T) { _ = git.NewCommand(git.DefaultContext, "config", "user.name").AddDynamicArguments(user.Name).Run(&git.RunOpts{Dir: repo.RepoPath()}) _ = git.NewCommand(git.DefaultContext, "config", "user.email").AddDynamicArguments(user.Email).Run(&git.RunOpts{Dir: repo.RepoPath()}) - gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(git.DefaultContext, repo) defer gitRepo.Close() commit, _ := gitRepo.GetBranchCommit("master") diff --git a/tests/integration/mirror_pull_test.go b/tests/integration/mirror_pull_test.go index 1e0edd9a2d..2e71b80fbb 100644 --- a/tests/integration/mirror_pull_test.go +++ b/tests/integration/mirror_pull_test.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/migration" "code.gitea.io/gitea/modules/repository" mirror_service "code.gitea.io/gitea/services/mirror" @@ -54,7 +55,7 @@ func TestMirrorPull(t *testing.T) { mirror, err := repository.MigrateRepositoryGitData(ctx, user, mirrorRepo, opts, nil) assert.NoError(t, err) - gitRepo, err := git.OpenRepository(git.DefaultContext, repoPath) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo) assert.NoError(t, err) defer gitRepo.Close() diff --git a/tests/integration/mirror_push_test.go b/tests/integration/mirror_push_test.go index c6f0c85616..3dc719593c 100644 --- a/tests/integration/mirror_push_test.go +++ b/tests/integration/mirror_push_test.go @@ -17,6 +17,7 @@ import ( user_model "code.gitea.io/gitea/models/user" gitea_context "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/services/migrations" mirror_service "code.gitea.io/gitea/services/mirror" @@ -55,14 +56,14 @@ func testMirrorPush(t *testing.T, u *url.URL) { ok := mirror_service.SyncPushMirror(context.Background(), mirrors[0].ID) assert.True(t, ok) - srcGitRepo, err := git.OpenRepository(git.DefaultContext, srcRepo.RepoPath()) + srcGitRepo, err := gitrepo.OpenRepository(git.DefaultContext, srcRepo) assert.NoError(t, err) defer srcGitRepo.Close() srcCommit, err := srcGitRepo.GetBranchCommit("master") assert.NoError(t, err) - mirrorGitRepo, err := git.OpenRepository(git.DefaultContext, mirrorRepo.RepoPath()) + mirrorGitRepo, err := gitrepo.OpenRepository(git.DefaultContext, mirrorRepo) assert.NoError(t, err) defer mirrorGitRepo.Close() diff --git a/tests/integration/pull_merge_test.go b/tests/integration/pull_merge_test.go index 2aa6742a56..fcd7fecd52 100644 --- a/tests/integration/pull_merge_test.go +++ b/tests/integration/pull_merge_test.go @@ -25,6 +25,7 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/models/webhook" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/modules/translation" @@ -255,7 +256,7 @@ func TestCantMergeConflict(t *testing.T) { BaseBranch: "base", }) - gitRepo, err := git.OpenRepository(git.DefaultContext, repo_model.RepoPath(user1.Name, repo1.Name)) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo1) assert.NoError(t, err) err = pull.Merge(context.Background(), pr, user1, gitRepo, repo_model.MergeStyleMerge, "", "CONFLICT", false) @@ -348,7 +349,7 @@ func TestCantMergeUnrelated(t *testing.T) { session.MakeRequest(t, req, http.StatusCreated) // Now this PR could be marked conflict - or at least a race may occur - so drop down to pure code at this point... - gitRepo, err := git.OpenRepository(git.DefaultContext, path) + gitRepo, err := gitrepo.OpenRepository(git.DefaultContext, repo1) assert.NoError(t, err) pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ HeadRepoID: repo1.ID, diff --git a/tests/integration/repofiles_change_test.go b/tests/integration/repofiles_change_test.go index e0edf07299..19fbd1754c 100644 --- a/tests/integration/repofiles_change_test.go +++ b/tests/integration/repofiles_change_test.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/models/unittest" "code.gitea.io/gitea/modules/contexttest" "code.gitea.io/gitea/modules/git" + "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" files_service "code.gitea.io/gitea/services/repository/files" @@ -262,7 +263,7 @@ func TestChangeRepoFilesForCreate(t *testing.T) { // asserts assert.NoError(t, err) - gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(git.DefaultContext, repo) defer gitRepo.Close() commitID, _ := gitRepo.GetBranchCommitID(opts.NewBranch) @@ -299,7 +300,7 @@ func TestChangeRepoFilesForUpdate(t *testing.T) { // asserts assert.NoError(t, err) - gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(git.DefaultContext, repo) defer gitRepo.Close() commit, _ := gitRepo.GetBranchCommit(opts.NewBranch) @@ -335,7 +336,7 @@ func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) { // asserts assert.NoError(t, err) - gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(git.DefaultContext, repo) defer gitRepo.Close() commit, _ := gitRepo.GetBranchCommit(opts.NewBranch) @@ -386,7 +387,7 @@ func TestChangeRepoFilesWithoutBranchNames(t *testing.T) { // asserts assert.NoError(t, err) - gitRepo, _ := git.OpenRepository(git.DefaultContext, repo.RepoPath()) + gitRepo, _ := gitrepo.OpenRepository(git.DefaultContext, repo) defer gitRepo.Close() commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch) From 61f8ca4906c4c51f9e7e9598417a9674556e670a Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 28 Jan 2024 00:20:17 +0100 Subject: [PATCH 67/76] Add screenshot for "Profile Readmes" to docs (#28964) introduced in #23260 ... the docs still looks to empty: https://docs.gitea.com/usage/profile-readme this changes it :) --- docs/content/usage/profile-readme.en-us.md | 4 ++++ docs/content/usage/profile-readme.png | Bin 0 -> 33680 bytes 2 files changed, 4 insertions(+) create mode 100644 docs/content/usage/profile-readme.png diff --git a/docs/content/usage/profile-readme.en-us.md b/docs/content/usage/profile-readme.en-us.md index 339176f7d4..fe42fa2723 100644 --- a/docs/content/usage/profile-readme.en-us.md +++ b/docs/content/usage/profile-readme.en-us.md @@ -19,3 +19,7 @@ To display a Markdown file in your Gitea user or organization profile page, crea Gitea will automatically display the contents of the file on your profile, in a new "Overview" above your repositories. Making the `.profile` repository private will hide the Profile README. + +Example of user with `.profile/README.md`: + +![profile readme screenshot](./profile-readme.png) diff --git a/docs/content/usage/profile-readme.png b/docs/content/usage/profile-readme.png new file mode 100644 index 0000000000000000000000000000000000000000..f8043ad02af3bf13d68b927c3b431b123236c5e6 GIT binary patch literal 33680 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 U60S7hb&5b)K|{V&*2Mom0nOr+O8@`> literal 0 HcmV?d00001 From d9b3849454e04c1f498c12e29b8c19660cbae328 Mon Sep 17 00:00:00 2001 From: wackbyte Date: Sun, 28 Jan 2024 07:36:44 -0500 Subject: [PATCH 68/76] Fix inconsistent naming of OAuth 2.0 `ENABLE` setting (#28951) Renames it to `ENABLED` to be consistent with other settings and deprecates it. I believe this change is necessary because other setting groups such as `attachment`, `cors`, `mailer`, etc. have an `ENABLED` setting, but `oauth2` is the only one with an `ENABLE` setting, which could cause confusion for users. This is no longer a breaking change because `ENABLE` has been set as deprecated and as an alias to `ENABLED`. --- custom/conf/app.example.ini | 2 +- .../config-cheat-sheet.en-us.md | 2 +- .../config-cheat-sheet.zh-cn.md | 2 +- modules/setting/oauth2.go | 19 +++++++++++++------ routers/web/user/setting/applications.go | 4 ++-- routers/web/web.go | 10 +++++----- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index b0875123b7..7032e709db 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -524,7 +524,7 @@ INTERNAL_TOKEN= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Enables OAuth2 provider -ENABLE = true +ENABLED = true ;; ;; Algorithm used to sign OAuth2 tokens. Valid values: HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512, EdDSA ;JWT_SIGNING_ALGORITHM = RS256 diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index eb9b8d1ae9..33732d080b 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -1107,7 +1107,7 @@ This section only does "set" config, a removed config key from this section won' ## OAuth2 (`oauth2`) -- `ENABLE`: **true**: Enables OAuth2 provider. +- `ENABLED`: **true**: Enables OAuth2 provider. - `ACCESS_TOKEN_EXPIRATION_TIME`: **3600**: Lifetime of an OAuth2 access token in seconds - `REFRESH_TOKEN_EXPIRATION_TIME`: **730**: Lifetime of an OAuth2 refresh token in hours - `INVALIDATE_REFRESH_TOKENS`: **false**: Check if refresh token has already been used diff --git a/docs/content/administration/config-cheat-sheet.zh-cn.md b/docs/content/administration/config-cheat-sheet.zh-cn.md index 415cba14ed..2cee70daab 100644 --- a/docs/content/administration/config-cheat-sheet.zh-cn.md +++ b/docs/content/administration/config-cheat-sheet.zh-cn.md @@ -1043,7 +1043,7 @@ Gitea 创建以下非唯一队列: ## OAuth2 (`oauth2`) -- `ENABLE`: **true**:启用OAuth2提供者。 +- `ENABLED`: **true**:启用OAuth2提供者。 - `ACCESS_TOKEN_EXPIRATION_TIME`:**3600**:OAuth2访问令牌的生命周期,以秒为单位。 - `REFRESH_TOKEN_EXPIRATION_TIME`:**730**:OAuth2刷新令牌的生命周期,以小时为单位。 - `INVALIDATE_REFRESH_TOKENS`:**false**:检查刷新令牌是否已被使用。 diff --git a/modules/setting/oauth2.go b/modules/setting/oauth2.go index 10cadf03dd..0d15e91ef0 100644 --- a/modules/setting/oauth2.go +++ b/modules/setting/oauth2.go @@ -93,7 +93,7 @@ func parseScopes(sec ConfigSection, name string) []string { } var OAuth2 = struct { - Enable bool + Enabled bool AccessTokenExpirationTime int64 RefreshTokenExpirationTime int64 InvalidateRefreshTokens bool @@ -103,7 +103,7 @@ var OAuth2 = struct { MaxTokenLength int DefaultApplications []string }{ - Enable: true, + Enabled: true, AccessTokenExpirationTime: 3600, RefreshTokenExpirationTime: 730, InvalidateRefreshTokens: false, @@ -114,16 +114,23 @@ var OAuth2 = struct { } func loadOAuth2From(rootCfg ConfigProvider) { - if err := rootCfg.Section("oauth2").MapTo(&OAuth2); err != nil { - log.Fatal("Failed to OAuth2 settings: %v", err) + sec := rootCfg.Section("oauth2") + if err := sec.MapTo(&OAuth2); err != nil { + log.Fatal("Failed to map OAuth2 settings: %v", err) return } - if !OAuth2.Enable { + // Handle the rename of ENABLE to ENABLED + deprecatedSetting(rootCfg, "oauth2", "ENABLE", "oauth2", "ENABLED", "v1.23.0") + if sec.HasKey("ENABLE") && !sec.HasKey("ENABLED") { + OAuth2.Enabled = sec.Key("ENABLE").MustBool(OAuth2.Enabled) + } + + if !OAuth2.Enabled { return } - OAuth2.JWTSecretBase64 = loadSecret(rootCfg.Section("oauth2"), "JWT_SECRET_URI", "JWT_SECRET") + OAuth2.JWTSecretBase64 = loadSecret(sec, "JWT_SECRET_URI", "JWT_SECRET") if !filepath.IsAbs(OAuth2.JWTSigningPrivateKeyFile) { OAuth2.JWTSigningPrivateKeyFile = filepath.Join(AppDataPath, OAuth2.JWTSigningPrivateKeyFile) diff --git a/routers/web/user/setting/applications.go b/routers/web/user/setting/applications.go index 69a93dbf03..a7e31fd505 100644 --- a/routers/web/user/setting/applications.go +++ b/routers/web/user/setting/applications.go @@ -95,9 +95,9 @@ func loadApplicationsData(ctx *context.Context) { return } ctx.Data["Tokens"] = tokens - ctx.Data["EnableOAuth2"] = setting.OAuth2.Enable + ctx.Data["EnableOAuth2"] = setting.OAuth2.Enabled ctx.Data["IsAdmin"] = ctx.Doer.IsAdmin - if setting.OAuth2.Enable { + if setting.OAuth2.Enabled { ctx.Data["Applications"], err = db.Find[auth_model.OAuth2Application](ctx, auth_model.FindOAuth2ApplicationsOptions{ OwnerID: ctx.Doer.ID, }) diff --git a/routers/web/web.go b/routers/web/web.go index ff0ce0c258..92cf5132b4 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -304,7 +304,7 @@ func registerRoutes(m *web.Route) { validation.AddBindingRules() linkAccountEnabled := func(ctx *context.Context) { - if !setting.Service.EnableOpenIDSignIn && !setting.Service.EnableOpenIDSignUp && !setting.OAuth2.Enable { + if !setting.Service.EnableOpenIDSignIn && !setting.Service.EnableOpenIDSignUp && !setting.OAuth2.Enabled { ctx.Error(http.StatusForbidden) return } @@ -768,7 +768,7 @@ func registerRoutes(m *web.Route) { m.Post("/delete", admin.DeleteApplication) }) }, func(ctx *context.Context) { - if !setting.OAuth2.Enable { + if !setting.OAuth2.Enabled { ctx.Error(http.StatusForbidden) return } @@ -779,7 +779,7 @@ func registerRoutes(m *web.Route) { addSettingsRunnersRoutes() addSettingsVariablesRoutes() }) - }, adminReq, ctxDataSet("EnableOAuth2", setting.OAuth2.Enable, "EnablePackages", setting.Packages.Enabled)) + }, adminReq, ctxDataSet("EnableOAuth2", setting.OAuth2.Enabled, "EnablePackages", setting.Packages.Enabled)) // ***** END: Admin ***** m.Group("", func() { @@ -891,7 +891,7 @@ func registerRoutes(m *web.Route) { m.Post("/delete", org.DeleteOAuth2Application) }) }, func(ctx *context.Context) { - if !setting.OAuth2.Enable { + if !setting.OAuth2.Enabled { ctx.Error(http.StatusForbidden) return } @@ -943,7 +943,7 @@ func registerRoutes(m *web.Route) { m.Post("/rebuild", org.RebuildCargoIndex) }) }, packagesEnabled) - }, ctxDataSet("EnableOAuth2", setting.OAuth2.Enable, "EnablePackages", setting.Packages.Enabled, "PageIsOrgSettings", true)) + }, ctxDataSet("EnableOAuth2", setting.OAuth2.Enabled, "EnablePackages", setting.Packages.Enabled, "PageIsOrgSettings", true)) }, context.OrgAssignment(true, true)) }, reqSignIn) // ***** END: Organization ***** From dfc1ae15b6a15aaa8487b770b2d2f7b36e171c5e Mon Sep 17 00:00:00 2001 From: Arnaud Morin Date: Sun, 28 Jan 2024 15:58:00 +0100 Subject: [PATCH 69/76] Fixing small space missing in sample config file (#28967) --- custom/conf/app.example.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 7032e709db..363bbcb151 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -431,7 +431,7 @@ SECRET_KEY = ;SECRET_KEY_URI = file:/etc/gitea/secret_key ;; ;; Secret used to validate communication within Gitea binary. -INTERNAL_TOKEN= +INTERNAL_TOKEN = ;; ;; Alternative location to specify internal token, instead of this file; you cannot specify both this and INTERNAL_TOKEN, and must pick one ;INTERNAL_TOKEN_URI = file:/etc/gitea/internal_token From 34633d85f18ff77643302302379078128dd4ddb7 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 29 Jan 2024 04:18:15 +0800 Subject: [PATCH 70/76] Fix bug for generated repository object format (#28969) A repository generated from a template repository should have the same git ObjectFormat. --- modules/repository/generate.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/modules/repository/generate.go b/modules/repository/generate.go index b32c4e058e..013dd8f76f 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -224,8 +224,7 @@ func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *r } } - // FIXME: fix the hash - if err := git.InitRepository(ctx, tmpDir, false, git.Sha1ObjectFormat.Name()); err != nil { + if err := git.InitRepository(ctx, tmpDir, false, templateRepo.ObjectFormatName); err != nil { return err } @@ -327,18 +326,19 @@ func (gro GenerateRepoOptions) IsValid() bool { // GenerateRepository generates a repository from a template func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templateRepo *repo_model.Repository, opts GenerateRepoOptions) (_ *repo_model.Repository, err error) { generateRepo := &repo_model.Repository{ - OwnerID: owner.ID, - Owner: owner, - OwnerName: owner.Name, - Name: opts.Name, - LowerName: strings.ToLower(opts.Name), - Description: opts.Description, - DefaultBranch: opts.DefaultBranch, - IsPrivate: opts.Private, - IsEmpty: !opts.GitContent || templateRepo.IsEmpty, - IsFsckEnabled: templateRepo.IsFsckEnabled, - TemplateID: templateRepo.ID, - TrustModel: templateRepo.TrustModel, + OwnerID: owner.ID, + Owner: owner, + OwnerName: owner.Name, + Name: opts.Name, + LowerName: strings.ToLower(opts.Name), + Description: opts.Description, + DefaultBranch: opts.DefaultBranch, + IsPrivate: opts.Private, + IsEmpty: !opts.GitContent || templateRepo.IsEmpty, + IsFsckEnabled: templateRepo.IsFsckEnabled, + TemplateID: templateRepo.ID, + TrustModel: templateRepo.TrustModel, + ObjectFormatName: templateRepo.ObjectFormatName, } if err = CreateRepositoryByExample(ctx, doer, owner, generateRepo, false, false); err != nil { @@ -358,8 +358,7 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ } } - // FIXME - fix the hash - if err = CheckInitRepository(ctx, owner.Name, generateRepo.Name, git.Sha1ObjectFormat.Name()); err != nil { + if err = CheckInitRepository(ctx, owner.Name, generateRepo.Name, generateRepo.ObjectFormatName); err != nil { return generateRepo, err } From 2a50d780f93957223da9494c61bb3181ffa7ff65 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Mon, 29 Jan 2024 00:24:21 +0000 Subject: [PATCH 71/76] [skip ci] Updated licenses and gitignores --- options/license/fmt-exception | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 options/license/fmt-exception diff --git a/options/license/fmt-exception b/options/license/fmt-exception new file mode 100644 index 0000000000..6036f7d360 --- /dev/null +++ b/options/license/fmt-exception @@ -0,0 +1,6 @@ +--- Optional exception to the license --- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into a machine-executable object form of such +source code, you may redistribute such embedded portions in such object form +without including the above copyright and permission notices. From 28fe3db1fb0f89bcb55829ced33c1282f85f6e97 Mon Sep 17 00:00:00 2001 From: cchangwen <157893811+cchangwen@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:18:40 +0800 Subject: [PATCH 72/76] Also match weakly validated ETags (#28957) https://stackoverflow.com/questions/51973120/where-does-the-w-in-an-etag-appear-from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag# --------- Co-authored-by: delvh --- modules/httpcache/httpcache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/httpcache/httpcache.go b/modules/httpcache/httpcache.go index b57b321832..40458dfc33 100644 --- a/modules/httpcache/httpcache.go +++ b/modules/httpcache/httpcache.go @@ -59,7 +59,7 @@ func checkIfNoneMatchIsValid(req *http.Request, etag string) bool { ifNoneMatch := req.Header.Get("If-None-Match") if len(ifNoneMatch) > 0 { for _, item := range strings.Split(ifNoneMatch, ",") { - item = strings.TrimSpace(item) + item = strings.TrimPrefix(strings.TrimSpace(item), "W/") // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag#directives if item == etag { return true } From 37ede3197a74ba43c95029101ca37b3f9e7cc325 Mon Sep 17 00:00:00 2001 From: Matheus Sampaio Queiroga Date: Mon, 29 Jan 2024 21:54:52 -0300 Subject: [PATCH 73/76] Fix google logo in security page (#28982) Fix google logo in user security page: #28701 Before ![before user security page](https://github.com/go-gitea/gitea/assets/50121801/6c058c28-8013-470a-b047-f47afecdca09) after ![user security page](https://github.com/go-gitea/gitea/assets/50121801/36053ee9-18c5-4ef0-a63a-8accc1d00adc) --- public/assets/img/svg/gitea-google.svg | 2 +- web_src/svg/gitea-google.svg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/assets/img/svg/gitea-google.svg b/public/assets/img/svg/gitea-google.svg index 9629ca03b6..7dd2622df6 100644 --- a/public/assets/img/svg/gitea-google.svg +++ b/public/assets/img/svg/gitea-google.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/web_src/svg/gitea-google.svg b/web_src/svg/gitea-google.svg index dbb741897c..d15a591b60 100644 --- a/web_src/svg/gitea-google.svg +++ b/web_src/svg/gitea-google.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From 8ef53c871bcb5c007b3640a347c7868585c9e4de Mon Sep 17 00:00:00 2001 From: Mike Cifelli <26522946+macifell@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:11:11 -0500 Subject: [PATCH 74/76] Update golang links to use https (#28980) Many of the golang links point to the old site and don't use https. This pull request updates these outdated links to https://go.dev . https://github.com/go-gitea/gitea/issues/28979 --- CONTRIBUTING.md | 2 +- .../content/administration/environment-variables.zh-cn.md | 4 ++-- docs/content/administration/mail-templates.en-us.md | 8 ++++---- docs/content/administration/mail-templates.zh-cn.md | 8 ++++---- docs/content/development/hacking-on-gitea.en-us.md | 2 +- docs/content/development/hacking-on-gitea.zh-cn.md | 2 +- docs/content/installation/from-source.en-us.md | 8 ++++---- docs/content/installation/from-source.zh-cn.md | 4 ++-- options/locale/locale_en-US.ini | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b43ce01ff2..a201f2fc38 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -110,7 +110,7 @@ See the [development setup instructions](https://docs.gitea.com/development/hack ### Backend -Go dependencies are managed using [Go Modules](https://golang.org/cmd/go/#hdr-Module_maintenance). \ +Go dependencies are managed using [Go Modules](https://go.dev/cmd/go/#hdr-Module_maintenance). \ You can find more details in the [go mod documentation](https://go.dev/ref/mod) and the [Go Modules Wiki](https://github.com/golang/go/wiki/Modules). Pull requests should only modify `go.mod` and `go.sum` where it is related to your change, be it a bugfix or a new feature. \ diff --git a/docs/content/administration/environment-variables.zh-cn.md b/docs/content/administration/environment-variables.zh-cn.md index 25e120becd..d5be9e03c2 100644 --- a/docs/content/administration/environment-variables.zh-cn.md +++ b/docs/content/administration/environment-variables.zh-cn.md @@ -29,9 +29,9 @@ GITEA_CUSTOM=/home/gitea/custom ./gitea web * `GOOS` * `GOARCH` -* [`GOPATH`](https://golang.org/cmd/go/#hdr-GOPATH_environment_variable) +* [`GOPATH`](https://go.dev/cmd/go/#hdr-GOPATH_environment_variable) -您可以在[官方文档](https://golang.org/cmd/go/#hdr-Environment_variables)中查阅这些配置参数的详细信息。 +您可以在[官方文档](https://go.dev/cmd/go/#hdr-Environment_variables)中查阅这些配置参数的详细信息。 ## Gitea 的文件目录 diff --git a/docs/content/administration/mail-templates.en-us.md b/docs/content/administration/mail-templates.en-us.md index a129453e1a..32b352da4b 100644 --- a/docs/content/administration/mail-templates.en-us.md +++ b/docs/content/administration/mail-templates.en-us.md @@ -85,7 +85,7 @@ Text and macros for the mail body Specifying a _subject_ section is optional (and therefore also the dash line separator). When used, the separator between _subject_ and _mail body_ templates requires at least three dashes; no other characters are allowed in the separator line. -_Subject_ and _mail body_ are parsed by [Golang's template engine](https://golang.org/pkg/text/template/) and +_Subject_ and _mail body_ are parsed by [Golang's template engine](https://go.dev/pkg/text/template/) and are provided with a _metadata context_ assembled for each notification. The context contains the following elements: | Name | Type | Available | Usage | @@ -110,7 +110,7 @@ All names are case sensitive. ### The _subject_ part of the template -The template engine used for the mail _subject_ is golang's [`text/template`](https://golang.org/pkg/text/template/). +The template engine used for the mail _subject_ is golang's [`text/template`](https://go.dev/pkg/text/template/). Please refer to the linked documentation for details about its syntax. The _subject_ is built using the following steps: @@ -138,7 +138,7 @@ the two templates, even if a valid subject template is present. ### The _mail body_ part of the template -The template engine used for the _mail body_ is golang's [`html/template`](https://golang.org/pkg/html/template/). +The template engine used for the _mail body_ is golang's [`html/template`](https://go.dev/pkg/html/template/). Please refer to the linked documentation for details about its syntax. The _mail body_ is parsed after the mail subject, so there is an additional _metadata_ field which is @@ -146,7 +146,7 @@ the actual rendered subject, after all considerations. The expected result is HTML (including structural elements like``, ``, etc.). Styling through `