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
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
Hide 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
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
)
sha
=
last_commit_id_for_path
(
sha
,
path
)
commit
(
sha
)
...
...
lib/gitlab/git/repository.rb
View file @
cf131bf7
...
...
@@ -613,32 +613,20 @@ module Gitlab
rugged
.
rev_parse
(
oid_or_ref_name
)
end
# Return
hash with submodules info for this repository
# Return
s url for submodule
#
# Ex.
# {
# "current_path/rack" => {
# "name" => "original_path/rack",
# "id" => "c67be4624545b4263184c4a0e8f887efd0a66320",
# "url" => "git://github.com/chneukirchen/rack.git"
# },
# "encoding" => {
# "id" => ....
# }
# }
# @repository.submodule_url_for('master', 'rack')
# # => git@localhost:rack.git
#
def
submodule
s
(
ref
)
commit
=
rev_parse_target
(
ref
)
return
{}
unless
commit
def
submodule
_url_for
(
ref
,
path
)
if
submodules
(
ref
).
any?
submodule
=
submodules
(
ref
)[
path
]
begin
content
=
blob_content
(
commit
,
".gitmodules"
)
rescue
InvalidBlobName
return
{}
if
submodule
submodule
[
'url'
]
end
end
parser
=
GitmodulesParser
.
new
(
content
)
fill_submodule_ids
(
commit
,
parser
.
parse
)
end
# Return total commits count accessible from passed ref
...
...
@@ -976,6 +964,23 @@ module Gitlab
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
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_DIRECTORIES_VARIABLES
).
compact
end
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
cf131bf7
...
...
@@ -348,7 +348,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_REPO_PATH
)
}
context
'where repo has submodules'
do
let
(
:submodules
)
{
repository
.
s
ubmodules
(
'master'
)
}
let
(
:submodules
)
{
repository
.
s
end
(
:submodules
,
'master'
)
}
let
(
:submodule
)
{
submodules
.
first
}
it
{
expect
(
submodules
).
to
be_kind_of
Hash
}
...
...
@@ -383,12 +383,12 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
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'
)
end
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
([
"six"
,
{
...
...
@@ -414,7 +414,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
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
expect
(
submodules
).
to
be_empty
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