From 2cd95d482d1adf9774fac823094b710b7c1489bf Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:34:09 -0400 Subject: [PATCH] version: loosen Debian orig tarball regex The regex to match Debian `orig` tarballs uses the standard regex for versions like `1.2.3` but it won't match versions without a dot. The `lcrack` formula uses a date-based version in the filename (`lcrack_20040914.orig.tar.gz`) and `mkcue` uses a single number (`mkcue_1.orig.tar.gz`), so we have to use a manual `version` in these formulae. This updates the regex to use the looser `NUMERIC_WITH_OPTIONAL_DOTS` pattern, which will also match the aforementioned versions. I tested this by checking versions of formulae before/after this change and confirming that they remain the same after removing the `version` calls from related formulae. --- Library/Homebrew/test/version_spec.rb | 11 +++++++++-- Library/Homebrew/version.rb | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/test/version_spec.rb b/Library/Homebrew/test/version_spec.rb index 49dfad7878..99c301fb30 100644 --- a/Library/Homebrew/test/version_spec.rb +++ b/Library/Homebrew/test/version_spec.rb @@ -625,16 +625,23 @@ RSpec.describe Version do .to be_detected_from("https://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz") end - specify "debian style 1" do + specify "debian style" do expect(described_class.new("3.03")) .to be_detected_from("https://ftp.de.debian.org/debian/pool/main/s/sl/sl_3.03.orig.tar.gz") end - specify "debian style 2" do + specify "debian style with letter suffix" do expect(described_class.new("1.01b")) .to be_detected_from("https://ftp.de.debian.org/debian/pool/main/m/mmv/mmv_1.01b.orig.tar.gz") end + specify "debian style dotless" do + expect(described_class.new("1")) + .to be_detected_from("https://deb.debian.org/debian/pool/main/e/example/example_1.orig.tar.gz") + expect(described_class.new("20040914")) + .to be_detected_from("https://deb.debian.org/debian/pool/main/e/example/example_20040914.orig.tar.gz") + end + specify "bottle style" do expect(described_class.new("4.8.0")) .to be_detected_from("https://homebrew.bintray.com/bottles/qt-4.8.0.lion.bottle.tar.gz") diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 3ab67d324c..0c9005219e 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -462,8 +462,11 @@ class Version # e.g. `https://search.maven.org/remotecontent?filepath=org/apache/orc/orc-tools/1.2.3/orc-tools-1.2.3-uber.jar` StemParser.new(/-(#{NUMERIC_WITH_DOTS})-/), - # e.g. `dash_0.5.5.1.orig.tar.gz (Debian style)` - StemParser.new(/_(#{NUMERIC_WITH_DOTS}[abc]?)\.orig$/), + # Debian style + # e.g. `dash_0.5.5.1.orig.tar.gz` + # e.g. `lcrack_20040914.orig.tar.gz` + # e.g. `mkcue_1.orig.tar.gz` + StemParser.new(/_(#{NUMERIC_WITH_OPTIONAL_DOTS}[abc]?)\.orig$/), # e.g. `https://www.openssl.org/source/openssl-0.9.8s.tar.gz` StemParser.new(/-v?(\d[^-]+)/),