Skip to content

Commit

Permalink
Merge branch 'main' into harry/removing-corepack-from-else-clause
Browse files Browse the repository at this point in the history
  • Loading branch information
thavaahariharangit authored Jan 16, 2025
2 parents 3bf31a0 + e0c8d70 commit 284d938
Show file tree
Hide file tree
Showing 54 changed files with 682 additions and 452 deletions.
84 changes: 42 additions & 42 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
PATH
remote: bundler
specs:
dependabot-bundler (0.292.0)
dependabot-common (= 0.292.0)
dependabot-bundler (0.293.0)
dependabot-common (= 0.293.0)
parallel (~> 1.24)

PATH
remote: cargo
specs:
dependabot-cargo (0.292.0)
dependabot-common (= 0.292.0)
dependabot-cargo (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: common
specs:
dependabot-common (0.292.0)
dependabot-common (0.293.0)
aws-sdk-codecommit (~> 1.28)
aws-sdk-ecr (~> 1.5)
bundler (>= 1.16, < 3.0.0)
Expand All @@ -38,113 +38,113 @@ PATH
PATH
remote: composer
specs:
dependabot-composer (0.292.0)
dependabot-common (= 0.292.0)
dependabot-composer (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: devcontainers
specs:
dependabot-devcontainers (0.292.0)
dependabot-common (= 0.292.0)
dependabot-devcontainers (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: docker
specs:
dependabot-docker (0.292.0)
dependabot-common (= 0.292.0)
dependabot-docker (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: dotnet_sdk
specs:
dependabot-dotnet_sdk (0.292.0)
dependabot-common (= 0.292.0)
dependabot-dotnet_sdk (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: elm
specs:
dependabot-elm (0.292.0)
dependabot-common (= 0.292.0)
dependabot-elm (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: git_submodules
specs:
dependabot-git_submodules (0.292.0)
dependabot-common (= 0.292.0)
dependabot-git_submodules (0.293.0)
dependabot-common (= 0.293.0)
parseconfig (~> 1.0, < 1.1.0)

PATH
remote: github_actions
specs:
dependabot-github_actions (0.292.0)
dependabot-common (= 0.292.0)
dependabot-github_actions (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: go_modules
specs:
dependabot-go_modules (0.292.0)
dependabot-common (= 0.292.0)
dependabot-go_modules (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: gradle
specs:
dependabot-gradle (0.292.0)
dependabot-common (= 0.292.0)
dependabot-maven (= 0.292.0)
dependabot-gradle (0.293.0)
dependabot-common (= 0.293.0)
dependabot-maven (= 0.293.0)

PATH
remote: hex
specs:
dependabot-hex (0.292.0)
dependabot-common (= 0.292.0)
dependabot-hex (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: maven
specs:
dependabot-maven (0.292.0)
dependabot-common (= 0.292.0)
dependabot-maven (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: npm_and_yarn
specs:
dependabot-npm_and_yarn (0.292.0)
dependabot-common (= 0.292.0)
dependabot-npm_and_yarn (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: nuget
specs:
dependabot-nuget (0.292.0)
dependabot-common (= 0.292.0)
dependabot-nuget (0.293.0)
dependabot-common (= 0.293.0)
rubyzip (>= 2.3.2, < 3.0)

PATH
remote: pub
specs:
dependabot-pub (0.292.0)
dependabot-common (= 0.292.0)
dependabot-pub (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: python
specs:
dependabot-python (0.292.0)
dependabot-common (= 0.292.0)
dependabot-python (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: silent
specs:
dependabot-silent (0.292.0)
dependabot-common (= 0.292.0)
dependabot-silent (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: swift
specs:
dependabot-swift (0.292.0)
dependabot-common (= 0.292.0)
dependabot-swift (0.293.0)
dependabot-common (= 0.293.0)

PATH
remote: terraform
specs:
dependabot-terraform (0.292.0)
dependabot-common (= 0.292.0)
dependabot-terraform (0.293.0)
dependabot-common (= 0.293.0)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion common/lib/dependabot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# frozen_string_literal: true

module Dependabot
VERSION = "0.292.0"
VERSION = "0.293.0"
end
10 changes: 10 additions & 0 deletions common/lib/dependabot/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def self.parser_error_details(error)

# rubocop:disable Lint/RedundantCopDisableDirective
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/AbcSize
sig { params(error: StandardError).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def self.updater_error_details(error)
case error
Expand All @@ -179,6 +180,14 @@ def self.updater_error_details(error)
"error-type": "dependency_file_not_evaluatable",
"error-detail": { message: error.message }
}
when Dependabot::DependencyFileNotParseable
{
"error-type": "dependency_file_not_parseable",
"error-detail": {
message: error.message,
"file-path": error.file_path
}
}
when Dependabot::GitDependenciesNotReachable
{
"error-type": "git_dependencies_not_reachable",
Expand Down Expand Up @@ -294,6 +303,7 @@ def self.updater_error_details(error)
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Lint/RedundantCopDisableDirective
# rubocop:enable Metrics/AbcSize

class DependabotError < StandardError
extend T::Sig
Expand Down
7 changes: 1 addition & 6 deletions common/lib/dependabot/workspace/change_attempt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ module Workspace
class ChangeAttempt
extend T::Sig

sig { returns(T.nilable(String)) }
attr_reader :diff

sig { returns(T.nilable(StandardError)) }
attr_reader :error

Expand All @@ -28,15 +25,13 @@ class ChangeAttempt
workspace: Dependabot::Workspace::Base,
id: String,
memo: T.nilable(String),
diff: T.nilable(String),
error: T.nilable(StandardError)
).void
end
def initialize(workspace, id:, memo:, diff: nil, error: nil)
def initialize(workspace, id:, memo:, error: nil)
@workspace = workspace
@id = id
@memo = memo
@diff = diff
@error = error
end

Expand Down
23 changes: 8 additions & 15 deletions common/lib/dependabot/workspace/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def store_change(memo = nil)
return nil if changed_files(ignored_mode: "no").empty?

debug("store_change - before: #{current_commit}")
sha, diff = commit(memo)
sha = commit(memo)

change_attempts << ChangeAttempt.new(self, id: sha, memo: memo, diff: diff)
change_attempts << ChangeAttempt.new(self, id: sha, memo: memo)
ensure
debug("store_change - after: #{current_commit}")
end
Expand All @@ -73,8 +73,8 @@ def store_change(memo = nil)
def capture_failed_change_attempt(memo = nil, error = nil)
return nil if changed_files(ignored_mode: "matching").empty? && error.nil?

sha, diff = stash(memo)
change_attempts << ChangeAttempt.new(self, id: sha, memo: memo, diff: diff, error: error)
sha = stash(memo)
change_attempts << ChangeAttempt.new(self, id: sha, memo: memo, error: error)
end

private
Expand Down Expand Up @@ -112,7 +112,7 @@ def changed_files(ignored_mode: "traditional")
).strip
end

sig { params(memo: T.nilable(String)).returns([String, String]) }
sig { params(memo: T.nilable(String)).returns(String) }
def stash(memo = nil)
msg = memo || "workspace change attempt"
run_shell_command("git add --all --force .")
Expand All @@ -122,19 +122,12 @@ def stash(memo = nil)
allow_unsafe_shell_command: true
)

sha = last_stash_sha
diff = run_shell_command(
"git stash show --patch #{sha}",
fingerprint: "git stash show --patch <sha>"
)

[sha, diff]
last_stash_sha
end

sig { params(memo: T.nilable(String)).returns([String, String]) }
sig { params(memo: T.nilable(String)).returns(String) }
def commit(memo = nil)
run_shell_command("git add #{path}")
diff = run_shell_command("git diff --cached .")

msg = memo || "workspace change"
run_shell_command(
Expand All @@ -143,7 +136,7 @@ def commit(memo = nil)
allow_unsafe_shell_command: true
)

[head_sha, diff]
head_sha
end

sig { params(sha: String).returns(String) }
Expand Down
33 changes: 0 additions & 33 deletions common/spec/dependabot/workspace/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,6 @@
workspace.store_change("rspec")
end

it "returns the diff of all changes" do
expect(workspace.changes.size).to eq(2)
expect(workspace.to_patch).to end_with(
<<~DIFF
gem "activesupport", ">= 6.0.0"
+gem "rspec", "~> 3.12.0", group: :test
+gem "timecop", "~> 0.9.6", group: :test
DIFF
)
end

context "when there are failed change attempts" do
before do
workspace.change("fail") do
Expand Down Expand Up @@ -123,12 +112,6 @@
expect(workspace.failed_change_attempts.size).to eq(1)
expect(workspace.change_attempts.size).to eq(1)
expect(workspace.change_attempts.first.id).to eq(`git rev-parse refs/stash`.strip)
expect(workspace.change_attempts.first.diff).to end_with(
<<~DIFF
gem "activesupport", ">= 6.0.0"
+gem "timecop", "~> 0.9.6", group: :test
DIFF
)
expect(workspace.change_attempts.first.memo).to eq("timecop")
expect(workspace.change_attempts.first.error).not_to be_nil
expect(workspace.change_attempts.first.error.message).to eq("uh oh")
Expand All @@ -152,16 +135,6 @@

it "captures the untracked/ignored files" do
expect(workspace.failed_change_attempts.size).to eq(1)
expect(workspace.failed_change_attempts.first.diff).to include(
<<~DIFF
gem "activesupport", ">= 6.0.0"
+gem "fail"
DIFF
)
expect(workspace.failed_change_attempts.first.diff).to include(
"diff --git a/ignored-file.txt b/ignored-file.txt",
"diff --git a/untracked-file.txt b/untracked-file.txt"
)
end
end
end
Expand Down Expand Up @@ -253,12 +226,6 @@
expect(workspace).to be_changed
expect(workspace.change_attempts.size).to eq(1)
expect(workspace.change_attempts.first.id).to eq(`git rev-parse HEAD`.strip)
expect(workspace.change_attempts.first.diff).to end_with(
<<~DIFF
gem "activesupport", ">= 6.0.0"
+gem "timecop", "~> 0.9.6", group: :test
DIFF
)
expect(workspace.change_attempts.first.memo).to eq("Update timecop")
expect(workspace.change_attempts.first.error).to be_nil
expect(workspace.change_attempts.first).not_to be_error
Expand Down
Loading

0 comments on commit 284d938

Please sign in to comment.