Skip to content

Commit

Permalink
Revert "fix: improve GetPushEventPayload"
Browse files Browse the repository at this point in the history
This reverts commit b99f9f8.
  • Loading branch information
wolfogre committed Mar 1, 2023
1 parent b99f9f8 commit e6f01cc
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions models/actions/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,13 @@ func (run *ActionRun) Duration() time.Duration {

func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {
if run.Event == webhook_module.HookEventPush {
return nil, fmt.Errorf("event %s is not a push event", run.Event)
}

payload := &api.PushPayload{}
if err := json.Unmarshal([]byte(run.EventPayload), payload); err != nil {
return nil, err
}

// Since it comes from json unmarshal, we should check if it's broken
if payload.HeadCommit == nil {
return nil, fmt.Errorf("nil HeadCommit")
}
if payload.Repo == nil {
return nil, fmt.Errorf("nil Repo")
}
if payload.Pusher == nil {
return nil, fmt.Errorf("nil Pusher")
}
if payload.Sender == nil {
return nil, fmt.Errorf("nil Sender")
var payload api.PushPayload
if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
return nil, err
}
return &payload, nil
}

return payload, nil
return nil, fmt.Errorf("event %s is not a push event", run.Event)
}

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

0 comments on commit e6f01cc

Please sign in to comment.