Skip to content

Fix path normalization deviation in UserCommitFiles Go port

Sami Hiltunen requested to merge smh-user-commit-files-path-normalization into master

The Ruby implementation's path normalization accepts double slashes in the path as is. This later causes Rugged to error out when attempting to add a file with such an invalid path to the index.

The Go port is cleaning the filepaths, which replaces double slashes with single slashes. This makes the filepath valid and thus adding the file to the index didn't error out.

This commit a special cases double slashes to workaround this quirk.

Related to #3254 (closed)

Fixes following failing specs:

rspec unit pg11 12/20

Failures:


Snippets::CreateService#execute when ProjectSnippet behaves like creates repository and files when repository creation fails with invalid file name returns an appropriate error
Failure/Error: expect(snippet.errors[:repository]).to eq ['Error creating the snippet - Invalid file name']
expected: ["Error creating the snippet - Invalid file name"]
got: []
(compared using ==)
Shared Example Group: "creates repository and files" called from ./spec/services/snippets/create_service_spec.rb:315
./spec/services/snippets/create_service_spec.rb:145:in `block (5 levels) in <top (required)>'
./spec/spec_helper.rb:354:in `block (3 levels) in <top (required)>'
./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
./spec/spec_helper.rb:345:in `block (2 levels) in <top (required)>'
./spec/spec_helper.rb:341:in `block (3 levels) in <top (required)>'
./spec/spec_helper.rb:341:in `block (2 levels) in <top (required)>'


Snippets::CreateService#execute when PersonalSnippet behaves like creates repository and files when repository creation fails with invalid file name returns an appropriate error
Failure/Error: expect(snippet.errors[:repository]).to eq ['Error creating the snippet - Invalid file name']
expected: ["Error creating the snippet - Invalid file name"]
got: []
(compared using ==)
Shared Example Group: "creates repository and files" called from ./spec/services/snippets/create_service_spec.rb:343
./spec/services/snippets/create_service_spec.rb:145:in `block (5 levels) in <top (required)>'
./spec/spec_helper.rb:354:in `block (3 levels) in <top (required)>'
./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
./spec/spec_helper.rb:345:in `block (2 levels) in <top (required)>'
./spec/spec_helper.rb:341:in `block (3 levels) in <top (required)>'
./spec/spec_helper.rb:341:in `block (2 levels) in <top (required)>'


Finished in 15 minutes 47 seconds (files took 57.65 seconds to load)
4111 examples, 2 failures
Failed examples:
rspec './spec/services/snippets/create_service_spec.rb[1:1:1:6:4:1]' # Snippets::CreateService#execute when ProjectSnippet behaves like creates repository and files when repository creation fails with invalid file name returns an appropriate error
rspec './spec/services/snippets/create_service_spec.rb[1:1:2:6:4:1]' # Snippets::CreateService#execute when PersonalSnippet behaves like creates repository and files when repository creation fails with invalid file name returns an appropriate error
Edited by Sami Hiltunen

Merge request reports