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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
f6ecb726
Commit
f6ecb726
authored
May 09, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Repository#xcode_project? method
parent
2de67448
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
3 deletions
+41
-3
app/models/repository.rb
app/models/repository.rb
+8
-2
lib/gitlab/file_detector.rb
lib/gitlab/file_detector.rb
+1
-0
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+32
-1
No files found.
app/models/repository.rb
View file @
f6ecb726
...
@@ -37,7 +37,7 @@ class Repository
...
@@ -37,7 +37,7 @@ class Repository
changelog license_blob license_key gitignore koding_yml
changelog license_blob license_key gitignore koding_yml
gitlab_ci_yml branch_names tag_names branch_count
gitlab_ci_yml branch_names tag_names branch_count
tag_count avatar exists? root_ref has_visible_content?
tag_count avatar exists? root_ref has_visible_content?
issue_template_names merge_request_template_names)
.
freeze
issue_template_names merge_request_template_names
xcode_project?
)
.
freeze
# Methods that use cache_method but only memoize the value
# Methods that use cache_method but only memoize the value
MEMOIZED_CACHED_METHODS
=
%i(license)
.
freeze
MEMOIZED_CACHED_METHODS
=
%i(license)
.
freeze
...
@@ -55,7 +55,8 @@ class Repository
...
@@ -55,7 +55,8 @@ class Repository
gitlab_ci: :gitlab_ci_yml
,
gitlab_ci: :gitlab_ci_yml
,
avatar: :avatar
,
avatar: :avatar
,
issue_template: :issue_template_names
,
issue_template: :issue_template_names
,
merge_request_template: :merge_request_template_names
merge_request_template: :merge_request_template_names
,
xcode_config: :xcode_project?
}.
freeze
}.
freeze
def
initialize
(
full_path
,
project
,
disk_path:
nil
,
is_wiki:
false
)
def
initialize
(
full_path
,
project
,
disk_path:
nil
,
is_wiki:
false
)
...
@@ -594,6 +595,11 @@ class Repository
...
@@ -594,6 +595,11 @@ class Repository
end
end
cache_method
:gitlab_ci_yml
cache_method
:gitlab_ci_yml
def
xcode_project?
file_on_head
(
:xcode_config
).
present?
end
cache_method
:xcode_project?
def
head_commit
def
head_commit
@head_commit
||=
commit
(
self
.
root_ref
)
@head_commit
||=
commit
(
self
.
root_ref
)
end
end
...
...
lib/gitlab/file_detector.rb
View file @
f6ecb726
...
@@ -14,6 +14,7 @@ module Gitlab
...
@@ -14,6 +14,7 @@ module Gitlab
avatar:
/\Alogo\.(png|jpg|gif)\z/
,
avatar:
/\Alogo\.(png|jpg|gif)\z/
,
issue_template:
%r{
\A\.
gitlab/issue_templates/[^/]+
\.
md
\z
}
,
issue_template:
%r{
\A\.
gitlab/issue_templates/[^/]+
\.
md
\z
}
,
merge_request_template:
%r{
\A\.
gitlab/merge_request_templates/[^/]+
\.
md
\z
}
,
merge_request_template:
%r{
\A\.
gitlab/merge_request_templates/[^/]+
\.
md
\z
}
,
xcode_config:
%r{
\A
[^/]*
\.
(xcodeproj|xcworkspace)
\z
}
,
# Configuration files
# Configuration files
gitignore:
'.gitignore'
,
gitignore:
'.gitignore'
,
...
...
spec/models/repository_spec.rb
View file @
f6ecb726
...
@@ -1733,7 +1733,8 @@ describe Repository do
...
@@ -1733,7 +1733,8 @@ describe Repository do
:gitlab_ci
,
:gitlab_ci
,
:avatar
,
:avatar
,
:issue_template
,
:issue_template
,
:merge_request_template
:merge_request_template
,
:xcode_config
])
])
repository
.
after_change_head
repository
.
after_change_head
...
@@ -2058,6 +2059,36 @@ describe Repository do
...
@@ -2058,6 +2059,36 @@ describe Repository do
end
end
end
end
describe
'#xcode_project?'
do
before
do
allow
(
repository
).
to
receive
(
:tree
).
with
(
:head
).
and_return
(
double
(
:tree
,
blobs:
[
blob
]))
end
context
'when the root contains a *.xcodeproj file'
do
let
(
:blob
)
{
double
(
:blob
,
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'
)
}
it
'returns true'
do
expect
(
repository
.
xcode_project?
).
to
be_truthy
end
end
context
'when the root contains no XCode config file'
do
let
(
:blob
)
{
double
(
:blob
,
path:
'subdir/Foo.xcworkspace'
)
}
it
'returns false'
do
expect
(
repository
.
xcode_project?
).
to
be_falsey
end
end
end
describe
"#keep_around"
do
describe
"#keep_around"
do
it
"does not fail if we attempt to reference bad commit"
do
it
"does not fail if we attempt to reference bad commit"
do
expect
(
repository
.
kept_around?
(
'abc1234'
)).
to
be_falsey
expect
(
repository
.
kept_around?
(
'abc1234'
)).
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