Skip to content

Commit e1057cc

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix line height on inline code preview (go-gitea#30372) Refactor more filterslice (go-gitea#30370) Fix ambiguous id when fetch Actions tasks (go-gitea#30382) Fix floated list items (go-gitea#30377) Fix actions design about default actions download url (go-gitea#30360) Add container.FilterSlice function (go-gitea#30339) Fix label-list rendering in timeline, decrease gap (go-gitea#30342) Performance optimization for git push (go-gitea#30104) Reduce checkbox size to 15px (go-gitea#30346)
2 parents d5add2e + 6cac11c commit e1057cc

File tree

29 files changed

+287
-287
lines changed

29 files changed

+287
-287
lines changed

cmd/hook.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -448,21 +448,24 @@ Gitea or set your environment appropriately.`, "")
448448

449449
func hookPrintResults(results []private.HookPostReceiveBranchResult) {
450450
for _, res := range results {
451-
if !res.Message {
452-
continue
453-
}
451+
hookPrintResult(res.Message, res.Create, res.Branch, res.URL)
452+
}
453+
}
454454

455-
fmt.Fprintln(os.Stderr, "")
456-
if res.Create {
457-
fmt.Fprintf(os.Stderr, "Create a new pull request for '%s':\n", res.Branch)
458-
fmt.Fprintf(os.Stderr, " %s\n", res.URL)
459-
} else {
460-
fmt.Fprint(os.Stderr, "Visit the existing pull request:\n")
461-
fmt.Fprintf(os.Stderr, " %s\n", res.URL)
462-
}
463-
fmt.Fprintln(os.Stderr, "")
464-
os.Stderr.Sync()
455+
func hookPrintResult(output, isCreate bool, branch, url string) {
456+
if !output {
457+
return
458+
}
459+
fmt.Fprintln(os.Stderr, "")
460+
if isCreate {
461+
fmt.Fprintf(os.Stderr, "Create a new pull request for '%s':\n", branch)
462+
fmt.Fprintf(os.Stderr, " %s\n", url)
463+
} else {
464+
fmt.Fprint(os.Stderr, "Visit the existing pull request:\n")
465+
fmt.Fprintf(os.Stderr, " %s\n", url)
465466
}
467+
fmt.Fprintln(os.Stderr, "")
468+
os.Stderr.Sync()
466469
}
467470

468471
func pushOptions() map[string]string {
@@ -691,6 +694,12 @@ Gitea or set your environment appropriately.`, "")
691694
}
692695
err = writeFlushPktLine(ctx, os.Stdout)
693696

697+
if err == nil {
698+
for _, res := range resp.Results {
699+
hookPrintResult(res.ShouldShowMessage, res.IsCreatePR, res.HeadBranch, res.URL)
700+
}
701+
}
702+
694703
return err
695704
}
696705

docs/content/usage/actions/design.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ However, if a job container tries to fetch code from localhost, it will fail bec
104104
### Connection 3, act runner to internet
105105

