Skip to content

Commit

Permalink
[Bazaar] Add Bazaar support
Browse files Browse the repository at this point in the history
  • Loading branch information
fmccann committed Nov 28, 2013
1 parent 89ac71d commit 0a81b9e
Show file tree
Hide file tree
Showing 29 changed files with 109 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cocoapods/command/spec.rb
Expand Up @@ -512,7 +512,7 @@ def spec_template(data)
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
# #
# Specify the location from where the source should be retrieved. # Specify the location from where the source should be retrieved.
# Supports git, hg, svn and HTTP. # Supports git, hg, bzr, svn and HTTP.
# #
s.source = { :git => "#{data[:source_url]}", #{data[:ref_type]} => "#{data[:ref]}" } s.source = { :git => "#{data[:source_url]}", #{data[:ref_type]} => "#{data[:ref]}" }
Expand Down
30 changes: 30 additions & 0 deletions lib/cocoapods/external_sources.rb
Expand Up @@ -16,6 +16,7 @@ def self.from_dependency(dependency, podfile_path)
klass = if params.key?(:git) then GitSource klass = if params.key?(:git) then GitSource
elsif params.key?(:svn) then SvnSource elsif params.key?(:svn) then SvnSource
elsif params.key?(:hg) then MercurialSource elsif params.key?(:hg) then MercurialSource
elsif params.key?(:bzr) then BazaarSource
elsif params.key?(:podspec) then PodspecSource elsif params.key?(:podspec) then PodspecSource
elsif params.key?(:path) then PathSource elsif params.key?(:path) then PathSource
end end
Expand Down Expand Up @@ -261,6 +262,35 @@ def description


#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#


# Provides support for fetching a specification file from a Bazaar
# source remote.
#
# Supports all the options of the downloader (is similar to the git key of
# `source` attribute of a specification).
#
# @note The podspec must be in the root of the repository and should have a
# name matching the one of the dependency.
#
class BazaarSource < AbstractExternalSource

# @see AbstractExternalSource#fetch
#
def fetch(sandbox)
pre_download(sandbox)
end

# @see AbstractExternalSource#description
#
def description
"from `#{params[:bzr]}`".tap do |description|
description << ", tag `#{params[:tag]}`" if params[:tag]
description << ", revision `#{params[:revision]}`" if params[:revision]
end
end
end

#-------------------------------------------------------------------------#

# Provides support for fetching a specification file from an URL. Can be # Provides support for fetching a specification file from an URL. Can be
# http, file, etc. # http, file, etc.
# #
Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/bzr-repo/.bzr/README
@@ -0,0 +1,3 @@
This is a Bazaar control directory.
Do not change any files in this directory.
See http://bazaar.canonical.com/ for more information about Bazaar.
1 change: 1 addition & 0 deletions spec/fixtures/bzr-repo/.bzr/branch-format
@@ -0,0 +1 @@
Bazaar-NG meta directory, format 1
Empty file.
1 change: 1 addition & 0 deletions spec/fixtures/bzr-repo/.bzr/branch/format
@@ -0,0 +1 @@
Bazaar Branch Format 7 (needs bzr 1.6)
1 change: 1 addition & 0 deletions spec/fixtures/bzr-repo/.bzr/branch/last-revision
@@ -0,0 +1 @@
2 fred@sharpnoodles.com-20131030202140-gg5dfrrtaotfxlrh
Empty file.
1 change: 1 addition & 0 deletions spec/fixtures/bzr-repo/.bzr/checkout/conflicts
@@ -0,0 +1 @@
BZR conflict list format 1
Binary file added spec/fixtures/bzr-repo/.bzr/checkout/dirstate
Binary file not shown.
1 change: 1 addition & 0 deletions spec/fixtures/bzr-repo/.bzr/checkout/format
@@ -0,0 +1 @@
Bazaar Working Tree Format 6 (bzr 1.14)
Empty file.
1 change: 1 addition & 0 deletions spec/fixtures/bzr-repo/.bzr/repository/format
@@ -0,0 +1 @@
Bazaar repository format 2a (needs bzr 1.16 or later)
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,8 @@
B+Tree Graph Index 2
node_ref_lists=1
key_elements=1
len=1
row_lengths=1
x��Q
� ��;�0޺�tK-�R4�n���?'oC�wK;l-W�.�6l��
���"��ǰ�^c��:��BMF@���,B
@@ -0,0 +1,5 @@
B+Tree Graph Index 2
node_ref_lists=0
key_elements=1
len=0
row_lengths=
@@ -0,0 +1,8 @@
B+Tree Graph Index 2
node_ref_lists=1
key_elements=2
len=3
row_lengths=1
x���M�0@a֜� �Lg ԅ�71�P,�ȏ��-+���M� W'ܦ5�C���H>xi�&��(�"ü��k���A�bo��ax{o�ļ���#P�B][��а^��IR`�2�
4i�����,FE�;;��t
"���t�J57�s�L :*��7�}�v�� e�
Expand Down
@@ -0,0 +1,7 @@
B+Tree Graph Index 2
node_ref_lists=0
key_elements=1
len=1
row_lengths=1
x���� P�L�Z
��8�'@8x0ы������&V|6�H�����cr7e�yhZC��b����r"&s�?�-
Expand Down
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
B+Tree Graph Index 2
node_ref_lists=0
key_elements=1
len=0
row_lengths=
Binary file not shown.
Binary file added spec/fixtures/bzr-repo/.bzr/repository/pack-names
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions spec/fixtures/bzr-repo/BazaarSource.podspec
@@ -0,0 +1,10 @@
Pod::Spec.new do |s|
s.name = "BazaarSource"
s.version = "0.0.1"
s.summary = "A short description of BazaarSource."
s.homepage = "http://EXAMPLE/BazaarSource"
s.license = 'MIT (example)'
s.author = { "Fred McCann" => "fred@sharpnoodles.com" }
s.source = { :git => "http://EXAMPLE/BazaarSource.git", :tag => "0.0.1" }
s.source_files = 'Classes', 'Classes/**/*.{h,m}'
end
1 change: 1 addition & 0 deletions spec/fixtures/bzr-repo/README
@@ -0,0 +1 @@
second commit
25 changes: 25 additions & 0 deletions spec/unit/external_sources_spec.rb
Expand Up @@ -148,6 +148,31 @@ module Pod


#---------------------------------------------------------------------------# #---------------------------------------------------------------------------#


describe ExternalSources::BazaarSource do

before do
dependency = Dependency.new("BazaarSource", :bzr => fixture('bzr-repo'))
@external_source = ExternalSources.from_dependency(dependency, nil)
end

it "creates a copy of the podspec" do
@external_source.fetch(config.sandbox)
path = config.sandbox.root + 'Local Podspecs/BazaarSource.podspec'
path.should.exist?
end

it "marks a LocalPod as downloaded" do
@external_source.fetch(config.sandbox)
config.sandbox.predownloaded_pods.should == ["BazaarSource"]
end

it "returns the description" do
@external_source.description.should.match %r|from `.*/bzr-repo`|
end
end

#---------------------------------------------------------------------------#

describe ExternalSources::PodspecSource do describe ExternalSources::PodspecSource do


before do before do
Expand Down

0 comments on commit 0a81b9e

Please sign in to comment.