Skip to content

Commit

Permalink
[Bazaar] Explicit support for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
fmccann committed Sep 3, 2013
1 parent bd50ca5 commit fc920ab
Show file tree
Hide file tree
Showing 43 changed files with 45 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The downloader class supports the following option keys:

- git: commit, tag, branch, submodules
- hg: revision
- bzr: revision
- bzr: revision, tag
- svn: revision, tag, folder
- http: type

Expand Down
12 changes: 7 additions & 5 deletions lib/cocoapods-downloader/bazaar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Downloader
class Bazaar < Base

def self.options
[:revision]
[:revision, :tag]
end

def options_specific?
Expand All @@ -24,8 +24,10 @@ def checkout_options
executable :bzr

def download!
if options[:revision]
download_revision!
if options[:tag]
download_revision!(options[:tag])
elsif options[:revision]
download_revision!(options[:revision])
else
download_head!
end
Expand All @@ -35,8 +37,8 @@ def download_head!
bzr! %|branch "#{url}" #{dir_opts} "#{target_path}"|
end

def download_revision!
bzr! %|branch "#{url}" #{dir_opts} -r '#{options[:revision]}' "#{target_path}"|
def download_revision!(rev)
bzr! %|branch "#{url}" #{dir_opts} -r #{rev} "#{target_path}"|
end

def dir_opts
Expand Down
13 changes: 10 additions & 3 deletions spec/cocoapods-downloaders/bazaar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,25 @@ module Downloader
tmp_folder('README').read.strip.should == 'First Commit'
end

it 'checks out a specific tag' do
it 'checks out a specific tag as a revision' do
options = { :bzr => fixture('bazaar-repo'), :revision => 'my_tag' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.download
tmp_folder('README').read.strip.should == 'Second Commit'
end

it 'checks out a specific tag as a tag' do
options = { :bzr => fixture('bazaar-repo'), :tag => 'my_other_tag' }
downloader = Downloader.for_target(tmp_folder, options)
downloader.download
tmp_folder('README').read.strip.should == 'Third Commit'
end

it 'checks out the head revision' do
options = { :bzr => fixture('bazaar-repo') }
downloader = Downloader.for_target(tmp_folder, options)
downloader.download
tmp_folder('README').read.strip.should == 'Second Commit'
tmp_folder('README').read.strip.should == 'Fourth Commit'
end

it 'returns the checked out revision' do
Expand All @@ -35,7 +42,7 @@ module Downloader
downloader.download
downloader.checkout_options.should == {
:bzr => fixture('bazaar-repo'),
:revision => '2'
:revision => '4'
}
end

Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/bazaar-repo/.bzr/branch/last-revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2 [email protected]20130902213642-af9p7t9cy38wp9p7
4 [email protected]20130903122427-q62tvv61aw0v4f4m
2 changes: 1 addition & 1 deletion spec/fixtures/bazaar-repo/.bzr/branch/tags
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d6:my_tag53:[email protected]20130902213642-af9p7t9cy38wp9p7e
d12:my_other_tag53:[email protected]:my_tag53:[email protected]20130903122345-4ladk888amaey5uxe
Binary file modified spec/fixtures/bazaar-repo/.bzr/checkout/dirstate
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
B+Tree Graph Index 2
node_ref_lists=1
key_elements=1
len=1
row_lengths=1
x��Q@0@�=E/@��h|H\��"A7����ܟp��*\<i���1�;�j�G 2�:��p�_�ۺ��V�E�L��I��'��
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
B+Tree Graph Index 2
node_ref_lists=0
key_elements=1
len=1
row_lengths=1
x����0 �ԙ"#��3q�&[Hа=w�w�qY�����"e�1�3\Y��̘ڥ�I�u�����rI�ڢ'
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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 modified spec/fixtures/bazaar-repo/.bzr/repository/pack-names
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/fixtures/bazaar-repo/README
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Second Commit
Fourth Commit
2 changes: 2 additions & 0 deletions spec/fixtures/mercurial-repo/.hg/cache/tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 df97b9ee89577f2da1925154472888b2b57e971e

0 comments on commit fc920ab

Please sign in to comment.