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
a9fa45f0
Commit
a9fa45f0
authored
Jun 20, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Represent DiffRefs as proper class instead of tuple array
parent
6ce25e7b
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
111 additions
and
57 deletions
+111
-57
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+0
-1
app/controllers/projects/compare_controller.rb
app/controllers/projects/compare_controller.rb
+13
-5
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+2
-2
app/models/commit.rb
app/models/commit.rb
+7
-0
app/models/merge_request.rb
app/models/merge_request.rb
+10
-6
app/views/projects/commit/show.html.haml
app/views/projects/commit/show.html.haml
+1
-2
app/views/projects/diffs/_diffs.html.haml
app/views/projects/diffs/_diffs.html.haml
+1
-1
app/views/projects/diffs/_image.html.haml
app/views/projects/diffs/_image.html.haml
+5
-6
app/workers/emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+14
-2
lib/gitlab/diff/diff_refs.rb
lib/gitlab/diff/diff_refs.rb
+26
-0
lib/gitlab/diff/file.rb
lib/gitlab/diff/file.rb
+9
-12
lib/gitlab/diff/highlight.rb
lib/gitlab/diff/highlight.rb
+6
-4
lib/gitlab/email/message/repository_push.rb
lib/gitlab/email/message/repository_push.rb
+6
-2
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+2
-4
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+1
-1
spec/lib/gitlab/diff/file_spec.rb
spec/lib/gitlab/diff/file_spec.rb
+1
-1
spec/lib/gitlab/diff/highlight_spec.rb
spec/lib/gitlab/diff/highlight_spec.rb
+3
-3
spec/lib/gitlab/diff/parallel_diff_spec.rb
spec/lib/gitlab/diff/parallel_diff_spec.rb
+1
-2
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+2
-2
No files found.
app/controllers/projects/blob_controller.rb
View file @
a9fa45f0
...
@@ -57,7 +57,7 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -57,7 +57,7 @@ class Projects::BlobController < Projects::ApplicationController
diffy
=
Diffy
::
Diff
.
new
(
@blob
.
data
,
@content
,
diff:
'-U 3'
,
include_diff_info:
true
)
diffy
=
Diffy
::
Diff
.
new
(
@blob
.
data
,
@content
,
diff:
'-U 3'
,
include_diff_info:
true
)
diff_lines
=
diffy
.
diff
.
scan
(
/.*\n/
)[
2
..-
1
]
diff_lines
=
diffy
.
diff
.
scan
(
/.*\n/
)[
2
..-
1
]
diff_lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff_lines
)
diff_lines
=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
diff_lines
)
@diff_lines
=
Gitlab
::
Diff
::
Highlight
.
new
(
diff_lines
).
highlight
@diff_lines
=
Gitlab
::
Diff
::
Highlight
.
new
(
diff_lines
,
repository:
@repository
).
highlight
render
layout:
false
render
layout:
false
end
end
...
...
app/controllers/projects/commit_controller.rb
View file @
a9fa45f0
...
@@ -121,7 +121,6 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -121,7 +121,6 @@ class Projects::CommitController < Projects::ApplicationController
opts
[
:ignore_whitespace_change
]
=
true
if
params
[
:format
]
==
'diff'
opts
[
:ignore_whitespace_change
]
=
true
if
params
[
:format
]
==
'diff'
@diffs
=
commit
.
diffs
(
opts
)
@diffs
=
commit
.
diffs
(
opts
)
@diff_refs
=
[
commit
.
parent
||
commit
,
commit
]
@notes_count
=
commit
.
notes
.
count
@notes_count
=
commit
.
notes
.
count
@statuses
=
CommitStatus
.
where
(
pipeline:
pipelines
)
@statuses
=
CommitStatus
.
where
(
pipeline:
pipelines
)
...
...
app/controllers/projects/compare_controller.rb
View file @
a9fa45f0
...
@@ -14,14 +14,22 @@ class Projects::CompareController < Projects::ApplicationController
...
@@ -14,14 +14,22 @@ class Projects::CompareController < Projects::ApplicationController
def
show
def
show
compare
=
CompareService
.
new
.
compare
=
CompareService
.
new
.
execute
(
@project
,
@head_ref
,
@project
,
@
base
_ref
,
diff_options
)
execute
(
@project
,
@head_ref
,
@project
,
@
start
_ref
,
diff_options
)
if
compare
if
compare
@commits
=
Commit
.
decorate
(
compare
.
commits
,
@project
)
@commits
=
Commit
.
decorate
(
compare
.
commits
,
@project
)
@start_commit
=
@project
.
commit
(
@start_ref
)
@commit
=
@project
.
commit
(
@head_ref
)
@commit
=
@project
.
commit
(
@head_ref
)
@base_commit
=
@project
.
merge_base_commit
(
@base_ref
,
@head_ref
)
@base_commit
=
@project
.
merge_base_commit
(
@start_ref
,
@head_ref
)
@diffs
=
compare
.
diffs
(
diff_options
)
@diffs
=
compare
.
diffs
(
diff_options
)
@diff_refs
=
[
@base_commit
,
@commit
]
@diff_refs
=
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
@base_commit
.
try
(
:sha
),
start_sha:
@start_commit
.
try
(
:sha
),
head_sha:
@commit
.
try
(
:sha
)
)
@diff_notes_disabled
=
true
@diff_notes_disabled
=
true
@grouped_diff_notes
=
{}
@grouped_diff_notes
=
{}
end
end
...
@@ -35,12 +43,12 @@ class Projects::CompareController < Projects::ApplicationController
...
@@ -35,12 +43,12 @@ class Projects::CompareController < Projects::ApplicationController
private
private
def
assign_ref_vars
def
assign_ref_vars
@
base
_ref
=
Addressable
::
URI
.
unescape
(
params
[
:from
])
@
start
_ref
=
Addressable
::
URI
.
unescape
(
params
[
:from
])
@ref
=
@head_ref
=
Addressable
::
URI
.
unescape
(
params
[
:to
])
@ref
=
@head_ref
=
Addressable
::
URI
.
unescape
(
params
[
:to
])
end
end
def
merge_request
def
merge_request
@merge_request
||=
@project
.
merge_requests
.
opened
.
@merge_request
||=
@project
.
merge_requests
.
opened
.
find_by
(
source_project:
@project
,
source_branch:
@head_ref
,
target_branch:
@
base
_ref
)
find_by
(
source_project:
@project
,
source_branch:
@head_ref
,
target_branch:
@
start
_ref
)
end
end
end
end
app/helpers/diff_helper.rb
View file @
a9fa45f0
...
@@ -30,8 +30,8 @@ module DiffHelper
...
@@ -30,8 +30,8 @@ module DiffHelper
options
options
end
end
def
safe_diff_files
(
diffs
,
diff_refs
)
def
safe_diff_files
(
diffs
,
diff_refs
:
nil
,
repository:
nil
)
diffs
.
decorate!
{
|
diff
|
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs
)
}
diffs
.
decorate!
{
|
diff
|
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs
:
diff_refs
,
repository:
repository
)
}
end
end
def
generate_line_code
(
file_path
,
line
)
def
generate_line_code
(
file_path
,
line
)
...
...
app/models/commit.rb
View file @
a9fa45f0
...
@@ -214,6 +214,13 @@ class Commit
...
@@ -214,6 +214,13 @@ class Commit
@raw
.
short_id
(
7
)
@raw
.
short_id
(
7
)
end
end
def
diff_refs
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
self
.
parent_id
||
self
.
sha
,
head_sha:
self
.
sha
)
end
def
pipelines
def
pipelines
@pipeline
||=
project
.
pipelines
.
where
(
sha:
sha
)
@pipeline
||=
project
.
pipelines
.
where
(
sha:
sha
)
end
end
...
...
app/models/merge_request.rb
View file @
a9fa45f0
...
@@ -249,6 +249,16 @@ class MergeRequest < ActiveRecord::Base
...
@@ -249,6 +249,16 @@ class MergeRequest < ActiveRecord::Base
source_branch_head
.
try
(
:sha
)
source_branch_head
.
try
(
:sha
)
end
end
def
diff_refs
return
nil
unless
diff_start_commit
||
diff_base_commit
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
diff_base_sha
,
start_sha:
diff_start_sha
,
head_sha:
diff_head_sha
)
end
def
validate_branches
def
validate_branches
if
target_project
==
source_project
&&
target_branch
==
source_branch
if
target_project
==
source_project
&&
target_branch
==
source_branch
errors
.
add
:branch_conflict
,
"You can not use same project/branch for source and target"
errors
.
add
:branch_conflict
,
"You can not use same project/branch for source and target"
...
@@ -622,12 +632,6 @@ class MergeRequest < ActiveRecord::Base
...
@@ -622,12 +632,6 @@ class MergeRequest < ActiveRecord::Base
end
end
def
pipeline
def
pipeline
end
def
diff_refs
return
nil
unless
diff_base_commit
[
diff_base_commit
,
last_commit
]
@pipeline
||=
source_project
.
pipeline
(
diff_head_sha
,
source_branch
)
if
diff_head_sha
&&
source_project
@pipeline
||=
source_project
.
pipeline
(
diff_head_sha
,
source_branch
)
if
diff_head_sha
&&
source_project
end
end
...
...
app/views/projects/commit/show.html.haml
View file @
a9fa45f0
...
@@ -7,8 +7,7 @@
...
@@ -7,8 +7,7 @@
=
render
"ci_menu"
=
render
"ci_menu"
-
else
-
else
%div
.block-connector
%div
.block-connector
=
render
"projects/diffs/diffs"
,
diffs:
@diffs
,
project:
@project
,
=
render
"projects/diffs/diffs"
,
diffs:
@diffs
,
project:
@project
,
diff_refs:
@commit
.
diff_refs
diff_refs:
@diff_refs
=
render
"projects/notes/notes_with_form"
=
render
"projects/notes/notes_with_form"
-
if
can_collaborate_with_project?
-
if
can_collaborate_with_project?
-
%w(revert cherry-pick)
.
each
do
|
type
|
-
%w(revert cherry-pick)
.
each
do
|
type
|
...
...
app/views/projects/diffs/_diffs.html.haml
View file @
a9fa45f0
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
-
if
diff_view
==
'parallel'
-
if
diff_view
==
'parallel'
-
fluid_layout
true
-
fluid_layout
true
-
diff_files
=
safe_diff_files
(
diffs
,
diff_refs
)
-
diff_files
=
safe_diff_files
(
diffs
,
diff_refs
:
diff_refs
,
repository:
project
.
repository
)
.content-block.oneline-block.files-changed
.content-block.oneline-block.files-changed
.inline-parallel-buttons
.inline-parallel-buttons
...
...
app/views/projects/diffs/_image.html.haml
View file @
a9fa45f0
-
diff
=
diff_file
.
diff
-
diff
=
diff_file
.
diff
-
file_raw_path
=
namespace_project_raw_path
(
@project
.
namespace
,
@project
,
tree_join
(
@commit
.
id
,
diff
.
new_path
))
-
file_raw_path
=
namespace_project_raw_path
(
@project
.
namespace
,
@project
,
tree_join
(
diff_file
.
new_ref
,
diff
.
new_path
))
// diff_refs will be nil for orphaned commits (e.g. first commit in repo)
// diff_refs will be nil for orphaned commits (e.g. first commit in repo)
-
if
diff_refs
-
if
diff_file
.
old_ref
-
old_commit_id
=
diff_refs
.
first
.
id
-
old_file_raw_path
=
namespace_project_raw_path
(
@project
.
namespace
,
@project
,
tree_join
(
diff_file
.
old_ref
,
diff
.
old_path
))
-
old_file_raw_path
=
namespace_project_raw_path
(
@project
.
namespace
,
@project
,
tree_join
(
old_commit_id
,
diff
.
old_path
))
-
if
diff
.
renamed_file
||
diff
.
new_file
||
diff
.
deleted_file
-
if
diff
.
renamed_file
||
diff
.
new_file
||
diff
.
deleted_file
.image
.image
...
@@ -16,7 +15,7 @@
...
@@ -16,7 +15,7 @@
%div
.two-up.view
%div
.two-up.view
%span
.wrap
%span
.wrap
.frame.deleted
.frame.deleted
%a
{
href:
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
old_commit_id
,
diff
.
old_path
))}
%a
{
href:
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
diff_file
.
old_ref
,
diff
.
old_path
))}
%img
{
src:
old_file_raw_path
}
%img
{
src:
old_file_raw_path
}
%p
.image-info.hide
%p
.image-info.hide
%span
.meta-filesize
=
"
#{
number_to_human_size
old_file
.
size
}
"
%span
.meta-filesize
=
"
#{
number_to_human_size
old_file
.
size
}
"
...
@@ -28,7 +27,7 @@
...
@@ -28,7 +27,7 @@
%span
.meta-height
%span
.meta-height
%span
.wrap
%span
.wrap
.frame.added
.frame.added
%a
{
href:
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@commit
.
id
,
diff
.
new_path
))}
%a
{
href:
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
diff_file
.
new_ref
,
diff
.
new_path
))}
%img
{
src:
file_raw_path
}
%img
{
src:
file_raw_path
}
%p
.image-info.hide
%p
.image-info.hide
%span
.meta-filesize
=
"
#{
number_to_human_size
file
.
size
}
"
%span
.meta-filesize
=
"
#{
number_to_human_size
file
.
size
}
"
...
...
app/workers/emails_on_push_worker.rb
View file @
a9fa45f0
...
@@ -28,18 +28,30 @@ class EmailsOnPushWorker
...
@@ -28,18 +28,30 @@ class EmailsOnPushWorker
:push
:push
end
end
merge_base_sha
=
project
.
merge_base_commit
(
before_sha
,
after_sha
).
try
(
:sha
)
diff_refs
=
nil
diff_refs
=
nil
compare
=
nil
compare
=
nil
reverse_compare
=
false
reverse_compare
=
false
if
action
==
:push
if
action
==
:push
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
before_sha
,
after_sha
)
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
before_sha
,
after_sha
)
diff_refs
=
[
project
.
merge_base_commit
(
before_sha
,
after_sha
),
project
.
commit
(
after_sha
)]
diff_refs
=
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
merge_base_sha
,
start_sha:
before_sha
,
head_sha:
after_sha
)
return
false
if
compare
.
same
return
false
if
compare
.
same
if
compare
.
commits
.
empty?
if
compare
.
commits
.
empty?
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
after_sha
,
before_sha
)
compare
=
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
after_sha
,
before_sha
)
diff_refs
=
[
project
.
merge_base_commit
(
after_sha
,
before_sha
),
project
.
commit
(
before_sha
)]
diff_refs
=
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
merge_base_sha
,
start_sha:
after_sha
,
head_sha:
before_sha
)
reverse_compare
=
true
reverse_compare
=
true
...
...
lib/gitlab/diff/diff_refs.rb
0 → 100644
View file @
a9fa45f0
module
Gitlab
module
Diff
class
DiffRefs
attr_reader
:base_sha
attr_reader
:start_sha
attr_reader
:head_sha
def
initialize
(
base_sha
:,
start_sha:
base_sha
,
head_sha
:)
@base_sha
=
base_sha
@start_sha
=
start_sha
@head_sha
=
head_sha
end
def
==
(
other
)
other
.
is_a?
(
self
.
class
)
&&
base_sha
==
other
.
base_sha
&&
start_sha
==
other
.
start_sha
&&
head_sha
==
other
.
head_sha
end
def
complete?
start_sha
&&
head_sha
end
end
end
end
lib/gitlab/diff/file.rb
View file @
a9fa45f0
module
Gitlab
module
Gitlab
module
Diff
module
Diff
class
File
class
File
attr_reader
:diff
,
:diff_refs
attr_reader
:diff
,
:
repository
,
:
diff_refs
delegate
:new_file
,
:deleted_file
,
:renamed_file
,
delegate
:new_file
,
:deleted_file
,
:renamed_file
,
:old_path
,
:new_path
,
to: :diff
,
prefix:
false
:old_path
,
:new_path
,
to: :diff
,
prefix:
false
def
initialize
(
diff
,
diff_refs
)
def
initialize
(
diff
,
repository
:,
diff_refs:
nil
)
@diff
=
diff
@diff
=
diff
@repository
=
repository
@diff_refs
=
diff_refs
@diff_refs
=
diff_refs
end
end
def
old_ref
def
old_ref
diff_refs
[
0
]
if
diff_refs
diff_refs
.
try
(
:base_sha
)
end
end
def
new_ref
def
new_ref
diff_refs
[
1
]
if
diff_refs
diff_refs
.
try
(
:head_sha
)
end
end
# Array of Gitlab::D
I
ff::Line objects
# Array of Gitlab::D
i
ff::Line objects
def
diff_lines
def
diff_lines
@lines
||=
parser
.
parse
(
raw_diff
.
each_line
).
to_a
@lines
||=
Gitlab
::
Diff
::
Parser
.
new
.
parse
(
raw_diff
.
each_line
).
to_a
end
def
too_large?
diff
.
too_large?
end
end
def
highlighted_diff_lines
def
highlighted_diff_lines
Gitlab
::
Diff
::
Highlight
.
new
(
self
).
highlight
@highlighted_diff_lines
||=
Gitlab
::
Diff
::
Highlight
.
new
(
self
,
repository:
self
.
repository
).
highlight
end
end
def
parallel_diff_lines
def
parallel_diff_lines
Gitlab
::
Diff
::
ParallelDiff
.
new
(
self
).
parallelize
@parallel_diff_lines
||=
Gitlab
::
Diff
::
ParallelDiff
.
new
(
self
).
parallelize
end
end
def
mode_changed?
def
mode_changed?
...
...
lib/gitlab/diff/highlight.rb
View file @
a9fa45f0
module
Gitlab
module
Gitlab
module
Diff
module
Diff
class
Highlight
class
Highlight
attr_reader
:diff_file
,
:diff_lines
,
:raw_lines
attr_reader
:diff_file
,
:diff_lines
,
:raw_lines
,
:repository
delegate
:old_path
,
:new_path
,
:old_ref
,
:new_ref
,
to: :diff_file
,
prefix: :diff
delegate
:old_path
,
:new_path
,
:old_ref
,
:new_ref
,
to: :diff_file
,
prefix: :diff
def
initialize
(
diff_lines
)
def
initialize
(
diff_lines
,
repository:
nil
)
@repository
=
repository
if
diff_lines
.
is_a?
(
Gitlab
::
Diff
::
File
)
if
diff_lines
.
is_a?
(
Gitlab
::
Diff
::
File
)
@diff_file
=
diff_lines
@diff_file
=
diff_lines
@diff_lines
=
@diff_file
.
diff_lines
@diff_lines
=
@diff_file
.
diff_lines
...
@@ -19,7 +21,7 @@ module Gitlab
...
@@ -19,7 +21,7 @@ module Gitlab
@diff_lines
.
map
.
with_index
do
|
diff_line
,
i
|
@diff_lines
.
map
.
with_index
do
|
diff_line
,
i
|
diff_line
=
diff_line
.
dup
diff_line
=
diff_line
.
dup
# ignore highlighting for "match" lines
# ignore highlighting for "match" lines
next
diff_line
if
diff_line
.
type
==
'match'
||
diff_line
.
type
==
'nonewline'
next
diff_line
if
diff_line
.
meta?
rich_line
=
highlight_line
(
diff_line
)
||
diff_line
.
text
rich_line
=
highlight_line
(
diff_line
)
||
diff_line
.
text
...
@@ -70,7 +72,7 @@ module Gitlab
...
@@ -70,7 +72,7 @@ module Gitlab
ref
=
send
(
"diff_
#{
version
}
_ref"
)
ref
=
send
(
"diff_
#{
version
}
_ref"
)
path
=
send
(
"diff_
#{
version
}
_path"
)
path
=
send
(
"diff_
#{
version
}
_path"
)
[
ref
.
project
.
repository
,
ref
.
id
,
path
]
[
self
.
repository
,
ref
,
path
]
end
end
end
end
end
end
...
...
lib/gitlab/email/message/repository_push.rb
View file @
a9fa45f0
...
@@ -33,11 +33,15 @@ module Gitlab
...
@@ -33,11 +33,15 @@ module Gitlab
end
end
def
commits
def
commits
@commits
||=
(
Commit
.
decorate
(
compare
.
commits
,
project
)
if
compare
)
return
unless
compare
@commits
||=
Commit
.
decorate
(
compare
.
commits
,
project
)
end
end
def
diffs
def
diffs
@diffs
||=
(
safe_diff_files
(
compare
.
diffs
(
max_files:
30
),
diff_refs
)
if
compare
)
return
unless
compare
@diffs
||=
safe_diff_files
(
compare
.
diffs
(
max_files:
30
),
diff_refs:
diff_refs
,
repository:
project
.
repository
)
end
end
def
diffs_count
def
diffs_count
...
...
lib/gitlab/workhorse.rb
View file @
a9fa45f0
...
@@ -38,12 +38,10 @@ module Gitlab
...
@@ -38,12 +38,10 @@ module Gitlab
end
end
def
send_git_diff
(
repository
,
diff_refs
)
def
send_git_diff
(
repository
,
diff_refs
)
from
,
to
=
diff_refs
params
=
{
params
=
{
'RepoPath'
=>
repository
.
path_to_repo
,
'RepoPath'
=>
repository
.
path_to_repo
,
'ShaFrom'
=>
from
.
sha
,
'ShaFrom'
=>
diff_refs
.
start_
sha
,
'ShaTo'
=>
to
.
sha
'ShaTo'
=>
diff_refs
.
head_
sha
}
}
[
[
...
...
spec/helpers/diff_helper_spec.rb
View file @
a9fa45f0
...
@@ -9,7 +9,7 @@ describe DiffHelper do
...
@@ -9,7 +9,7 @@ describe DiffHelper do
let
(
:diffs
)
{
commit
.
diffs
}
let
(
:diffs
)
{
commit
.
diffs
}
let
(
:diff
)
{
diffs
.
first
}
let
(
:diff
)
{
diffs
.
first
}
let
(
:diff_refs
)
{
[
commit
.
parent
,
commit
]
}
let
(
:diff_refs
)
{
[
commit
.
parent
,
commit
]
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs
)
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs
:
diff_refs
,
repository:
repository
)
}
describe
'diff_view'
do
describe
'diff_view'
do
it
'returns a valid value when cookie is set'
do
it
'returns a valid value when cookie is set'
do
...
...
spec/lib/gitlab/diff/file_spec.rb
View file @
a9fa45f0
...
@@ -6,7 +6,7 @@ describe Gitlab::Diff::File, lib: true do
...
@@ -6,7 +6,7 @@ describe Gitlab::Diff::File, lib: true do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
[
commit
.
parent
,
commit
]
)
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs:
commit
.
diff_refs
,
repository:
project
.
repository
)
}
describe
:diff_lines
do
describe
:diff_lines
do
let
(
:diff_lines
)
{
diff_file
.
diff_lines
}
let
(
:diff_lines
)
{
diff_file
.
diff_lines
}
...
...
spec/lib/gitlab/diff/highlight_spec.rb
View file @
a9fa45f0
...
@@ -6,11 +6,11 @@ describe Gitlab::Diff::Highlight, lib: true do
...
@@ -6,11 +6,11 @@ describe Gitlab::Diff::Highlight, lib: true do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
[
commit
.
parent
,
commit
]
)
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs:
commit
.
diff_refs
,
repository:
project
.
repository
)
}
describe
'#highlight'
do
describe
'#highlight'
do
context
"with a diff file"
do
context
"with a diff file"
do
let
(
:subject
)
{
Gitlab
::
Diff
::
Highlight
.
new
(
diff_file
).
highlight
}
let
(
:subject
)
{
Gitlab
::
Diff
::
Highlight
.
new
(
diff_file
,
repository:
project
.
repository
).
highlight
}
it
'should return Gitlab::Diff::Line elements'
do
it
'should return Gitlab::Diff::Line elements'
do
expect
(
subject
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
expect
(
subject
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
...
@@ -41,7 +41,7 @@ describe Gitlab::Diff::Highlight, lib: true do
...
@@ -41,7 +41,7 @@ describe Gitlab::Diff::Highlight, lib: true do
end
end
context
"with diff lines"
do
context
"with diff lines"
do
let
(
:subject
)
{
Gitlab
::
Diff
::
Highlight
.
new
(
diff_file
.
diff_lines
).
highlight
}
let
(
:subject
)
{
Gitlab
::
Diff
::
Highlight
.
new
(
diff_file
.
diff_lines
,
repository:
project
.
repository
).
highlight
}
it
'should return Gitlab::Diff::Line elements'
do
it
'should return Gitlab::Diff::Line elements'
do
expect
(
subject
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
expect
(
subject
.
first
).
to
be_an_instance_of
(
Gitlab
::
Diff
::
Line
)
...
...
spec/lib/gitlab/diff/parallel_diff_spec.rb
View file @
a9fa45f0
...
@@ -8,8 +8,7 @@ describe Gitlab::Diff::ParallelDiff, lib: true do
...
@@ -8,8 +8,7 @@ describe Gitlab::Diff::ParallelDiff, lib: true do
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diffs
)
{
commit
.
diffs
}
let
(
:diffs
)
{
commit
.
diffs
}
let
(
:diff
)
{
diffs
.
first
}
let
(
:diff
)
{
diffs
.
first
}
let
(
:diff_refs
)
{
[
commit
.
parent
,
commit
]
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs:
commit
.
diff_refs
,
repository:
repository
)
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
,
diff_refs
)
}
subject
{
described_class
.
new
(
diff_file
)
}
subject
{
described_class
.
new
(
diff_file
)
}
let
(
:parallel_diff_result_array
)
{
YAML
.
load_file
(
"
#{
Rails
.
root
}
/spec/fixtures/parallel_diff_result.yml"
)
}
let
(
:parallel_diff_result_array
)
{
YAML
.
load_file
(
"
#{
Rails
.
root
}
/spec/fixtures/parallel_diff_result.yml"
)
}
...
...
spec/mailers/notify_spec.rb
View file @
a9fa45f0
...
@@ -948,7 +948,7 @@ describe Notify do
...
@@ -948,7 +948,7 @@ describe Notify do
let
(
:commits
)
{
Commit
.
decorate
(
compare
.
commits
,
nil
)
}
let
(
:commits
)
{
Commit
.
decorate
(
compare
.
commits
,
nil
)
}
let
(
:diff_path
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
Commit
.
new
(
compare
.
base
,
project
),
to:
Commit
.
new
(
compare
.
head
,
project
))
}
let
(
:diff_path
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
Commit
.
new
(
compare
.
base
,
project
),
to:
Commit
.
new
(
compare
.
head
,
project
))
}
let
(
:send_from_committer_email
)
{
false
}
let
(
:send_from_committer_email
)
{
false
}
let
(
:diff_refs
)
{
[
project
.
merge_base_commit
(
sample_image_commit
.
id
,
sample_commit
.
id
),
project
.
commit
(
sample_commit
.
id
)]
}
let
(
:diff_refs
)
{
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
project
.
merge_base_commit
(
sample_image_commit
.
id
,
sample_commit
.
id
).
id
,
head_sha:
sample_commit
.
id
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
reverse_compare:
false
,
diff_refs:
diff_refs
,
send_from_committer_email:
send_from_committer_email
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
reverse_compare:
false
,
diff_refs:
diff_refs
,
send_from_committer_email:
send_from_committer_email
)
}
...
@@ -1049,7 +1049,7 @@ describe Notify do
...
@@ -1049,7 +1049,7 @@ describe Notify do
let
(
:compare
)
{
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
sample_commit
.
parent_id
,
sample_commit
.
id
)
}
let
(
:compare
)
{
Gitlab
::
Git
::
Compare
.
new
(
project
.
repository
.
raw_repository
,
sample_commit
.
parent_id
,
sample_commit
.
id
)
}
let
(
:commits
)
{
Commit
.
decorate
(
compare
.
commits
,
nil
)
}
let
(
:commits
)
{
Commit
.
decorate
(
compare
.
commits
,
nil
)
}
let
(
:diff_path
)
{
namespace_project_commit_path
(
project
.
namespace
,
project
,
commits
.
first
)
}
let
(
:diff_path
)
{
namespace_project_commit_path
(
project
.
namespace
,
project
,
commits
.
first
)
}
let
(
:diff_refs
)
{
[
project
.
merge_base_commit
(
sample_commit
.
parent_id
,
sample_commit
.
id
),
project
.
commit
(
sample_commit
.
id
)]
}
let
(
:diff_refs
)
{
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
project
.
merge_base_commit
(
sample_image_commit
.
id
,
sample_commit
.
id
).
id
,
head_sha:
sample_commit
.
id
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
diff_refs:
diff_refs
)
}
subject
{
Notify
.
repository_push_email
(
project
.
id
,
author_id:
user
.
id
,
ref:
'refs/heads/master'
,
action: :push
,
compare:
compare
,
diff_refs:
diff_refs
)
}
...
...
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