Skip to content

Commit 4f97ad2

Browse files
authored
Merge branch 'main' into issue-updates
2 parents 3d2ec73 + c9d0e63 commit 4f97ad2

File tree

208 files changed

+1444
-785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+1444
-785
lines changed

.eslintrc.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ rules:
296296
jquery/no-delegate: [2]
297297
jquery/no-each: [0]
298298
jquery/no-extend: [2]
299-
jquery/no-fade: [0]
299+
jquery/no-fade: [2]
300300
jquery/no-filter: [0]
301301
jquery/no-find: [0]
302302
jquery/no-global-eval: [2]
@@ -309,7 +309,7 @@ rules:
309309
jquery/no-is-function: [2]
310310
jquery/no-is: [0]
311311
jquery/no-load: [2]
312-
jquery/no-map: [0]
312+
jquery/no-map: [2]
313313
jquery/no-merge: [2]
314314
jquery/no-param: [2]
315315
jquery/no-parent: [0]
@@ -451,7 +451,7 @@ rules:
451451
no-jquery/no-load: [2]
452452
no-jquery/no-map-collection: [0]
453453
no-jquery/no-map-util: [2]
454-
no-jquery/no-map: [0]
454+
no-jquery/no-map: [2]
455455
no-jquery/no-merge: [2]
456456
no-jquery/no-node-name: [2]
457457
no-jquery/no-noop: [2]

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,7 @@ test-mssql\#%: integrations.mssql.test generate-ini-mssql
602602
test-mssql-migration: migrations.mssql.test migrations.individual.mssql.test
603603

604604
.PHONY: playwright
605-
playwright: $(PLAYWRIGHT_DIR)
606-
npm install --no-save @playwright/test
605+
playwright: deps-frontend
607606
npx playwright install $(PLAYWRIGHT_FLAGS)
608607

609608
.PHONY: test-e2e%

cmd/keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func runKeys(c *cli.Context) error {
7171
ctx, cancel := installSignals()
7272
defer cancel()
7373

74-
setup(ctx, false)
74+
setup(ctx, c.Bool("debug"))
7575

7676
authorizedString, extra := private.AuthorizedPublicKeyByContent(ctx, content)
7777
// do not use handleCliResponseExtra or cli.NewExitError, if it exists immediately, it breaks some tests like Test_CmdKeys

cmd/serv.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,10 @@ func setup(ctx context.Context, debug bool) {
6363
setupConsoleLogger(log.FATAL, false, os.Stderr)
6464
}
6565
setting.MustInstalled()
66-
if debug {
67-
setting.RunMode = "dev"
68-
}
69-
70-
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
71-
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
7266
if _, err := os.Stat(setting.RepoRootPath); err != nil {
73-
if os.IsNotExist(err) {
74-
_ = fail(ctx, "Incorrect configuration, no repository directory.", "Directory `[repository].ROOT` %q was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository].ROOT` an absolute value.", setting.RepoRootPath)
75-
} else {
76-
_ = fail(ctx, "Incorrect configuration, repository directory is inaccessible", "Directory `[repository].ROOT` %q is inaccessible. err: %v", setting.RepoRootPath, err)
77-
}
67+
_ = fail(ctx, "Unable to access repository path", "Unable to access repository path %q, err: %v", setting.RepoRootPath, err)
7868
return
7969
}
80-
8170
if err := git.InitSimple(context.Background()); err != nil {
8271
_ = fail(ctx, "Failed to init git", "Failed to init git, err: %v", err)
8372
}

docs/content/usage/issue-pull-request-templates.en-us.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ menu:
1919

2020
Some projects have a standard list of questions that users need to answer
2121
when creating an issue or pull request. Gitea supports adding templates to the
22-
main branch of the repository so that they can autopopulate the form when users are
22+
**default branch of the repository** so that they can autopopulate the form when users are
2323
creating issues and pull requests. This will cut down on the initial back and forth
2424
of getting some clarifying details.
25+
It is currently not possible to provide generic issue/pull-request templates globally.
2526

2627
Additionally, the New Issue page URL can be suffixed with `?title=Issue+Title&body=Issue+Text` and the form will be populated with those strings. Those strings will be used instead of the template if there is one.
2728

modules/actions/github.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,45 @@ const (
2525
GithubEventSchedule = "schedule"
2626
)
2727

28+
// IsDefaultBranchWorkflow returns true if the event only triggers workflows on the default branch
29+
func IsDefaultBranchWorkflow(triggedEvent webhook_module.HookEventType) bool {
30+
switch triggedEvent {
31+
case webhook_module.HookEventDelete:
32+
// GitHub "delete" event
33+
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#delete
34+
return true
35+
case webhook_module.HookEventFork:
36+
// GitHub "fork" event
37+
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#fork
38+
return true
39+
case webhook_module.HookEventIssueComment:
40+
// GitHub "issue_comment" event
41+
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment
42+
return true
43+
case webhook_module.HookEventPullRequestComment:
44+
// GitHub "pull_request_comment" event
45+
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_comment-use-issue_comment
46+
return true
47+
case webhook_module.HookEventWiki:
48+
// GitHub "gollum" event
49+
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#gollum
50+
return true
51+
case webhook_module.HookEventSchedule:
52+
// GitHub "schedule" event
53+
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
54+
return true
55+
case webhook_module.HookEventIssues,
56+
webhook_module.HookEventIssueAssign,
57+
webhook_module.HookEventIssueLabel,
58+
webhook_module.HookEventIssueMilestone:
59+
// Github "issues" event
60+
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues
61+
return true
62+
}
63+
64+
return false
65+
}
66+
2867
// canGithubEventMatch check if the input Github event can match any Gitea event.
2968
func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEventType) bool {
3069
switch eventName {
@@ -75,6 +114,11 @@ func canGithubEventMatch(eventName string, triggedEvent webhook_module.HookEvent
75114
case GithubEventSchedule:
76115
return triggedEvent == webhook_module.HookEventSchedule
77116

117+
case GithubEventIssueComment:
118+
// https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_comment-use-issue_comment
119+
return triggedEvent == webhook_module.HookEventIssueComment ||
120+
triggedEvent == webhook_module.HookEventPullRequestComment
121+
78122
default:
79123
return eventName == string(triggedEvent)
80124
}

modules/actions/github_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ func TestCanGithubEventMatch(t *testing.T) {
103103
webhook_module.HookEventCreate,
104104
true,
105105
},
106+
{
107+
"create pull request comment",
108+
GithubEventIssueComment,
109+
webhook_module.HookEventPullRequestComment,
110+
true,
111+
},
106112
}
107113

108114
for _, tc := range testCases {

modules/git/batch_reader.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,7 @@ headerLoop:
203203
}
204204

205205
// Discard the rest of the tag
206-
discard := size - n + 1
207-
for discard > math.MaxInt32 {
208-
_, err := rd.Discard(math.MaxInt32)
209-
if err != nil {
210-
return id, err
211-
}
212-
discard -= math.MaxInt32
213-
}
214-
_, err := rd.Discard(int(discard))
215-
return id, err
206+
return id, DiscardFull(rd, size-n+1)
216207
}
217208

