Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special case single star branch/tag constraint #745

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/manager/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ func anyPatternMatches(s string, patterns []string) bool {
return true
}

// Treat a single star as a special case, matching everything.
// See https://github.com/opendevstack/ods-pipeline/issues/691
if patterns[0] == "*" {
return true
}

for _, pattern := range patterns {
if matched, err := path.Match(pattern, s); matched && err == nil {
return true
Expand Down
12 changes: 12 additions & 0 deletions internal/manager/receive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,18 @@ func TestIdentifyPipelineConfig(t *testing.T) {
wantPipelineIndex: 0,
wantTriggerIndex: 0,
},
"branch push - pipeline with one trigger with * constraint": {
pInfo: PipelineInfo{ChangeRefType: "BRANCH", GitRef: "feature/foo"},
odsConfig: config.ODS{
Pipelines: []config.Pipeline{
{Triggers: []config.Trigger{
{Branches: []string{"*"}},
}},
},
},
wantPipelineIndex: 0,
wantTriggerIndex: 0,
},
"branch push - pipeline with one trigger with matching branch constraint upper case": {
pInfo: PipelineInfo{ChangeRefType: "BRANCH", GitRef: "feature/FOO-123-hello-world"},
odsConfig: config.ODS{
Expand Down
Loading