diff --git a/common/lib/dependabot/file_fetchers/base.rb b/common/lib/dependabot/file_fetchers/base.rb index 561f4aee62f..32a6ca12413 100644 --- a/common/lib/dependabot/file_fetchers/base.rb +++ b/common/lib/dependabot/file_fetchers/base.rb @@ -26,8 +26,11 @@ class Base Dependabot::Clients::CodeCommit::NotFound ].freeze - GIT_SUBMODULE_ERROR_REGEX = + GIT_SUBMODULE_INACCESSIBLE_ERROR = /^fatal: unable to access '(?.*)': The requested URL returned error: (?\d+)$/ + GIT_SUBMODULE_CLONE_ERROR = + /^fatal: clone of '(?.*)' into submodule path '.*' failed$/ + GIT_SUBMODULE_ERROR_REGEX = /(#{GIT_SUBMODULE_INACCESSIBLE_ERROR})|(#{GIT_SUBMODULE_CLONE_ERROR})/ def self.required_files_in?(_filename_array) raise NotImplementedError @@ -604,7 +607,7 @@ def _clone_repo_contents(target_directory:) CMD ) rescue SharedHelpers::HelperSubprocessFailed => e - raise unless e.message.match?(GIT_SUBMODULE_ERROR_REGEX) && e.message.include?("submodule") + raise unless GIT_SUBMODULE_ERROR_REGEX && e.message.downcase.include?("submodule") submodule_cloning_failed = true match = e.message.match(GIT_SUBMODULE_ERROR_REGEX) @@ -613,7 +616,7 @@ def _clone_repo_contents(target_directory:) # Submodules might be in the repo but unrelated to dependencies, # so ignoring this error to try the update anyway since the base repo exists. - Dependabot.logger.error("Cloning of submodule failed: #{url} error: #{code}") + Dependabot.logger.error("Cloning of submodule failed: #{url} error: #{code || 'unknown'}") end if source.commit diff --git a/common/spec/dependabot/file_fetchers/base_spec.rb b/common/spec/dependabot/file_fetchers/base_spec.rb index 659fd5ced29..b992833517a 100644 --- a/common/spec/dependabot/file_fetchers/base_spec.rb +++ b/common/spec/dependabot/file_fetchers/base_spec.rb @@ -1569,6 +1569,9 @@ def fetch_files let(:repo) do "dependabot-fixtures/go-modules-app-with-inaccessible-submodules" end + let(:branch) do + "with-git-urls" + end it "does not raise an error" do clone_repo_contents