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
Boxiang Sun
gitlab-ce
Commits
5cce1278
Commit
5cce1278
authored
Jan 27, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly determine MR diff base when MR has merge conflicts
parent
a93f7099
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
22 deletions
+19
-22
CHANGELOG
CHANGELOG
+1
-2
app/controllers/projects/compare_controller.rb
app/controllers/projects/compare_controller.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+2
-2
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+11
-17
app/models/project.rb
app/models/project.rb
+4
-0
No files found.
CHANGELOG
View file @
5cce1278
...
@@ -20,8 +20,7 @@ v 8.4.2 (unreleased)
...
@@ -20,8 +20,7 @@ v 8.4.2 (unreleased)
improvement when checking if a repository was empty
improvement when checking if a repository was empty
- Add instrumentation for Gitlab::Git::Repository instance methods so we can
- Add instrumentation for Gitlab::Git::Repository instance methods so we can
track them in Performance Monitoring.
track them in Performance Monitoring.
- Correctly highlight MR diff when MR has merge conflicts
v 8.4.2 (unreleased)
- Fix method undefined when using external commit status in builds
- Fix method undefined when using external commit status in builds
v 8.4.1
v 8.4.1
...
...
app/controllers/projects/compare_controller.rb
View file @
5cce1278
...
@@ -21,7 +21,7 @@ class Projects::CompareController < Projects::ApplicationController
...
@@ -21,7 +21,7 @@ class Projects::CompareController < Projects::ApplicationController
@commits
=
Commit
.
decorate
(
compare_result
.
commits
,
@project
)
@commits
=
Commit
.
decorate
(
compare_result
.
commits
,
@project
)
@diffs
=
compare_result
.
diffs
@diffs
=
compare_result
.
diffs
@commit
=
@project
.
commit
(
head_ref
)
@commit
=
@project
.
commit
(
head_ref
)
@base_commit
=
@project
.
commit
(
base
_ref
)
@base_commit
=
@project
.
merge_base_commit
(
base_ref
,
head
_ref
)
@diff_refs
=
[
@base_commit
,
@commit
]
@diff_refs
=
[
@base_commit
,
@commit
]
@line_notes
=
[]
@line_notes
=
[]
end
end
...
...
app/models/merge_request.rb
View file @
5cce1278
...
@@ -184,7 +184,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -184,7 +184,7 @@ class MergeRequest < ActiveRecord::Base
if
merge_request_diff
if
merge_request_diff
merge_request_diff
.
base_commit
merge_request_diff
.
base_commit
else
else
self
.
target_project
.
commit
(
self
.
target_branch
)
self
.
target_project
.
merge_base_commit
(
self
.
source_sha
,
self
.
target_branch
)
end
end
end
end
...
@@ -489,7 +489,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -489,7 +489,7 @@ class MergeRequest < ActiveRecord::Base
end
end
def
source_sha
def
source_sha
commits
.
firs
t
.
sha
last_commi
t
.
sha
end
end
def
fetch_ref
def
fetch_ref
...
...
app/models/merge_request_diff.rb
View file @
5cce1278
...
@@ -48,14 +48,11 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -48,14 +48,11 @@ class MergeRequestDiff < ActiveRecord::Base
end
end
def
diffs_no_whitespace
def
diffs_no_whitespace
# Get latest sha of branch from source project
source_sha
=
merge_request
.
source_project
.
commit
(
source_branch
).
sha
compare_result
=
Gitlab
::
CompareResult
.
new
(
compare_result
=
Gitlab
::
CompareResult
.
new
(
Gitlab
::
Git
::
Compare
.
new
(
Gitlab
::
Git
::
Compare
.
new
(
merge_request
.
target_project
.
repository
.
raw_repository
,
self
.
repository
.
raw_repository
,
merge_request
.
target_branch
,
self
.
target_branch
,
source_sha
,
s
elf
.
s
ource_sha
,
),
{
ignore_whitespace_change:
true
}
),
{
ignore_whitespace_change:
true
}
)
)
@diffs_no_whitespace
||=
load_diffs
(
dump_commits
(
compare_result
.
diffs
))
@diffs_no_whitespace
||=
load_diffs
(
dump_commits
(
compare_result
.
diffs
))
...
@@ -83,8 +80,6 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -83,8 +80,6 @@ class MergeRequestDiff < ActiveRecord::Base
@last_commit_short_sha
||=
last_commit
.
short_id
@last_commit_short_sha
||=
last_commit
.
short_id
end
end
private
def
dump_commits
(
commits
)
def
dump_commits
(
commits
)
commits
.
map
(
&
:to_hash
)
commits
.
map
(
&
:to_hash
)
end
end
...
@@ -163,7 +158,7 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -163,7 +158,7 @@ class MergeRequestDiff < ActiveRecord::Base
self
.
st_diffs
=
new_diffs
self
.
st_diffs
=
new_diffs
self
.
base_commit_sha
=
merge_request
.
target_project
.
commit
(
target_branch
).
try
(
:sha
)
self
.
base_commit_sha
=
self
.
repository
.
merge_base
(
self
.
source_sha
,
self
.
target_branch
)
self
.
save
self
.
save
end
end
...
@@ -181,7 +176,10 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -181,7 +176,10 @@ class MergeRequestDiff < ActiveRecord::Base
merge_request
.
target_project
.
repository
merge_request
.
target_project
.
repository
end
end
private
def
source_sha
source_commit
=
merge_request
.
source_project
.
commit
(
source_branch
)
source_commit
.
try
(
:sha
)
end
def
compare_result
def
compare_result
@compare_result
||=
@compare_result
||=
...
@@ -189,15 +187,11 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -189,15 +187,11 @@ class MergeRequestDiff < ActiveRecord::Base
# Update ref for merge request
# Update ref for merge request
merge_request
.
fetch_ref
merge_request
.
fetch_ref
# Get latest sha of branch from source project
source_commit
=
merge_request
.
source_project
.
commit
(
source_branch
)
source_sha
=
source_commit
.
try
(
:sha
)
Gitlab
::
CompareResult
.
new
(
Gitlab
::
CompareResult
.
new
(
Gitlab
::
Git
::
Compare
.
new
(
Gitlab
::
Git
::
Compare
.
new
(
merge_request
.
target_project
.
repository
.
raw_repository
,
self
.
repository
.
raw_repository
,
merge_request
.
target_branch
,
self
.
target_branch
,
s
ource_sha
,
s
elf
.
source_sha
)
)
)
)
end
end
...
...
app/models/project.rb
View file @
5cce1278
...
@@ -348,6 +348,10 @@ class Project < ActiveRecord::Base
...
@@ -348,6 +348,10 @@ class Project < ActiveRecord::Base
repository
.
commit
(
id
)
repository
.
commit
(
id
)
end
end
def
merge_base_commit
(
first_commit_id
,
second_commit_id
)
repository
.
commit
(
repository
.
merge_base
(
first_commit_id
,
second_commit_id
))
end
def
saved?
def
saved?
id
&&
persisted?
id
&&
persisted?
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