Fix conflict highlighting

Conflicts used to take a `Repository` and pass that to
`Gitlab::Highlight.highlight`, which would call `#gitattribute` on the
repository. Now they use a `Gitlab::Git::Repository`, which didn't have that
method defined - but defining it on `Gitlab::Git::Repository` does make it
available on `Repository` through `method_missing`, so we can do that and both
cases will work.
This commit is contained in:
Sean McGivern 2017-11-17 17:57:48 +00:00
parent 371180a47d
commit 64a9e53bd1
3 changed files with 11 additions and 4 deletions

View file

@ -994,10 +994,6 @@ class Repository
raw_repository.ls_files(actual_ref)
end
def gitattribute(path, name)
raw_repository.attributes(path)[name]
end
def copy_gitattributes(ref)
actual_ref = ref || root_ref
begin

View file

@ -984,6 +984,10 @@ module Gitlab
@attributes.attributes(path)
end
def gitattribute(path, name)
attributes(path)[name]
end
def languages(ref = nil)
Gitlab::GitalyClient.migrate(:commit_languages) do |is_enabled|
if is_enabled

View file

@ -84,6 +84,13 @@ describe Gitlab::Conflict::File do
expect(line.text).to eq(html_to_text(line.rich_text))
end
end
# This spec will break if Rouge's highlighting changes, but we need to
# ensure that the lines are actually highlighted.
it 'highlights the lines correctly' do
expect(conflict_file.lines.first.rich_text)
.to eq("<span id=\"LC1\" class=\"line\" lang=\"ruby\"><span class=\"k\">module</span> <span class=\"nn\">Gitlab</span></span>\n")
end
end
describe '#sections' do