Fix branch condition on tags (#917)

* Fix branch condition on tags

* Add docs

* Update docs/docs/20-usage/20-pipeline-syntax.md

Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
qwerty287 2022-05-16 20:04:00 +02:00 committed by GitHub
parent 70af29f9a2
commit 687d57217d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -302,6 +302,10 @@ Example conditional execution by repository:
#### `branch`
:::note
Branch conditions are not applied to tags.
:::
Example conditional execution by branch:
```diff

View file

@ -53,7 +53,6 @@ func (c *Constraints) Match(metadata frontend.Metadata) bool {
match := c.Platform.Match(metadata.Sys.Arch) &&
c.Environment.Match(metadata.Curr.Target) &&
c.Event.Match(metadata.Curr.Event) &&
c.Branch.Match(metadata.Curr.Commit.Branch) &&
c.Repo.Match(metadata.Repo.Name) &&
c.Ref.Match(metadata.Curr.Commit.Ref) &&
c.Instance.Match(metadata.Sys.Host) &&
@ -63,6 +62,9 @@ func (c *Constraints) Match(metadata frontend.Metadata) bool {
if metadata.Curr.Event == frontend.EventPull || metadata.Curr.Event == frontend.EventPush {
match = match && c.Path.Match(metadata.Curr.Commit.ChangedFiles, metadata.Curr.Commit.Message)
}
if metadata.Curr.Event != frontend.EventTag {
match = match && c.Branch.Match(metadata.Curr.Commit.Branch)
}
return match
}