Skip to content

Commit d2f8da1

Browse files
authored
Merge branch 'main' into fix-issue-due-edit
2 parents 795871d + ec261b6 commit d2f8da1

File tree

11 files changed

+228
-95
lines changed

11 files changed

+228
-95
lines changed

modules/actions/workflows.go

+107-35
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/gobwas/glob"
1717
"github.com/nektos/act/pkg/jobparser"
1818
"github.com/nektos/act/pkg/model"
19+
"github.com/nektos/act/pkg/workflowpattern"
1920
)
2021

2122
func ListWorkflows(commit *git.Commit) (git.Entries, error) {
@@ -152,40 +153,94 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
152153
}
153154

154155
matchTimes := 0
156+
hasBranchFilter := false
157+
hasTagFilter := false
158+
refName := git.RefName(pushPayload.Ref)
155159
// all acts conditions should be satisfied
156160
for cond, vals := range evt.Acts {
157161
switch cond {
158-
case "branches", "tags":
159-
refShortName := git.RefName(pushPayload.Ref).ShortName()
160-
for _, val := range vals {
161-
if glob.MustCompile(val, '/').Match(refShortName) {
162-
matchTimes++
162+
case "branches":
163+
hasBranchFilter = true
164+
if !refName.IsBranch() {
165+
break
166+
}
167+
patterns, err := workflowpattern.CompilePatterns(vals...)
168+
if err != nil {
169+
break
170+
}
171+
if !workflowpattern.Skip(patterns, []string{refName.ShortName()}, &workflowpattern.EmptyTraceWriter{}) {
172+
matchTimes++
173+
}
174+
case "branches-ignore":
175+
hasBranchFilter = true
176+
if !refName.IsBranch() {
177+
break
178+
}
179+
patterns, err := workflowpattern.CompilePatterns(vals...)
180+
if err != nil {
181+
break
182+
}
183+
if !workflowpattern.Filter(patterns, []string{refName.ShortName()}, &workflowpattern.EmptyTraceWriter{}) {
184+
matchTimes++
185+
}
186+
case "tags":
187+
hasTagFilter = true
188+
if !refName.IsTag() {
189+
break
190+
}
191+
patterns, err := workflowpattern.CompilePatterns(vals...)
192+
if err != nil {
193+
break
194+
}
195+
if !workflowpattern.Skip(patterns, []string{refName.ShortName()}, &workflowpattern.EmptyTraceWriter{}) {
196+
matchTimes++
197+
}
198+
case "tags-ignore":
199+
hasTagFilter = true
200+
if !refName.IsTag() {
201+
break
202+
}
203+
patterns, err := workflowpattern.CompilePatterns(vals...)
204+
if err != nil {
205+
break
206+
}
207+
if !workflowpattern.Filter(patterns, []string{refName.ShortName()}, &workflowpattern.EmptyTraceWriter{}) {
208+
matchTimes++
209+
}
210+
case "paths":
211+
filesChanged, err := commit.GetFilesChangedSinceCommit(pushPayload.Before)
212+
if err != nil {
213+
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", commit.ID.String(), err)
214+
} else {
215+
patterns, err := workflowpattern.CompilePatterns(vals...)
216+
if err != nil {
163217
break
164218
}
219+
if !workflowpattern.Skip(patterns, filesChanged, &workflowpattern.EmptyTraceWriter{}) {
220+
matchTimes++
221+
}
165222
}
166-
case "paths":
223+
case "paths-ignore":
167224
filesChanged, err := commit.GetFilesChangedSinceCommit(pushPayload.Before)
168225
if err != nil {
169226
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", commit.ID.String(), err)
170227
} else {
171-
for _, val := range vals {
172-
matched := false
173-
for _, file := range filesChanged {
174-
if glob.MustCompile(val, '/').Match(file) {
175-
matched = true
176-
break
177-
}
178-
}
179-
if matched {
180-
matchTimes++
181-
break
182-
}
228+
patterns, err := workflowpattern.CompilePatterns(vals...)
229+
if err != nil {
230+
break
231+
}
232+
if !workflowpattern.Filter(patterns, filesChanged, &workflowpattern.EmptyTraceWriter{}) {
233+
matchTimes++
183234
}
184235
}
185236
default:
186237
log.Warn("push event unsupported condition %q", cond)
187238
}
188239
}
240+
// if both branch and tag filter are defined in the workflow only one needs to match
241+
if hasBranchFilter && hasTagFilter {
242+
matchTimes++
243+
}
189244
return matchTimes == len(evt.Acts)
190245
}
191246

@@ -237,30 +292,47 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
237292
}
238293
}
239294
case "branches":
240-
refShortName := git.RefName(prPayload.PullRequest.Base.Ref).ShortName()
241-
for _, val := range vals {
242-
if glob.MustCompile(val, '/').Match(refShortName) {
243-
matchTimes++
295+
refName := git.RefName(prPayload.PullRequest.Base.Ref)
296+
patterns, err := workflowpattern.CompilePatterns(vals...)
297+
if err != nil {
298+
break
299+
}
300+
if !workflowpattern.Skip(patterns, []string{refName.ShortName()}, &workflowpattern.EmptyTraceWriter{}) {
301+
matchTimes++
302+
}
303+
case "branches-ignore":
304+
refName := git.RefName(prPayload.PullRequest.Base.Ref)
305+
patterns, err := workflowpattern.CompilePatterns(vals...)
306+
if err != nil {
307+
break
308+
}
309+
if !workflowpattern.Filter(patterns, []string{refName.ShortName()}, &workflowpattern.EmptyTraceWriter{}) {
310+
matchTimes++
311+
}
312+
case "paths":
313+
filesChanged, err := commit.GetFilesChangedSinceCommit(prPayload.PullRequest.Base.Ref)
314+
if err != nil {
315+
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", commit.ID.String(), err)
316+
} else {
317+
patterns, err := workflowpattern.CompilePatterns(vals...)
318+
if err != nil {
244319
break
245320
}
321+
if !workflowpattern.Skip(patterns, filesChanged, &workflowpattern.EmptyTraceWriter{}) {
322+
matchTimes++
323+
}
246324
}
247-
case "paths":
325+
case "paths-ignore":
248326
filesChanged, err := commit.GetFilesChangedSinceCommit(prPayload.PullRequest.Base.Ref)
249327
if err != nil {
250328
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", commit.ID.String(), err)
251329
} else {
252-
for _, val := range vals {
253-
matched := false
254-
for _, file := range filesChanged {
255-
if glob.MustCompile(val, '/').Match(file) {
256-
matched = true
257-
break
258-
}
259-
}
260-
if matched {
261-
matchTimes++
262-
break
263-
}
330+
patterns, err := workflowpattern.CompilePatterns(vals...)
331+
if err != nil {
332+
break
333+
}
334+
if !workflowpattern.Filter(patterns, filesChanged, &workflowpattern.EmptyTraceWriter{}) {
335+
matchTimes++
264336
}
265337
}
266338
default:

options/locale/locale_en-US.ini

+2
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ release = Release
10681068
releases = Releases
10691069
tag = Tag
10701070
released_this = released this
1071+
tagged_this = tagged this
10711072
file.title = %s at %s
10721073
file_raw = Raw
10731074
file_history = History
@@ -2287,6 +2288,7 @@ release.compare = Compare
22872288
release.edit = edit
22882289
release.ahead.commits = <strong>%d</strong> commits
22892290
release.ahead.target = to %s since this release
2291+
tag.ahead.target = to %s since this tag
22902292
release.source_code = Source Code
22912293
release.new_subheader = Releases organize project versions.
22922294
release.edit_subheader = Releases organize project versions.

options/locale/locale_ja-JP.ini

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ active_stopwatch=進行中のタイムトラッカー
1919
create_new=作成…
2020
user_profile_and_more=プロフィールと設定…
2121
signed_in_as=サインイン済み
22+
enable_javascript=このウェブサイトにはJavaScriptが必要です。
2223
toc=目次
2324
licenses=ライセンス
2425
return_to_gitea=Giteaに戻る
@@ -2248,7 +2249,9 @@ diff.review.header=レビューの送信
22482249
diff.review.placeholder=レビューコメント
22492250
diff.review.comment=コメント
22502251
diff.review.approve=承認
2252+
diff.review.self_reject=プルリクエストの作成者は自分のプルリクエストで変更要請できません
22512253
diff.review.reject=変更要請
2254+
diff.review.self_approve=プルリクエストの作成者は自分のプルリクエストを承認できません
22522255
diff.committed_by=committed by
22532256
diff.protected=保護されているファイル
22542257
diff.image.side_by_side=並べて表示
@@ -3127,6 +3130,7 @@ error.unit_not_allowed=このセクションへのアクセスが許可されて
31273130
title=パッケージ
31283131
desc=リポジトリ パッケージを管理します。
31293132
empty=パッケージはまだありません。
3133+
empty.documentation=パッケージレジストリの詳細については、 <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/packages/overview/">ドキュメント</a> を参照してください。
31303134
empty.repo=パッケージはアップロードしたけども、ここに表示されない? <a href="%[1]s">パッケージ設定</a>を開いて、パッケージをこのリポジトリにリンクしてください。
31313135
filter.type=タイプ
31323136
filter.type.all=すべて

routers/web/repo/actions/view.go

+42
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"code.gitea.io/gitea/models/db"
1515
"code.gitea.io/gitea/models/unit"
1616
"code.gitea.io/gitea/modules/actions"
17+
"code.gitea.io/gitea/modules/base"
1718
context_module "code.gitea.io/gitea/modules/context"
1819
"code.gitea.io/gitea/modules/log"
1920
"code.gitea.io/gitea/modules/timeutil"
@@ -57,6 +58,7 @@ type ViewResponse struct {
5758
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
5859
Done bool `json:"done"`
5960
Jobs []*ViewJob `json:"jobs"`
61+
Commit ViewCommit `json:"commit"`
6062
} `json:"run"`
6163
CurrentJob struct {
6264
Title string `json:"title"`
@@ -76,6 +78,25 @@ type ViewJob struct {
7678
CanRerun bool `json:"canRerun"`
7779
}
7880

81+
type ViewCommit struct {
82+
LocaleCommit string `json:"localeCommit"`
83+
LocalePushedBy string `json:"localePushedBy"`
84+
ShortSha string `json:"shortSHA"`
85+
Link string `json:"link"`
86+
Pusher ViewUser `json:"pusher"`
87+
Branch ViewBranch `json:"branch"`
88+
}
89+
90+
type ViewUser struct {
91+
DisplayName string `json:"displayName"`
92+
Link string `json:"link"`
93+
}
94+
95+
type ViewBranch struct {
96+
Name string `json:"name"`
97+
Link string `json:"link"`
98+
}
99+
79100
type ViewJobStep struct {
80101
Summary string `json:"summary"`
81102
Duration string `json:"duration"`
@@ -104,6 +125,10 @@ func ViewPost(ctx *context_module.Context) {
104125
return
105126
}
106127
run := current.Run
128+
if err := run.LoadAttributes(ctx); err != nil {
129+
ctx.Error(http.StatusInternalServerError, err.Error())
130+
return
131+
}
107132

108133
resp := &ViewResponse{}
109134

@@ -123,6 +148,23 @@ func ViewPost(ctx *context_module.Context) {
123148
})
124149
}
125150

151+
pusher := ViewUser{
152+
DisplayName: run.TriggerUser.GetDisplayName(),
153+
Link: run.TriggerUser.HomeLink(),
154+
}
155+
branch := ViewBranch{
156+
Name: run.PrettyRef(),
157+
Link: run.RefLink(),
158+
}
159+
resp.State.Run.Commit = ViewCommit{
160+
LocaleCommit: ctx.Tr("actions.runs.commit"),
161+
LocalePushedBy: ctx.Tr("actions.runs.pushed_by"),
162+
ShortSha: base.ShortSha(run.CommitSHA),
163+
Link: fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA),
164+
Pusher: pusher,
165+
Branch: branch,
166+
}
167+
126168
var task *actions_model.ActionTask
127169
if current.TaskID > 0 {
128170
var err error

routers/web/repo/release.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ func releasesOrTagsFeed(ctx *context.Context, isReleasesOnly bool, formatType st
226226

227227
// SingleRelease renders a single release's page
228228
func SingleRelease(ctx *context.Context) {
229-
ctx.Data["Title"] = ctx.Tr("repo.release.releases")
230229
ctx.Data["PageIsReleaseList"] = true
230+
ctx.Data["DefaultBranch"] = ctx.Repo.Repository.DefaultBranch
231231

232232
writeAccess := ctx.Repo.CanWrite(unit.TypeReleases)
233233
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived
@@ -241,6 +241,12 @@ func SingleRelease(ctx *context.Context) {
241241
ctx.ServerError("GetReleasesByRepoID", err)
242242
return
243243
}
244+
ctx.Data["PageIsSingleTag"] = release.IsTag
245+
if release.IsTag {
246+
ctx.Data["Title"] = release.TagName
247+
} else {
248+
ctx.Data["Title"] = release.Title
249+
}
244250

245251
err = repo_model.GetReleaseAttachments(ctx, release)
246252
if err != nil {

services/repository/push.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,20 @@ func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo
374374
rel, has := relMap[lowerTag]
375375

376376
if !has {
377+
parts := strings.SplitN(tag.Message, "\n", 2)
378+
note := ""
379+
if len(parts) > 1 {
380+
note = parts[1]
381+
}
377382
rel = &repo_model.Release{
378383
RepoID: repo.ID,
379-
Title: "",
384+
Title: parts[0],
380385
TagName: tags[i],
381386
LowerTagName: lowerTag,
382387
Target: "",
383388
Sha1: commit.ID.String(),
384389
NumCommits: commitsCount,
385-
Note: "",
390+
Note: note,
386391
IsDraft: false,
387392
IsPrerelease: false,
388393
IsTag: true,

templates/projects/new.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<input type="hidden" name="board_type" value="{{.type}}">
3939
<div class="default text">{{.locale.Tr "repo.projects.template.desc_helper"}}</div>
4040
<div class="menu">
41-
{{range $element := .ProjectTypes}}
41+
{{range $element := .BoardTypes}}
4242
<div class="item" data-id="{{$element.BoardType}}" data-value="{{$element.BoardType}}">{{$.locale.Tr $element.Translation}}</div>
4343
{{end}}
4444
</div>

templates/repo/commits_list_small.tmpl

+8-15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
{{avatarByEmail $.root.Context .Author.Email .Author.Name}}
1414
{{end}}
1515

16+
{{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}}
17+
1618
<span class="ui float right shabox">
1719
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $.root}}
1820
{{$class := "ui sha label"}}
@@ -30,23 +32,14 @@
3032
{{$class = (printf "%s%s" $class " isWarning")}}
3133
{{end}}
3234
{{end}}
33-
{{if $.comment.Issue.PullRequest.BaseRepo.Name}}
34-
<a href="{{$.comment.Issue.PullRequest.BaseRepo.Link}}/commit/{{PathEscape .ID.String}}" rel="nofollow" class="{{$class}}">
35-
{{else}}
36-
<span class="{{$class}}">
37-
{{end}}
38-
<span class="shortsha">{{ShortSha .ID.String}}</span>
39-
{{if .Signature}}
40-
{{template "repo/shabox_badge" dict "root" $.root "verification" .Verification}}
41-
{{end}}
42-
{{if $.comment.Issue.PullRequest.BaseRepo.Name}}
43-
</a>
44-
{{else}}
45-
</span>
46-
{{end}}
35+
<a href="{{$commitLink}}" rel="nofollow" class="{{$class}}">
36+
<span class="shortsha">{{ShortSha .ID.String}}</span>
37+
{{if .Signature}}
38+
{{template "repo/shabox_badge" dict "root" $.root "verification" .Verification}}
39+
{{end}}
40+
</a>
4741
</span>
4842

49-
{{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}}
5043
<span class="gt-mono commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject $.root.Context .Message ($.comment.Issue.PullRequest.BaseRepo.Link|Escape) $commitLink $.comment.Issue.PullRequest.BaseRepo.ComposeMetas}}</span>
5144
{{if IsMultilineCommitMessage .Message}}
5245
<button class="ui button ellipsis-button" aria-expanded="false">...</button>

0 commit comments

Comments
 (0)