fix: import

This commit is contained in:
Jason Song 2022-12-29 15:02:10 +08:00
parent f11a31e54e
commit c84094011e
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5
3 changed files with 21 additions and 21 deletions

View File

@ -9,18 +9,18 @@ import (
"code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
packages_model "code.gitea.io/gitea/models/packages"
"code.gitea.io/gitea/models/perm"
perm_model "code.gitea.io/gitea/models/perm"
access_model "code.gitea.io/gitea/models/perm/access"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification/base"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/services/convert"
)
type actionsNotifier struct {
@ -132,7 +132,7 @@ func (n *actionsNotifier) NotifyIssueChangeLabels(ctx context.Context, doer *use
Action: api.HookIssueLabelUpdated,
Index: issue.Index,
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil),
Repository: convert.ToRepo(ctx, issue.Repo, perm.AccessModeNone),
Repository: convert.ToRepo(ctx, issue.Repo, perm_model.AccessModeNone),
Sender: convert.ToUser(doer, nil),
}).
Notify(ctx)
@ -220,7 +220,7 @@ func (n *actionsNotifier) NotifyCreateRepository(ctx context.Context, doer, u *u
newNotifyInput(repo, doer, webhook.HookEventRepository).WithPayload(&api.RepositoryPayload{
Action: api.HookRepoCreated,
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner),
Repository: convert.ToRepo(ctx, repo, perm_model.AccessModeOwner),
Organization: convert.ToUser(u, nil),
Sender: convert.ToUser(doer, nil),
}).Notify(ctx)
@ -247,7 +247,7 @@ func (n *actionsNotifier) NotifyForkRepository(ctx context.Context, doer *user_m
WithRef(oldRepo.DefaultBranch).
WithPayload(&api.RepositoryPayload{
Action: api.HookRepoCreated,
Repository: convert.ToRepo(ctx, repo, perm.AccessModeOwner),
Repository: convert.ToRepo(ctx, repo, perm_model.AccessModeOwner),
Organization: convert.ToUser(u, nil),
Sender: convert.ToUser(doer, nil),
}).Notify(ctx)
@ -358,7 +358,7 @@ func (n *actionsNotifier) NotifyPushCommits(ctx context.Context, pusher *user_mo
CompareURL: setting.AppURL + commits.CompareURL,
Commits: apiCommits,
HeadCommit: apiHeadCommit,
Repo: convert.ToRepo(ctx, repo, perm.AccessModeOwner),
Repo: convert.ToRepo(ctx, repo, perm_model.AccessModeOwner),
Pusher: apiPusher,
Sender: apiPusher,
}).
@ -369,7 +369,7 @@ func (n *actionsNotifier) NotifyCreateRef(ctx context.Context, pusher *user_mode
ctx = withMethod(ctx, "NotifyCreateRef")
apiPusher := convert.ToUser(pusher, nil)
apiRepo := convert.ToRepo(ctx, repo, perm.AccessModeNone)
apiRepo := convert.ToRepo(ctx, repo, perm_model.AccessModeNone)
refName := git.RefEndName(refFullName)
newNotifyInput(repo, pusher, webhook.HookEventCreate).
@ -388,7 +388,7 @@ func (n *actionsNotifier) NotifyDeleteRef(ctx context.Context, pusher *user_mode
ctx = withMethod(ctx, "NotifyDeleteRef")
apiPusher := convert.ToUser(pusher, nil)
apiRepo := convert.ToRepo(ctx, repo, perm.AccessModeNone)
apiRepo := convert.ToRepo(ctx, repo, perm_model.AccessModeNone)
refName := git.RefEndName(refFullName)
newNotifyInput(repo, pusher, webhook.HookEventDelete).
@ -423,7 +423,7 @@ func (n *actionsNotifier) NotifySyncPushCommits(ctx context.Context, pusher *use
Commits: apiCommits,
TotalCommits: commits.Len,
HeadCommit: apiHeadCommit,
Repo: convert.ToRepo(ctx, repo, perm.AccessModeOwner),
Repo: convert.ToRepo(ctx, repo, perm_model.AccessModeOwner),
Pusher: apiPusher,
Sender: apiPusher,
}).
@ -488,7 +488,7 @@ func (n *actionsNotifier) NotifyPullRequestSynchronized(ctx context.Context, doe
Action: api.HookIssueSynchronized,
Index: pr.Issue.Index,
PullRequest: convert.ToAPIPullRequest(ctx, pr, nil),
Repository: convert.ToRepo(ctx, pr.Issue.Repo, perm.AccessModeNone),
Repository: convert.ToRepo(ctx, pr.Issue.Repo, perm_model.AccessModeNone),
Sender: convert.ToUser(doer, nil),
}).
WithPullRequest(pr).

