head and url behavior and github default urls
- From:
- Trevor Wennblom
- Date:
- 2011-08-26 @ 04:16
1)
seeing several of the formulas have both a `head` and a `url` i was
checking how those worked together. it seems that when `--head` is used,
if url is available the option is disregarded. i'm assuming this is a bug,
but i wanted to check if it was correct behavior? [1]
2)
a large number of formula's make reference to github, it seems some
redundancy could be cut down by having a default head based on url, and a
default home based on url or head. thoughts? [2]
[1]: https://gist.github.com/1172672#file_formula_head_url.md
## ex A
```
require 'formula'
class Titlecase < Formula
# url 'https://github.com/ap/titlecase.git'
head 'https://github.com/ap/titlecase.git'
# version 'v1010'
homepage 'http://plasmasturm.org/code/titlecase/'
def install
bin.install "titlecase"
end
end
```
output:
```
% brew install --head titlecase
==> Cloning https://github.com/ap/titlecase.git
Updating /mydir/Library/Caches/Homebrew/titlecase--git
/usr/local/Cellar/titlecase/HEAD: 4.0K, built in 2 seconds
```
## ex B
```
require 'formula'
class Titlecase < Formula
url 'https://github.com/ap/titlecase.git'
head 'https://github.com/ap/titlecase.git'
# version 'v1010'
homepage 'http://plasmasturm.org/code/titlecase/'
def install
bin.install "titlecase"
end
end
```
output:
```
% brew install --head titlecase
Error: Invalid @version
```
## ex C
```
require 'formula'
class Titlecase < Formula
url 'https://github.com/ap/titlecase.git'
head 'https://github.com/ap/titlecase.git'
version 'v1010'
homepage 'http://plasmasturm.org/code/titlecase/'
def install
bin.install "titlecase"
end
end
```
output:
```
% brew install --head titlecase
==> Cloning https://github.com/ap/titlecase.git
Updating /mydir/Library/Caches/Homebrew/titlecase--git
/usr/local/Cellar/titlecase/v1010: 4.0K, built in 2 seconds
```
[2]: https://gist.github.com/1172672#file_github_link_defaults.rb
ary = %w(
https://github.com/ap/titlecase/tarball/stuff
https://github.com/ap/titlecase.git
https://github.com/ap/titlecase/
https://github.com/ap/titlecase
git://github.com/ap/titlecase.git
git://github.com/ap/titlecase/
git://github.com/ap/titlecase
)
def github_link_to_default_home link
t = github_regexp_match(link)
raise unless t
t.gsub(%r{^git://}, 'https://')
end
def github_link_to_default_head link
t = github_regexp_match(link)
raise unless t
t.gsub(%r{^https://}, 'git://') + '.git'
end
def github_regexp_match link
re = Regexp.new("^(?<capture>(https|git)://github\.com/.*?/.*?)($|\.git|/.*)")
re.match(link)
(Regexp.last_match and Regexp.last_match['capture']) ?
Regexp.last_match['capture'] : nil
end
puts "Testing default home:"
ary.each {|a| puts github_link_to_default_home(a) }
puts "\nTesting default head:"
ary.each {|a| puts github_link_to_default_head(a) }
=begin
Testing default home:
https://github.com/ap/titlecase
https://github.com/ap/titlecase
https://github.com/ap/titlecase
https://github.com/ap/titlecase
https://github.com/ap/titlecase
https://github.com/ap/titlecase
https://github.com/ap/titlecase
Testing default head:
git://github.com/ap/titlecase.git
git://github.com/ap/titlecase.git
git://github.com/ap/titlecase.git
git://github.com/ap/titlecase.git
git://github.com/ap/titlecase.git
git://github.com/ap/titlecase.git
git://github.com/ap/titlecase.git
=end
Re: [homebrew] head and url behavior and github default urls
- From:
- Charlie Sharpsteen
- Date:
- 2011-08-26 @ 04:57
On Thu, Aug 25, 2011 at 9:16 PM, Trevor Wennblom <trevor@well.com> wrote:
>
> 2)
> a large number of formula's make reference to github, it seems some
> redundancy could be cut down by having a default head based on url, and a
> default home based on url or head. thoughts? [2]
>
Most formulae install software that is hosted somewhere other than github.
It is also quite possible to have weird corner cases where the HEAD is
hosted on GitHub, but the stable URL is somewhere else like an official
project site. Also, pasting in values for `head` and `url` is pretty easy
and only happens during formula creation---hardly a repetitive operation.
Because of this, I'm not convinced that increasing the complexity of
Homebrew's logic is worth the marginal benefit.
-Charlie
Re: [homebrew] head and url behavior and github default urls
- From:
- Jack Nagel
- Date:
- 2011-08-26 @ 04:33
On Thu, Aug 25, 2011 at 11:16 PM, Trevor Wennblom <trevor@well.com> wrote:
> 1)
> seeing several of the formulas have both a `head` and a `url` i was
checking how those worked together. it seems that when `--head` is used,
if url is available the option is disregarded. i'm assuming this is a bug,
but i wanted to check if it was correct behavior? [1]
It's '--HEAD', in all caps (though perhaps this should be relaxed).
Jack
Re: [homebrew] head and url behavior and github default urls
- From:
- Trevor Wennblom
- Date:
- 2011-08-26 @ 05:18
On Aug 25, 2011, at 11:33 PM, Jack Nagel wrote:
> It's '--HEAD', in all caps (though perhaps this should be relaxed).
ah, right-o. thanks.