Skip to content

Commit e6f01cc

Browse files
committed
Revert "fix: improve GetPushEventPayload"
This reverts commit b99f9f8.
1 parent b99f9f8 commit e6f01cc

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

models/actions/run.go

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,13 @@ func (run *ActionRun) Duration() time.Duration {
119119

120120
func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {
121121
if run.Event == webhook_module.HookEventPush {
122-
return nil, fmt.Errorf("event %s is not a push event", run.Event)
123-
}
124-
125-
payload := &api.PushPayload{}
126-
if err := json.Unmarshal([]byte(run.EventPayload), payload); err != nil {
127-
return nil, err
128-
}
129-
130-
// Since it comes from json unmarshal, we should check if it's broken
131-
if payload.HeadCommit == nil {
132-
return nil, fmt.Errorf("nil HeadCommit")
133-
}
134-
if payload.Repo == nil {
135-
return nil, fmt.Errorf("nil Repo")
136-
}
137-
if payload.Pusher == nil {
138-
return nil, fmt.Errorf("nil Pusher")
139-
}
140-
if payload.Sender == nil {
141-
return nil, fmt.Errorf("nil Sender")
122+
var payload api.PushPayload
123+
if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
124+
return nil, err
125+
}
126+
return &payload, nil
142127
}
143-
144-
return payload, nil
128+
return nil, fmt.Errorf("event %s is not a push event", run.Event)
145129
}
146130

147131
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {

0 commit comments

Comments
 (0)