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
0c25bb4d
Commit
0c25bb4d
authored
Jun 01, 2020
by
David Kim
Committed by
Nick Thomas
Jun 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add file_identifier_hash to diff position
parent
a5f6efc8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
2 deletions
+32
-2
lib/gitlab/diff/formatters/base_formatter.rb
lib/gitlab/diff/formatters/base_formatter.rb
+10
-1
lib/gitlab/diff/position.rb
lib/gitlab/diff/position.rb
+1
-0
spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
+1
-0
spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
+1
-0
spec/spec_helper.rb
spec/spec_helper.rb
+4
-0
spec/support/shared_examples/lib/gitlab/position_formatters_shared_examples.rb
...xamples/lib/gitlab/position_formatters_shared_examples.rb
+15
-1
No files found.
lib/gitlab/diff/formatters/base_formatter.rb
View file @
0c25bb4d
...
...
@@ -6,6 +6,7 @@ module Gitlab
class
BaseFormatter
attr_reader
:old_path
attr_reader
:new_path
attr_reader
:file_identifier_hash
attr_reader
:base_sha
attr_reader
:start_sha
attr_reader
:head_sha
...
...
@@ -16,6 +17,7 @@ module Gitlab
attrs
[
:diff_refs
]
=
diff_file
.
diff_refs
attrs
[
:old_path
]
=
diff_file
.
old_path
attrs
[
:new_path
]
=
diff_file
.
new_path
attrs
[
:file_identifier_hash
]
=
diff_file
.
file_identifier_hash
end
if
diff_refs
=
attrs
[
:diff_refs
]
...
...
@@ -26,6 +28,7 @@ module Gitlab
@old_path
=
attrs
[
:old_path
]
@new_path
=
attrs
[
:new_path
]
@file_identifier_hash
=
attrs
[
:file_identifier_hash
]
@base_sha
=
attrs
[
:base_sha
]
@start_sha
=
attrs
[
:start_sha
]
@head_sha
=
attrs
[
:head_sha
]
...
...
@@ -36,7 +39,7 @@ module Gitlab
end
def
to_h
{
out
=
{
base_sha:
base_sha
,
start_sha:
start_sha
,
head_sha:
head_sha
,
...
...
@@ -44,6 +47,12 @@ module Gitlab
new_path:
new_path
,
position_type:
position_type
}
if
Feature
.
enabled?
(
:file_identifier_hash
)
out
[
:file_identifier_hash
]
=
file_identifier_hash
end
out
end
def
position_type
...
...
lib/gitlab/diff/position.rb
View file @
0c25bb4d
...
...
@@ -9,6 +9,7 @@ module Gitlab
delegate
:old_path
,
:new_path
,
:file_identifier_hash
,
:base_sha
,
:start_sha
,
:head_sha
,
...
...
spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
View file @
0c25bb4d
...
...
@@ -10,6 +10,7 @@ describe Gitlab::Diff::Formatters::ImageFormatter do
head_sha:
789
,
old_path:
'old_image.png'
,
new_path:
'new_image.png'
,
file_identifier_hash:
'777'
,
position_type:
'image'
}
end
...
...
spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
View file @
0c25bb4d
...
...
@@ -10,6 +10,7 @@ describe Gitlab::Diff::Formatters::TextFormatter do
head_sha:
789
,
old_path:
'old_path.txt'
,
new_path:
'new_path.txt'
,
file_identifier_hash:
'777'
,
line_range:
nil
}
end
...
...
spec/spec_helper.rb
View file @
0c25bb4d
...
...
@@ -195,6 +195,10 @@ RSpec.configure do |config|
stub_feature_flags
(
flag
=>
enable_rugged
)
end
# Disable the usage of file_identifier_hash by default until it is ready
# See https://gitlab.com/gitlab-org/gitlab/-/issues/33867
stub_feature_flags
(
file_identifier_hash:
false
)
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:can_use_disk?
).
and_return
(
enable_rugged
)
end
...
...
spec/support/shared_examples/lib/gitlab/position_formatters_shared_examples.rb
View file @
0c25bb4d
...
...
@@ -32,7 +32,21 @@ RSpec.shared_examples "position formatter" do
subject
{
formatter
.
to_h
}
it
{
is_expected
.
to
eq
(
formatter_hash
)
}
context
'when file_identifier_hash is disabled'
do
before
do
stub_feature_flags
(
file_identifier_hash:
false
)
end
it
{
is_expected
.
to
eq
(
formatter_hash
.
except
(
:file_identifier_hash
))
}
end
context
'when file_identifier_hash is enabled'
do
before
do
stub_feature_flags
(
file_identifier_hash:
true
)
end
it
{
is_expected
.
to
eq
(
formatter_hash
)
}
end
end
describe
'#=='
do
...
...
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