-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bundler v1 Deprecation Warning (#10421)
* created abstraction for package manager information that can be used in dependabot-core * added generation of deprecation and unsupported notices for bundler that is applicable for eco-systems. * passed generated deprecation notice to pr message.
- Loading branch information
Showing
30 changed files
with
2,541 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# typed: strong | ||
# frozen_string_literal: true | ||
|
||
require "sorbet-runtime" | ||
require "dependabot/bundler/version" | ||
require "dependabot/package_manager" | ||
|
||
module Dependabot | ||
module Bundler | ||
PACKAGE_MANAGER = "bundler" | ||
|
||
SUPPORTED_BUNDLER_VERSIONS = T.let([ | ||
Version.new("2") | ||
].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_BUNDLER_VERSIONS = T.let([ | ||
Version.new("1") | ||
].freeze, T::Array[Dependabot::Version]) | ||
|
||
class PackageManager < PackageManagerBase | ||
extend T::Sig | ||
|
||
sig { params(version: T.any(String, Dependabot::Version)).void } | ||
def initialize(version) | ||
@version = T.let(Version.new(version), Dependabot::Version) | ||
@name = T.let(PACKAGE_MANAGER, String) | ||
@deprecated_versions = T.let(DEPRECATED_BUNDLER_VERSIONS, T::Array[Dependabot::Version]) | ||
@supported_versions = T.let(SUPPORTED_BUNDLER_VERSIONS, T::Array[Dependabot::Version]) | ||
end | ||
|
||
sig { override.returns(String) } | ||
attr_reader :name | ||
|
||
sig { override.returns(Dependabot::Version) } | ||
attr_reader :version | ||
|
||
sig { override.returns(T::Array[Dependabot::Version]) } | ||
attr_reader :deprecated_versions | ||
|
||
sig { override.returns(T::Array[Dependabot::Version]) } | ||
attr_reader :supported_versions | ||
|
||
sig { override.returns(T::Boolean) } | ||
def deprecated? | ||
deprecated_versions.include?(version) | ||
end | ||
sig { override.returns(T::Boolean) } | ||
def unsupported? | ||
!deprecated? && version < supported_versions.first | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
bundler/spec/dependabot/bundler/package_manager_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
require "dependabot/bundler/package_manager" | ||
require "dependabot/package_manager" | ||
require "spec_helper" | ||
|
||
RSpec.describe Dependabot::Bundler::PackageManager do | ||
let(:package_manager) { described_class.new(version) } | ||
|
||
describe "#initialize" do | ||
context "when version is a String" do | ||
let(:version) { "2" } | ||
|
||
it "sets the version correctly" do | ||
expect(package_manager.version).to eq(Dependabot::Bundler::Version.new(version)) | ||
end | ||
|
||
it "sets the name correctly" do | ||
expect(package_manager.name).to eq(Dependabot::Bundler::PACKAGE_MANAGER) | ||
end | ||
|
||
it "sets the deprecated_versions correctly" do | ||
expect(package_manager.deprecated_versions).to eq(Dependabot::Bundler::DEPRECATED_BUNDLER_VERSIONS) | ||
end | ||
|
||
it "sets the supported_versions correctly" do | ||
expect(package_manager.supported_versions).to eq(Dependabot::Bundler::SUPPORTED_BUNDLER_VERSIONS) | ||
end | ||
end | ||
|
||
context "when version is a Dependabot::Bundler::Version" do | ||
let(:version) { Dependabot::Bundler::Version.new("2") } | ||
|
||
it "sets the version correctly" do | ||
expect(package_manager.version).to eq(version) | ||
end | ||
|
||
it "sets the name correctly" do | ||
expect(package_manager.name).to eq(Dependabot::Bundler::PACKAGE_MANAGER) | ||
end | ||
|
||
it "sets the deprecated_versions correctly" do | ||
expect(package_manager.deprecated_versions).to eq(Dependabot::Bundler::DEPRECATED_BUNDLER_VERSIONS) | ||
end | ||
|
||
it "sets the supported_versions correctly" do | ||
expect(package_manager.supported_versions).to eq(Dependabot::Bundler::SUPPORTED_BUNDLER_VERSIONS) | ||
end | ||
end | ||
end | ||
|
||
describe "#deprecated?" do | ||
context "when version is deprecated?" do | ||
let(:version) { "1" } | ||
|
||
it "returns true" do | ||
expect(package_manager.deprecated?).to be true | ||
end | ||
end | ||
|
||
context "when version is not deprecated" do | ||
let(:version) { "2" } | ||
|
||
it "returns false" do | ||
expect(package_manager.deprecated?).to be false | ||
end | ||
end | ||
end | ||
|
||
describe "#unsupported" do | ||
context "when version is deprecated?" do | ||
let(:version) { "1" } | ||
|
||
it "returns false" do | ||
expect(package_manager.unsupported?).to be false | ||
end | ||
end | ||
|
||
context "when version is supported" do | ||
let(:version) { "2" } | ||
|
||
it "returns false" do | ||
expect(package_manager.unsupported?).to be false | ||
end | ||
end | ||
|
||
context "when version is unsupported?" do | ||
let(:version) { "0.9" } | ||
|
||
it "returns true" do | ||
expect(package_manager.unsupported?).to be true | ||
end | ||
end | ||
end | ||
|
||
describe "#supported_versions" do | ||
context "when there are supported versions" do | ||
let(:version) { "2" } | ||
|
||
it "returns the correct supported versions" do | ||
expect(package_manager.supported_versions).to eq([Dependabot::Bundler::Version.new("2")]) | ||
end | ||
end | ||
end | ||
|
||
describe "#deprecated_versions" do | ||
context "when there are deprecated versions" do | ||
let(:version) { "2" } | ||
|
||
it "returns the correct deprecated versions" do | ||
expect(package_manager.deprecated_versions).to eq([Dependabot::Bundler::Version.new("1")]) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.