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
83cda43a
Commit
83cda43a
authored
May 18, 2018
by
Douwe Maan
Committed by
Douwe Maan
May 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Xcode project detection by looking for dirs instead of files
parent
83660e57
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
13 deletions
+23
-13
app/models/repository.rb
app/models/repository.rb
+15
-5
lib/gitlab/file_detector.rb
lib/gitlab/file_detector.rb
+1
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+7
-7
No files found.
app/models/repository.rb
View file @
83cda43a
...
...
@@ -596,7 +596,7 @@ class Repository
cache_method
:gitlab_ci_yml
def
xcode_project?
file_on_head
(
:xcode_config
).
present?
file_on_head
(
:xcode_config
,
:tree
).
present?
end
cache_method
:xcode_project?
...
...
@@ -920,11 +920,21 @@ class Repository
end
end
def
file_on_head
(
type
)
if
head
=
tree
(
:head
)
head
.
blobs
.
find
do
|
blob
|
Gitlab
::
FileDetector
.
type_of
(
blob
.
path
)
==
type
def
file_on_head
(
type
,
object_type
=
:blob
)
return
unless
head
=
tree
(
:head
)
objects
=
case
object_type
when
:blob
head
.
blobs
when
:tree
head
.
trees
else
raise
ArgumentError
,
"Object type
#{
object_type
}
is not supported"
end
objects
.
find
do
|
object
|
Gitlab
::
FileDetector
.
type_of
(
object
.
path
)
==
type
end
end
...
...
lib/gitlab/file_detector.rb
View file @
83cda43a
...
...
@@ -14,7 +14,7 @@ module Gitlab
avatar:
/\Alogo\.(png|jpg|gif)\z/
,
issue_template:
%r{
\A\.
gitlab/issue_templates/[^/]+
\.
md
\z
}
,
merge_request_template:
%r{
\A\.
gitlab/merge_request_templates/[^/]+
\.
md
\z
}
,
xcode_config:
%r{
\A
[^/]*
\.
(xcodeproj|xcworkspace)
\z
}
,
xcode_config:
%r{
\A
[^/]*
\.
(xcodeproj|xcworkspace)
(/.+)?
\z
}
,
# Configuration files
gitignore:
'.gitignore'
,
...
...
spec/models/repository_spec.rb
View file @
83cda43a
...
...
@@ -2021,27 +2021,27 @@ describe Repository do
describe
'#xcode_project?'
do
before
do
allow
(
repository
).
to
receive
(
:tree
).
with
(
:head
).
and_return
(
double
(
:tree
,
blobs:
[
blob
]))
allow
(
repository
).
to
receive
(
:tree
).
with
(
:head
).
and_return
(
double
(
:tree
,
trees:
[
tree
]))
end
context
'when the root contains a *.xcodeproj
file
'
do
let
(
:
blob
)
{
double
(
:blob
,
path:
'Foo.xcodeproj'
)
}
context
'when the root contains a *.xcodeproj
directory
'
do
let
(
:
tree
)
{
double
(
:tree
,
path:
'Foo.xcodeproj'
)
}
it
'returns true'
do
expect
(
repository
.
xcode_project?
).
to
be_truthy
end
end
context
'when the root contains a *.xcworkspace
file
'
do
let
(
:
blob
)
{
double
(
:blob
,
path:
'Foo.xcworkspace'
)
}
context
'when the root contains a *.xcworkspace
directory
'
do
let
(
:
tree
)
{
double
(
:tree
,
path:
'Foo.xcworkspace'
)
}
it
'returns true'
do
expect
(
repository
.
xcode_project?
).
to
be_truthy
end
end
context
'when the root contains no X
Code config file
'
do
let
(
:
blob
)
{
double
(
:blob
,
path:
'subdir/Foo.xcworkspace
'
)
}
context
'when the root contains no X
code config directory
'
do
let
(
:
tree
)
{
double
(
:tree
,
path:
'Foo
'
)
}
it
'returns false'
do
expect
(
repository
.
xcode_project?
).
to
be_falsey
...
...
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