Skip to content

fix .xcode-version file read when it has whitespaces#423

Merged
KrauseFx merged 1 commit into
xcpretty:masterfrom
rogerluan:strip-xcode-version
Mar 25, 2021
Merged

fix .xcode-version file read when it has whitespaces#423
KrauseFx merged 1 commit into
xcpretty:masterfrom
rogerluan:strip-xcode-version

Conversation

@rogerluan

Copy link
Copy Markdown
Collaborator

Resolves #421

This PR simply trims whitespaces around the file read.

I was misled by these docs https://github.com/fastlane/ci/blob/master/docs/xcode-version.md#file-content that xcode-install would strip whitespaces, but it actually doesn't (yet), and caused that very misleading behavior (which also happens to be extremely hard to debug or notice because visually - on Terminal - it never prints the trailing whitespaces 😬 ).

I tried adding a unit test to cover this case, but honestly I couldn't make it work. This is what I ended up with, in spec/install_spec.rb:

it 'reads .xcode-version and trim whitespaces if needed' do
  Installer.any_instance.expects(:download).with('6.3', true, nil, nil, 3).returns('/some/path')
  Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
  File.expects(:exist?).with('.xcode-version').returns(true)
  File.expects(:read).with('.xcode-version').returns('6.3\n')
  Command::Install.run([])
end

@rogerluan

Copy link
Copy Markdown
Collaborator Author

The CI failure seems to be unrelated (and present in master as well) 🤔

@KrauseFx KrauseFx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@KrauseFx
KrauseFx merged commit a956fc1 into xcpretty:master Mar 25, 2021
@rogerluan
rogerluan deleted the strip-xcode-version branch April 21, 2021 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xcversion install without explicit version (using .xcode-version) fails

2 participants