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
5174e99a
Commit
5174e99a
authored
Mar 08, 2018
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused Compare#base_commit
parent
c6273ec5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
36 deletions
+19
-36
app/models/compare.rb
app/models/compare.rb
+5
-10
spec/models/compare_spec.rb
spec/models/compare_spec.rb
+14
-26
No files found.
app/models/compare.rb
View file @
5174e99a
...
@@ -41,21 +41,16 @@ class Compare
...
@@ -41,21 +41,16 @@ class Compare
end
end
alias_method
:commit
,
:head_commit
alias_method
:commit
,
:head_commit
def
base_commit
strong_memoize
(
:base_commit
)
do
return
unless
start_commit
&&
head_commit
return
OpenStruct
.
new
(
sha:
@base_sha
)
if
@base_sha
project
.
merge_base_commit
(
start_commit
.
id
,
head_commit
.
id
)
end
end
def
start_commit_sha
def
start_commit_sha
start_commit
&
.
sha
start_commit
&
.
sha
end
end
def
base_commit_sha
def
base_commit_sha
base_commit
&
.
sha
strong_memoize
(
:base_commit
)
do
next
unless
start_commit
&&
head_commit
@base_sha
||
project
.
merge_base_commit
(
start_commit
.
id
,
head_commit
.
id
)
&
.
sha
end
end
end
def
head_commit_sha
def
head_commit_sha
...
...
spec/models/compare_spec.rb
View file @
5174e99a
...
@@ -37,28 +37,6 @@ describe Compare do
...
@@ -37,28 +37,6 @@ describe Compare do
end
end
end
end
describe
'#base_commit'
do
let
(
:base_commit
)
{
Commit
.
new
(
another_sample_commit
,
project
)
}
it
'returns project merge base commit'
do
expect
(
project
).
to
receive
(
:merge_base_commit
).
with
(
start_commit
.
id
,
head_commit
.
id
).
and_return
(
base_commit
)
expect
(
subject
.
base_commit
).
to
eq
(
base_commit
)
end
it
'returns nil if there is no start_commit'
do
expect
(
subject
).
to
receive
(
:start_commit
).
and_return
(
nil
)
expect
(
subject
.
base_commit
).
to
eq
(
nil
)
end
it
'returns nil if there is no head commit'
do
expect
(
subject
).
to
receive
(
:head_commit
).
and_return
(
nil
)
expect
(
subject
.
base_commit
).
to
eq
(
nil
)
end
end
describe
'#base_commit_sha'
do
describe
'#base_commit_sha'
do
it
'returns @base_sha if it is present'
do
it
'returns @base_sha if it is present'
do
expect
(
project
).
not_to
receive
(
:merge_base_commit
)
expect
(
project
).
not_to
receive
(
:merge_base_commit
)
...
@@ -87,13 +65,23 @@ describe Compare do
...
@@ -87,13 +65,23 @@ describe Compare do
3
.
times
{
subject
.
base_commit_sha
}
3
.
times
{
subject
.
base_commit_sha
}
end
end
it
'returns nil if there is no start_commit'
do
expect
(
subject
).
to
receive
(
:start_commit
).
and_return
(
nil
)
expect
(
subject
.
base_commit_sha
).
to
eq
(
nil
)
end
end
describe
'#diff_refs'
do
it
'returns nil if there is no head commit'
do
it
'uses base_commit sha as base_sha'
do
expect
(
subject
).
to
receive
(
:head_commit
).
and_return
(
nil
)
expect
(
subject
).
to
receive
(
:base_commit
).
at_least
(
:once
).
and_call_original
expect
(
subject
.
base_commit_sha
).
to
eq
(
nil
)
end
end
expect
(
subject
.
diff_refs
.
base_sha
).
to
eq
(
subject
.
base_commit
.
id
)
describe
'#diff_refs'
do
it
'uses base_commit_sha sha as base_sha'
do
expect
(
subject
.
diff_refs
.
base_sha
).
to
eq
(
subject
.
base_commit_sha
)
end
end
it
'uses start_commit sha as start_sha'
do
it
'uses start_commit sha as start_sha'
do
...
...
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