From ddd1323c0013b700c01d4a7a2b3b37a8664e6d4a Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Thu, 7 Nov 2019 15:43:45 -0500 Subject: [PATCH 1/2] Optionally symlink a plugin's spec/manageiq Add the option to symlink a plugin's spec/manageiq instead of a shallow clone, allowing for local repositories to be linked together to test groups of changes. --- lib/generators/manageiq/plugin/templates/bin/setup | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/generators/manageiq/plugin/templates/bin/setup b/lib/generators/manageiq/plugin/templates/bin/setup index b3837b0559f..3b186e6d489 100755 --- a/lib/generators/manageiq/plugin/templates/bin/setup +++ b/lib/generators/manageiq/plugin/templates/bin/setup @@ -2,8 +2,14 @@ require 'pathname' gem_root = Pathname.new(__dir__).join("..") +spec_manageiq = gem_root.join("spec/manageiq") -unless gem_root.join("spec/manageiq").exist? +if ENV.key?("MANAGEIQ_REPO") + puts "== Symlinking spec/manageiq to #{ENV["MANAGEIQ_REPO"]}" + + spec_manageiq.rmtree if spec_manageiq.exist? + system "ln -s #{ENV["MANAGEIQ_REPO"]} spec/manageiq" +elsif !spec_manageiq.exist? puts "== Cloning manageiq sample app ==" system "git clone https://github.com/ManageIQ/manageiq.git --branch master --depth 1 spec/manageiq" end From e21c51fce09223c60e1772ee2da317faa3fc0e67 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Thu, 7 Nov 2019 19:16:02 -0500 Subject: [PATCH 2/2] Use fully-qualified paths when symlinking --- lib/generators/manageiq/plugin/templates/bin/setup | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/generators/manageiq/plugin/templates/bin/setup b/lib/generators/manageiq/plugin/templates/bin/setup index 3b186e6d489..7d8ae6b3cbb 100755 --- a/lib/generators/manageiq/plugin/templates/bin/setup +++ b/lib/generators/manageiq/plugin/templates/bin/setup @@ -1,14 +1,16 @@ #!/usr/bin/env ruby require 'pathname' +require 'fileutils' gem_root = Pathname.new(__dir__).join("..") spec_manageiq = gem_root.join("spec/manageiq") if ENV.key?("MANAGEIQ_REPO") - puts "== Symlinking spec/manageiq to #{ENV["MANAGEIQ_REPO"]}" + manageiq_repo = Pathname.new(ENV["MANAGEIQ_REPO"]) + puts "== Symlinking spec/manageiq to #{manageiq_repo}" - spec_manageiq.rmtree if spec_manageiq.exist? - system "ln -s #{ENV["MANAGEIQ_REPO"]} spec/manageiq" + FileUtils.rm_rf(spec_manageiq.expand_path) + FileUtils.ln_s(manageiq_repo.expand_path, spec_manageiq.expand_path) elsif !spec_manageiq.exist? puts "== Cloning manageiq sample app ==" system "git clone https://github.com/ManageIQ/manageiq.git --branch master --depth 1 spec/manageiq"