-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: adding a project to a workspace is broken on 0.17.0 #155
Conversation
Method “<<“ was missing a conversion from string path to FileReference
Looks good, can you add a test and an entry to the Changelog? |
@irrationalfab Sure, I'm working on it. But which version of rspec should I use? I'm using rspec 2.14.8 but I'm getting some misbehavior in workspace_spec.rb. Moreover, in Gemfile there aren't references to rspec. |
Xcodeproj uses bacon, see the |
Ok thank you and sorry for the stupid question. Can you check if change log is ok? |
Looks good to me, usually to prevent merge conflicts we use the |
Ok, done! thank you for your support ;) |
Ace! |
Fix: adding a project to a workspace is broken on 0.17.0
Thank you for the patch 🍻 |
@irrationalfab I have just found out that this bug causes a bigger problem: if you add a project with the bugged << and then try to save the workspace, the workspace file gets totally empty. Maybe it should be better to add a validation before the actual write to disk |
The best way would be to add validation and coercion to the method: def <<(proj)
proj = proj.path if proj.is_a?(Project)
unless proj.is_a?(String)
raise ArgumentError, "The proj `#{}` parameter must be either a string or a project"
end
# ...
end (untested code) |
Yes, this is ok, but what if other parts of code (not the << method) create a corrupt version of the workspace without errors? When workspace gets saved, exceptions get thrown and the saved workspace file is cleared. I think there should be some kind of checks there too |
I think that it would be simpler to guard the methods that edit the workspace, like done in the above example. |
Since version 0.17.0, workspace.rb uses new FileReference system instead of string paths (#150), but there was a bug when executing “<<“ method:
Method “<<“ was missing a conversion from the input string path to a FileReference instance.