Skip to content
Snippets Groups Projects
Commit faa9bd40 authored by Alejandro Rodríguez's avatar Alejandro Rodríguez
Browse files

Create a Gitlab::Git submodule for conlict-related files

Rename classes to (hopefully) clearer names while we're doing that.
parent 3fcab51e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -40,7 +40,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, subject.new_line, 0)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, subject.new_line, 0)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -108,7 +108,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, subject.new_line, 15)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, subject.new_line, 15)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -149,7 +149,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, subject.new_line, subject.old_line)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, subject.new_line, subject.old_line)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -189,7 +189,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, 13, subject.old_line)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, 13, subject.old_line)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -233,7 +233,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, subject.new_line, 5)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, subject.new_line, 5)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -274,7 +274,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, subject.new_line, subject.old_line)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, subject.new_line, subject.old_line)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -314,7 +314,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, 4, subject.old_line)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, 4, subject.old_line)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -357,7 +357,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, 0, subject.old_line)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, 0, subject.old_line)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -399,7 +399,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, subject.new_line, 0)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, subject.new_line, 0)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
@@ -447,7 +447,7 @@ describe Gitlab::Diff::Position do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(subject.file_path, 0, subject.old_line)
line_code = Gitlab::Git::Conflict::LineCode.generate(subject.file_path, 0, subject.old_line)
 
expect(subject.line_code(project.repository)).to eq(line_code)
end
Loading
Loading
require 'spec_helper'
 
describe Gitlab::Git::ConflictParser do
describe Gitlab::Git::Conflict::Parser do
describe '.parse' do
def parse_text(text)
described_class.parse(text, our_path: 'README.md', their_path: 'README.md')
Loading
Loading
@@ -125,12 +125,12 @@ CONFLICT
context 'when there is a non-start delimiter first' do
it 'raises UnexpectedDelimiter when there is a middle delimiter first' do
expect { parse_text('=======') }
.to raise_error(Gitlab::Git::ConflictParser::UnexpectedDelimiter)
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
 
it 'raises UnexpectedDelimiter when there is an end delimiter first' do
expect { parse_text('>>>>>>> README.md') }
.to raise_error(Gitlab::Git::ConflictParser::UnexpectedDelimiter)
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
 
it 'does not raise when there is an end delimiter for a different path first' do
Loading
Loading
@@ -145,12 +145,12 @@ CONFLICT
 
it 'raises UnexpectedDelimiter when it is followed by an end delimiter' do
expect { parse_text(start_text + '>>>>>>> README.md' + end_text) }
.to raise_error(Gitlab::Git::ConflictParser::UnexpectedDelimiter)
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
 
it 'raises UnexpectedDelimiter when it is followed by another start delimiter' do
expect { parse_text(start_text + start_text + end_text) }
.to raise_error(Gitlab::Git::ConflictParser::UnexpectedDelimiter)
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
 
it 'does not raise when it is followed by a start delimiter for a different path' do
Loading
Loading
@@ -165,12 +165,12 @@ CONFLICT
 
it 'raises UnexpectedDelimiter when it is followed by another middle delimiter' do
expect { parse_text(start_text + '=======' + end_text) }
.to raise_error(Gitlab::Git::ConflictParser::UnexpectedDelimiter)
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
 
it 'raises UnexpectedDelimiter when it is followed by a start delimiter' do
expect { parse_text(start_text + start_text + end_text) }
.to raise_error(Gitlab::Git::ConflictParser::UnexpectedDelimiter)
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
 
it 'does not raise when it is followed by a start delimiter for another path' do
Loading
Loading
@@ -183,25 +183,25 @@ CONFLICT
start_text = "<<<<<<< README.md\n=======\n"
 
expect { parse_text(start_text) }
.to raise_error(Gitlab::Git::ConflictParser::MissingEndDelimiter)
.to raise_error(Gitlab::Git::Conflict::Parser::MissingEndDelimiter)
 
expect { parse_text(start_text + '>>>>>>> some-other-path.md') }
.to raise_error(Gitlab::Git::ConflictParser::MissingEndDelimiter)
.to raise_error(Gitlab::Git::Conflict::Parser::MissingEndDelimiter)
end
end
 
context 'other file types' do
it 'raises UnmergeableFile when lines is blank, indicating a binary file' do
expect { parse_text('') }
.to raise_error(Gitlab::Git::ConflictParser::UnmergeableFile)
.to raise_error(Gitlab::Git::Conflict::Parser::UnmergeableFile)
 
expect { parse_text(nil) }
.to raise_error(Gitlab::Git::ConflictParser::UnmergeableFile)
.to raise_error(Gitlab::Git::Conflict::Parser::UnmergeableFile)
end
 
it 'raises UnmergeableFile when the file is over 200 KB' do
expect { parse_text('a' * 204801) }
.to raise_error(Gitlab::Git::ConflictParser::UnmergeableFile)
.to raise_error(Gitlab::Git::Conflict::Parser::UnmergeableFile)
end
 
# All text from Rugged has an encoding of ASCII_8BIT, so force that in
Loading
Loading
@@ -216,7 +216,7 @@ CONFLICT
context 'when the file contains non-UTF-8 characters' do
it 'raises UnsupportedEncoding' do
expect { parse_text("a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) }
.to raise_error(Gitlab::Git::ConflictParser::UnsupportedEncoding)
.to raise_error(Gitlab::Git::Conflict::Parser::UnsupportedEncoding)
end
end
end
Loading
Loading
Loading
Loading
@@ -105,7 +105,7 @@ describe DiffNote do
 
describe "#line_code" do
it "returns the correct line code" do
line_code = Gitlab::Git::DiffLineCode.generate(position.file_path, position.formatter.new_line, 15)
line_code = Gitlab::Git::Conflict::LineCode.generate(position.file_path, position.formatter.new_line, 15)
 
expect(subject.line_code).to eq(line_code)
end
Loading
Loading
Loading
Loading
@@ -204,16 +204,16 @@ describe MergeRequests::Conflicts::ResolveService do
 
it 'raises a ResolutionError error' do
expect { service.execute(user, invalid_params) }
.to raise_error(Gitlab::Git::Merge::ResolutionError)
.to raise_error(Gitlab::Git::Conflict::Resolver::ResolutionError)
end
end
 
context 'when the content of a file is unchanged' do
let(:merge) do
MergeRequests::Conflicts::ListService.new(merge_request).conflicts.merge
let(:resolver) do
MergeRequests::Conflicts::ListService.new(merge_request).conflicts.resolver
end
let(:regex_conflict) do
merge.conflict_for_path('files/ruby/regex.rb', 'files/ruby/regex.rb')
resolver.conflict_for_path('files/ruby/regex.rb', 'files/ruby/regex.rb')
end
 
let(:invalid_params) do
Loading
Loading
@@ -235,7 +235,7 @@ describe MergeRequests::Conflicts::ResolveService do
 
it 'raises a ResolutionError error' do
expect { service.execute(user, invalid_params) }
.to raise_error(Gitlab::Git::Merge::ResolutionError)
.to raise_error(Gitlab::Git::Conflict::Resolver::ResolutionError)
end
end
 
Loading
Loading
@@ -255,7 +255,7 @@ describe MergeRequests::Conflicts::ResolveService do
 
it 'raises a ResolutionError error' do
expect { service.execute(user, invalid_params) }
.to raise_error(Gitlab::Git::Merge::ResolutionError)
.to raise_error(Gitlab::Git::Conflict::Resolver::ResolutionError)
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment