diff --git a/Gemfile.lock b/Gemfile.lock index d1ae43c..05be824 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: foobara - revision: 9d258143cf0a58a3bd7a63c89443dff0fc45ef14 + revision: 76232e8f44a65cc6267fc43f82cdd1ccfe6f7f67 branch: main specs: foobara (0.0.1) @@ -38,7 +38,7 @@ GIT GIT remote: https://github.com/foobara/foob.git - revision: f54b66cfe5ab557d556e56b846e3ed079eca9f79 + revision: 32e226216f04c02c285add2869774b1d40203c86 specs: foobara-foob (0.0.1) @@ -58,7 +58,7 @@ GIT GIT remote: https://github.com/foobara/sh-cli-connector.git - revision: caf838a83c38501ca8d6e1181f103c2bbabd3fd3 + revision: b08ff244e38ea10e01d36d07adb48937fe1998ca specs: foobara-sh-cli-connector (0.1.0) @@ -93,7 +93,7 @@ GEM rexml diff-lcs (1.5.1) docile (1.4.0) - dotenv (3.1.0) + dotenv (3.1.1) ffi (1.16.3) formatador (1.1.0) guard (2.18.1) @@ -157,7 +157,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - rubocop (1.63.3) + rubocop (1.63.4) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -168,8 +168,8 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.2) - parser (>= 3.3.0.4) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) rubocop-capybara (2.20.0) rubocop (~> 1.41) rubocop-factory_bot (2.25.1) diff --git a/spec/foobara/remote_imports/import_command_spec.rb b/spec/foobara/remote_imports/import_command_spec.rb index e17acf7..2013c62 100644 --- a/spec/foobara/remote_imports/import_command_spec.rb +++ b/spec/foobara/remote_imports/import_command_spec.rb @@ -52,6 +52,19 @@ expect(SomeOrg::Math).to be_foobara_domain end + context "when using a partial match" do + let(:to_import) { "CreateNestedNoCollisions" } + + it "creates the command" do + expect(outcome).to be_success + + expect(result.size).to eq(1) + command = result.first + expect(command).to be < Foobara::Command + expect(command).to eq(NestedModelsNoCollisions::CreateNestedNoCollisions) + end + end + context "when creating all commands" do let(:inputs) do { diff --git a/src/foobara/remote_imports/import_base.rb b/src/foobara/remote_imports/import_base.rb index 81711b8..1e26f4f 100644 --- a/src/foobara/remote_imports/import_base.rb +++ b/src/foobara/remote_imports/import_base.rb @@ -113,9 +113,27 @@ def load_manifest_from_url def filter_manifests_to_import return if to_import.nil? || to_import.empty? + references = manifests_to_import.map(&:reference) + filter = Util.array(to_import) - not_found = filter - manifests_to_import.map(&:reference) + filter.map! do |name| + if references.include?(name) + name + else + suffix = "::#{name}" + + partial_matches = references.select { |reference| reference.end_with?(suffix) } + + if partial_matches.size == 1 + partial_matches.first + else + name + end + end + end + + not_found = filter - references if not_found.any? add_input_error :to_import, :not_found, "Could not find #{not_found}", not_found: