Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab
Merge requests
!179308
Draft: feat: ...
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Draft: feat: ...
rabbixt/gitlab:rabbixt-negated-change-globs
into
master
Overview
3
Commits
5
Pipelines
10
Changes
1
Closed
Carl P. Corliss
requested to merge
rabbixt/gitlab:rabbixt-negated-change-globs
into
master
1 month ago
Overview
3
Commits
5
Pipelines
10
Changes
1
Expand
...
Edited
1 month ago
by
Carl P. Corliss
0
0
Merge request reports
Viewing commit
32b8e2f3
Show latest version
1 file
+
8
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
32b8e2f3
rubocop fixes
· 32b8e2f3
Carl P. Corliss
authored
1 month ago
lib/gitlab/ci/build/policy/changes.rb
+
8
−
6
Options
@@ -5,6 +5,8 @@ module Ci
module
Build
module
Policy
class
Changes
<
Policy
::
Specification
FNMATCH_FLAGS
=
File
::
FNM_PATHNAME
|
File
::
FNM_DOTMATCH
|
File
::
FNM_EXTGLOB
def
initialize
(
globs
)
@globs
=
Array
(
globs
)
end
@@ -18,18 +20,18 @@ def satisfied_by?(pipeline, context)
positive_matches
=
[]
@globs
.
each
do
|
glob
|
if
glob
.
start_with?
(
'!'
)
# negative glob pattern
negative_matches
<<
File
.
fnmatch?
(
glob
[
1
..
],
path
,
F
ile
::
FNM_PATHNAME
|
File
::
FNM_DOTMATCH
|
File
::
FNM_EXTGLOB
)
if
glob
.
start_with?
(
'!'
)
negative_matches
<<
File
.
fnmatch?
(
glob
[
1
..
],
path
,
F
NMATCH_FLAGS
)
else
positive_matches
<<
File
.
fnmatch?
(
glob
,
path
,
F
ile
::
FNM_PATHNAME
|
File
::
FNM_DOTMATCH
|
File
::
FNM_EXTGLOB
)
positive_matches
<<
File
.
fnmatch?
(
glob
,
path
,
F
NMATCH_FLAGS
)
end
end
if
positive_matches
.
empty?
&&
negative_matches
.
empty?
# Path doesn't match any of our patterns, so not a match
false
false
elsif
positive_matches
.
empty?
# No positive matches means that we were only supplied negated patterns.
# No positive matches means that we were only supplied negated patterns.
# Which is the same as saying "Allow all EXCEPT these (negated) globs." So,
# if none of our negated globs matched, then the path is okay to allow.
!
negative_matches
.
any?
@@ -43,4 +45,4 @@ def satisfied_by?(pipeline, context)
end
end
end
end
\ No newline at end of file
end
Loading