mirror of https://github.com/go-gitea/gitea
ParseRawOn is not required, use WorkflowDispatchConfig instead
This commit is contained in:
parent
0e6759196b
commit
300f068507
2
go.mod
2
go.mod
|
@ -302,7 +302,7 @@ replace github.com/hashicorp/go-version => github.com/6543/go-version v1.3.1
|
|||
|
||||
replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142115-2c99e1ffdfa0
|
||||
|
||||
replace github.com/nektos/act => gitea.com/pangliang/act v0.251.2-0.20231129053409-6a00b5cb3ceb
|
||||
replace github.com/nektos/act => gitea.com/pangliang/act v0.251.2-0.20231207061303-82548746b6e4
|
||||
|
||||
replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5
|
||||
|
||||
|
|
1
go.sum
1
go.sum
|
@ -65,6 +65,7 @@ gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4 h1:IFT+hup2xejHq
|
|||
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4/go.mod h1:HBqmLbz56JWpfEGG0prskAV97ATNRoj5LDmPicD22hU=
|
||||
gitea.com/pangliang/act v0.251.2-0.20231129053409-6a00b5cb3ceb h1:l1Jlxn7D6J+VfoP3R4F1IjxojZ7GEu2+tKeCet5HBkk=
|
||||
gitea.com/pangliang/act v0.251.2-0.20231129053409-6a00b5cb3ceb/go.mod h1:YthlRq0FUQIzgfJ3ZWvCvVq3I3VsC9s2NYQ9b2Uxccs=
|
||||
gitea.com/pangliang/act v0.251.2-0.20231207061303-82548746b6e4/go.mod h1:YthlRq0FUQIzgfJ3ZWvCvVq3I3VsC9s2NYQ9b2Uxccs=
|
||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
|
||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
|
||||
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121 h1:r3qt8PCHnfjOv9PN3H+XXKmDA1dfFMIN1AislhlA/ps=
|
||||
|
|
|
@ -7,11 +7,8 @@ import (
|
|||
"bytes"
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
webhook_module "code.gitea.io/gitea/modules/webhook"
|
||||
"fmt"
|
||||
"github.com/nektos/act/pkg/jobparser"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
|
@ -160,41 +157,33 @@ func List(ctx *context.Context) {
|
|||
ctx.Data["CurWorkflowDisabled"] = isWorkflowDisabled
|
||||
|
||||
if !isWorkflowDisabled && curWorkflow != nil {
|
||||
if events, err := jobparser.ParseRawOn(&curWorkflow.RawOn); err == nil {
|
||||
workflowDispatchConfig := curWorkflow.WorkflowDispatchConfig()
|
||||
if workflowDispatchConfig != nil {
|
||||
ctx.Data["AllowTriggerWorkflowDispatchEvent"] = true
|
||||
ctx.Data["WorkflowDispatchConfig"] = workflowDispatchConfig
|
||||
|
||||
branchOpts := git_model.FindBranchOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
IsDeletedBranch: util.OptionalBoolFalse,
|
||||
ListOptions: db.ListOptions{
|
||||
ListAll: true,
|
||||
},
|
||||
}
|
||||
branches, err := git_model.FindBranchNames(ctx, branchOpts)
|
||||
if err != nil {
|
||||
log.Warn("ignore check invalid workflow events %q: %v", curWorkflow.Name, err)
|
||||
} else {
|
||||
for _, event := range events {
|
||||
if event.Name == webhook_module.HookEventWorkflowDispatch.Event() {
|
||||
ctx.Data["AllowTriggerWorkflowDispatchEvent"] = true
|
||||
ctx.Data["WorkflowDispatchConfig"] = event.WorkflowDispatch()
|
||||
ctx.JSON(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
// always put default branch on the top if it exists
|
||||
if slices.Contains(branches, ctx.Repo.Repository.DefaultBranch) {
|
||||
branches = util.SliceRemoveAll(branches, ctx.Repo.Repository.DefaultBranch)
|
||||
branches = append([]string{ctx.Repo.Repository.DefaultBranch}, branches...)
|
||||
}
|
||||
ctx.Data["Branches"] = branches
|
||||
|
||||
branchOpts := git_model.FindBranchOptions{
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
IsDeletedBranch: util.OptionalBoolFalse,
|
||||
ListOptions: db.ListOptions{
|
||||
ListAll: true,
|
||||
},
|
||||
}
|
||||
branches, err := git_model.FindBranchNames(ctx, branchOpts)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
// always put default branch on the top if it exists
|
||||
if slices.Contains(branches, ctx.Repo.Repository.DefaultBranch) {
|
||||
branches = util.SliceRemoveAll(branches, ctx.Repo.Repository.DefaultBranch)
|
||||
branches = append([]string{ctx.Repo.Repository.DefaultBranch}, branches...)
|
||||
}
|
||||
ctx.Data["Branches"] = branches
|
||||
|
||||
tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||
if err == nil {
|
||||
ctx.Data["Tags"] = tags
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||
if err == nil {
|
||||
ctx.Data["Tags"] = tags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue