Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Detect versions in tags #20891

Closed
wants to merge 3 commits into from

3 participants

@jacknagel
Owner

Addresses #18300.

@adamv
Owner

Nice.

(Does this work correctly for heads on branches?)

@jacknagel
Owner

It only tries to detect it if :tag is given; haven't given any thought to other cases

@jacknagel
Owner

I think the CI failure is because the running bot doesn't have the new detection logic, and it loads formula files that then appear to be missing versions, so it should be OK.

@mikemcquaid
Owner

@jacknagel The failures look like they are on the "non-executables are installed to bin" (assuming @adamv made those warnings throw a failure like mentioned). The only time it does the different detection logic is if it's outside of running an actual brew foo command and instead inside the brew-test-bot code itself.

@adamv
Owner

Oh sweet, is that everything from this change that installs non-bins?

@jacknagel
Owner

@mikemcquaid I was looking at an earlier failure: http://bot.brew.sh/job/Homebrew%20Pull%20Requests/380/version=mountain_lion/console

I've since repushed, not sure what the difference is though.

@mikemcquaid
Owner

Ah, yes, that looks like a problem. Looking.

@mikemcquaid
Owner

This stuff seems to happen enough that I'm reconsidering my "brew-test-bot should always be the master version` approach. Thoughts?

@jacknagel
Owner

There are pros and cons to both approaches, I guess; I defer to your judgement.

