BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
49d63dc1
Unverified
Commit
49d63dc1
authored
Aug 15, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix and refactor merge request diff_refs method
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
643a368f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
27 deletions
+11
-27
diff_note.rb
app/models/diff_note.rb
+1
-5
merge_request.rb
app/models/merge_request.rb
+2
-15
merge_request_diff.rb
app/models/merge_request_diff.rb
+1
-1
merge_request_spec.rb
spec/models/merge_request_spec.rb
+7
-6
No files found.
app/models/diff_note.rb
View file @
49d63dc1
...
...
@@ -79,11 +79,7 @@ class DiffNote < Note
end
def
noteable_diff_refs
if
noteable
.
respond_to?
(
:diff_sha_refs
)
noteable
.
diff_sha_refs
else
noteable
.
diff_refs
end
noteable
.
diff_refs
end
def
set_original_position
...
...
app/models/merge_request.rb
View file @
49d63dc1
...
...
@@ -270,7 +270,7 @@ class MergeRequest < ActiveRecord::Base
end
def
diff_refs
if
persisted
?
if
merge_request_diff
&&
merge_request_diff
.
diff_refs_by_sha
?
merge_request_diff
.
diff_refs
else
start_sha
=
target_branch_sha
...
...
@@ -287,19 +287,6 @@ class MergeRequest < ActiveRecord::Base
end
end
# Return diff_refs instance trying to not touch the git repository
def
diff_sha_refs
if
merge_request_diff
&&
merge_request_diff
.
diff_refs_by_sha?
return
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
merge_request_diff
.
base_commit_sha
,
start_sha:
merge_request_diff
.
start_commit_sha
,
head_sha:
merge_request_diff
.
head_commit_sha
)
else
diff_refs
end
end
def
validate_branches
if
target_project
==
source_project
&&
target_branch
==
source_branch
errors
.
add
:branch_conflict
,
"You can not use same project/branch for source and target"
...
...
@@ -716,7 +703,7 @@ class MergeRequest < ActiveRecord::Base
end
def
support_new_diff_notes?
diff_
sha_refs
&&
diff_sha
_refs
.
complete?
diff_
refs
&&
diff
_refs
.
complete?
end
def
update_diff_notes_positions
(
old_diff_refs
:,
new_diff_refs
:)
...
...
app/models/merge_request_diff.rb
View file @
49d63dc1
...
...
@@ -128,7 +128,7 @@ class MergeRequestDiff < ActiveRecord::Base
end
def
diff_refs
return
unless
start_commit
||
base_commit
return
unless
start_commit
_sha
||
base_commit_sha
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
base_commit_sha
,
...
...
spec/models/merge_request_spec.rb
View file @
49d63dc1
...
...
@@ -723,7 +723,6 @@ describe MergeRequest, models: true do
end
end
<<<<<<<
HEAD
describe
'#branch_merge_base_commit'
do
context
'source and target branch exist'
do
it
{
expect
(
subject
.
branch_merge_base_commit
.
sha
).
to
eq
(
'ae73cb07c9eeaf35924a10f713b364d32b2dd34f'
)
}
...
...
@@ -737,8 +736,11 @@ describe MergeRequest, models: true do
it
'returns nil'
do
expect
(
subject
.
branch_merge_base_commit
).
to
be_nil
=======
describe
"#diff_sha_refs"
do
end
end
end
describe
"#diff_refs"
do
context
"with diffs"
do
subject
{
create
(
:merge_request
,
:with_diffs
)
}
...
...
@@ -747,7 +749,7 @@ describe MergeRequest, models: true do
expect_any_instance_of
(
Repository
).
not_to
receive
(
:commit
)
subject
.
diff_
sha_
refs
subject
.
diff_refs
end
it
"returns expected diff_refs"
do
...
...
@@ -757,8 +759,7 @@ describe MergeRequest, models: true do
head_sha:
subject
.
merge_request_diff
.
head_commit_sha
)
expect
(
subject
.
diff_sha_refs
).
to
eq
(
expected_diff_refs
)
>>>>>>>
master
expect
(
subject
.
diff_refs
).
to
eq
(
expected_diff_refs
)
end
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