BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
12 deletions
+7
-12
merge_request_diff.rb
app/models/merge_request_diff.rb
+7
-11
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
validates
:start_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_save
:keep_around_commits
,
unless: :importing?
def
set_diff_range
if
persisted?
# Workaround for old MergeRequestDiff object
# that does not have head_commit_sha in the database
# Those variables are used for collecting commits and diff from git repository.
# After object is created those sha are stored in the database.
# However some old MergeRequestDiff records don't
# have those variables in the database so we try to initialize it
def
initialize_commits_sha
self
.
start_commit_sha
||=
merge_request
.
target_branch_sha
self
.
head_commit_sha
||=
last_commit
.
sha
self
.
head_commit_sha
||=
last_commit
.
try
(
:sha
)
||
merge_request
.
source_branch_
sha
self
.
base_commit_sha
||=
find_base_sha
else
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
# 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
before
do
page
.
within
'.mr-version-switch'
do
find
(
'.btn-link'
).
click
#find('a', text: '6f6d7e7e').click
click_link
'6f6d7e7e'
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