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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle fancy wildcard branch patterns #49

Merged
merged 2 commits into from Apr 17, 2019
Merged

Handle fancy wildcard branch patterns #49

merged 2 commits into from Apr 17, 2019

Conversation

lox
Copy link

@lox lox commented Apr 10, 2019

Based on feedback in https://forum.buildkite.community/t/cli-steps-dont-run-when-there-is-a-negated-branch-filter/400/5, this adds support for different branch filter patterns.

@keithpitt I'd love some feedback on what the actual types of patterns that are supported are 馃槄

@lox lox requested a review from keithpitt April 10, 2019 05:51
@keithpitt
Copy link
Member

These are "matching" fixtures. Left is the pattern, right is the branch. All return "yes, it's a match"

# empty branch names
[ "foo", nil ],
[ "", nil ],
[ "    ", nil ],

# empty branch configs
[ nil, "foo" ],
[ nil, "" ],
[ nil, "       " ],

# single name branch matches
[ "foo bar", "foo" ],
[ "foo             bar", "bar" ],

# with whitespace
[ "    master   ", "master" ],
[ "master   ", "master" ],
[ "   master", "master" ],

# ones with a slash
[ "feature/authentication", "feature/authentication" ],

# not-checking
[ "!foo", "master" ],
[ "!release/production !release/test", "master" ],

# prefix wildcards
[ "*-do-the-thing", "can-you-do-the-thing" ],
[ "!*-do-the-thing", "can-you-do-the-thing-please" ],

# wildcards
[ "release/*", "release/foo" ],
[ "release/*", "release/bar/bing" ],
[ "release-*", "release-thingy" ],
[ "release-* release/*", "release-thingy" ],
[ "release-* release/*", "release/thingy" ],
[ "this-*-thing-is-the-*", "this-ruby-thing-is-the-worst" ],
[ "this-*-thing-is-the-*", "this-regex-thing-is-the-best" ],
[ "this-*-thing-is-the-*", "this-*-thing-is-the-*" ],
[ "this-*-thing-is-the-*", "this--thing-is-the-best-" ],

Here's are the ones that return false, not a match:

# branch names
[ "foo         bar", "bang" ],

# not-matchers
[ "!foo bar", "foo" ],
[ "!release/*", "release/foo" ],
[ "!release/*", "release/bar" ],
[ "!refs/tags/*", "refs/tags/production" ],
[ "!release/production !release/test", "release/production" ],
[ "!release/production !release/test", "release/test" ],

# ones with a slash
[ "feature/authentication", "update/deployment" ],

# wildcards
[ "release-*", "release/thingy" ],
[ "release-*", "master" ],
[ "*-do-the-thing", "this-is-not-the-thing" ],

@keithpitt
Copy link
Member

Feel free to pilfer the data and add them into the test suite!

if branches != nil {
// Sometimes branches are space delimited, sometimes comma
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BK backend doesn't support branches: "foo, bar" - is that what this bit is for? Or is this something else?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool, not sure where I got that from, but will ditch it.

@lox
Copy link
Author

lox commented Apr 16, 2019

Mind reviewing where I got up to when you get a minute @keithpitt?

@lox
Copy link
Author

lox commented Apr 17, 2019

Gonna yolo merge this.

@lox lox merged commit 9adc7d7 into master Apr 17, 2019
@lox lox deleted the handle-branch-patterns branch April 17, 2019 22:28
@gerrywastaken
Copy link

Thanks @lox!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants