Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict type Dependabot::Hex::MixFileGitPinUpdater #9983

Merged
merged 2 commits into from
Jun 12, 2024
Merged
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
16 changes: 15 additions & 1 deletion hex/lib/dependabot/hex/file_updater/mixfile_git_pin_updater.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# typed: true
# typed: strong
# frozen_string_literal: true

require "dependabot/hex/file_updater"
require "dependabot/shared_helpers"
require "sorbet-runtime"

module Dependabot
module Hex
class FileUpdater
class MixfileGitPinUpdater
extend T::Sig

sig { params(dependency_name: String, mixfile_content: String, previous_pin: String, updated_pin: String).void }
def initialize(dependency_name:, mixfile_content:,
previous_pin:, updated_pin:)
@dependency_name = dependency_name
Expand All @@ -16,6 +20,7 @@ def initialize(dependency_name:, mixfile_content:,
@updated_pin = updated_pin
end

sig { returns(String) }
def updated_content
updated_content = update_pin(mixfile_content)

Expand All @@ -26,11 +31,19 @@ def updated_content

private

sig { returns(String) }
attr_reader :dependency_name

sig { returns(String) }
attr_reader :mixfile_content

sig { returns(String) }
attr_reader :previous_pin

sig { returns(String) }
attr_reader :updated_pin

sig { params(content: String).returns(String) }
def update_pin(content)
requirement_line_regex =
/
Expand All @@ -43,6 +56,7 @@ def update_pin(content)
end
end

sig { returns(T::Boolean) }
def content_should_change?
previous_pin == updated_pin
end
Expand Down
Loading