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
Tatuya Kamada
gitlab-ce
Commits
29ac60d7
Commit
29ac60d7
authored
Aug 15, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change the way old merge request diff handled
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
a8fe213e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
+19
-12
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+18
-11
No files found.
app/models/merge_request.rb
View file @
29ac60d7
...
...
@@ -261,7 +261,7 @@ class MergeRequest < ActiveRecord::Base
end
def
diff_refs
if
merge_request_diff
if
persisted?
merge_request_diff
.
diff_refs
else
start_sha
=
target_branch_sha
...
...
app/models/merge_request_diff.rb
View file @
29ac60d7
...
...
@@ -22,10 +22,6 @@ class MergeRequestDiff < ActiveRecord::Base
serialize
:st_commits
serialize
:st_diffs
# For compatibility with old MergeRequestDiff which
# does not store those variables in database
after_initialize
:ensure_commits_sha
,
if: :persisted?
# All diff information is collected from repository after object is created.
# It allows you to override variables like head_commit_sha before getting diff.
after_create
:save_git_content
,
unless: :importing?
...
...
@@ -50,6 +46,20 @@ class MergeRequestDiff < ActiveRecord::Base
self
.
base_commit_sha
||=
find_base_sha
end
# This method will rely on repository branch sha
# in case start_commit_sha is nil. Its necesarry for old merge request diff
# created before version 8.4 to work
def
safe_start_commit_sha
start_commit_sha
||
merge_request
.
target_branch_sha
end
# This method will rely on repository branch sha
# in case head_commit_sha is nil. Its necesarry for old merge request diff
# created before version 8.4 to work
def
safe_head_commit_sha
head_commit_sha
||
last_commit
.
try
(
:sha
)
||
merge_request
.
source_branch_sha
end
def
size
real_size
.
presence
||
diffs
.
size
end
...
...
@@ -60,8 +70,8 @@ class MergeRequestDiff < ActiveRecord::Base
begin
compare
=
Gitlab
::
Git
::
Compare
.
new
(
repository
.
raw_repository
,
start_commit_sha
,
head_commit_sha
s
afe_s
tart_commit_sha
,
safe_
head_commit_sha
)
compare
.
diffs
(
options
)
end
...
...
@@ -126,8 +136,8 @@ class MergeRequestDiff < ActiveRecord::Base
Gitlab
::
Git
::
Compare
.
new
(
repository
.
raw_repository
,
start_commit_sha
,
head_commit_sha
s
afe_s
tart_commit_sha
,
safe_
head_commit_sha
)
end
end
...
...
@@ -216,9 +226,6 @@ class MergeRequestDiff < ActiveRecord::Base
return
unless
head_commit_sha
&&
start_commit_sha
project
.
merge_base_commit
(
head_commit_sha
,
start_commit_sha
).
try
(
:sha
)
rescue
Rugged
::
OdbError
# In case head or start commit does not exist in the repository any more
nil
end
def
utf8_st_diffs
...
...
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