diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-02-17 16:49:16 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-02-18 11:46:05 +0100 |
commit | c475b171114e9bd49b2f1779eb91d392328928d8 (patch) | |
tree | 47294bb19b097ab95229ff3e4bf069c5badb8ab2 /spec | |
parent | 8b918267c7477f7e1a36b4f3cc12c9e244204cb9 (diff) | |
download | gitlab-ce-c475b171114e9bd49b2f1779eb91d392328928d8.tar.gz |
Only set autocrlf when creating/updating files
Setting the "autocrlf" Git option is an overkill since it's rarely
actually needed. More importantly, it has quite the impact on
performance (see gitlab-org/gitlab-ce#13457 for more information).
By setting "autocrlf" when creating or updating files we guarantee the
option is always set properly when we actually need it _without_
introducing overhead for requests that have nothing to do with this
option.
Fixes gitlab-org/gitlab-ce#13457
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 2cd0606a61d..8ff198f572d 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -200,13 +200,22 @@ describe Repository, models: true do describe :commit_with_hooks do context 'when pre hooks were successful' do - it 'should run without errors' do - expect_any_instance_of(GitHooksService).to receive(:execute).and_return(true) + before do + expect_any_instance_of(GitHooksService).to receive(:execute). + and_return(true) + end + it 'should run without errors' do expect do repository.commit_with_hooks(user, 'feature') { sample_commit.id } end.not_to raise_error end + + it 'should ensure the autocrlf Git option is set to :input' do + expect(repository).to receive(:update_autocrlf_option) + + repository.commit_with_hooks(user, 'feature') { sample_commit.id } + end end context 'when pre hooks failed' do @@ -249,6 +258,33 @@ describe Repository, models: true do end end + describe '#update_autocrlf_option' do + describe 'when autocrlf is not already set to :input' do + before do + repository.raw_repository.autocrlf = true + end + + it 'sets autocrlf to :input' do + repository.update_autocrlf_option + + expect(repository.raw_repository.autocrlf).to eq(:input) + end + end + + describe 'when autocrlf is already set to :input' do + before do + repository.raw_repository.autocrlf = :input + end + + it 'does nothing' do + expect(repository.raw_repository).to_not receive(:autocrlf=). + with(:input) + + repository.update_autocrlf_option + end + end + end + describe '#empty?' do let(:empty_repository) { create(:project_empty_repo).repository } |