From 8c2fe2d1b55c0cf98531f4fef9a8ce46321e0ee8 Mon Sep 17 00:00:00 2001 From: Landon Grindheim Date: Tue, 9 Apr 2024 13:27:04 -0400 Subject: [PATCH 1/3] Update how we record Bundler versions We rely on this information for metrics, not application logic. I believe we're receiving poor information and making decisions based on it. I'm updating this to see if we're indeed supporting as many Bundler v1 projects as it seems. --- bundler/lib/dependabot/bundler/helpers.rb | 4 ++-- bundler/spec/dependabot/bundler/helper_spec.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bundler/lib/dependabot/bundler/helpers.rb b/bundler/lib/dependabot/bundler/helpers.rb index f72f91fcb0..1d2b951451 100644 --- a/bundler/lib/dependabot/bundler/helpers.rb +++ b/bundler/lib/dependabot/bundler/helpers.rb @@ -30,9 +30,9 @@ def self.detected_bundler_version(lockfile) return "unknown" unless lockfile if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX)) - matches[:version] + matches[:version].to_i else - "1" + "unknown" end end end diff --git a/bundler/spec/dependabot/bundler/helper_spec.rb b/bundler/spec/dependabot/bundler/helper_spec.rb index b016c846ca..7a61762433 100644 --- a/bundler/spec/dependabot/bundler/helper_spec.rb +++ b/bundler/spec/dependabot/bundler/helper_spec.rb @@ -76,8 +76,8 @@ def described_method(lockfile) expect(described_method(no_lockfile)).to eql("unknown") end - it "is 1 if there is no bundled with string" do - expect(described_method(lockfile_bundled_with_missing)).to eql("1") + it "is unknown if there is no bundled with string" do + expect(described_method(lockfile_bundled_with_missing)).to eql("unknown") end it "is 1 if it was bundled with a v1.x version" do @@ -88,7 +88,7 @@ def described_method(lockfile) expect(described_method(lockfile_bundled_with_v2)).to eql("2") end - it "is 1 if it was bundled with a future version" do + it "reports the version if it was bundled with a future version" do expect(described_method(lockfile_bundled_with_future_version)).to eql("3") end end From 00f69a0afde7fdfadc1355897a7d860ff6aa647a Mon Sep 17 00:00:00 2001 From: Landon Grindheim Date: Tue, 9 Apr 2024 13:32:38 -0400 Subject: [PATCH 2/3] Cast versions to a String for consistency --- bundler/lib/dependabot/bundler/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler/lib/dependabot/bundler/helpers.rb b/bundler/lib/dependabot/bundler/helpers.rb index 1d2b951451..f47689205f 100644 --- a/bundler/lib/dependabot/bundler/helpers.rb +++ b/bundler/lib/dependabot/bundler/helpers.rb @@ -30,7 +30,7 @@ def self.detected_bundler_version(lockfile) return "unknown" unless lockfile if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX)) - matches[:version].to_i + matches[:version].to_i.to_s else "unknown" end From 65b295372092c5ebb787fca08f275f39886fc769 Mon Sep 17 00:00:00 2001 From: Landon Grindheim Date: Tue, 9 Apr 2024 13:35:17 -0400 Subject: [PATCH 3/3] Differentiate values missing from the lockfile Co-authored-by: Jake Coffman --- bundler/lib/dependabot/bundler/helpers.rb | 2 +- bundler/spec/dependabot/bundler/helper_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundler/lib/dependabot/bundler/helpers.rb b/bundler/lib/dependabot/bundler/helpers.rb index f47689205f..f477e0e881 100644 --- a/bundler/lib/dependabot/bundler/helpers.rb +++ b/bundler/lib/dependabot/bundler/helpers.rb @@ -32,7 +32,7 @@ def self.detected_bundler_version(lockfile) if (matches = lockfile.content.match(BUNDLER_MAJOR_VERSION_REGEX)) matches[:version].to_i.to_s else - "unknown" + "unspecified" end end end diff --git a/bundler/spec/dependabot/bundler/helper_spec.rb b/bundler/spec/dependabot/bundler/helper_spec.rb index 7a61762433..7f165ebe85 100644 --- a/bundler/spec/dependabot/bundler/helper_spec.rb +++ b/bundler/spec/dependabot/bundler/helper_spec.rb @@ -76,8 +76,8 @@ def described_method(lockfile) expect(described_method(no_lockfile)).to eql("unknown") end - it "is unknown if there is no bundled with string" do - expect(described_method(lockfile_bundled_with_missing)).to eql("unknown") + it "is unspecified if there is no bundled with string" do + expect(described_method(lockfile_bundled_with_missing)).to eql("unspecified") end it "is 1 if it was bundled with a v1.x version" do