106106
When you use some actions like `actions/checkout@v4`, the act runner downloads the scripts, not the job containers.
107-
By default, it downloads from [gitea.com](http://gitea.com/), so it requires access to the internet.
107+
By default, it downloads from [github.com](http://github.com/), so it requires access to the internet. If you configure the `DEFAULT_ACTIONS_URL` to `self`, then it will download from your Gitea instance by default. Then it will not connect to internet when downloading the action itself.
108108
It also downloads some docker images from Docker Hub by default, which also requires internet access.
109109

110110
However, internet access is not strictly necessary.

docs/content/usage/actions/design.zh-cn.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ act runner 必须能够连接到Gitea以接收任务并发送执行结果回来
105105
### 连接 3,act runner到互联网
106106

107107
当您使用诸如 `actions/checkout@v4` 的一些Actions时,act runner下载的是脚本,而不是Job容器。
108-
默认情况下,它从[gitea.com](http://gitea.com/)下载,因此需要访问互联网。
108+
默认情况下,它从[github.com](http://github.com/)下载,因此需要访问互联网。如果您设置的是 self,
109+
那么默认将从您的当前Gitea实例下载,那么此步骤不需要连接到互联网。
109110
它还默认从Docker Hub下载一些Docker镜像,这也需要互联网访问。
110111

111112
然而,互联网访问并不是绝对必需的。

models/actions/run_job_list.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@ import (
1616
type ActionJobList []*ActionRunJob
1717

1818
func (jobs ActionJobList) GetRunIDs() []int64 {
19-
ids := make(container.Set[int64], len(jobs))
20-
for _, j := range jobs {
21-
if j.RunID == 0 {
22-
continue
23-
}
24-
ids.Add(j.RunID)
25-
}
26-
return ids.Values()
19+
return container.FilterSlice(jobs, func(j *ActionRunJob) (int64, bool) {
20+
return j.RunID, j.RunID != 0
21+
})
2722
}
2823

2924
func (jobs ActionJobList) LoadRuns(ctx context.Context, withRepo bool) error {

models/actions/run_list.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ type RunList []*ActionRun
1919

2020
// GetUserIDs returns a slice of user's id
2121
func (runs RunList) GetUserIDs() []int64 {
22-
ids := make(container.Set[int64], len(runs))
23-
for _, run := range runs {
24-
ids.Add(run.TriggerUserID)
25-
}
26-
return ids.Values()
22+
return container.FilterSlice(runs, func(run *ActionRun) (int64, bool) {
23+
return run.TriggerUserID, true
24+
})
2725
}
2826

2927
func (runs RunList) GetRepoIDs() []int64 {
30-
ids := make(container.Set[int64], len(runs))
31-
for _, run := range runs {
32-
ids.Add(run.RepoID)
33-
}
34-
return ids.Values()
28+
return container.FilterSlice(runs, func(run *ActionRun) (int64, bool) {
29+
return run.RepoID, true
30+
})
3531
}
3632

3733
func (runs RunList) LoadTriggerUser(ctx context.Context) error {

models/actions/runner_list.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@ type RunnerList []*ActionRunner
1616

1717
// GetUserIDs returns a slice of user's id
1818
func (runners RunnerList) GetUserIDs() []int64 {
19-
ids := make(container.Set[int64], len(runners))
20-
for _, runner := range runners {
21-
if runner.OwnerID == 0 {
22-
continue
23-
}
24-
ids.Add(runner.OwnerID)
25-
}
26-
return ids.Values()
19+
return container.FilterSlice(runners, func(runner *ActionRunner) (int64, bool) {
20+
return runner.OwnerID, runner.OwnerID != 0
21+
})
2722
}
2823

2924
func (runners RunnerList) LoadOwners(ctx context.Context) error {
@@ -41,16 +36,9 @@ func (runners RunnerList) LoadOwners(ctx context.Context) error {
4136
}
4237

4338
func (runners RunnerList) getRepoIDs() []int64 {
44-
repoIDs := make(container.Set[int64], len(runners))
45-
for _, runner := range runners {
46-
if runner.RepoID == 0 {
47-
continue
48-
}
49-
if _, ok := repoIDs[runner.RepoID]; !ok {
50-
repoIDs[runner.RepoID] = struct{}{}
51-
}
52-
}
53-
return repoIDs.Values()
39+
return container.FilterSlice(runners, func(runner *ActionRunner) (int64, bool) {
40+
return runner.RepoID, runner.RepoID > 0
41+
})
5442
}
5543

5644
func (runners RunnerList) LoadRepos(ctx context.Context) error {

models/actions/schedule_list.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@ type ScheduleList []*ActionSchedule
1818

1919
// GetUserIDs returns a slice of user's id
2020
func (schedules ScheduleList) GetUserIDs() []int64 {
21-
ids := make(container.Set[int64], len(schedules))
22-
for _, schedule := range schedules {
23-
ids.Add(schedule.TriggerUserID)
24-
}
25-
return ids.Values()
21+
return container.FilterSlice(schedules, func(schedule *ActionSchedule) (int64, bool) {
22+
return schedule.TriggerUserID, true
23+
})
2624
}
2725

2826
func (schedules ScheduleList) GetRepoIDs() []int64 {
29-
ids := make(container.Set[int64], len(schedules))
30-
for _, schedule := range schedules {
31-
ids.Add(schedule.RepoID)
32-
}
33-
return ids.Values()
27+
return container.FilterSlice(schedules, func(schedule *ActionSchedule) (int64, bool) {
28+
return schedule.RepoID, true
29+
})
3430
}
3531

3632
func (schedules ScheduleList) LoadTriggerUser(ctx context.Context) error {

models/actions/schedule_spec_list.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ import (
1616
type SpecList []*ActionScheduleSpec
1717

1818
func (specs SpecList) GetScheduleIDs() []int64 {
19-
ids := make(container.Set[int64], len(specs))
20-
for _, spec := range specs {
21-
ids.Add(spec.ScheduleID)
22-
}
23-
return ids.Values()
19+
return container.FilterSlice(specs, func(spec *ActionScheduleSpec) (int64, bool) {
20+
return spec.ScheduleID, true
21+
})
2422
}
2523

2624
func (specs SpecList) LoadSchedules(ctx context.Context) error {
@@ -46,11 +44,9 @@ func (specs SpecList) LoadSchedules(ctx context.Context) error {
4644
}
4745

4846
func (specs SpecList) GetRepoIDs() []int64 {
49-
ids := make(container.Set[int64], len(specs))
50-
for _, spec := range specs {
51-
ids.Add(spec.RepoID)
52-
}
53-
return ids.Values()
47+
return container.FilterSlice(specs, func(spec *ActionScheduleSpec) (int64, bool) {
48+
return spec.RepoID, true
49+
})
5450
}
5551

5652
func (specs SpecList) LoadRepos(ctx context.Context) error {

models/actions/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
228228
if runner.RepoID != 0 {
229229
jobCond = builder.Eq{"repo_id": runner.RepoID}
230230
} else if runner.OwnerID != 0 {
231-
jobCond = builder.In("repo_id", builder.Select("id").From("repository").
231+
jobCond = builder.In("repo_id", builder.Select("`repository`.id").From("repository").
232232
Join("INNER", "repo_unit", "`repository`.id = `repo_unit`.repo_id").
233233
Where(builder.Eq{"`repository`.owner_id": runner.OwnerID, "`repo_unit`.type": unit.TypeActions}))
234234
}

models/actions/task_list.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@ import (
1616
type TaskList []*ActionTask
1717

1818
func (tasks TaskList) GetJobIDs() []int64 {
19-
ids := make(container.Set[int64], len(tasks))
20-
for _, t := range tasks {
21-
if t.JobID == 0 {
22-
continue
23-
}
24-
ids.Add(t.JobID)
25-
}
26-
return ids.Values()
19+
return container.FilterSlice(tasks, func(t *ActionTask) (int64, bool) {
20+
return t.JobID, t.JobID != 0
21+
})
2722
}
2823

2924
func (tasks TaskList) LoadJobs(ctx context.Context) error {

0 commit comments

Comments
 (0)