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
Tatuya Kamada
gitlab-ce
Commits
37519345
Commit
37519345
authored
Jun 20, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style diff and blob file headers the same way
parent
4c1bf77c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
77 additions
and
54 deletions
+77
-54
app/assets/stylesheets/framework/files.scss
app/assets/stylesheets/framework/files.scss
+1
-1
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+11
-0
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+10
-0
app/views/notify/note_merge_request_email.html.haml
app/views/notify/note_merge_request_email.html.haml
+2
-2
app/views/projects/diffs/_file.html.haml
app/views/projects/diffs/_file.html.haml
+15
-30
app/views/projects/diffs/_file_header.html.haml
app/views/projects/diffs/_file_header.html.haml
+25
-0
app/views/projects/notes/discussions/_diff_with_notes.html.haml
...ews/projects/notes/discussions/_diff_with_notes.html.haml
+8
-11
lib/gitlab/diff/file.rb
lib/gitlab/diff/file.rb
+5
-10
No files found.
app/assets/stylesheets/framework/files.scss
View file @
37519345
...
...
@@ -50,7 +50,7 @@
}
a
:not
(
.btn
)
{
color
:
$gl-
dark-link
-color
;
color
:
$gl-
text
-color
;
}
.left-options
{
...
...
app/helpers/application_helper.rb
View file @
37519345
...
...
@@ -306,4 +306,15 @@ module ApplicationHelper
def
truncate_first_line
(
message
,
length
=
50
)
truncate
(
message
.
each_line
.
first
.
chomp
,
length:
length
)
if
message
end
# While similarly named to Rails's `link_to_if`, this method behaves quite differently.
# If `condition` is truthy, a link will be returned with the result of the block
# as its body. If `condition` is falsy, only the result of the block will be returned.
def
conditional_link_to
(
condition
,
options
,
html_options
=
{},
&
block
)
if
condition
link_to
options
,
html_options
,
&
block
else
capture
(
&
block
)
end
end
end
app/helpers/notes_helper.rb
View file @
37519345
...
...
@@ -79,4 +79,14 @@ module NotesHelper
full_key
=
{
project:
note
.
project
,
user_id:
note
.
author_id
}
@max_access_by_user_id
[
full_key
]
end
def
diff_note_path
(
note
)
return
unless
note
.
diff_note?
if
note
.
for_merge_request?
&&
note
.
active?
diffs_namespace_project_merge_request_path
(
note
.
project
.
namespace
,
note
.
project
,
note
.
noteable
,
anchor:
note
.
line_code
)
elsif
note
.
for_commit?
namespace_project_commit_path
(
note
.
project
.
namespace
,
note
.
project
,
note
.
noteable
,
anchor:
note
.
line_code
)
end
end
end
app/views/notify/note_merge_request_email.html.haml
View file @
37519345
-
if
@note
.
legacy_
diff_note?
-
if
@note
.
diff_note?
%p
.details
New comment on diff for
=
link_to
@note
.
diff_file_path
,
@target_url
=
link_to
@note
.
diff_file
.
file
_path
,
@target_url
\:
=
render
'note_message'
app/views/projects/diffs/_file.html.haml
View file @
37519345
.diff-file.file-holder
{
id:
"diff-#{i}"
,
data:
diff_file_html_data
(
project
,
diff_file
)}
.file-title
{
id:
"file-path-#{hexdigest(diff_file.file_path)}"
}
-
if
diff_file
.
diff
.
submodule?
%span
=
icon
(
'archive fw'
)
%span
=
submodule_link
(
blob
,
@commit
.
id
,
project
.
repository
)
-
else
=
blob_icon
blob
.
mode
,
blob
.
name
=
link_to
"#diff-
#{
i
}
"
do
-
if
diff_file
.
renamed_file
-
old_path
,
new_path
=
mark_inline_diffs
(
diff_file
.
old_path
,
diff_file
.
new_path
)
=
old_path
→
=
new_path
-
else
%span
=
diff_file
.
new_path
-
if
diff_file
.
deleted_file
deleted
-
if
diff_file
.
mode_changed?
%small
=
"
#{
diff_file
.
diff
.
a_mode
}
→
#{
diff_file
.
diff
.
b_mode
}
"
=
render
"projects/diffs/file_header"
,
diff_file:
diff_file
,
blob:
blob
,
diff_commit:
diff_commit
,
project:
project
,
url:
"#diff-
#{
i
}
"
-
unless
diff_file
.
submodule?
.file-actions.hidden-xs
-
if
blob_text_viewable?
(
blob
)
=
link_to
'#'
,
class:
'js-toggle-diff-comments btn active has-tooltip btn-file-option'
,
title:
"Toggle comments for this file"
do
...
...
@@ -42,15 +21,21 @@
-
return
unless
blob
.
respond_to?
(
:text?
)
-
if
diff_file
.
too_large?
.nothing-here-block
This diff could not be displayed because it is too large.
-
elsif
blob_text_viewable?
(
blob
)
&&
!
project
.
repository
.
diffable?
(
blob
)
.nothing-here-block
This diff was suppressed by a .gitattributes entry.
-
elsif
blob_text_viewable?
(
blob
)
-
if
diff_view
==
'parallel'
=
render
"projects/diffs/parallel_view"
,
diff_file:
diff_file
,
project:
project
,
blob:
blob
,
index:
i
-
else
=
render
"projects/diffs/text_file"
,
diff_file:
diff_file
,
index:
i
-
elsif
blob
.
only_display_raw?
.nothing-here-block
This file is too large to display.
-
elsif
blob_text_viewable?
(
blob
)
-
if
!
project
.
repository
.
diffable?
(
blob
)
.nothing-here-block
This diff was suppressed by a .gitattributes entry.
-
elsif
diff_file
.
diff_lines
.
length
>
0
-
if
diff_view
==
'parallel'
=
render
"projects/diffs/parallel_view"
,
diff_file:
diff_file
,
project:
project
,
blob:
blob
,
index:
i
-
else
=
render
"projects/diffs/text_file"
,
diff_file:
diff_file
,
index:
i
-
else
-
if
diff_file
.
mode_changed?
.nothing-here-block
File mode changed
-
elsif
diff_file
.
renamed_file
.nothing-here-block
File moved
-
elsif
blob
.
image?
-
old_blob
=
diff_file
.
old_blob
(
diff_commit
)
=
render
"projects/diffs/image"
,
diff_file:
diff_file
,
old_file:
old_blob
,
file:
blob
,
index:
i
...
...
app/views/projects/diffs/_file_header.html.haml
0 → 100644
View file @
37519345
-
if
defined?
(
blob
)
&&
blob
&&
diff_file
.
submodule?
%span
=
icon
(
'archive fw'
)
%span
=
submodule_link
(
blob
,
diff_commit
.
id
,
project
.
repository
)
-
else
=
conditional_link_to
url
.
present?
,
url
do
=
blob_icon
diff_file
.
b_mode
,
diff_file
.
file_path
-
if
diff_file
.
renamed_file
-
old_path
,
new_path
=
mark_inline_diffs
(
diff_file
.
old_path
,
diff_file
.
new_path
)
%strong
=
old_path
→
%strong
=
new_path
-
else
%strong
=
diff_file
.
new_path
-
if
diff_file
.
deleted_file
deleted
-
if
diff_file
.
mode_changed?
%small
=
"
#{
diff_file
.
a_mode
}
→
#{
diff_file
.
b_mode
}
"
app/views/projects/notes/discussions/_diff_with_notes.html.haml
View file @
37519345
-
note
=
discussion_notes
.
first
-
diff
=
note
.
diff
-
return
unless
diff
-
diff_file
=
note
.
diff_file
-
return
unless
diff_file
-
blob
=
note
.
blob
.diff-file.file-holder
.file-title
=
render
"projects/diffs/file_header"
,
diff_file:
diff_file
,
blob:
blob
,
diff_commit:
diff_file
.
content_commit
,
project:
note
.
project
,
url:
diff_note_path
(
note
)
.diff-file
.diff-header
%span
-
if
diff
.
deleted_file
=
diff
.
old_path
-
else
=
diff
.
new_path
-
if
diff
.
a_mode
&&
diff
.
b_mode
&&
diff
.
a_mode
!=
diff
.
b_mode
%span
.file-mode
=
"
#{
diff
.
a_mode
}
→
#{
diff
.
b_mode
}
"
.diff-content.code.js-syntax-highlight
%table
-
note
.
truncated_diff_lines
.
each
do
|
line
|
...
...
lib/gitlab/diff/file.rb
View file @
37519345
...
...
@@ -4,7 +4,8 @@ module Gitlab
attr_reader
:diff
,
:repository
,
:diff_refs
delegate
:new_file
,
:deleted_file
,
:renamed_file
,
:old_path
,
:new_path
,
to: :diff
,
prefix:
false
:old_path
,
:new_path
,
:a_mode
,
:b_mode
,
:submodule?
,
:too_large?
,
to: :diff
,
prefix:
false
def
initialize
(
diff
,
repository
:,
diff_refs:
nil
)
@diff
=
diff
...
...
@@ -40,11 +41,7 @@ module Gitlab
end
def
mode_changed?
!!
(
diff
.
a_mode
&&
diff
.
b_mode
&&
diff
.
a_mode
!=
diff
.
b_mode
)
end
def
parser
Gitlab
::
Diff
::
Parser
.
new
a_mode
&&
b_mode
&&
a_mode
!=
b_mode
end
def
raw_diff
...
...
@@ -56,13 +53,11 @@ module Gitlab
end
def
prev_line
(
index
)
if
index
>
0
diff_lines
[
index
-
1
]
end
diff_lines
[
index
-
1
]
if
index
>
0
end
def
file_path
new_path
.
presence
||
old_path
.
presence
new_path
.
presence
||
old_path
end
def
added_lines
...
...
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