Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ccf52282
Commit
ccf52282
authored
May 07, 2021
by
Furkan Ayhan
Committed by
Mark Chao
May 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support wildcard with double asterisks for CI file includes
parent
c92f0085
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
10 deletions
+75
-10
app/models/repository.rb
app/models/repository.rb
+7
-1
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+14
-2
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+54
-7
No files found.
app/models/repository.rb
View file @
ccf52282
...
@@ -995,7 +995,13 @@ class Repository
...
@@ -995,7 +995,13 @@ class Repository
def
search_files_by_wildcard_path
(
path
,
ref
=
'HEAD'
)
def
search_files_by_wildcard_path
(
path
,
ref
=
'HEAD'
)
# We need to use RE2 to match Gitaly's regexp engine
# We need to use RE2 to match Gitaly's regexp engine
regexp_string
=
RE2
::
Regexp
.
escape
(
path
).
gsub
(
'\*'
,
'.*?'
)
regexp_string
=
RE2
::
Regexp
.
escape
(
path
)
anything
=
'.*?'
anything_but_not_slash
=
'([^\/])*?'
regexp_string
.
gsub!
(
'\*\*'
,
anything
)
regexp_string
.
gsub!
(
'\*'
,
anything_but_not_slash
)
raw_repository
.
search_files_by_regexp
(
"^
#{
regexp_string
}
$"
,
ref
)
raw_repository
.
search_files_by_regexp
(
"^
#{
regexp_string
}
$"
,
ref
)
end
end
...
...
doc/ci/yaml/README.md
View file @
ccf52282
...
@@ -487,7 +487,7 @@ Use local includes instead of symbolic links.
...
@@ -487,7 +487,7 @@ Use local includes instead of symbolic links.
> - It's not recommended for production use.
> - It's not recommended for production use.
> - To use it in GitLab self-managed instances, ask a GitLab administrator to enable it. **(CORE ONLY)**
> - To use it in GitLab self-managed instances, ask a GitLab administrator to enable it. **(CORE ONLY)**
You can use wildcard paths (
`*`
) with
`include:local`
.
You can use wildcard paths (
`*`
and
`**`
) with
`include:local`
.
Example:
Example:
...
@@ -495,7 +495,19 @@ Example:
...
@@ -495,7 +495,19 @@ Example:
include
:
'
configs/*.yml'
include
:
'
configs/*.yml'
```
```
When the pipeline runs, it adds all
`.yml`
files in the
`configs`
folder into the pipeline configuration.
When the pipeline runs, GitLab:
-
Adds all
`.yml`
files in the
`configs`
directory into the pipeline configuration.
-
Does not add
`.yml`
files in subfolders of the
`configs`
directory. To allow this,
add the following configuration:
```
yaml
# This matches all `.yml` files in `configs` and any subfolder in it.
include
:
'
configs/**.yml'
# This matches all `.yml` files only in subfolders of `configs`.
include
:
'
configs/**/*.yml'
```
The wildcard file paths feature is under development and not ready for production use. It is
The wildcard file paths feature is under development and not ready for production use. It is
deployed behind a feature flag that is
**disabled by default**
.
deployed behind a feature flag that is
**disabled by default**
.
...
...
spec/models/repository_spec.rb
View file @
ccf52282
...
@@ -1006,19 +1006,58 @@ RSpec.describe Repository do
...
@@ -1006,19 +1006,58 @@ RSpec.describe Repository do
end
end
end
end
context
'when specifying a path with wildcard'
do
context
'when specifying a wildcard path'
do
let
(
:path
)
{
'files/*/*.png'
}
let
(
:path
)
{
'*.md'
}
it
'returns files matching the path in the root folder'
do
expect
(
result
).
to
contain_exactly
(
'CONTRIBUTING.md'
,
'MAINTENANCE.md'
,
'PROCESS.md'
,
'README.md'
)
end
end
context
'when specifying a wildcard path for all'
do
let
(
:path
)
{
'**.md'
}
it
'returns all matching files in all folders'
do
expect
(
result
).
to
contain_exactly
(
'CONTRIBUTING.md'
,
'MAINTENANCE.md'
,
'PROCESS.md'
,
'README.md'
,
'files/markdown/ruby-style-guide.md'
,
'with space/README.md'
)
end
end
context
'when specifying a path to subfolders using two asterisks and a slash'
do
let
(
:path
)
{
'files/**/*.md'
}
it
'returns all files matching the path'
do
it
'returns all files matching the path'
do
expect
(
result
).
to
contain_exactly
(
'files/images/logo-black.png'
,
expect
(
result
).
to
contain_exactly
(
'files/markdown/ruby-style-guide.md'
)
'files/images/logo-white.png'
)
end
end
context
'when specifying a wildcard path to subfolder with just two asterisks'
do
let
(
:path
)
{
'files/**.md'
}
it
'returns all files in the matching path'
do
expect
(
result
).
to
contain_exactly
(
'files/markdown/ruby-style-guide.md'
)
end
end
context
'when specifying a wildcard path to subfolder with one asterisk'
do
let
(
:path
)
{
'files/*/*.md'
}
it
'returns all files in the matching path'
do
expect
(
result
).
to
contain_exactly
(
'files/markdown/ruby-style-guide.md'
)
end
end
end
end
context
'when specifying a
n extension with wildcard
'
do
context
'when specifying a
wildcard path for an unknown number of subfolder levels
'
do
let
(
:path
)
{
'*.rb'
}
let
(
:path
)
{
'*
*/*
.rb'
}
it
'returns all
files matching the extension
'
do
it
'returns all
matched files in all subfolders
'
do
expect
(
result
).
to
contain_exactly
(
'encoding/russian.rb'
,
expect
(
result
).
to
contain_exactly
(
'encoding/russian.rb'
,
'files/ruby/popen.rb'
,
'files/ruby/popen.rb'
,
'files/ruby/regex.rb'
,
'files/ruby/regex.rb'
,
...
@@ -1026,6 +1065,14 @@ RSpec.describe Repository do
...
@@ -1026,6 +1065,14 @@ RSpec.describe Repository do
end
end
end
end
context
'when specifying a wildcard path to one level of subfolders'
do
let
(
:path
)
{
'*/*.rb'
}
it
'returns all matched files in one subfolder'
do
expect
(
result
).
to
contain_exactly
(
'encoding/russian.rb'
)
end
end
context
'when sending regexp'
do
context
'when sending regexp'
do
let
(
:path
)
{
'.*\.rb'
}
let
(
:path
)
{
'.*\.rb'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment