Skip to content

Commit c5e41c2

Browse files
authored
Merge branch 'main' into fix-push-tag-err
2 parents 38c48dd + b094f9b commit c5e41c2

36 files changed

+400
-199
lines changed

modules/gitrepo/gitrepo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ func RepositoryFromRequestContextOrOpen(ctx reqctx.RequestContext, repo Reposito
6969
ctx.SetContextValue(ck, gitRepo)
7070
return gitRepo, nil
7171
}
72+
73+
// IsRepositoryExist returns true if the repository directory exists in the disk
74+
func IsRepositoryExist(ctx context.Context, repo Repository) (bool, error) {
75+
return util.IsExist(repoPath(repo))
76+
}

modules/markup/markdown/markdown.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,27 +159,27 @@ func render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error
159159
limit: setting.UI.MaxDisplayFileSize * 3,
160160
}
161161

162+
// FIXME: Don't read all to memory, but goldmark doesn't support
163+
buf, err := io.ReadAll(input)
164+
if err != nil {
165+
log.Error("Unable to ReadAll: %v", err)
166+
return err
167+
}
168+
buf = giteautil.NormalizeEOL(buf)
169+
162170
// FIXME: should we include a timeout to abort the renderer if it takes too long?
163171
defer func() {
164172
err := recover()
165173
if err == nil {
166174
return
167175
}
168176

169-
log.Warn("Unable to render markdown due to panic in goldmark: %v", err)
170-
if (!setting.IsProd && !setting.IsInTesting) || log.IsDebug() {
171-
log.Error("Panic in markdown: %v\n%s", err, log.Stack(2))
172-
}
177+
log.Error("Panic in markdown: %v\n%s", err, log.Stack(2))
178+
escapedHTML := template.HTMLEscapeString(giteautil.UnsafeBytesToString(buf))
179+
_, _ = output.Write(giteautil.UnsafeStringToBytes(escapedHTML))
173180
}()
174181

175-
// FIXME: Don't read all to memory, but goldmark doesn't support
176182
pc := newParserContext(ctx)
177-
buf, err := io.ReadAll(input)
178-
if err != nil {
179-
log.Error("Unable to ReadAll: %v", err)
180-
return err
181-
}
182-
buf = giteautil.NormalizeEOL(buf)
183183

184184
// Preserve original length.
185185
bufWithMetadataLength := len(buf)

