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
Léo-Paul Géneau
gitlab-ce
Commits
2db75f8d
Commit
2db75f8d
authored
Jul 06, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make methods private that don't need to be public
parent
228d2a4c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
43 deletions
+47
-43
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+47
-43
No files found.
app/models/merge_request_diff.rb
View file @
2db75f8d
...
...
@@ -65,42 +65,36 @@ class MergeRequestDiff < ActiveRecord::Base
def
base_commit
return
unless
self
.
base_commit_sha
merge_request
.
target_
project
.
commit
(
self
.
base_commit_sha
)
project
.
commit
(
self
.
base_commit_sha
)
end
def
start_commit
return
unless
self
.
start_commit_sha
merge_request
.
target_
project
.
commit
(
self
.
start_commit_sha
)
project
.
commit
(
self
.
start_commit_sha
)
end
def
head_commit
return
last_commit
unless
self
.
head_commit_sha
merge_request
.
target_
project
.
commit
(
self
.
head_commit_sha
)
project
.
commit
(
self
.
head_commit_sha
)
end
def
dump_commits
(
commits
)
commits
.
map
(
&
:to_hash
)
end
def
load_commits
(
array
)
array
.
map
{
|
hash
|
Commit
.
new
(
Gitlab
::
Git
::
Commit
.
new
(
hash
),
merge_request
.
source_project
)
}
end
def
compare
@compare
||=
begin
# Update ref for merge request
merge_request
.
fetch_ref
def
dump_diffs
(
diffs
)
if
diffs
.
respond_to?
(
:map
)
diffs
.
map
(
&
:to_hash
)
Gitlab
::
Git
::
Compare
.
new
(
self
.
repository
.
raw_repository
,
self
.
target_branch_sha
,
self
.
source_branch_sha
)
end
end
def
load_diffs
(
raw
,
options
)
if
raw
.
respond_to?
(
:each
)
Gitlab
::
Git
::
DiffCollection
.
new
(
raw
,
options
)
else
Gitlab
::
Git
::
DiffCollection
.
new
([])
end
end
private
# Collect array of Git::Commit objects
# between target and source branches
...
...
@@ -114,6 +108,14 @@ class MergeRequestDiff < ActiveRecord::Base
commits
end
def
dump_commits
(
commits
)
commits
.
map
(
&
:to_hash
)
end
def
load_commits
(
array
)
array
.
map
{
|
hash
|
Commit
.
new
(
Gitlab
::
Git
::
Commit
.
new
(
hash
),
merge_request
.
source_project
)
}
end
# Reload all commits related to current merge request from repo
# and save it as array of hashes in st_commits db field
def
reload_commits
...
...
@@ -128,6 +130,26 @@ class MergeRequestDiff < ActiveRecord::Base
update_columns_serialized
(
new_attributes
)
end
# Collect array of Git::Diff objects
# between target and source branches
def
unmerged_diffs
compare
.
diffs
(
Commit
.
max_diff_options
)
end
def
dump_diffs
(
diffs
)
if
diffs
.
respond_to?
(
:map
)
diffs
.
map
(
&
:to_hash
)
end
end
def
load_diffs
(
raw
,
options
)
if
raw
.
respond_to?
(
:each
)
Gitlab
::
Git
::
DiffCollection
.
new
(
raw
,
options
)
else
Gitlab
::
Git
::
DiffCollection
.
new
([])
end
end
# Reload diffs between branches related to current merge request from repo
# and save it as array of hashes in st_diffs db field
def
reload_diffs
...
...
@@ -164,42 +186,24 @@ class MergeRequestDiff < ActiveRecord::Base
keep_around_commits
end
# Collect array of Git::Diff objects
# between target and source branches
def
unmerged_diffs
compare
.
diffs
(
Commit
.
max_diff_options
)
def
project
merge_request
.
target_project
end
def
repository
merge_request
.
target_
project
.
repository
project
.
repository
end
def
branch_base_commit
return
unless
self
.
source_branch_sha
&&
self
.
target_branch_sha
merge_request
.
target_
project
.
merge_base_commit
(
self
.
source_branch_sha
,
self
.
target_branch_sha
)
project
.
merge_base_commit
(
self
.
source_branch_sha
,
self
.
target_branch_sha
)
end
def
branch_base_sha
branch_base_commit
.
try
(
:sha
)
end
def
compare
@compare
||=
begin
# Update ref for merge request
merge_request
.
fetch_ref
Gitlab
::
Git
::
Compare
.
new
(
self
.
repository
.
raw_repository
,
self
.
target_branch_sha
,
self
.
source_branch_sha
)
end
end
private
#
# #save or #update_attributes providing changes on serialized attributes do a lot of
# serialization and deserialization calls resulting in bad performance.
...
...
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