@jacknagel jacknagel closed this pull request from a commit
@jacknagel jacknagel Detect versions in tag specs
Closes #18300.
Closes #20891.
a16c80a
@jacknagel jacknagel closed this in a16c80a
@jacknagel jacknagel deleted the jacknagel:version branch
@nddrylliog nddrylliog referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@handyman5 handyman5 referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@shelhamer shelhamer referenced this pull request from a commit
@jacknagel jacknagel Detect versions in tag specs
Closes #18300.
Closes #20891.
0a9b410
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  Library/Formula/closure-compiler.rb
@@ -3,7 +3,6 @@
class ClosureCompiler < Formula
homepage 'http://code.google.com/p/closure-compiler/'
url 'https://code.google.com/p/closure-compiler/', :using => :git, :tag => 'v20130411'
- version '20130411'
head 'https://code.google.com/p/closure-compiler/', :using => :git
View
1  Library/Formula/git-flow.rb
@@ -13,7 +13,6 @@ class GitFlow < Formula
# Use the tag instead of the tarball to get submodules
url 'https://github.com/nvie/gitflow.git', :tag => '0.4.1'
- version '0.4.1'
head 'https://github.com/nvie/gitflow.git', :branch => 'develop'
View
1  Library/Formula/git-now.rb
@@ -3,7 +3,6 @@
class GitNow < Formula
homepage 'https://github.com/iwata/git-now'
url 'https://github.com/iwata/git-now.git', :tag => 'v0.1.0.9'
- version '0.1.0.9'
head 'https://github.com/iwata/git-now.git', :branch => 'develop'
View
4 Library/Formula/ical-buddy.rb
@@ -4,9 +4,7 @@ class IcalBuddy < Formula
# NOTE: the official tarball doesn't actually contain any source,
# just a prebuilt i386 binary
homepage 'http://hasseg.org/icalBuddy/'
- url 'http://hasseg.org/git-public/icalBuddy.git',
- :tag => 'v1.8.8'
- version '1.8.8'
+ url 'http://hasseg.org/git-public/icalBuddy.git', :tag => 'v1.8.8'
head 'http://hasseg.org/git-public/icalBuddy.git'
View
1  Library/Formula/libwebsockets.rb
@@ -3,7 +3,6 @@
class Libwebsockets < Formula
homepage 'http://git.warmcat.com/cgi-bin/cgit/libwebsockets'
url 'git://git.warmcat.com/libwebsockets', :tag => 'v1.22-chrome26-firefox18'
- version '1.22'
depends_on 'cmake' => :build
View
1  Library/Formula/mr.rb
@@ -3,7 +3,6 @@
class Mr < Formula
homepage 'http://kitenet.net/~joey/code/mr/'
url 'http://git.kitenet.net/git/mr.git', :tag => '1.15'
- version '1.15'
def install
system "make"
View
1  Library/Formula/multimarkdown.rb
@@ -5,7 +5,6 @@ class Multimarkdown < Formula
# Use the tag instead of the tarball to get submodules
url 'https://github.com/fletcher/peg-multimarkdown.git', :tag => '3.7'
- version '3.7'
head 'https://github.com/fletcher/peg-multimarkdown.git', :branch => 'development'
View
2  Library/Formula/tmap.rb
@@ -3,8 +3,6 @@
class Tmap < Formula
homepage 'https://github.com/iontorrent/TMAP'
url 'https://github.com/iontorrent/TMAP.git', :tag => 'tmap.3.2.0'
- sha1 'da3eb4ce3428cec1f5ac12467af4802df6188711'
- version '3.2.0'
head 'https://github.com/iontorrent/TMAP.git'
View
2  Library/Formula/torsocks.rb
@@ -3,7 +3,7 @@
class Torsocks < Formula
homepage 'https://gitweb.torproject.org/torsocks.git/'
url 'https://git.torproject.org/torsocks.git', :tag => '1.3'
- version '1.3'
+
head 'https://git.torproject.org/torsocks.git', :branch => 'master'
depends_on :autoconf
View
1  Library/Formula/trash.rb
@@ -3,7 +3,6 @@
class Trash < Formula
homepage 'http://hasseg.org/trash/'
url 'http://hasseg.org/git-public/trash.git/', :using => :git, :tag => 'v0.8.2'
- version '0.8.2'
def install
system "make"
View
1  Library/Formula/tuntap.rb
@@ -3,7 +3,6 @@
class Tuntap < Formula
homepage 'http://tuntaposx.sourceforge.net/'
url 'git://git.code.sf.net/p/tuntaposx/code', :tag => 'release_20111101'
- version '20111101'
head 'git://git.code.sf.net/p/tuntaposx/code', :branch => 'master'
View
2  Library/Homebrew/cmd/audit.rb
@@ -276,7 +276,7 @@ def audit_specs
problem "Invalid or missing #{spec} version"
else
version_text = s.version unless s.version.detected_from_url?
- version_url = Version.parse(s.url)
+ version_url = Version.detect(s.url, s.specs)
if version_url.to_s == version_text.to_s && s.version.instance_of?(Version)
problem "#{spec} version #{version_text} is redundant with version scanned from URL"
end
View
19 Library/Homebrew/formula_support.rb
@@ -35,6 +35,16 @@ def verify_download_integrity fn
raise e
end
+ def detect_version(val)
+ case val
+ when nil then Version.detect(url, specs)
+ when String then Version.new(val)
+ when Hash then Version.new_with_scheme(*val.shift)
+ else
+ raise TypeError, "version '#{val.inspect}' should be a string"
+ end
+ end
+
# The methods that follow are used in the block-form DSL spec methods
Checksum::TYPES.each do |cksum|
class_eval <<-EOS, __FILE__, __LINE__ + 1
@@ -52,14 +62,7 @@ def url val=nil, specs={}
end
def version val=nil
- @version ||= case val
- when nil then Version.parse(@url)
- when Hash
- key, value = val.shift
- scheme = VersionSchemeDetector.new(value).detect
- scheme.new(key)
- else Version.new(val)
- end
+ @version ||= detect_version(val)
end
def mirror val
View
12 Library/Homebrew/test/test_software_spec.rb
@@ -60,6 +60,18 @@ def test_version_with_scheme
assert_instance_of scheme, @spec.version
end
+ def test_version_from_tag
+ @spec.url('http://foo.com/bar-1.0.tar.gz', :tag => 'v1.0.2')
+ assert_version_equal '1.0.2', @spec.version
+ assert @spec.version.detected_from_url?
+ end
+
+ def test_rejects_non_string_versions
+ assert_raises(TypeError) { @spec.version(1) }
+ assert_raises(TypeError) { @spec.version(2.0) }
+ assert_raises(TypeError) { @spec.version(Object.new) }
+ end
+
def test_mirrors
assert_empty @spec.mirrors
@spec.mirror('foo')
View
37 Library/Homebrew/version.rb
@@ -146,6 +146,22 @@ def <=>(other)
end
end
+ def self.new_with_scheme(value, scheme)
+ if Class === scheme && scheme.ancestors.include?(Version)
+ scheme.new(value)
+ else
+ raise TypeError, "Unknown version scheme #{scheme.inspect}"
+ end
+ end
+
+ def self.detect(url, specs={})
+ if specs.has_key?(:tag)
+ new(specs[:tag][/((?:\d+\.)*\d+)/, 1], true)
+ else
+ parse(url)
+ end
+ end
+
def initialize(val, detected=false)
@version = val.to_s
@detected_from_url = detected
@@ -295,24 +311,3 @@ def self._parse spec
return m.captures.first unless m.nil?
end
end
-
-class VersionSchemeDetector
- def initialize scheme
- @scheme = scheme
- end
-
- def detect
- if @scheme.is_a? Class and @scheme.ancestors.include? Version
- @scheme
- elsif @scheme.is_a? Symbol then detect_from_symbol
- else
- raise "Unknown version scheme #{@scheme} was requested."
- end
- end
-
- private
-
- def detect_from_symbol
- raise "Unknown version scheme #{@scheme} was requested."
- end
-end
Something went wrong with that request. Please try again.