218209
// ReadTreeID reads a tree ID from a cat-file --batch stream, throwing away the rest of the stream.
@@ -238,16 +229,7 @@ headerLoop:
238229
}
239230

240231
// Discard the rest of the commit
241-
discard := size - n + 1
242-
for discard > math.MaxInt32 {
243-
_, err := rd.Discard(math.MaxInt32)
244-
if err != nil {
245-
return id, err
246-
}
247-
discard -= math.MaxInt32
248-
}
249-
_, err := rd.Discard(int(discard))
250-
return id, err
232+
return id, DiscardFull(rd, size-n+1)
251233
}
252234

253235
// git tree files are a list:
@@ -345,3 +327,21 @@ func init() {
345327
_, filename, _, _ := runtime.Caller(0)
346328
callerPrefix = strings.TrimSuffix(filename, "modules/git/batch_reader.go")
347329
}
330+
331+
func DiscardFull(rd *bufio.Reader, discard int64) error {
332+
if discard > math.MaxInt32 {
333+
n, err := rd.Discard(math.MaxInt32)
334+
discard -= int64(n)
335+
if err != nil {
336+
return err
337+
}
338+
}
339+
for discard > 0 {
340+
n, err := rd.Discard(int(discard))
341+
discard -= int64(n)
342+
if err != nil {
343+
return err
344+
}
345+
}
346+
return nil
347+
}

modules/git/blob_nogogit.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"bufio"
1010
"bytes"
1111
"io"
12-
"math"
1312

1413
"code.gitea.io/gitea/modules/log"
1514
)
@@ -104,25 +103,6 @@ func (b *blobReader) Read(p []byte) (n int, err error) {
104103
// Close implements io.Closer
105104
func (b *blobReader) Close() error {
106105
defer b.cancel()
107-
if b.n > 0 {
108-
for b.n > math.MaxInt32 {
109-
n, err := b.rd.Discard(math.MaxInt32)
110-
b.n -= int64(n)
111-
if err != nil {
112-
return err
113-
}
114-
b.n -= math.MaxInt32
115-
}
116-
n, err := b.rd.Discard(int(b.n))
117-
b.n -= int64(n)
118-
if err != nil {
119-
return err
120-
}
121-
}
122-
if b.n == 0 {
123-
_, err := b.rd.Discard(1)
124-
b.n--
125-
return err
126-
}
127-
return nil
106+
107+
return DiscardFull(b.rd, b.n+1)
128108
}

modules/git/commit_info_nogogit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ func GetLastCommitForPaths(ctx context.Context, commit *Commit, treePath string,
151151
return nil, err
152152
}
153153
if typ != "commit" {
154+
if err := DiscardFull(batchReader, size+1); err != nil {
155+
return nil, err
156+
}
154157
return nil, fmt.Errorf("unexpected type: %s for commit id: %s", typ, commitID)
155158
}
156159
c, err = CommitFromReader(commit.repo, MustIDFromString(commitID), io.LimitReader(batchReader, size))

0 commit comments

Comments
 (0)