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
cf131bf7
Commit
cf131bf7
authored
Jun 27, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Gitlab::Ggit::Repository#submodules private
parent
99bdfd18
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
41 deletions
+30
-41
app/models/repository.rb
app/models/repository.rb
+0
-16
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+26
-21
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+4
-4
No files found.
app/models/repository.rb
View file @
cf131bf7
...
@@ -605,22 +605,6 @@ class Repository
...
@@ -605,22 +605,6 @@ class Repository
end
end
end
end
# Returns url for submodule
#
# Ex.
# @repository.submodule_url_for('master', 'rack')
# # => git@localhost:rack.git
#
def
submodule_url_for
(
ref
,
path
)
if
submodules
(
ref
).
any?
submodule
=
submodules
(
ref
)[
path
]
if
submodule
submodule
[
'url'
]
end
end
end
def
last_commit_for_path
(
sha
,
path
)
def
last_commit_for_path
(
sha
,
path
)
sha
=
last_commit_id_for_path
(
sha
,
path
)
sha
=
last_commit_id_for_path
(
sha
,
path
)
commit
(
sha
)
commit
(
sha
)
...
...
lib/gitlab/git/repository.rb
View file @
cf131bf7
...
@@ -613,32 +613,20 @@ module Gitlab
...
@@ -613,32 +613,20 @@ module Gitlab
rugged
.
rev_parse
(
oid_or_ref_name
)
rugged
.
rev_parse
(
oid_or_ref_name
)
end
end
# Return
hash with submodules info for this repository
# Return
s url for submodule
#
#
# Ex.
# Ex.
# {
# @repository.submodule_url_for('master', 'rack')
# "current_path/rack" => {
# # => git@localhost:rack.git
# "name" => "original_path/rack",
# "id" => "c67be4624545b4263184c4a0e8f887efd0a66320",
# "url" => "git://github.com/chneukirchen/rack.git"
# },
# "encoding" => {
# "id" => ....
# }
# }
#
#
def
submodule
s
(
ref
)
def
submodule
_url_for
(
ref
,
path
)
commit
=
rev_parse_target
(
ref
)
if
submodules
(
ref
).
any?
return
{}
unless
commit
submodule
=
submodules
(
ref
)[
path
]
begin
if
submodule
content
=
blob_content
(
commit
,
".gitmodules"
)
submodule
[
'url'
]
rescue
InvalidBlobName
end
return
{}
end
end
parser
=
GitmodulesParser
.
new
(
content
)
fill_submodule_ids
(
commit
,
parser
.
parse
)
end
end
# Return total commits count accessible from passed ref
# Return total commits count accessible from passed ref
...
@@ -976,6 +964,23 @@ module Gitlab
...
@@ -976,6 +964,23 @@ module Gitlab
private
private
# We are trying to deprecate this method because it does a lot of work
# but it seems to be used only to look up submodule URL's.
# https://gitlab.com/gitlab-org/gitaly/issues/329
def
submodules
(
ref
)
commit
=
rev_parse_target
(
ref
)
return
{}
unless
commit
begin
content
=
blob_content
(
commit
,
".gitmodules"
)
rescue
InvalidBlobName
return
{}
end
parser
=
GitmodulesParser
.
new
(
content
)
fill_submodule_ids
(
commit
,
parser
.
parse
)
end
def
alternate_object_directories
def
alternate_object_directories
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_DIRECTORIES_VARIABLES
).
compact
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_DIRECTORIES_VARIABLES
).
compact
end
end
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
cf131bf7
...
@@ -348,7 +348,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -348,7 +348,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_REPO_PATH
)
}
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_REPO_PATH
)
}
context
'where repo has submodules'
do
context
'where repo has submodules'
do
let
(
:submodules
)
{
repository
.
s
ubmodules
(
'master'
)
}
let
(
:submodules
)
{
repository
.
s
end
(
:submodules
,
'master'
)
}
let
(
:submodule
)
{
submodules
.
first
}
let
(
:submodule
)
{
submodules
.
first
}
it
{
expect
(
submodules
).
to
be_kind_of
Hash
}
it
{
expect
(
submodules
).
to
be_kind_of
Hash
}
...
@@ -383,12 +383,12 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -383,12 +383,12 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
it
'should not have an entry for an uncommited submodule dir'
do
it
'should not have an entry for an uncommited submodule dir'
do
submodules
=
repository
.
s
ubmodules
(
'fix-existing-submodule-dir'
)
submodules
=
repository
.
s
end
(
:submodules
,
'fix-existing-submodule-dir'
)
expect
(
submodules
).
not_to
have_key
(
'submodule-existing-dir'
)
expect
(
submodules
).
not_to
have_key
(
'submodule-existing-dir'
)
end
end
it
'should handle tags correctly'
do
it
'should handle tags correctly'
do
submodules
=
repository
.
s
ubmodules
(
'v1.2.1'
)
submodules
=
repository
.
s
end
(
:submodules
,
'v1.2.1'
)
expect
(
submodules
.
first
).
to
eq
([
expect
(
submodules
.
first
).
to
eq
([
"six"
,
{
"six"
,
{
...
@@ -414,7 +414,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -414,7 +414,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
context
'where repo doesn\'t have submodules'
do
context
'where repo doesn\'t have submodules'
do
let
(
:submodules
)
{
repository
.
s
ubmodules
(
'6d39438'
)
}
let
(
:submodules
)
{
repository
.
s
end
(
:submodules
,
'6d39438'
)
}
it
'should return an empty hash'
do
it
'should return an empty hash'
do
expect
(
submodules
).
to
be_empty
expect
(
submodules
).
to
be_empty
end
end
...
...
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