Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bzr support #4

Merged
merged 5 commits into from

4 participants

@fmccann

Basic support for Bazaar repositories.

@coveralls

Coverage Status

Coverage remained the same when pulling c02a2fb on fmccann:bzr_support into 7cfddec on CocoaPods:master.

@coveralls

Coverage Status

Coverage remained the same when pulling 843f750 on fmccann:bzr_support into 7cfddec on CocoaPods:master.

@orta
Owner

:beers:

@alloy
Owner

Awesome.

One question, though, is it not common for people to use tags in the Bazaar world? And even if it’s not, I still think it would be better to have support for that too, unless there’s a specific reason not to?

@fmccann
@alloy
Owner

Thanks.

As far as I could tell tags are, like in many other systems, aliases to specific revisions, so they’re technically not needed. However, in our case the semantic value of these aliases is much more needed, as it allows people to easily see that a spec is using a revision that’s deemed special according to the lib’s author.

@coveralls

Coverage Status

Coverage remained the same when pulling fc920ab on fmccann:bzr_support into 7cfddec on CocoaPods:master.

@fmccann
@coveralls

Coverage Status

Coverage remained the same when pulling 7901194 on fmccann:bzr_support into 7cfddec on CocoaPods:master.

@alloy
Owner

Awesome, thanks!

@alloy alloy merged commit 8bb9a80 into from
@fmccann fmccann deleted the branch
@alloy
Owner

@fmccann Btw, are using this in conjunction with CocoaPods? If so, it would be great if you could take a look at implementing the Bazaar support for installing directly from a repo. For instance, a Podfile like this:

pod 'BazaarRepo', :bzr => 'URL'
@fmccann
@alloy
Owner

Thanks. That’s what I figured you were doing and that’s also what I’m adding to the CHANGELOG for CocoaPods 0.25.0:

  • Partial support has been added for the Bazaar SCM. This allows specifications
    to use the :bzr option, but only when used from a spec repo.

    Patches to add support for external options, such as installing directly from
    a Bazaar repo, will be gladly accepted.

    Fred McCann
    #4

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.
Showing with 168 additions and 0 deletions.
  1. +1 −0  README.markdown
  2. +2 −0  lib/cocoapods-downloader.rb
  3. +52 −0 lib/cocoapods-downloader/bazaar.rb
  4. +61 −0 spec/cocoapods-downloaders/bazaar_spec.rb
  5. +3 −0  spec/fixtures/bazaar-repo/.bzr/README
  6. +1 −0  spec/fixtures/bazaar-repo/.bzr/branch-format
  7. 0  spec/fixtures/bazaar-repo/.bzr/branch/branch.conf
  8. +1 −0  spec/fixtures/bazaar-repo/.bzr/branch/format
  9. +1 −0  spec/fixtures/bazaar-repo/.bzr/branch/last-revision
  10. +1 −0  spec/fixtures/bazaar-repo/.bzr/branch/tags
  11. +1 −0  spec/fixtures/bazaar-repo/.bzr/checkout/conflicts
  12. BIN  spec/fixtures/bazaar-repo/.bzr/checkout/dirstate
  13. +1 −0  spec/fixtures/bazaar-repo/.bzr/checkout/format
  14. 0  spec/fixtures/bazaar-repo/.bzr/checkout/views
  15. +1 −0  spec/fixtures/bazaar-repo/.bzr/repository/format
  16. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.cix
  17. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.iix
  18. +6 −0 spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.rix
  19. +5 −0 spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.six
  20. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.tix
  21. +6 −0 spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.cix
  22. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.iix
  23. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.rix
  24. +5 −0 spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.six
  25. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.tix
  26. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.cix
  27. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.iix
  28. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.rix
  29. +5 −0 spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.six
  30. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.tix
  31. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.cix
  32. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.iix
  33. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.rix
  34. +5 −0 spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.six
  35. BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.tix
  36. +7 −0 spec/fixtures/bazaar-repo/.bzr/repository/pack-names
  37. BIN  spec/fixtures/bazaar-repo/.bzr/repository/packs/0eee32389584c19d27fb19f04c01564d.pack
  38. BIN  spec/fixtures/bazaar-repo/.bzr/repository/packs/16b1053ed12916f4f545020352384e52.pack
  39. BIN  spec/fixtures/bazaar-repo/.bzr/repository/packs/7ce6129415e312dba7c6ca36ee0f2157.pack
  40. BIN  spec/fixtures/bazaar-repo/.bzr/repository/packs/f9604713d4ada772a21468a6846344b2.pack
  41. +1 −0  spec/fixtures/bazaar-repo/README
  42. +2 −0  spec/fixtures/mercurial-repo/.hg/cache/tags
