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
948ac8b9
Commit
948ac8b9
authored
Dec 10, 2019
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Lint errors
Add localization in gitlab.pot Fix various lint errors and messages
parent
53ee65fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
11 deletions
+19
-11
app/models/diff_note.rb
app/models/diff_note.rb
+11
-6
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/models/diff_note_spec.rb
spec/models/diff_note_spec.rb
+2
-3
spec/support/shared_examples/models/diff_note_after_commit_shared_examples.rb
...examples/models/diff_note_after_commit_shared_examples.rb
+0
-2
No files found.
app/models/diff_note.rb
View file @
948ac8b9
...
...
@@ -39,13 +39,16 @@ class DiffNote < Note
return
unless
should_create_diff_file?
diff_file
=
fetch_diff_file
raise
NoteDiffFileCreationError
,
DIFF_FILE_NOT_FOUND_MESSAGE
unless
diff_file
raise
NoteDiffFileCreationError
,
DIFF_FILE_NOT_FOUND_MESSAGE
unless
diff_file
diff_line
=
diff_file
.
line_for_position
(
self
.
original_position
)
raise
NoteDiffFileCreationError
,
DIFF_LINE_NOT_FOUND_MESSAGE
%
{
file_path:
diff_file
.
file_path
,
new_pos:
original_position
.
new_line
,
old_pos:
original_position
.
old_line
}
unless
diff_line
unless
diff_line
raise
NoteDiffFileCreationError
,
DIFF_LINE_NOT_FOUND_MESSAGE
%
{
file_path:
diff_file
.
file_path
,
new_pos:
original_position
.
new_line
,
old_pos:
original_position
.
old_line
}
end
creation_params
=
diff_file
.
diff
.
to_hash
.
except
(
:too_large
)
...
...
@@ -121,6 +124,7 @@ class DiffNote < Note
def
fetch_diff_file
return
note_diff_file
.
raw_diff_file
if
note_diff_file
if
created_at_diff?
(
noteable
.
diff_refs
)
# We're able to use the already persisted diffs (Postgres) if we're
# presenting a "current version" of the MR discussion diff.
...
...
@@ -132,6 +136,7 @@ class DiffNote < Note
# if line is not found in persisted diffs, fallback and retrieve file from repository using gitaly
file
=
nil
if
file
&
.
line_for_position
(
original_position
).
nil?
&&
importing?
end
file
||=
original_position
.
diff_file
(
repository
)
file
&
.
unfold_diff_lines
(
position
)
...
...
locale/gitlab.pot
View file @
948ac8b9
...
...
@@ -7373,6 +7373,12 @@ msgstr ""
msgid "Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later."
msgstr ""
msgid "Failed to find diff file"
msgstr ""
msgid "Failed to find diff line for: %{file_path}, new_pos: %{new_pos}, old_pos: %{old_pos}"
msgstr ""
msgid "Failed to get ref."
msgstr ""
...
...
spec/models/diff_note_spec.rb
View file @
948ac8b9
...
...
@@ -91,7 +91,6 @@ describe DiffNote do
end
describe
'#create_diff_file callback'
do
context
'merge request'
do
let
(
:position
)
do
Gitlab
::
Diff
::
Position
.
new
(
old_path:
"files/ruby/popen.rb"
,
...
...
@@ -101,6 +100,7 @@ describe DiffNote do
diff_refs:
merge_request
.
diff_refs
)
end
subject
{
build
(
:diff_note_on_merge_request
,
project:
project
,
position:
position
,
noteable:
merge_request
)
}
let
(
:diff_file_from_repository
)
do
position
.
diff_file
(
project
.
repository
)
end
...
...
@@ -168,7 +168,6 @@ describe DiffNote do
subject
.
save
expect
(
subject
.
reload
.
note_diff_file
).
to
be_present
end
end
end
end
...
...
@@ -189,7 +188,7 @@ describe DiffNote do
end
it
'does not create diff note file if it is a reply'
do
diff_note
=
create
(
:diff_note_on_merge_request
,
project:
project
,
noteable:
merge_request
)
diff_note
=
create
(
:diff_note_on_merge_request
,
project:
project
,
noteable:
merge_request
)
expect
{
create
(
:diff_note_on_merge_request
,
noteable:
merge_request
,
in_reply_to:
diff_note
)
}
.
not_to
change
(
NoteDiffFile
,
:count
)
end
...
...
spec/support/shared_examples/models/diff_note_after_commit_shared_examples.rb
View file @
948ac8b9
# frozen_string_literal: true
shared_examples
'a valid diff note with after commit callback'
do
context
'when diff file is fetched from repository'
do
before
do
allow_any_instance_of
(
::
Gitlab
::
Diff
::
Position
).
to
receive
(
:diff_file
).
with
(
project
.
repository
).
and_return
(
diff_file_from_repository
)
...
...
@@ -31,7 +30,6 @@ shared_examples 'a valid diff note with after commit callback' do
subject
.
save
expect
(
subject
.
reload
.
note_diff_file
).
to
be_present
end
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