modules/markup/markdown/markdown_attention_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ func TestAttention(t *testing.T) {
2323
defer svg.MockIcon("octicon-alert")()
2424
defer svg.MockIcon("octicon-stop")()
2525

26+
test := func(input, expected string) {
27+
result, err := markdown.RenderString(markup.NewTestRenderContext(), input)
28+
assert.NoError(t, err)
29+
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(result)))
30+
}
2631
renderAttention := func(attention, icon string) string {
2732
tmpl := `<blockquote class="attention-header attention-{attention}"><p><svg class="attention-icon attention-{attention} svg {icon}" width="16" height="16"></svg><strong class="attention-{attention}">{Attention}</strong></p>`
2833
tmpl = strings.ReplaceAll(tmpl, "{attention}", attention)
@@ -31,12 +36,6 @@ func TestAttention(t *testing.T) {
3136
return tmpl
3237
}
3338

34-
test := func(input, expected string) {
35-
result, err := markdown.RenderString(markup.NewTestRenderContext(), input)
36-
assert.NoError(t, err)
37-
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(string(result)))
38-
}
39-
4039
test(`
4140
> [!NOTE]
4241
> text
@@ -53,4 +52,7 @@ func TestAttention(t *testing.T) {
5352

5453
// legacy GitHub style
5554
test(`> **warning**`, renderAttention("warning", "octicon-alert")+"\n</blockquote>")
55+
56+
// edge case (it used to cause panic)
57+
test(">\ntext", "<blockquote>\n</blockquote>\n<p>text</p>")
5658
}

modules/markup/markdown/transform_blockquote.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ func (g *ASTTransformer) transformBlockquote(v *ast.Blockquote, reader text.Read
115115

116116
// grab these nodes and make sure we adhere to the attention blockquote structure
117117
firstParagraph := v.FirstChild()
118+
if firstParagraph == nil {
119+
return ast.WalkContinue, nil
120+
}
118121
g.applyElementDir(firstParagraph)
119122

120123
attentionType, processedNodes := g.extractBlockquoteAttentionEmphasis(firstParagraph, reader)

modules/markup/renderer_test.go

Lines changed: 0 additions & 4 deletions
This file was deleted.

modules/migration/retry_downloader.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,34 @@ var _ Downloader = &RetryDownloader{}
1313
// RetryDownloader retry the downloads
1414
type RetryDownloader struct {
1515
Downloader
16-
ctx context.Context
1716
RetryTimes int // the total execute times
1817
RetryDelay int // time to delay seconds
1918
}
2019

2120
// NewRetryDownloader creates a retry downloader
22-
func NewRetryDownloader(ctx context.Context, downloader Downloader, retryTimes, retryDelay int) *RetryDownloader {
21+
func NewRetryDownloader(downloader Downloader, retryTimes, retryDelay int) *RetryDownloader {
2322
return &RetryDownloader{
2423
Downloader: downloader,
25-
ctx: ctx,
2624
RetryTimes: retryTimes,
2725
RetryDelay: retryDelay,
2826
}
2927
}
3028

31-
func (d *RetryDownloader) retry(work func() error) error {
29+
func (d *RetryDownloader) retry(ctx context.Context, work func(context.Context) error) error {
3230
var (
3331
times = d.RetryTimes
3432
err error
3533
)
3634
for ; times > 0; times-- {
37-
if err = work(); err == nil {
35+
if err = work(ctx); err == nil {
3836
return nil
3937
}
4038
if IsErrNotSupported(err) {
4139
return err
4240
}
4341
select {
44-
case <-d.ctx.Done():
45-
return d.ctx.Err()
42+
case <-ctx.Done():
43+
return ctx.Err()
4644
case <-time.After(time.Second * time.Duration(d.RetryDelay)):
4745
}
4846
}
@@ -56,7 +54,7 @@ func (d *RetryDownloader) GetRepoInfo(ctx context.Context) (*Repository, error)
5654
err error
5755
)
5856

59-
err = d.retry(func() error {
57+
err = d.retry(ctx, func(ctx context.Context) error {
6058
repo, err = d.Downloader.GetRepoInfo(ctx)
6159
return err
6260
})
@@ -71,7 +69,7 @@ func (d *RetryDownloader) GetTopics(ctx context.Context) ([]string, error) {
7169
err error
7270
)
7371

74-
err = d.retry(func() error {
72+
err = d.retry(ctx, func(ctx context.Context) error {
7573
topics, err = d.Downloader.GetTopics(ctx)
7674
return err
7775
})
@@ -86,7 +84,7 @@ func (d *RetryDownloader) GetMilestones(ctx context.Context) ([]*Milestone, erro
8684
err error
8785
)
8886

89-
err = d.retry(func() error {
87+
err = d.retry(ctx, func(ctx context.Context) error {
9088
milestones, err = d.Downloader.GetMilestones(ctx)
9189
return err
9290
})
@@ -101,7 +99,7 @@ func (d *RetryDownloader) GetReleases(ctx context.Context) ([]*Release, error) {
10199
err error
102100
)
103101

104-
err = d.retry(func() error {
102+
err = d.retry(ctx, func(ctx context.Context) error {
105103
releases, err = d.Downloader.GetReleases(ctx)
106104
return err
107105
})
@@ -116,7 +114,7 @@ func (d *RetryDownloader) GetLabels(ctx context.Context) ([]*Label, error) {
116114
err error
117115
)
118116

119-
err = d.retry(func() error {
117+
err = d.retry(ctx, func(ctx context.Context) error {
120118
labels, err = d.Downloader.GetLabels(ctx)
121119
return err
122120
})
@@ -132,7 +130,7 @@ func (d *RetryDownloader) GetIssues(ctx context.Context, page, perPage int) ([]*
132130
err error
133131
)
134132

135-
err = d.retry(func() error {
133+
err = d.retry(ctx, func(ctx context.Context) error {
136134
issues, isEnd, err = d.Downloader.GetIssues(ctx, page, perPage)
137135
return err
138136
})
@@ -148,7 +146,7 @@ func (d *RetryDownloader) GetComments(ctx context.Context, commentable Commentab
148146
err error
149147
)
150148

151-
err = d.retry(func() error {
149+
err = d.retry(ctx, func(context.Context) error {
152150
comments, isEnd, err = d.Downloader.GetComments(ctx, commentable)
153151
return err
154152
})
@@ -164,7 +162,7 @@ func (d *RetryDownloader) GetPullRequests(ctx context.Context, page, perPage int
164162
isEnd bool
165163
)
166164

167-
err = d.retry(func() error {
165+
err = d.retry(ctx, func(ctx context.Context) error {
168166
prs, isEnd, err = d.Downloader.GetPullRequests(ctx, page, perPage)
169167
return err
170168
})
@@ -178,7 +176,7 @@ func (d *RetryDownloader) GetReviews(ctx context.Context, reviewable Reviewable)
178176
reviews []*Review
179177
err error
180178
)
181-
err = d.retry(func() error {
179+
err = d.retry(ctx, func(ctx context.Context) error {
182180
reviews, err = d.Downloader.GetReviews(ctx, reviewable)
183181
return err
184182
})

modules/repository/init.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
issues_model "code.gitea.io/gitea/models/issues"
1414
repo_model "code.gitea.io/gitea/models/repo"
1515
"code.gitea.io/gitea/modules/git"
16+
"code.gitea.io/gitea/modules/gitrepo"
1617
"code.gitea.io/gitea/modules/label"
1718
"code.gitea.io/gitea/modules/log"
1819
"code.gitea.io/gitea/modules/options"
@@ -120,25 +121,24 @@ func LoadRepoConfig() error {
120121
return nil
121122
}
122123

123-
func CheckInitRepository(ctx context.Context, owner, name, objectFormatName string) (err error) {
124+
func CheckInitRepository(ctx context.Context, repo *repo_model.Repository) (err error) {
124125
// Somehow the directory could exist.
125-
repoPath := repo_model.RepoPath(owner, name)
126-
isExist, err := util.IsExist(repoPath)
126+
isExist, err := gitrepo.IsRepositoryExist(ctx, repo)
127127
if err != nil {
128-
log.Error("Unable to check if %s exists. Error: %v", repoPath, err)
128+
log.Error("Unable to check if %s exists. Error: %v", repo.FullName(), err)
129129
return err
130130
}
131131
if isExist {
132132
return repo_model.ErrRepoFilesAlreadyExist{
133-
Uname: owner,
134-
Name: name,
133+
Uname: repo.OwnerName,
134+
Name: repo.Name,
135135
}
136136
}
137137

138138
// Init git bare new repository.
139-
if err = git.InitRepository(ctx, repoPath, true, objectFormatName); err != nil {
139+
if err = git.InitRepository(ctx, repo.RepoPath(), true, repo.ObjectFormatName); err != nil {
140140
return fmt.Errorf("git.InitRepository: %w", err)
141-
} else if err = CreateDelegateHooks(repoPath); err != nil {
141+
} else if err = CreateDelegateHooks(repo.RepoPath()); err != nil {
142142
return fmt.Errorf("createDelegateHooks: %w", err)
143143
}
144144
return nil

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,7 @@ commits.signed_by_untrusted_user_unmatched = Signed by untrusted user who does n
14071407
commits.gpg_key_id = GPG Key ID
14081408
commits.ssh_key_fingerprint = SSH Key Fingerprint
14091409
commits.view_path=View at this point in history
1410+
commits.view_file_diff = View changes to this file in this commit
14101411
14111412
commit.operations = Operations
14121413
commit.revert = Revert

options/locale/locale_fr-FR.ini

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,8 @@ issues.filter_milestones=Filtrer le jalon
14631463
issues.filter_projects=Filtrer par projet
14641464
issues.filter_labels=Filtrer par labels
14651465
issues.filter_reviewers=Filtrer par évaluateur
1466+
issues.filter_no_results=Aucun résultat
1467+
issues.filter_no_results_placeholder=Essayez d’ajuster vos filtres de recherche.
14661468
issues.new=Nouveau ticket
14671469
issues.new.title_empty=Le titre ne peut pas être vide
14681470
issues.new.labels=Labels
@@ -1935,6 +1937,7 @@ pulls.outdated_with_base_branch=Cette branche est désynchronisée avec la branc
19351937
pulls.close=Fermer la demande d’ajout
19361938
pulls.closed_at=`a fermé cette demande d'ajout <a id="%[1]s" href="#%[1]s">%[2]s</a>.`
19371939
pulls.reopened_at=`a rouvert cette demande d'ajout <a id="%[1]s" href="#%[1]s">%[2]s</a>.`
1940+
pulls.cmd_instruction_hint=Voir les instructions en ligne de commande
19381941
pulls.cmd_instruction_checkout_title=Basculer
19391942
pulls.cmd_instruction_checkout_desc=Depuis votre dépôt, basculer sur une nouvelle branche et tester des modifications.
19401943
pulls.cmd_instruction_merge_title=Fusionner
@@ -2376,6 +2379,9 @@ settings.event_pull_request_review_request=Demande d’évaluation
23762379
settings.event_pull_request_review_request_desc=Création ou suppresion de demandes d’évaluation.
23772380
settings.event_pull_request_approvals=Approbations de demande d'ajout
23782381
settings.event_pull_request_merge=Fusion de demande d'ajout
2382+
settings.event_header_workflow=Événements du flux de travail
2383+
settings.event_workflow_job=Tâches du flux de travail
2384+
settings.event_workflow_job_desc=Tâche du flux de travail Gitea Actions en file d’attente, en attente, en cours ou terminée.
23792385
settings.event_package=Paquet
23802386
settings.event_package_desc=Paquet créé ou supprimé.
23812387
settings.branch_filter=Filtre de branche
@@ -2454,7 +2460,7 @@ settings.protect_whitelist_teams=Équipes autorisées à pousser :
24542460
settings.protect_force_push_allowlist_users=Utilisateurs autorisés à pousser en force :
24552461
settings.protect_force_push_allowlist_teams=Équipes autorisées à pousser en force :
24562462
settings.protect_force_push_allowlist_deploy_keys=Clés de déploiement pouvant pousser autorisées à pousser en force.
2457-
settings.protect_merge_whitelist_committers=Activer la liste d’autorisés pour la fusion
2463+
settings.protect_merge_whitelist_committers=Fusion sur autorisation uniquement
24582464
settings.protect_merge_whitelist_committers_desc=N’autoriser que les utilisateurs et les équipes listés à appliquer les demandes de fusion sur cette branche.
24592465
settings.protect_merge_whitelist_users=Utilisateurs autorisés à fusionner :
24602466
settings.protect_merge_whitelist_teams=Équipes autorisées à fusionner :
@@ -2468,7 +2474,7 @@ settings.protect_invalid_status_check_pattern=Motif de vérification des statuts
24682474
settings.protect_no_valid_status_check_patterns=Aucun motif de vérification des statuts valide.
24692475
settings.protect_required_approvals=Minimum d'approbations requis :
24702476
settings.protect_required_approvals_desc=Permet de fusionner les demandes d’ajout lorsque suffisamment d’évaluation sont positives.
2471-
settings.protect_approvals_whitelist_enabled=Restreindre les approbations aux utilisateurs ou aux équipes sur liste d’autorisés
2477+
settings.protect_approvals_whitelist_enabled=Restreindre les approbations sur autorisation uniquement
24722478
settings.protect_approvals_whitelist_enabled_desc=Seuls les évaluations des utilisateurs ou des équipes suivantes compteront dans les approbations requises. Si laissé vide, les évaluations de toute personne ayant un accès en écriture seront comptabilisées à la place.
24732479
settings.protect_approvals_whitelist_users=Évaluateurs autorisés :
24742480
settings.protect_approvals_whitelist_teams=Équipes d’évaluateurs autorisés :

options/locale/locale_ga-IE.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,9 @@ settings.event_pull_request_review_request=Iarratas ar Athbhreithniú Tarraingth
23792379
settings.event_pull_request_review_request_desc=Tarraing athbhreithniú iarratais iarrtha nó baineadh iarratas athbhreithnithe.
23802380
settings.event_pull_request_approvals=Ceaduithe Iarratais Tarraing
23812381
settings.event_pull_request_merge=Cumaisc Iarratas Tarraing
2382+
settings.event_header_workflow=Imeachtaí Sreabhadh Oibre
2383+
settings.event_workflow_job=Poist Sreabhadh Oibre
2384+
settings.event_workflow_job_desc=Gitea Actions Sreabhadh oibre post ciúáilte, ag fanacht, ar siúl, nó críochnaithe.
23822385
settings.event_package=Pacáiste
23832386
settings.event_package_desc=Pacáiste a cruthaíodh nó a scriosadh i stóras.
23842387
settings.branch_filter=Scagaire brainse

0 commit comments

Comments
 (0)