View File

@ -14,17 +14,17 @@ import (
packages_model "code.gitea.io/gitea/models/packages"
access_model "code.gitea.io/gitea/models/perm/access"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
unit_model "code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook"
webhook_model "code.gitea.io/gitea/models/webhook"
actions_module "code.gitea.io/gitea/modules/actions"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
actions_service "code.gitea.io/gitea/services/actions"
"code.gitea.io/gitea/services/convert"
"github.com/nektos/act/pkg/jobparser"
)
@ -54,7 +54,7 @@ type notifyInput struct {
// required
Repo *repo_model.Repository
Doer *user_model.User
Event webhook.HookEventType
Event webhook_model.HookEventType
// optional
Ref string
@ -62,7 +62,7 @@ type notifyInput struct {
PullRequest *issues_model.PullRequest
}
func newNotifyInput(repo *repo_model.Repository, doer *user_model.User, event webhook.HookEventType) *notifyInput {
func newNotifyInput(repo *repo_model.Repository, doer *user_model.User, event webhook_model.HookEventType) *notifyInput {
return &notifyInput{
Repo: repo,
Ref: repo.DefaultBranch,
@ -98,12 +98,12 @@ func (input *notifyInput) Notify(ctx context.Context) {
}
func notify(ctx context.Context, input *notifyInput) error {
if unit.TypeActions.UnitGlobalDisabled() {
if unit_model.TypeActions.UnitGlobalDisabled() {
return nil
}
if err := input.Repo.LoadUnits(db.DefaultContext); err != nil {
return fmt.Errorf("repo.LoadUnits: %w", err)
} else if !input.Repo.UnitEnabled(ctx, unit.TypeActions) {
} else if !input.Repo.UnitEnabled(ctx, unit_model.TypeActions) {
return nil
}
@ -171,7 +171,7 @@ func notify(ctx context.Context, input *notifyInput) error {
return nil
}
func newNotifyInputFromIssue(issue *issues_model.Issue, event webhook.HookEventType) *notifyInput {
func newNotifyInputFromIssue(issue *issues_model.Issue, event webhook_model.HookEventType) *notifyInput {
return newNotifyInput(issue.Repo, issue.Poster, event)
}
@ -183,7 +183,7 @@ func notifyRelease(ctx context.Context, doer *user_model.User, rel *repo_model.R
mode, _ := access_model.AccessLevel(ctx, doer, rel.Repo)
newNotifyInput(rel.Repo, doer, webhook.HookEventRelease).
newNotifyInput(rel.Repo, doer, webhook_model.HookEventRelease).
WithRef(ref).
WithPayload(&api.ReleasePayload{
Action: action,
@ -206,7 +206,7 @@ func notifyPackage(ctx context.Context, sender *user_model.User, pd *packages_mo
return
}
newNotifyInput(pd.Repository, sender, webhook.HookEventPackage).
newNotifyInput(pd.Repository, sender, webhook_model.HookEventPackage).
WithPayload(&api.PackagePayload{
Action: action,
Package: apiPackage,

View File

@ -12,10 +12,10 @@ import (
"code.gitea.io/gitea/modules/actions"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/convert"
)
const (