Skip to content

Commit

Permalink
Remove inconsistent language requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
amazimbe committed Nov 28, 2024
1 parent 9381b0d commit 142f767
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
11 changes: 1 addition & 10 deletions hex/lib/dependabot/hex/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def package_manager
sig { returns(T.nilable(Ecosystem::VersionManager)) }
def language
@language ||= T.let(
Language.new(elixir_version, nil),
Language.new(elixir_version),
T.nilable(Dependabot::Hex::Language)
)
end
Expand All @@ -189,15 +189,6 @@ def hex_info
}
end, T.nilable(T::Hash[Symbol, T.nilable(String)]))
end

sig { returns(T.nilable(Dependabot::Hex::Requirement)) }
def language_requirement
command = "mix run --eval 'Mix.Project.config()[:elixir] |> IO.puts()'"
requirement = SharedHelpers.run_shell_command(command)
return if requirement.empty? || requirement.nil?

Dependabot::Hex::Requirement.new(requirement)
end
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions hex/lib/dependabot/hex/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ module Hex
class Language < Dependabot::Ecosystem::VersionManager
extend T::Sig

sig { params(raw_version: String, requirement: T.nilable(Requirement)).void }
def initialize(raw_version, requirement = nil)
super(LANGUAGE, Version.new(raw_version), [], [], requirement)
sig { params(raw_version: String).void }
def initialize(raw_version)
super(LANGUAGE, Version.new(raw_version))
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions hex/spec/dependabot/hex/file_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@
it "returns the correct package manager" do
expect(package_manager.name).to eq "hex"
expect(package_manager.requirement).to be_nil
expect(package_manager.version.to_s).to eq "2.1.1"
expect(package_manager.version.to_s).to eq "2.0.6"
end
end

Expand All @@ -476,7 +476,7 @@
it "returns the correct language" do
expect(language.name).to eq "elixir"
expect(language.requirement).to be_nil
expect(language.version.to_s).to eq "1.17.3"
expect(language.version.to_s).to eq "1.14.4"
end
end
end
Expand Down
10 changes: 1 addition & 9 deletions hex/spec/dependabot/hex/language_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# typed: false
# frozen_string_literal: true

require "dependabot/hex/requirement"
require "dependabot/hex/language"
require "dependabot/ecosystem"
require "spec_helper"

RSpec.describe Dependabot::Hex::Language do
subject(:language) { described_class.new(version, requirement) }
subject(:language) { described_class.new(version) }

let(:version) { "1.17.3" }
let(:requirement) { Dependabot::Hex::Requirement.new("~> 1.5") }

describe "#version" do
it "returns the version" do
Expand All @@ -24,12 +22,6 @@
end
end

describe "#requirement" do
it "returns the requirement" do
expect(language.requirement).to eq(requirement)
end
end

describe "#unsupported?" do
it "returns false by default" do
expect(language.unsupported?).to be false
Expand Down

0 comments on commit 142f767

Please sign in to comment.