mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-15 22:41:19 +00:00
Ignore gitlab push events without commits (#3339)
Example of the resulting buggy pipeline: ![image](https://github.com/woodpecker-ci/woodpecker/assets/32853499/1e4bedc6-465b-466e-8d89-a7348e374c7f)
This commit is contained in:
parent
db4a50951c
commit
baf2e645bc
2 changed files with 6 additions and 2 deletions
|
@ -655,6 +655,9 @@ func (g *GitLab) Hook(ctx context.Context, req *http.Request) (*model.Repo, *mod
|
|||
|
||||
return repo, pipeline, nil
|
||||
case *gitlab.PushEvent:
|
||||
if event.TotalCommitsCount == 0 {
|
||||
return nil, nil, &forge_types.ErrIgnoreEvent{Event: string(eventType), Reason: "no commits"}
|
||||
}
|
||||
return convertPushHook(event)
|
||||
case *gitlab.TagEvent:
|
||||
return convertTagHook(event)
|
||||
|
|
|
@ -47,10 +47,11 @@ var ErrNotImplemented = errors.New("not implemented")
|
|||
|
||||
type ErrIgnoreEvent struct {
|
||||
Event string
|
||||
Reason string
|
||||
}
|
||||
|
||||
func (err *ErrIgnoreEvent) Error() string {
|
||||
return fmt.Sprintf("explicit ignored event '%s'", err.Event)
|
||||
return fmt.Sprintf("explicit ignored event '%s', reason: %s", err.Event, err.Reason)
|
||||
}
|
||||
|
||||
func (*ErrIgnoreEvent) Is(target error) bool {
|
||||
|
|
Loading…
Reference in a new issue