BigW Consortium Gitlab

Commit f72598b6 by Alejandro Rodríguez

Move Gitlab::Diff::LineCode to module Gitlab::Git

parent 9fda629a
...@@ -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::Diff::LineCode.generate(diff.new_path, line.new_pos, line.old_pos) break opts[:line_code] = Gitlab::Git::DiffLineCode.generate(diff.new_path, line.new_pos, line.old_pos)
end end
break if opts[:line_code] break if opts[:line_code]
......
...@@ -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::Diff::LineCode.generate(diff.new_path, line.new_pos, line.old_pos) break opts[:line_code] = Gitlab::Git::DiffLineCode.generate(diff.new_path, line.new_pos, line.old_pos)
end end
break if opts[:line_code] break if opts[:line_code]
......
...@@ -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::Diff::LineCode.generate(file_path, line.new_pos, line.old_pos) Gitlab::Git::DiffLineCode.generate(file_path, line.new_pos, line.old_pos)
end end
def on_diff? def on_diff?
......
...@@ -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::Diff::LineCode.generate(pr_comment.file_path, pr_comment.new_pos, pr_comment.old_pos) Gitlab::Git::DiffLineCode.generate(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)
......
...@@ -163,7 +163,7 @@ module Gitlab ...@@ -163,7 +163,7 @@ module Gitlab
end end
def line_code(line) def line_code(line)
Gitlab::Diff::LineCode.generate(our_path, line.new_pos, line.old_pos) Gitlab::Git::DiffLineCode.generate(our_path, line.new_pos, line.old_pos)
end end
def create_match_line(line) def create_match_line(line)
......
...@@ -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::Diff::LineCode.generate(file_path, line.new_pos, line.old_pos) Gitlab::Git::DiffLineCode.generate(file_path, line.new_pos, line.old_pos)
end end
def line_for_line_code(code) def line_for_line_code(code)
......
module Gitlab module Gitlab
module Diff module Git
class LineCode class DiffLineCode
def self.generate(file_path, new_line_position, old_line_position) def self.generate(file_path, new_line_position, old_line_position)
"#{Digest::SHA1.hexdigest(file_path)}_#{old_line_position}_#{new_line_position}" "#{Digest::SHA1.hexdigest(file_path)}_#{old_line_position}_#{new_line_position}"
end end
......
...@@ -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::Diff::LineCode.generate(file_path, line.new_pos, line.old_pos) Gitlab::Git::DiffLineCode.generate(file_path, line.new_pos, line.old_pos)
end end
def on_diff? def on_diff?
......
...@@ -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::Diff::LineCode.generate(subject.file_path, subject.new_line, 0) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, subject.new_line, 15) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, subject.new_line, subject.old_line) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, 13, subject.old_line) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, subject.new_line, 5) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, subject.new_line, subject.old_line) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, 4, subject.old_line) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, 0, subject.old_line) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, subject.new_line, 0) line_code = Gitlab::Git::DiffLineCode.generate(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::Diff::LineCode.generate(subject.file_path, 0, subject.old_line) line_code = Gitlab::Git::DiffLineCode.generate(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
......
...@@ -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::Diff::LineCode.generate(position.file_path, position.formatter.new_line, 15) line_code = Gitlab::Git::DiffLineCode.generate(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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment