Skip to content

Commit 139f55a

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Use repo object format name instead of detecting from git repository (go-gitea#29702) Improve CSV rendering (go-gitea#29638) Remove jQuery AJAX from the comment edit history (go-gitea#29703) fix: rendering internal file links in org (go-gitea#29669) Fix broken webhooks (go-gitea#29690) Suppress error from monaco-editor (go-gitea#29684)
2 parents d0615dd + 3c6fc25 commit 139f55a

File tree

11 files changed

+108
-56
lines changed

11 files changed

+108
-56
lines changed

modules/indexer/code/git.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,9 @@ func genesisChanges(ctx context.Context, repo *repo_model.Repository, revision s
9191
return nil, runErr
9292
}
9393

94+
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
95+
9496
var err error
95-
objectFormat, err := git.GetObjectFormatOfRepo(ctx, repo.RepoPath())
96-
if err != nil {
97-
return nil, err
98-
}
9997
changes.Updates, err = parseGitLsTreeOutput(objectFormat, stdout)
10098
return &changes, err
10199
}
@@ -174,10 +172,8 @@ func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revisio
174172
return nil, err
175173
}
176174

177-
objectFormat, err := git.GetObjectFormatOfRepo(ctx, repo.RepoPath())
178-
if err != nil {
179-
return nil, err
180-
}
175+
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
176+
181177
changes.Updates, err = parseGitLsTreeOutput(objectFormat, lsTreeStdout)
182178
return &changes, err
183179
}

modules/markup/orgmode/orgmode.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,18 @@ func (r *Writer) resolveLink(kind, link string) string {
142142
// so we need to try to guess the link kind again here
143143
kind = org.RegularLink{URL: link}.Kind()
144144
}
145+
145146
base := r.Ctx.Links.Base
147+
if r.Ctx.IsWiki {
148+
base = r.Ctx.Links.WikiLink()
149+
} else if r.Ctx.Links.HasBranchInfo() {
150+
base = r.Ctx.Links.SrcLink()
151+
}
152+
146153
if kind == "image" || kind == "video" {
147154
base = r.Ctx.Links.ResolveMediaLink(r.Ctx.IsWiki)
148155
}
156+
149157
link = util.URLJoin(base, link)
150158
}
151159
return link

modules/markup/orgmode/orgmode_test.go

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,50 @@ const AppURL = "http://localhost:3000/"
1919
func TestRender_StandardLinks(t *testing.T) {
2020
setting.AppURL = AppURL
2121

22-
test := func(input, expected string) {
22+
test := func(input, expected string, isWiki bool) {
2323
buffer, err := RenderString(&markup.RenderContext{
2424
Ctx: git.DefaultContext,
2525
Links: markup.Links{
2626
Base: "/relative-path",
2727
BranchPath: "branch/main",
2828
},
29+
IsWiki: isWiki,
2930
}, input)
3031
assert.NoError(t, err)
3132
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
3233
}
3334

3435
test("[[https://google.com/]]",
35-
`<p><a href="https://google.com/">https://google.com/</a></p>`)
36+
`<p><a href="https://google.com/">https://google.com/</a></p>`, false)
3637
test("[[WikiPage][The WikiPage Desc]]",
37-
`<p><a href="/relative-path/WikiPage">The WikiPage Desc</a></p>`)
38+
`<p><a href="/relative-path/wiki/WikiPage">The WikiPage Desc</a></p>`, true)
3839
test("[[ImageLink.svg][The Image Desc]]",
39-
`<p><a href="/relative-path/media/branch/main/ImageLink.svg">The Image Desc</a></p>`)
40+
`<p><a href="/relative-path/media/branch/main/ImageLink.svg">The Image Desc</a></p>`, false)
41+
}
42+
43+
func TestRender_InternalLinks(t *testing.T) {
44+
setting.AppURL = AppURL
45+
46+
test := func(input, expected string) {
47+
buffer, err := RenderString(&markup.RenderContext{
48+
Ctx: git.DefaultContext,
49+
Links: markup.Links{
50+
Base: "/relative-path",
51+
BranchPath: "branch/main",
52+
},
53+
}, input)
54+
assert.NoError(t, err)
55+
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
56+
}
57+
58+
test("[[file:test.org][Test]]",
59+
`<p><a href="/relative-path/src/branch/main/test.org">Test</a></p>`)
60+
test("[[./test.org][Test]]",
61+
`<p><a href="/relative-path/src/branch/main/test.org">Test</a></p>`)
62+
test("[[test.org][Test]]",
63+
`<p><a href="/relative-path/src/branch/main/test.org">Test</a></p>`)
64+
test("[[path/to/test.org][Test]]",
65+
`<p><a href="/relative-path/src/branch/main/path/to/test.org">Test</a></p>`)
4066
}
4167