View
1  README.markdown
@@ -29,6 +29,7 @@ The downloader class supports the following option keys:
- git: commit, tag, branch, submodules
- hg: revision
+- bzr: revision, tag
- svn: revision, tag, folder
- http: type
View
2  lib/cocoapods-downloader.rb
@@ -16,12 +16,14 @@ def self.downloader_class_by_key
require 'cocoapods-downloader/mercurial'
require 'cocoapods-downloader/subversion'
require 'cocoapods-downloader/http'
+ require 'cocoapods-downloader/bazaar'
{
:git => Git,
:hg => Mercurial,
:svn => Subversion,
:http => Http,
+ :bzr => Bazaar,
}
end
View
52 lib/cocoapods-downloader/bazaar.rb
@@ -0,0 +1,52 @@
+module Pod
+ module Downloader
+ class Bazaar < Base
+
+ def self.options
+ [:revision, :tag]
+ end
+
+ def options_specific?
+ !options[:revision].nil?
+ end
+
+ def checkout_options
+ Dir.chdir(target_path) do
+ options = {}
+ options[:bzr] = url
+ options[:revision] = `bzr revno`.chomp
+ options
+ end
+ end
+
+ private
+
+ executable :bzr
+
+ def download!
+ if options[:tag]
+ download_revision!(options[:tag])
+ elsif options[:revision]
+ download_revision!(options[:revision])
+ else
+ download_head!
+ end
+ end
+
+ def download_head!
+ bzr! %|branch "#{url}" #{dir_opts} "#{target_path}"|
+ end
+
+ def download_revision!(rev)
+ bzr! %|branch "#{url}" #{dir_opts} -r '#{rev}' "#{target_path}"|
+ end
+
+ def dir_opts
+ return '--use-existing-dir' if @target_path.exist?
+ ''
+ end
+
+ end
+ end
+end
+
View
61 spec/cocoapods-downloaders/bazaar_spec.rb
@@ -0,0 +1,61 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+module Pod
+ module Downloader
+ describe 'Bazaar' do
+
+ before do
+ tmp_folder.rmtree if tmp_folder.exist?
+ end
+
+ it 'checks out a specific revision' do
+ options = { :bzr => fixture('bazaar-repo'), :revision => '1' }
+ downloader = Downloader.for_target(tmp_folder, options)
+ downloader.download
+ tmp_folder('README').read.strip.should == 'First Commit'
+ end
+
+ 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 == 'Fourth Commit'
+ end
+
+ it 'returns the checked out revision' do
+ options = { :bzr => fixture('bazaar-repo') }
+ downloader = Downloader.for_target(tmp_folder, options)
+ downloader.download
+ downloader.checkout_options.should == {
+ :bzr => fixture('bazaar-repo'),
+ :revision => '4'
+ }
+ end
+
+ it 'returns whether the provided options are specific' do
+ Downloader.for_target('path', :bzr => 'url').options_specific?.should.be.false
+ Downloader.for_target('path', :bzr => 'url', :revision => '').options_specific?.should.be.true
+ end
+
+ it 'raises if it fails to download' do
+ options = { :bzr => 'missing-repo', :revision => '12' }
+ downloader = Downloader.for_target(tmp_folder, options)
+ lambda { downloader.download }.should.raise DownloaderError
+ end
+ end
+ end
+end
View
3  spec/fixtures/bazaar-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.
View
1  spec/fixtures/bazaar-repo/.bzr/branch-format
@@ -0,0 +1 @@
+Bazaar-NG meta directory, format 1
View
0  spec/fixtures/bazaar-repo/.bzr/branch/branch.conf
No changes.
View
1  spec/fixtures/bazaar-repo/.bzr/branch/format
@@ -0,0 +1 @@
+Bazaar Branch Format 7 (needs bzr 1.6)
View
1  spec/fixtures/bazaar-repo/.bzr/branch/last-revision
@@ -0,0 +1 @@
+4 fred@sharpnoodles.com-20130903122427-q62tvv61aw0v4f4m
View
1  spec/fixtures/bazaar-repo/.bzr/branch/tags
@@ -0,0 +1 @@
+d12:my_other_tag53:fred@sharpnoodles.com-20130903122403-19amncmj76umtisz6:my_tag53:fred@sharpnoodles.com-20130903122345-4ladk888amaey5uxe
View
1  spec/fixtures/bazaar-repo/.bzr/checkout/conflicts
@@ -0,0 +1 @@
+BZR conflict list format 1
View
BIN  spec/fixtures/bazaar-repo/.bzr/checkout/dirstate
Binary file not shown
View
1  spec/fixtures/bazaar-repo/.bzr/checkout/format
@@ -0,0 +1 @@
+Bazaar Working Tree Format 6 (bzr 1.14)
View
0  spec/fixtures/bazaar-repo/.bzr/checkout/views
No changes.
View
1  spec/fixtures/bazaar-repo/.bzr/repository/format
@@ -0,0 +1 @@
+Bazaar repository format 2a (needs bzr 1.16 or later)
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.cix
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.iix
Binary file not shown
View
6 spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.rix
@@ -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��'��
View
5 spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.six
@@ -0,0 +1,5 @@
+B+Tree Graph Index 2
+node_ref_lists=0
+key_elements=1
+len=0
+row_lengths=
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/0eee32389584c19d27fb19f04c01564d.tix
Binary file not shown
View
6 spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.cix
@@ -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�ڢ'
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.iix
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.rix
Binary file not shown
View
5 spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.six
@@ -0,0 +1,5 @@
+B+Tree Graph Index 2
+node_ref_lists=0
+key_elements=1
+len=0
+row_lengths=
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/16b1053ed12916f4f545020352384e52.tix
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.cix
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.iix
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.rix
Binary file not shown
View
5 spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.six
@@ -0,0 +1,5 @@
+B+Tree Graph Index 2
+node_ref_lists=0
+key_elements=1
+len=0
+row_lengths=
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/7ce6129415e312dba7c6ca36ee0f2157.tix
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.cix
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.iix
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.rix
Binary file not shown
View
5 spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.six
@@ -0,0 +1,5 @@
+B+Tree Graph Index 2
+node_ref_lists=0
+key_elements=1
+len=0
+row_lengths=
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/indices/f9604713d4ada772a21468a6846344b2.tix
Binary file not shown
View
7 spec/fixtures/bazaar-repo/.bzr/repository/pack-names
@@ -0,0 +1,7 @@
+B+Tree Graph Index 2
+node_ref_lists=0
+key_elements=1
+len=4
+row_lengths=1
+x�E�;�1 DQ�Y�����
+X�ǖ�����3PE����x����>�����u��űO�&�s]�,�CZpC�~�Lj��u�1�]GZ���ސ�A�G��k���:GL�C��6�����I�t���އwuQ=ߥN�D�� ��1�
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/packs/0eee32389584c19d27fb19f04c01564d.pack
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/packs/16b1053ed12916f4f545020352384e52.pack
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/packs/7ce6129415e312dba7c6ca36ee0f2157.pack
Binary file not shown
View
BIN  spec/fixtures/bazaar-repo/.bzr/repository/packs/f9604713d4ada772a21468a6846344b2.pack
Binary file not shown
View
1  spec/fixtures/bazaar-repo/README
@@ -0,0 +1 @@
+Fourth Commit
View
2  spec/fixtures/mercurial-repo/.hg/cache/tags
@@ -0,0 +1,2 @@
+1 df97b9ee89577f2da1925154472888b2b57e971e
+
Something went wrong with that request. Please try again.