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
1281ac55
Commit
1281ac55
authored
Oct 16, 2019
by
Igor
Committed by
Kamil Trzciński
Oct 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix caching of submodule links for shas with dashes
parent
f1e701e0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
lib/gitlab/submodule_links.rb
lib/gitlab/submodule_links.rb
+4
-2
spec/lib/gitlab/submodule_links_spec.rb
spec/lib/gitlab/submodule_links_spec.rb
+16
-2
No files found.
lib/gitlab/submodule_links.rb
View file @
1281ac55
...
@@ -6,6 +6,7 @@ module Gitlab
...
@@ -6,6 +6,7 @@ module Gitlab
def
initialize
(
repository
)
def
initialize
(
repository
)
@repository
=
repository
@repository
=
repository
@cache_store
=
{}
end
end
def
for
(
submodule
,
sha
)
def
for
(
submodule
,
sha
)
...
@@ -18,8 +19,9 @@ module Gitlab
...
@@ -18,8 +19,9 @@ module Gitlab
attr_reader
:repository
attr_reader
:repository
def
submodule_urls_for
(
sha
)
def
submodule_urls_for
(
sha
)
strong_memoize
(
:"submodule_urls_for_
#{
sha
}
"
)
do
@cache_store
.
fetch
(
sha
)
do
repository
.
submodule_urls_for
(
sha
)
submodule_urls
=
repository
.
submodule_urls_for
(
sha
)
@cache_store
[
sha
]
=
submodule_urls
end
end
end
end
...
...
spec/lib/gitlab/submodule_links_spec.rb
View file @
1281ac55
...
@@ -8,7 +8,9 @@ describe Gitlab::SubmoduleLinks do
...
@@ -8,7 +8,9 @@ describe Gitlab::SubmoduleLinks do
let
(
:links
)
{
described_class
.
new
(
repo
)
}
let
(
:links
)
{
described_class
.
new
(
repo
)
}
describe
'#for'
do
describe
'#for'
do
subject
{
links
.
for
(
submodule_item
,
'ref'
)
}
let
(
:ref
)
{
'ref'
}
subject
{
links
.
for
(
submodule_item
,
ref
)
}
context
'when there is no .gitmodules file'
do
context
'when there is no .gitmodules file'
do
before
do
before
do
...
@@ -35,11 +37,23 @@ describe Gitlab::SubmoduleLinks do
...
@@ -35,11 +37,23 @@ describe Gitlab::SubmoduleLinks do
stub_urls
({
'gitlab-foss'
=>
'git@gitlab.com:gitlab-org/gitlab-foss.git'
})
stub_urls
({
'gitlab-foss'
=>
'git@gitlab.com:gitlab-org/gitlab-foss.git'
})
end
end
it
'returns links and caches the by ref'
do
expect
(
subject
).
to
eq
([
'https://gitlab.com/gitlab-org/gitlab-foss'
,
'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash'
])
cache_store
=
links
.
instance_variable_get
(
"@cache_store"
)
expect
(
cache_store
[
ref
]).
to
eq
({
"gitlab-foss"
=>
"git@gitlab.com:gitlab-org/gitlab-foss.git"
})
end
context
'when ref name contains a dash'
do
let
(
:ref
)
{
'signed-commits'
}
it
'returns links'
do
it
'returns links'
do
expect
(
subject
).
to
eq
([
'https://gitlab.com/gitlab-org/gitlab-foss'
,
'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash'
])
expect
(
subject
).
to
eq
([
'https://gitlab.com/gitlab-org/gitlab-foss'
,
'https://gitlab.com/gitlab-org/gitlab-foss/tree/hash'
])
end
end
end
end
end
end
end
def
stub_urls
(
urls
)
def
stub_urls
(
urls
)
allow
(
repo
).
to
receive
(
:submodule_urls_for
).
and_return
(
urls
)
allow
(
repo
).
to
receive
(
:submodule_urls_for
).
and_return
(
urls
)
...
...
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