From 345aabcaff934b65c14857ae1c3363b12c29dda9 Mon Sep 17 00:00:00 2001 From: jakecoffman Date: Mon, 28 Nov 2022 15:25:36 -0600 Subject: [PATCH 1/2] submodule cloning may not be important to the job, ignore errors --- common/lib/dependabot/file_fetchers/base.rb | 9 ++++++--- common/spec/dependabot/file_fetchers/base_spec.rb | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/lib/dependabot/file_fetchers/base.rb b/common/lib/dependabot/file_fetchers/base.rb index 561f4aee62f..ff4776f951f 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_ERROR_REGEX1 = /^fatal: unable to access '(?.*)': The requested URL returned error: (?\d+)$/ + GIT_SUBMODULE_ERROR_REGEX2 = + /^fatal: clone of '(?.*)' into submodule path '.*' failed$/ + GIT_SUBMODULE_ERROR_REGEX = /(#{GIT_SUBMODULE_ERROR_REGEX1})|(#{GIT_SUBMODULE_ERROR_REGEX2})/ 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 From 25442e44fa3634fbcbc5369b7bf52135564d5cc1 Mon Sep 17 00:00:00 2001 From: jakecoffman Date: Tue, 29 Nov 2022 08:09:58 -0600 Subject: [PATCH 2/2] improve names --- common/lib/dependabot/file_fetchers/base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/lib/dependabot/file_fetchers/base.rb b/common/lib/dependabot/file_fetchers/base.rb index ff4776f951f..32a6ca12413 100644 --- a/common/lib/dependabot/file_fetchers/base.rb +++ b/common/lib/dependabot/file_fetchers/base.rb @@ -26,11 +26,11 @@ class Base Dependabot::Clients::CodeCommit::NotFound ].freeze - GIT_SUBMODULE_ERROR_REGEX1 = + GIT_SUBMODULE_INACCESSIBLE_ERROR = /^fatal: unable to access '(?.*)': The requested URL returned error: (?\d+)$/ - GIT_SUBMODULE_ERROR_REGEX2 = + GIT_SUBMODULE_CLONE_ERROR = /^fatal: clone of '(?.*)' into submodule path '.*' failed$/ - GIT_SUBMODULE_ERROR_REGEX = /(#{GIT_SUBMODULE_ERROR_REGEX1})|(#{GIT_SUBMODULE_ERROR_REGEX2})/ + GIT_SUBMODULE_ERROR_REGEX = /(#{GIT_SUBMODULE_INACCESSIBLE_ERROR})|(#{GIT_SUBMODULE_CLONE_ERROR})/ def self.required_files_in?(_filename_array) raise NotImplementedError