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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
0e974b52
Commit
0e974b52
authored
Jul 28, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor MergeRequestDiff initialize method
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
b0a02384
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
17 deletions
+12
-17
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+12
-16
spec/features/merge_requests/merge_request_versions_spec.rb
spec/features/merge_requests/merge_request_versions_spec.rb
+0
-1
No files found.
app/models/merge_request_diff.rb
View file @
0e974b52
...
@@ -25,22 +25,18 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -25,22 +25,18 @@ class MergeRequestDiff < ActiveRecord::Base
validates
:start_commit_sha
,
presence:
true
,
unless: :importing?
validates
:start_commit_sha
,
presence:
true
,
unless: :importing?
validates
:head_commit_sha
,
presence:
true
,
unless: :importing?
validates
:head_commit_sha
,
presence:
true
,
unless: :importing?
after_initialize
:set_diff_range
,
unless: :importing?
after_initialize
:initialize_commits_sha
,
unless: :importing?
after_create
:save_git_content
,
unless: :importing?
after_create
:save_git_content
,
unless: :importing?
after_save
:keep_around_commits
,
unless: :importing?
after_save
:keep_around_commits
,
unless: :importing?
def
set_diff_range
# Those variables are used for collecting commits and diff from git repository.
if
persisted?
# After object is created those sha are stored in the database.
# Workaround for old MergeRequestDiff object
# However some old MergeRequestDiff records don't
# that does not have head_commit_sha in the database
# have those variables in the database so we try to initialize it
self
.
start_commit_sha
||=
merge_request
.
target_branch_sha
def
initialize_commits_sha
self
.
head_commit_sha
||=
last_commit
.
sha
self
.
start_commit_sha
||=
merge_request
.
target_branch_sha
self
.
base_commit_sha
||=
find_base_sha
self
.
head_commit_sha
||=
last_commit
.
try
(
:sha
)
||
merge_request
.
source_branch_sha
else
self
.
base_commit_sha
||=
find_base_sha
self
.
start_commit_sha
||=
merge_request
.
target_branch_sha
self
.
head_commit_sha
||=
merge_request
.
source_branch_sha
self
.
base_commit_sha
||=
find_base_sha
end
end
end
# Collect information about commits and diff from repository
# Collect information about commits and diff from repository
...
...
spec/features/merge_requests/merge_request_versions_spec.rb
View file @
0e974b52
...
@@ -22,7 +22,6 @@ feature 'Merge Request versions', js: true, feature: true do
...
@@ -22,7 +22,6 @@ feature 'Merge Request versions', js: true, feature: true do
before
do
before
do
page
.
within
'.mr-version-switch'
do
page
.
within
'.mr-version-switch'
do
find
(
'.btn-link'
).
click
find
(
'.btn-link'
).
click
#find('a', text: '6f6d7e7e').click
click_link
'6f6d7e7e'
click_link
'6f6d7e7e'
end
end
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