Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions common/lib/dependabot/file_fetchers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ class Base
Dependabot::Clients::CodeCommit::NotFound
].freeze

GIT_SUBMODULE_ERROR_REGEX =
GIT_SUBMODULE_INACCESSIBLE_ERROR =
/^fatal: unable to access '(?<url>.*)': The requested URL returned error: (?<code>\d+)$/
GIT_SUBMODULE_CLONE_ERROR =
/^fatal: clone of '(?<url>.*)' 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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions common/spec/dependabot/file_fetchers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down