mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 11:51:02 +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
|
return repo, pipeline, nil
|
||||||
case *gitlab.PushEvent:
|
case *gitlab.PushEvent:
|
||||||
|
if event.TotalCommitsCount == 0 {
|
||||||
|
return nil, nil, &forge_types.ErrIgnoreEvent{Event: string(eventType), Reason: "no commits"}
|
||||||
|
}
|
||||||
return convertPushHook(event)
|
return convertPushHook(event)
|
||||||
case *gitlab.TagEvent:
|
case *gitlab.TagEvent:
|
||||||
return convertTagHook(event)
|
return convertTagHook(event)
|
||||||
|
|
|
@ -46,11 +46,12 @@ var _ error = new(AuthError)
|
||||||
var ErrNotImplemented = errors.New("not implemented")
|
var ErrNotImplemented = errors.New("not implemented")
|
||||||
|
|
||||||
type ErrIgnoreEvent struct {
|
type ErrIgnoreEvent struct {
|
||||||
Event string
|
Event string
|
||||||
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err *ErrIgnoreEvent) Error() 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 {
|
func (*ErrIgnoreEvent) Is(target error) bool {
|
||||||
|
|
Loading…
Reference in a new issue