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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
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
Hide 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
...
@@ -65,42 +65,36 @@ class MergeRequestDiff < ActiveRecord::Base
def
base_commit
def
base_commit
return
unless
self
.
base_commit_sha
return
unless
self
.
base_commit_sha
merge_request
.
target_
project
.
commit
(
self
.
base_commit_sha
)
project
.
commit
(
self
.
base_commit_sha
)
end
end
def
start_commit
def
start_commit
return
unless
self
.
start_commit_sha
return
unless
self
.
start_commit_sha
merge_request
.
target_
project
.
commit
(
self
.
start_commit_sha
)
project
.
commit
(
self
.
start_commit_sha
)
end
end
def
head_commit
def
head_commit
return
last_commit
unless
self
.
head_commit_sha
return
last_commit
unless
self
.
head_commit_sha
merge_request
.
target_
project
.
commit
(
self
.
head_commit_sha
)
project
.
commit
(
self
.
head_commit_sha
)
end
end
def
dump_commits
(
commits
)
def
compare
commits
.
map
(
&
:to_hash
)
@compare
||=
end
begin
# Update ref for merge request
def
load_commits
(
array
)
merge_request
.
fetch_ref
array
.
map
{
|
hash
|
Commit
.
new
(
Gitlab
::
Git
::
Commit
.
new
(
hash
),
merge_request
.
source_project
)
}
end
def
dump_diffs
(
diffs
)
Gitlab
::
Git
::
Compare
.
new
(
if
diffs
.
respond_to?
(
:map
)
self
.
repository
.
raw_repository
,
diffs
.
map
(
&
:to_hash
)
self
.
target_branch_sha
,
end
self
.
source_branch_sha
)
end
end
end
def
load_diffs
(
raw
,
options
)
private
if
raw
.
respond_to?
(
:each
)
Gitlab
::
Git
::
DiffCollection
.
new
(
raw
,
options
)
else
Gitlab
::
Git
::
DiffCollection
.
new
([])
end
end
# Collect array of Git::Commit objects
# Collect array of Git::Commit objects
# between target and source branches
# between target and source branches
...
@@ -114,6 +108,14 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -114,6 +108,14 @@ class MergeRequestDiff < ActiveRecord::Base
commits
commits
end
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
# Reload all commits related to current merge request from repo
# and save it as array of hashes in st_commits db field
# and save it as array of hashes in st_commits db field
def
reload_commits
def
reload_commits
...
@@ -128,6 +130,26 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -128,6 +130,26 @@ class MergeRequestDiff < ActiveRecord::Base
update_columns_serialized
(
new_attributes
)
update_columns_serialized
(
new_attributes
)
end
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
# Reload diffs between branches related to current merge request from repo
# and save it as array of hashes in st_diffs db field
# and save it as array of hashes in st_diffs db field
def
reload_diffs
def
reload_diffs
...
@@ -164,42 +186,24 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -164,42 +186,24 @@ class MergeRequestDiff < ActiveRecord::Base
keep_around_commits
keep_around_commits
end
end
# Collect array of Git::Diff objects
def
project
# between target and source branches
merge_request
.
target_project
def
unmerged_diffs
compare
.
diffs
(
Commit
.
max_diff_options
)
end
end
def
repository
def
repository
merge_request
.
target_
project
.
repository
project
.
repository
end
end
def
branch_base_commit
def
branch_base_commit
return
unless
self
.
source_branch_sha
&&
self
.
target_branch_sha
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
end
def
branch_base_sha
def
branch_base_sha
branch_base_commit
.
try
(
:sha
)
branch_base_commit
.
try
(
:sha
)
end
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
# #save or #update_attributes providing changes on serialized attributes do a lot of
# serialization and deserialization calls resulting in bad performance.
# 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