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
8f05fbba
Commit
8f05fbba
authored
Aug 04, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont show comment on diff if diff line was changed after comment left
parent
2d75b454
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
12 deletions
+27
-12
app/helpers/commits_helper.rb
app/helpers/commits_helper.rb
+3
-1
app/models/note.rb
app/models/note.rb
+11
-0
app/views/projects/commits/_text_file.html.haml
app/views/projects/commits/_text_file.html.haml
+2
-2
app/views/projects/notes/_diff_notes_with_reply.html.haml
app/views/projects/notes/_diff_notes_with_reply.html.haml
+11
-9
No files found.
app/helpers/commits_helper.rb
View file @
8f05fbba
...
...
@@ -38,6 +38,8 @@ module CommitsHelper
lines_arr
=
::
Gitlab
::
InlineDiff
.
processing
diff_arr
lines_arr
.
each
do
|
line
|
raw_line
=
line
.
dup
next
if
line
.
match
(
/^\-\-\- \/dev\/null/
)
next
if
line
.
match
(
/^\+\+\+ \/dev\/null/
)
next
if
line
.
match
(
/^\-\-\- a/
)
...
...
@@ -58,7 +60,7 @@ module CommitsHelper
else
type
=
identification_type
(
line
)
line_code
=
build_line_anchor
(
diff
,
line_new
,
line_old
)
yield
(
full_line
,
type
,
line_code
,
line_new
,
line_old
)
yield
(
full_line
,
type
,
line_code
,
line_new
,
line_old
,
raw_line
)
end
...
...
app/models/note.rb
View file @
8f05fbba
...
...
@@ -99,10 +99,21 @@ class Note < ActiveRecord::Base
diff
.
new_path
if
diff
end
def
diff_old_line
line_code
.
split
(
'_'
)[
1
].
to_i
end
def
diff_new_line
line_code
.
split
(
'_'
)[
2
].
to_i
end
def
diff_line
if
diff
@diff_line
||=
diff
.
diff
.
lines
.
select
{
|
line
|
line
=~
/\A\+/
}[
diff_new_line
]
||
diff
.
diff
.
lines
.
select
{
|
line
|
line
=~
/\A\-/
}[
diff_old_line
]
end
end
def
discussion_id
@discussion_id
||=
[
:discussion
,
noteable_type
.
try
(
:underscore
),
noteable_id
||
commit_id
,
line_code
].
join
(
"-"
).
to_sym
end
...
...
app/views/projects/commits/_text_file.html.haml
View file @
8f05fbba
...
...
@@ -3,7 +3,7 @@
%a
.supp_diff_link
Diff suppressed. Click to show
%table
.text-file
{
class:
"#{'hide' if too_big}"
}
-
each_diff_line
(
diff
,
index
)
do
|
line
,
type
,
line_code
,
line_new
,
line_old
|
-
each_diff_line
(
diff
,
index
)
do
|
line
,
type
,
line_code
,
line_new
,
line_old
,
raw_line
|
%tr
.line_holder
{
id:
line_code
,
class:
"#{type}"
}
-
if
type
==
"match"
%td
.old_line
=
"..."
...
...
@@ -20,4 +20,4 @@
-
if
@reply_allowed
-
comments
=
@line_notes
.
select
{
|
n
|
n
.
line_code
==
line_code
}.
sort_by
(
&
:created_at
)
-
unless
comments
.
empty?
=
render
"projects/notes/diff_notes_with_reply"
,
notes:
comments
=
render
"projects/notes/diff_notes_with_reply"
,
notes:
comments
,
raw_line:
raw_line
app/views/projects/notes/_diff_notes_with_reply.html.haml
View file @
8f05fbba
-
note
=
notes
.
first
# example note
%tr
.notes_holder
-# Check if line want not changed since comment was left
-
if
!
defined?
(
raw_line
)
||
raw_line
==
note
.
diff_line
%tr
.notes_holder
%td
.notes_line
{
colspan:
2
}
%span
.btn.disabled
%i
.icon-comment
...
...
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