-
Notifications
You must be signed in to change notification settings - Fork 33
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
u3d/install: do not reinstall already installed packages #202
Conversation
This is still [WIP] because:
|
lib/u3d/installation.rb
Outdated
end | ||
pack << 'Documentation' if specific_dir?("#{root_path}/Editor/Data/Documentation/", check_empty: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could have a method under each PlatformInstallation called
def module_files_pattern(module_name)
return "#{root_path}/Editor/Data/Documentation/*" if module_name == "Documentation"
return ....
end
or something similar
and then do a
['Documentation', 'StandardAssets', 'MonoDevelop'].each do |module_name|
patern = module_files_pattern(module_name)
pack << module_name if Dir.glob(pattern).count > 0
end
better idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I installed 2017.3.0f3 on the first slave with all sub-modules, in case you need to find the paths.
lib/u3d/commands.rb
Outdated
UI.important "Ignoring #{pack} module, it is already installed" if packages.delete(pack) | ||
installed_packages = unity.packages | ||
packages.each do |pack| | ||
if installed_packages.include?(pack) || installed_packages.any? { |installed| !package_aliases[pack].nil? && package_aliases[pack].include?(installed) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to move this whole logic into a method "package_installed?" or similar.
lib/u3d/commands.rb
Outdated
installed_packages = unity.packages | ||
packages.each do |pack| | ||
if installed_packages.include?(pack) || installed_packages.any? { |installed| !package_aliases[pack].nil? && package_aliases[pack].include?(installed) } | ||
UI.important "Ignoring #{pack} module, it is already installed" if packages.delete(pack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the if need to go away?
packages.delete(pack)
UI.important "Ignoring #{pack} module, it is already installed"
Implemented modifications and the Mac part. |
lib/u3d/commands.rb
Outdated
result | ||
end | ||
|
||
def package_installed?(package, installed_packages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be better to move this to unity? I don't think command should have too much logic anyway.
E.g. if unity.package_installed?
existed, it would be less code here.
lib/u3d/installation.rb
Outdated
when 'MonoDevelop' | ||
return "#{root_path}/MonoDevelop.app/" | ||
else | ||
return '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail here instead of silent return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also give a good name to this PR. And make it so that it's description explicitly mark the proper issues as closed.
lib/u3d/installation.rb
Outdated
when 'MonoDevelop' | ||
return "#{root_path}/MonoDevelop.app/" | ||
else | ||
UI.user_error! "No pattern is known for #{module_name} on Mac" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe crash!
instead?
spec/support/installations.rb
Outdated
@@ -95,5 +95,6 @@ def fake_installation(version, packages: []) | |||
allow(unity).to receive(:version) { version } | |||
allow(unity).to receive(:root_path) { 'foo' } | |||
allow(unity).to receive(:packages) { packages } | |||
unity.stub(:package_installed?) { |arg| packages.include?(arg) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe keep using allow
instead of the somewhat deprecated stub
?
https://relishapp.com/rspec/rspec-mocks/v/2-14/docs/method-stubs/stub-with-substitute-implementation
lib/u3d/installation.rb
Outdated
PlaybackEngineUtils.list_module_configs(root_path).each do |mpath| | ||
pack << PlaybackEngineUtils.module_name(mpath) | ||
end | ||
%w[Documentation StandardAssets MonoDevelop].each do |module_name| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move that to a module or Installation class constant. Maybe something like SPECIAL_PACKAGES? Better name idea?
lib/u3d/installation.rb
Outdated
end | ||
|
||
def package_installed?(package) | ||
return false unless packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can replace the two lines with
return true if (packages || []).include?(package)
and maybe change the default packages
implementation to return a []
instead of false?
lib/u3d/installation.rb
Outdated
return true if packages.include?(package) | ||
|
||
aliases = Installation.package_aliases[package] | ||
return false if aliases[package].nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think aliases[package]
can get nil. You meant empty right?
In which case, we may just skip the line entirely as it is covered by the next one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it can when the package is not known ie aliases['NewPackage'] = nil
. It makes it so that we don't crash when some package is not known, which would make u3d unusable for versions with unknown packages. So this line is mandatory imo.
lib/u3d/installation.rb
Outdated
@@ -44,6 +46,37 @@ def self.create(root_path: nil, path: nil) | |||
WindowsInstallation.new(root_path: root_path, path: path) | |||
end | |||
end | |||
|
|||
def self.package_aliases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be cached as well into a PACKAGE_ALIASES
and documented.
We should add some tests to the |
Fixes #198
This solve the issues of non-matching package name between installed and available by: