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
Jérome Perrin
gitlab-ce
Commits
87cb74a7
Commit
87cb74a7
authored
Jul 13, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure MergeRequest commit methods work when either compare_commits or merge_request_diff is set
parent
64701b51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
7 deletions
+32
-7
app/controllers/projects/merge_requests/creations_controller.rb
...ntrollers/projects/merge_requests/creations_controller.rb
+1
-1
app/models/merge_request.rb
app/models/merge_request.rb
+31
-6
No files found.
app/controllers/projects/merge_requests/creations_controller.rb
View file @
87cb74a7
...
...
@@ -107,7 +107,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
@target_project
=
@merge_request
.
target_project
@source_project
=
@merge_request
.
source_project
@commits
=
@merge_request
.
com
pare_commits
.
reverse
@commits
=
@merge_request
.
com
mits
@commit
=
@merge_request
.
diff_head_commit
@note_counts
=
Note
.
where
(
commit_id:
@commits
.
map
(
&
:id
))
...
...
app/models/merge_request.rb
View file @
87cb74a7
...
...
@@ -32,9 +32,6 @@ class MergeRequest < ActiveRecord::Base
after_create
:ensure_merge_request_diff
,
unless: :importing?
after_update
:reload_diff_if_branch_changed
delegate
:commits
,
:real_size
,
:commit_shas
,
:commits_count
,
to: :merge_request_diff
,
prefix:
nil
# When this attribute is true some MR validation is ignored
# It allows us to close or modify broken merge requests
attr_accessor
:allow_broken
...
...
@@ -224,6 +221,36 @@ class MergeRequest < ActiveRecord::Base
"
#{
project
.
to_reference
(
from
,
full:
full
)
}#{
reference
}
"
end
def
commits
if
persisted?
merge_request_diff
.
commits
elsif
compare_commits
compare_commits
.
reverse
else
[]
end
end
def
commits_count
if
persisted?
merge_request_diff
.
commits_count
elsif
compare_commits
compare_commits
.
size
else
0
end
end
def
commit_shas
if
persisted?
merge_request_diff
.
commit_shas
elsif
compare_commits
compare_commits
.
reverse
.
map
(
&
:sha
)
else
[]
end
end
def
first_commit
merge_request_diff
?
merge_request_diff
.
first_commit
:
compare_commits
.
first
end
...
...
@@ -246,9 +273,7 @@ class MergeRequest < ActiveRecord::Base
def
diff_size
# Calling `merge_request_diff.diffs.real_size` will also perform
# highlighting, which we don't need here.
return
real_size
if
merge_request_diff
diffs
.
real_size
merge_request_diff
&
.
real_size
||
diffs
.
real_size
end
def
diff_base_commit
...
...
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