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
Jérome Perrin
gitlab-ce
Commits
9fdde369
Commit
9fdde369
authored
Oct 10, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move line code generation into Gitlab::Git
Having a distinct class just for that was a bit overkill
parent
faa9bd40
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
25 additions
and
43 deletions
+25
-43
lib/api/commits.rb
lib/api/commits.rb
+1
-1
lib/api/v3/commits.rb
lib/api/v3/commits.rb
+1
-1
lib/github/representation/comment.rb
lib/github/representation/comment.rb
+1
-1
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+1
-1
lib/gitlab/conflict/file.rb
lib/gitlab/conflict/file.rb
+1
-12
lib/gitlab/diff/file.rb
lib/gitlab/diff/file.rb
+1
-1
lib/gitlab/git.rb
lib/gitlab/git.rb
+4
-0
lib/gitlab/git/conflict/file.rb
lib/gitlab/git/conflict/file.rb
+3
-3
lib/gitlab/git/conflict/line_code.rb
lib/gitlab/git/conflict/line_code.rb
+0
-11
lib/gitlab/github_import/comment_formatter.rb
lib/gitlab/github_import/comment_formatter.rb
+1
-1
spec/lib/gitlab/diff/position_spec.rb
spec/lib/gitlab/diff/position_spec.rb
+10
-10
spec/models/diff_note_spec.rb
spec/models/diff_note_spec.rb
+1
-1
No files found.
lib/api/commits.rb
View file @
9fdde369
...
@@ -186,7 +186,7 @@ module API
...
@@ -186,7 +186,7 @@ module API
lines
.
each
do
|
line
|
lines
.
each
do
|
line
|
next
unless
line
.
new_pos
==
params
[
:line
]
&&
line
.
type
==
params
[
:line_type
]
next
unless
line
.
new_pos
==
params
[
:line
]
&&
line
.
type
==
params
[
:line_type
]
break
opts
[
:line_code
]
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
diff
.
new_path
,
line
.
new_pos
,
line
.
old_pos
)
break
opts
[
:line_code
]
=
Gitlab
::
Git
.
diff_line_cod
e
(
diff
.
new_path
,
line
.
new_pos
,
line
.
old_pos
)
end
end
break
if
opts
[
:line_code
]
break
if
opts
[
:line_code
]
...
...
lib/api/v3/commits.rb
View file @
9fdde369
...
@@ -173,7 +173,7 @@ module API
...
@@ -173,7 +173,7 @@ module API
lines
.
each
do
|
line
|
lines
.
each
do
|
line
|
next
unless
line
.
new_pos
==
params
[
:line
]
&&
line
.
type
==
params
[
:line_type
]
next
unless
line
.
new_pos
==
params
[
:line
]
&&
line
.
type
==
params
[
:line_type
]
break
opts
[
:line_code
]
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
diff
.
new_path
,
line
.
new_pos
,
line
.
old_pos
)
break
opts
[
:line_code
]
=
Gitlab
::
Git
.
diff_line_cod
e
(
diff
.
new_path
,
line
.
new_pos
,
line
.
old_pos
)
end
end
break
if
opts
[
:line_code
]
break
if
opts
[
:line_code
]
...
...
lib/github/representation/comment.rb
View file @
9fdde369
...
@@ -23,7 +23,7 @@ module Github
...
@@ -23,7 +23,7 @@ module Github
private
private
def
generate_line_code
(
line
)
def
generate_line_code
(
line
)
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
file_path
,
line
.
new_pos
,
line
.
old_pos
)
Gitlab
::
Git
.
diff_line_cod
e
(
file_path
,
line
.
new_pos
,
line
.
old_pos
)
end
end
def
on_diff?
def
on_diff?
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
9fdde369
...
@@ -241,7 +241,7 @@ module Gitlab
...
@@ -241,7 +241,7 @@ module Gitlab
end
end
def
generate_line_code
(
pr_comment
)
def
generate_line_code
(
pr_comment
)
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
pr_comment
.
file_path
,
pr_comment
.
new_pos
,
pr_comment
.
old_pos
)
Gitlab
::
Git
.
diff_line_cod
e
(
pr_comment
.
file_path
,
pr_comment
.
new_pos
,
pr_comment
.
old_pos
)
end
end
def
pull_request_comment_attributes
(
comment
)
def
pull_request_comment_attributes
(
comment
)
...
...
lib/gitlab/conflict/file.rb
View file @
9fdde369
...
@@ -110,7 +110,7 @@ module Gitlab
...
@@ -110,7 +110,7 @@ module Gitlab
end
end
def
line_code
(
line
)
def
line_code
(
line
)
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
our_path
,
line
.
new_pos
,
line
.
old_pos
)
Gitlab
::
Git
.
diff_line_cod
e
(
our_path
,
line
.
new_pos
,
line
.
old_pos
)
end
end
def
create_match_line
(
line
)
def
create_match_line
(
line
)
...
@@ -174,17 +174,6 @@ module Gitlab
...
@@ -174,17 +174,6 @@ module Gitlab
new_path:
our_path
)
new_path:
our_path
)
end
end
# Don't try to print merge_request.
def
inspect
instance_variables
=
[
:content
,
:their_path
,
:our_path
,
:our_mode
,
:type
].
map
do
|
instance_variable
|
value
=
instance_variable_get
(
"@
#{
instance_variable
}
"
)
"
#{
instance_variable
}
=
\"
#{
value
}
\"
"
end
"#<
#{
self
.
class
}
#{
instance_variables
.
join
(
' '
)
}
>"
end
private
private
def
map_raw_lines
(
raw_lines
)
def
map_raw_lines
(
raw_lines
)
...
...
lib/gitlab/diff/file.rb
View file @
9fdde369
...
@@ -49,7 +49,7 @@ module Gitlab
...
@@ -49,7 +49,7 @@ module Gitlab
def
line_code
(
line
)
def
line_code
(
line
)
return
if
line
.
meta?
return
if
line
.
meta?
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
file_path
,
line
.
new_pos
,
line
.
old_pos
)
Gitlab
::
Git
.
diff_line_cod
e
(
file_path
,
line
.
new_pos
,
line
.
old_pos
)
end
end
def
line_for_line_code
(
code
)
def
line_for_line_code
(
code
)
...
...
lib/gitlab/git.rb
View file @
9fdde369
...
@@ -66,6 +66,10 @@ module Gitlab
...
@@ -66,6 +66,10 @@ module Gitlab
end
end
end
end
end
end
def
diff_line_code
(
file_path
,
new_line_position
,
old_line_position
)
"
#{
Digest
::
SHA1
.
hexdigest
(
file_path
)
}
_
#{
old_line_position
}
_
#{
new_line_position
}
"
end
end
end
end
end
end
end
lib/gitlab/git/conflict/file.rb
View file @
9fdde369
...
@@ -46,7 +46,7 @@ module Gitlab
...
@@ -46,7 +46,7 @@ module Gitlab
end
end
def
line_code
(
line
)
def
line_code
(
line
)
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
our_path
,
line
[
:line_new
],
line
[
:line_old
])
Gitlab
::
Git
.
diff_line_cod
e
(
our_path
,
line
[
:line_new
],
line
[
:line_old
])
end
end
def
resolve_lines
(
resolution
)
def
resolve_lines
(
resolution
)
...
...
lib/gitlab/git/conflict/line_code.rb
deleted
100644 → 0
View file @
faa9bd40
module
Gitlab
module
Git
module
Conflict
class
LineCode
def
self
.
generate
(
file_path
,
new_line_position
,
old_line_position
)
"
#{
Digest
::
SHA1
.
hexdigest
(
file_path
)
}
_
#{
old_line_position
}
_
#{
new_line_position
}
"
end
end
end
end
end
lib/gitlab/github_import/comment_formatter.rb
View file @
9fdde369
...
@@ -38,7 +38,7 @@ module Gitlab
...
@@ -38,7 +38,7 @@ module Gitlab
end
end
def
generate_line_code
(
line
)
def
generate_line_code
(
line
)
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
file_path
,
line
.
new_pos
,
line
.
old_pos
)
Gitlab
::
Git
.
diff_line_cod
e
(
file_path
,
line
.
new_pos
,
line
.
old_pos
)
end
end
def
on_diff?
def
on_diff?
...
...
spec/lib/gitlab/diff/position_spec.rb
View file @
9fdde369
...
@@ -40,7 +40,7 @@ describe Gitlab::Diff::Position do
...
@@ -40,7 +40,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
subject
.
new_line
,
0
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
subject
.
new_line
,
0
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -108,7 +108,7 @@ describe Gitlab::Diff::Position do
...
@@ -108,7 +108,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
subject
.
new_line
,
15
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
subject
.
new_line
,
15
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -149,7 +149,7 @@ describe Gitlab::Diff::Position do
...
@@ -149,7 +149,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
subject
.
new_line
,
subject
.
old_line
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
subject
.
new_line
,
subject
.
old_line
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -189,7 +189,7 @@ describe Gitlab::Diff::Position do
...
@@ -189,7 +189,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
13
,
subject
.
old_line
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
13
,
subject
.
old_line
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -233,7 +233,7 @@ describe Gitlab::Diff::Position do
...
@@ -233,7 +233,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
subject
.
new_line
,
5
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
subject
.
new_line
,
5
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -274,7 +274,7 @@ describe Gitlab::Diff::Position do
...
@@ -274,7 +274,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
subject
.
new_line
,
subject
.
old_line
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
subject
.
new_line
,
subject
.
old_line
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -314,7 +314,7 @@ describe Gitlab::Diff::Position do
...
@@ -314,7 +314,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
4
,
subject
.
old_line
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
4
,
subject
.
old_line
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -357,7 +357,7 @@ describe Gitlab::Diff::Position do
...
@@ -357,7 +357,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
0
,
subject
.
old_line
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
0
,
subject
.
old_line
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -399,7 +399,7 @@ describe Gitlab::Diff::Position do
...
@@ -399,7 +399,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
subject
.
new_line
,
0
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
subject
.
new_line
,
0
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
@@ -447,7 +447,7 @@ describe Gitlab::Diff::Position do
...
@@ -447,7 +447,7 @@ describe Gitlab::Diff::Position do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
subject
.
file_path
,
0
,
subject
.
old_line
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
subject
.
file_path
,
0
,
subject
.
old_line
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
expect
(
subject
.
line_code
(
project
.
repository
)).
to
eq
(
line_code
)
end
end
...
...
spec/models/diff_note_spec.rb
View file @
9fdde369
...
@@ -105,7 +105,7 @@ describe DiffNote do
...
@@ -105,7 +105,7 @@ describe DiffNote do
describe
"#line_code"
do
describe
"#line_code"
do
it
"returns the correct line code"
do
it
"returns the correct line code"
do
line_code
=
Gitlab
::
Git
::
Conflict
::
LineCode
.
generat
e
(
position
.
file_path
,
position
.
formatter
.
new_line
,
15
)
line_code
=
Gitlab
::
Git
.
diff_line_cod
e
(
position
.
file_path
,
position
.
formatter
.
new_line
,
15
)
expect
(
subject
.
line_code
).
to
eq
(
line_code
)
expect
(
subject
.
line_code
).
to
eq
(
line_code
)
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