4268
func TestRender_Media(t *testing.T) {

routers/web/repo/branch.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,7 @@ func RestoreBranchPost(ctx *context.Context) {
148148
return
149149
}
150150

151-
objectFormat, err := git.GetObjectFormatOfRepo(ctx, ctx.Repo.Repository.RepoPath())
152-
if err != nil {
153-
log.Error("RestoreBranch: CreateBranch: %w", err)
154-
ctx.Flash.Error(ctx.Tr("repo.branch.restore_failed", deletedBranch.Name))
155-
return
156-
}
151+
objectFormat := git.ObjectFormatFromName(ctx.Repo.Repository.ObjectFormatName)
157152

158153
// Don't return error below this
159154
if err := repo_service.PushUpdate(

routers/web/repo/setting/webhook.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -657,12 +657,7 @@ func TestWebhook(ctx *context.Context) {
657657
commit := ctx.Repo.Commit
658658
if commit == nil {
659659
ghost := user_model.NewGhostUser()
660-
objectFormat, err := git.GetObjectFormatOfRepo(ctx, ctx.Repo.Repository.RepoPath())
661-
if err != nil {
662-
ctx.Flash.Error("GetObjectFormatOfRepo: " + err.Error())
663-
ctx.Status(http.StatusInternalServerError)
664-
return
665-
}
660+
objectFormat := git.ObjectFormatFromName(ctx.Repo.Repository.ObjectFormatName)
666661
commit = &git.Commit{
667662
ID: objectFormat.EmptyObjectID(),
668663
Author: ghost.NewGitSig(),

services/mirror/mirror_pull.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
479479
log.Error("SyncMirrors [repo: %-v]: unable to GetRefCommitID [ref_name: %s]: %v", m.Repo, result.refName, err)
480480
continue
481481
}
482-
objectFormat, err := git.GetObjectFormatOfRepo(ctx, m.Repo.RepoPath())
483-
if err != nil {
484-
log.Error("SyncMirrors [repo: %-v]: unable to GetHashTypeOfRepo: %v", m.Repo, err)
485-
}
482+
objectFormat := git.ObjectFormatFromName(m.Repo.ObjectFormatName)
486483
notify_service.SyncPushCommits(ctx, m.Repo.MustOwner(ctx), m.Repo, &repo_module.PushUpdateOptions{
487484
RefFullName: result.refName,
488485
OldCommitID: objectFormat.EmptyObjectID().String(),

services/pull/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
337337
}
338338
if err == nil {
339339
for _, pr := range prs {
340-
objectFormat, _ := git.GetObjectFormatOfRepo(ctx, pr.BaseRepo.RepoPath())
340+
objectFormat := git.ObjectFormatFromName(pr.BaseRepo.ObjectFormatName)
341341
if newCommitID != "" && newCommitID != objectFormat.EmptyObjectID().String() {
342342
changed, err := checkIfPRContentChanged(ctx, pr, oldCommitID, newCommitID)
343343
if err != nil {

services/release/release.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,7 @@ func DeleteReleaseByID(ctx context.Context, repo *repo_model.Repository, rel *re
326326
}
327327

328328
refName := git.RefNameFromTag(rel.TagName)
329-
objectFormat, err := git.GetObjectFormatOfRepo(ctx, repo.RepoPath())
330-
if err != nil {
331-
return err
332-
}
329+
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
333330
notify_service.PushCommits(
334331
ctx, doer, repo,
335332
&repository.PushUpdateOptions{

web_src/css/repo.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,7 @@
14201420

14211421
.repository .data-table tr {
14221422
border-top: 0;
1423+
background: none !important;
14231424
}
14241425

14251426
.repository .data-table td,
@@ -1432,6 +1433,21 @@
14321433
border: 1px solid var(--color-secondary);
14331434
}
14341435

1436+
/* the border css competes with .markup where all tables have outer border which would add a double
1437+
border here, remove only the outer borders from this table */
1438+
.repository .data-table tr:first-child :is(td,th) {
1439+
border-top: none !important;
1440+
}
1441+
.repository .data-table tr:last-child :is(td,th) {
1442+
border-bottom: none !important;
1443+
}
1444+
.repository .data-table tr :is(td,th):first-child {
1445+
border-left: none !important;
1446+
}
1447+
.repository .data-table tr :is(td,th):last-child {
1448+
border-right: none !important;
1449+
}
1450+
14351451
.repository .data-table td {
14361452
white-space: pre-line;
14371453
}
@@ -1469,7 +1485,7 @@
14691485
min-width: 50px;
14701486
font-family: monospace;
14711487
line-height: 20px;
1472-
color: var(--color-secondary-dark-2);
1488+
color: var(--color-text-light-1);
14731489
white-space: nowrap;
14741490
vertical-align: top;
14751491
cursor: pointer;

web_src/js/bootstrap.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@
66
// This file must be imported before any lazy-loading is being attempted.
77
__webpack_public_path__ = `${window.config?.assetUrlPrefix ?? '/assets'}/`;
88

9+
const filteredErrors = new Set([
10+
'getModifierState is not a function', // https://github.com/microsoft/monaco-editor/issues/4325
11+
]);
12+
913
export function showGlobalErrorMessage(msg) {
1014
const pageContent = document.querySelector('.page-content');
1115
if (!pageContent) return;
1216

17+
for (const filteredError of filteredErrors) {
18+
if (msg.includes(filteredError)) return;
19+
}
20+
1321
// compact the message to a data attribute to avoid too many duplicated messages
1422
const msgCompact = msg.replace(/\W/g, '').trim();
1523
let msgDiv = pageContent.querySelector(`.js-global-error[data-global-error-msg-compact="${msgCompact}"]`);

0 commit comments

Comments
 (0)