From 696bacb290ab2e726dee04d0be8303e3a1f76aca Mon Sep 17 00:00:00 2001 From: wanghaosq Date: Wed, 1 Dec 2021 17:38:31 +0800 Subject: [PATCH] fix --- api/swagger.yaml | 4 ++ gitee/hook_event_models.go | 1 + gitee/hook_projecthook_accessors.go | 17 +++++++ ....go => hook_pullrequestevent_accessors.go} | 26 ++++++---- gitee/hook_pullrequesthook_accessors.go | 48 +++++++++++++++++++ 5 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 gitee/hook_projecthook_accessors.go rename gitee/{hook_pullrequest_accessors.go => hook_pullrequestevent_accessors.go} (86%) create mode 100644 gitee/hook_pullrequesthook_accessors.go diff --git a/api/swagger.yaml b/api/swagger.yaml index dbb16ac..7a53189 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -14483,6 +14483,10 @@ definitions: $ref: "#/definitions/UserBasic" milestone: $ref: "#/definitions/Milestone" + stale_labels: + type: "array" + items: + $ref: "#/definitions/StaleLabels" labels: type: "array" items: diff --git a/gitee/hook_event_models.go b/gitee/hook_event_models.go index 009440b..cbb5a33 100644 --- a/gitee/hook_event_models.go +++ b/gitee/hook_event_models.go @@ -158,6 +158,7 @@ type PullRequestHook struct { PatchUrl string `json:"patch_url,omitempty"` Title string `json:"title,omitempty"` Body string `json:"body,omitempty"` + StaleLabels []LabelHook `json:"stale_labels,omitempty"` Labels []LabelHook `json:"labels,omitempty"` CreatedAt string `json:"created_at,omitempty"` UpdatedAt string `json:"updated_at,omitempty"` diff --git a/gitee/hook_projecthook_accessors.go b/gitee/hook_projecthook_accessors.go new file mode 100644 index 0000000..90dd83e --- /dev/null +++ b/gitee/hook_projecthook_accessors.go @@ -0,0 +1,17 @@ +package gitee + +func (pj *ProjectHook) GetNameSpace() string { + if pj == nil { + return "" + } + + return pj.Namespace +} + +func (pj *ProjectHook) GetPath() string { + if pj == nil { + return "" + } + + return pj.Path +} \ No newline at end of file diff --git a/gitee/hook_pullrequest_accessors.go b/gitee/hook_pullrequestevent_accessors.go similarity index 86% rename from gitee/hook_pullrequest_accessors.go rename to gitee/hook_pullrequestevent_accessors.go index 45c6eac..0db9452 100644 --- a/gitee/hook_pullrequest_accessors.go +++ b/gitee/hook_pullrequestevent_accessors.go @@ -16,28 +16,28 @@ func (p *PullRequestEvent) GetActionDesc() string{ } func (p *PullRequestEvent) GetPullRequest() *PullRequestHook { - if p == nil || p.PullRequest == nil { + if p == nil { return nil } return p.PullRequest } func (p *PullRequestEvent) GetAuthor() *UserHook { - if p == nil || p.Author == nil { + if p == nil { return nil } return p.Author } func (p *PullRequestEvent) GetProject() *ProjectHook { - if p == nil || p.Project == nil { + if p == nil { return nil } return p.Project } func (p *PullRequestEvent) GetRepository() *ProjectHook { - if p == nil || p.Repository == nil { + if p == nil { return nil } return p.Repository @@ -100,42 +100,42 @@ func (p *PullRequestEvent) GetTargetBranch() string{ } func (p *PullRequestEvent) GetSourceRepo() *RepoInfo { - if p == nil || p.SourceRepo == nil { + if p == nil { return nil } return p.SourceRepo } func (p *PullRequestEvent) GetTargetRepo() *RepoInfo { - if p == nil || p.TargetRepo == nil { + if p == nil { return nil } return p.TargetRepo } func (p *PullRequestEvent) GetUpdatedBy() *UserHook { - if p == nil || p.UpdatedBy == nil { + if p == nil { return nil } return p.UpdatedBy } func (p *PullRequestEvent) GetSender() *UserHook { - if p == nil || p.Sender == nil { + if p == nil { return nil } return p.Sender } func (p *PullRequestEvent) GetTargetUser() *UserHook { - if p == nil || p.TargetUser == nil { + if p == nil { return nil } return p.TargetUser } func (p *PullRequestEvent) GetEnterprise() *EnterpriseHook { - if p == nil || p.Enterprise == nil { + if p == nil { return nil } return p.Enterprise @@ -154,3 +154,9 @@ func (p *PullRequestEvent) GetPassword() string{ } return *p.Password } + +func (p *PullRequestEvent) GetOwnerAndRepo() (string, string) { + r := p.GetRepository() + + return r.GetNameSpace(), r.GetPath() +} diff --git a/gitee/hook_pullrequesthook_accessors.go b/gitee/hook_pullrequesthook_accessors.go new file mode 100644 index 0000000..73d543a --- /dev/null +++ b/gitee/hook_pullrequesthook_accessors.go @@ -0,0 +1,48 @@ +package gitee + +func (ph *PullRequestHook) GetUser() *UserHook { + if ph == nil { + return nil + } + + return ph.User +} + +func (ph *PullRequestHook) GetAssignee() *UserHook { + if ph == nil { + return nil + } + + return ph.Assignee +} + +func (ph *PullRequestHook) GetMilestone() *MilestoneHook { + if ph == nil { + return nil + } + + return ph.Milestone +} + +func (ph *PullRequestHook) GetHead() *BranchHook { + if ph == nil { + return nil + } + + return ph.Head +} + +func (ph *PullRequestHook) GetBase() *BranchHook { + if ph == nil { + return nil + } + + return ph.Base +} +func (ph *PullRequestHook) GetUpdatedBy() *UserHook { + if ph == nil { + return nil + } + + return ph.UpdatedBy +} \ No newline at end of file