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
Boxiang Sun
gitlab-ce
Commits
39b6e678
Commit
39b6e678
authored
Jul 06, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify HAML code using unless condition and nesting
Extract diff line data attributes to helper methods
parent
fa981c97
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
14 deletions
+30
-14
app/controllers/projects/compare_controller.rb
app/controllers/projects/compare_controller.rb
+0
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+0
-1
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+21
-0
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+0
-1
app/views/projects/diffs/_line.html.haml
app/views/projects/diffs/_line.html.haml
+3
-3
app/views/projects/diffs/_parallel_view.html.haml
app/views/projects/diffs/_parallel_view.html.haml
+5
-6
app/views/projects/diffs/_text_file.html.haml
app/views/projects/diffs/_text_file.html.haml
+1
-2
No files found.
app/controllers/projects/compare_controller.rb
View file @
39b6e678
...
@@ -24,7 +24,6 @@ class Projects::CompareController < Projects::ApplicationController
...
@@ -24,7 +24,6 @@ class Projects::CompareController < Projects::ApplicationController
@diff_refs
=
[
@base_commit
,
@commit
]
@diff_refs
=
[
@base_commit
,
@commit
]
@diff_notes_disabled
=
true
@diff_notes_disabled
=
true
@grouped_diff_notes
=
{}
@grouped_diff_notes
=
{}
@comments_target
=
{}
end
end
end
end
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
39b6e678
...
@@ -138,7 +138,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -138,7 +138,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@base_commit
=
@merge_request
.
diff_base_commit
@base_commit
=
@merge_request
.
diff_base_commit
@diffs
=
@merge_request
.
compare
.
diffs
(
diff_options
)
if
@merge_request
.
compare
@diffs
=
@merge_request
.
compare
.
diffs
(
diff_options
)
if
@merge_request
.
compare
@diff_notes_disabled
=
true
@diff_notes_disabled
=
true
@comments_target
=
{}
@pipeline
=
@merge_request
.
pipeline
@pipeline
=
@merge_request
.
pipeline
@statuses
=
@pipeline
.
statuses
if
@pipeline
@statuses
=
@pipeline
.
statuses
if
@pipeline
...
...
app/helpers/notes_helper.rb
View file @
39b6e678
...
@@ -24,6 +24,27 @@ module NotesHelper
...
@@ -24,6 +24,27 @@ module NotesHelper
}.
to_json
}.
to_json
end
end
def
note_text_file_data
return
{}
unless
defined?
(
@comments_target
)
&&
@comments_target
.
any?
@comments_target
.
slice
(
:noteable_id
,
:noteable_type
,
:commit_id
).
merge
(
note_type:
LegacyDiffNote
.
name
)
end
def
note_line_parallel_data
(
line_code
,
line_type
)
data
=
{
line_code:
line_code
,
line_type:
line_type
,
}
unless
@diff_notes_disabled
data
.
merge!
(
discussion_id:
discussion_id
(
line_code
)
)
end
data
end
def
discussion_id
(
line_code
)
def
discussion_id
(
line_code
)
LegacyDiffNote
.
build_discussion_id
(
LegacyDiffNote
.
build_discussion_id
(
@comments_target
[
:noteable_type
],
@comments_target
[
:noteable_type
],
...
...
app/mailers/emails/projects.rb
View file @
39b6e678
...
@@ -30,7 +30,6 @@ module Emails
...
@@ -30,7 +30,6 @@ module Emails
@target_url
=
@message
.
target_url
@target_url
=
@message
.
target_url
@project
=
Project
.
find
(
project_id
)
@project
=
Project
.
find
(
project_id
)
@diff_notes_disabled
=
true
@diff_notes_disabled
=
true
@comments_target
=
{}
add_project_headers
add_project_headers
headers
[
'X-GitLab-Author'
]
=
@message
.
author_username
headers
[
'X-GitLab-Author'
]
=
@message
.
author_username
...
...
app/views/projects/diffs/_line.html.haml
View file @
39b6e678
-
type
=
line
.
type
-
type
=
line
.
type
-
line_data
=
@
comments_target
.
any?
?
{
data:
{
discussion_id:
discussion_id
(
line_code
)
}
}
:
{
}
-
line_data
=
@
diff_notes_disabled
?
{}
:
{
data:
{
discussion_id:
discussion_id
(
line_code
)
}
}
%tr
.line_holder
{
line_data
,
id:
line_code
,
class:
type
}
%tr
.line_holder
{
line_data
,
id:
line_code
,
class:
type
}
-
case
type
-
case
type
-
when
'match'
-
when
'match'
...
@@ -15,11 +15,11 @@
...
@@ -15,11 +15,11 @@
-
if
defined?
(
plain
)
&&
plain
-
if
defined?
(
plain
)
&&
plain
=
link_text
=
link_text
-
else
-
else
%a
{
href:
"##{line_code}"
,
data:
{
linenumber:
link_text
}}
=
" "
%a
{
href:
"##{line_code}"
,
data:
{
linenumber:
link_text
}}
%td
.new_line.diff-line-num
{
class:
type
,
data:
{
linenumber:
line
.
new_pos
}
}
%td
.new_line.diff-line-num
{
class:
type
,
data:
{
linenumber:
line
.
new_pos
}
}
-
link_text
=
type
==
"old"
?
" "
:
line
.
new_pos
-
link_text
=
type
==
"old"
?
" "
:
line
.
new_pos
-
if
defined?
(
plain
)
&&
plain
-
if
defined?
(
plain
)
&&
plain
=
link_text
=
link_text
-
else
-
else
%a
{
href:
"##{line_code}"
,
data:
{
linenumber:
link_text
}}
=
""
%a
{
href:
"##{line_code}"
,
data:
{
linenumber:
link_text
}}
%td
.line_content
{
class:
[
'noteable_line'
,
type
],
data:
{
line_code:
line_code
,
line_type:
type
}
}=
diff_line_content
(
line
.
text
,
type
)
%td
.line_content
{
class:
[
'noteable_line'
,
type
],
data:
{
line_code:
line_code
,
line_type:
type
}
}=
diff_line_content
(
line
.
text
,
type
)
app/views/projects/diffs/_parallel_view.html.haml
View file @
39b6e678
/ Side-by-side diff view
/ Side-by-side diff view
-
text_file_data
=
@comments_target
.
any?
?
{
data:
{
noteable_id:
@comments_target
[
:noteable_id
],
noteable_type:
@comments_target
[
:noteable_type
],
commit_id:
@comments_target
[
:commit_id
],
note_type:
LegacyDiffNote
.
name
}
}
:
{}
%div
.text-file.diff-wrap-lines.code.file-content.js-syntax-highlight
{
data:
note_text_file_data
}
%div
.text-file.diff-wrap-lines.code.file-content.js-syntax-highlight
{
text_file_data
}
%table
%table
-
diff_file
.
parallel_diff_lines
.
each
do
|
line
|
-
diff_file
.
parallel_diff_lines
.
each
do
|
line
|
-
left
=
line
[
:left
]
-
left
=
line
[
:left
]
...
@@ -14,9 +13,9 @@
...
@@ -14,9 +13,9 @@
%td
.new_line.diff-line-num.empty-cell
%td
.new_line.diff-line-num.empty-cell
%td
.line_content.parallel.match
=
left
[
:text
]
%td
.line_content.parallel.match
=
left
[
:text
]
-
else
-
else
%td
.old_line.diff-line-num
{
id:
left
[
:line_code
],
class:
"#{left[:type]} #{'empty-cell'
if !
left[:number]}"
,
data:
{
linenumber:
left
[
:number
]
}}
%td
.old_line.diff-line-num
{
id:
left
[
:line_code
],
class:
"#{left[:type]} #{'empty-cell'
unless
left[:number]}"
,
data:
{
linenumber:
left
[
:number
]
}}
%a
{
href:
"##{left[:line_code]}"
}=
raw
(
left
[
:number
])
%a
{
href:
"##{left[:line_code]}"
}=
raw
(
left
[
:number
])
%td
.line_content
{
class:
"parallel noteable_line #{left[:type]} #{'empty-cell' if left[:text].empty?}"
,
data:
{
discussion_id:
discussion_id
(
left
[
:line_code
]),
line_type:
left
[
:type
],
line_code:
left
[
:line_code
]
}
}=
diff_line_content
(
left
[
:text
])
%td
.line_content
{
class:
"parallel noteable_line #{left[:type]} #{'empty-cell' if left[:text].empty?}"
,
data:
note_line_parallel_data
(
left
[
:line_code
],
left
[
:type
])
}=
diff_line_content
(
left
[
:text
])
-
if
right
[
:type
]
==
'new'
-
if
right
[
:type
]
==
'new'
-
new_line_class
=
'new'
-
new_line_class
=
'new'
...
@@ -25,9 +24,9 @@
...
@@ -25,9 +24,9 @@
-
new_line_class
=
nil
-
new_line_class
=
nil
-
new_line_code
=
left
[
:line_code
]
-
new_line_code
=
left
[
:line_code
]
%td
.new_line.diff-line-num
{
id:
new_line_code
,
class:
"#{new_line_class} #{'empty-cell'
if !
right[:number]}"
,
data:
{
linenumber:
right
[
:number
]
}
}
%td
.new_line.diff-line-num
{
id:
new_line_code
,
class:
"#{new_line_class} #{'empty-cell'
unless
right[:number]}"
,
data:
{
linenumber:
right
[
:number
]
}
}
%a
{
href:
"##{new_line_code}"
}=
raw
(
right
[
:number
])
%a
{
href:
"##{new_line_code}"
}=
raw
(
right
[
:number
])
%td
.line_content.parallel
{
class:
"noteable_line #{new_line_class} #{'empty-cell' if right[:text].empty?}"
,
data:
{
discussion_id:
discussion_id
(
new_line_code
),
line_type:
new_line_class
,
line_code:
new_line_code
}
}=
diff_line_content
(
right
[
:text
])
%td
.line_content.parallel
{
class:
"noteable_line #{new_line_class} #{'empty-cell' if right[:text].empty?}"
,
data:
note_line_parallel_data
(
new_line_code
,
new_line_class
)
}=
diff_line_content
(
right
[
:text
])
-
unless
@diff_notes_disabled
-
unless
@diff_notes_disabled
-
notes_left
,
notes_right
=
organize_comments
(
left
,
right
)
-
notes_left
,
notes_right
=
organize_comments
(
left
,
right
)
...
...
app/views/projects/diffs/_text_file.html.haml
View file @
39b6e678
...
@@ -3,8 +3,7 @@
...
@@ -3,8 +3,7 @@
.suppressed-container
.suppressed-container
%a
.show-suppressed-diff.js-show-suppressed-diff
Changes suppressed. Click to show.
%a
.show-suppressed-diff.js-show-suppressed-diff
Changes suppressed. Click to show.
-
text_file_data
=
@comments_target
.
any?
?
{
data:
{
noteable_id:
@comments_target
[
:noteable_id
],
noteable_type:
@comments_target
[
:noteable_type
],
commit_id:
@comments_target
[
:commit_id
],
note_type:
LegacyDiffNote
.
name
}
}
:
{}
%table
.text-file.code.js-syntax-highlight
{
data:
note_text_file_data
,
class:
too_big
?
'hide'
:
''
}
%table
.text-file.code.js-syntax-highlight
{
text_file_data
,
class:
too_big
?
'hide'
:
''
}
-
last_line
=
0
-
last_line
=
0
-
diff_file
.
highlighted_diff_lines
.
each_with_index
do
|
line
,
index
|
-
diff_file
.
highlighted_diff_lines
.
each_with_index
do
|
line
,
index
|
...
...
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