From 53748d3c29614f519e05c35506698115e98b8f4a Mon Sep 17 00:00:00 2001 From: Esteban Date: Sun, 13 Apr 2014 11:51:19 +0200 Subject: [PATCH 1/8] Enabled tag downloader --- lib/cocoapods-downloader/mercurial.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cocoapods-downloader/mercurial.rb b/lib/cocoapods-downloader/mercurial.rb index fef2ce5..02241a3 100644 --- a/lib/cocoapods-downloader/mercurial.rb +++ b/lib/cocoapods-downloader/mercurial.rb @@ -3,7 +3,7 @@ module Downloader class Mercurial < Base def self.options - [:revision] + [:revision, :tag] end def options_specific? @@ -26,6 +26,8 @@ def checkout_options def download! if options[:revision] download_revision! + elsif options[:tag] + download_tag! else download_head! end @@ -38,6 +40,10 @@ def download_head! def download_revision! hg! %|clone "#{url}" --rev '#{options[:revision]}' #{@target_path.shellescape}| end + + def download_tag! + hg! %|clone "#{url}" --updaterev '#{options[:tag]}' #{@target_path.shellescape}| + end end end From ce7e7ef3f70444585ee75612c2318a638c0e66e4 Mon Sep 17 00:00:00 2001 From: Esteban Date: Sun, 13 Apr 2014 12:11:48 +0200 Subject: [PATCH 2/8] Enabled branch downloader --- lib/cocoapods-downloader/mercurial.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/cocoapods-downloader/mercurial.rb b/lib/cocoapods-downloader/mercurial.rb index 02241a3..5529caa 100644 --- a/lib/cocoapods-downloader/mercurial.rb +++ b/lib/cocoapods-downloader/mercurial.rb @@ -3,7 +3,7 @@ module Downloader class Mercurial < Base def self.options - [:revision, :tag] + [:revision, :tag, :branch] end def options_specific? @@ -28,6 +28,8 @@ def download! download_revision! elsif options[:tag] download_tag! + elsif options[:branch] + download_branch! else download_head! end @@ -45,6 +47,9 @@ def download_tag! hg! %|clone "#{url}" --updaterev '#{options[:tag]}' #{@target_path.shellescape}| end + def download_branch! + hg! %|clone "#{url}" --updaterev '#{options[:branch]}' #{@target_path.shellescape}| + end end end end From 50816165c9f8d4c45388432c12a42cf2de3d588d Mon Sep 17 00:00:00 2001 From: Esteban Date: Sun, 13 Apr 2014 12:14:02 +0200 Subject: [PATCH 3/8] Updated documentation --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 0c73152..e680dab 100644 --- a/README.markdown +++ b/README.markdown @@ -30,7 +30,7 @@ The downloader class supports the following option keys: - git: commit, tag, branch, submodules - svn: revision, tag, folder, externals -- hg: revision +- hg: revision, tag, branch - http: type, flatten - bzr: revision, tag From 66ffaab43f26401cd85fecdeeb07b3f175862cc1 Mon Sep 17 00:00:00 2001 From: Esteban Date: Sun, 13 Apr 2014 21:10:42 +0200 Subject: [PATCH 4/8] Adjusted options_specific --- lib/cocoapods-downloader/mercurial.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cocoapods-downloader/mercurial.rb b/lib/cocoapods-downloader/mercurial.rb index 5529caa..dd88249 100644 --- a/lib/cocoapods-downloader/mercurial.rb +++ b/lib/cocoapods-downloader/mercurial.rb @@ -7,7 +7,7 @@ def self.options end def options_specific? - !options[:revision].nil? + !options[:revision].nil? || !options[:tag].nil? end def checkout_options From 968d3238cc4d61a64024e4d0baf573cf8ba3f131 Mon Sep 17 00:00:00 2001 From: Esteban Date: Sun, 13 Apr 2014 21:55:58 +0200 Subject: [PATCH 5/8] Added test commits to mercurial test repository --- spec/fixtures/mercurial-repo/.hg/branch | 1 + .../mercurial-repo/.hg/cache/branch2-served | 4 ++++ .../mercurial-repo/.hg/cache/branchheads | 4 +++- spec/fixtures/mercurial-repo/.hg/cache/tags | 3 ++- spec/fixtures/mercurial-repo/.hg/dirstate | Bin 63 -> 87 bytes .../mercurial-repo/.hg/last-message.txt | 2 +- .../mercurial-repo/.hg/store/00changelog.i | Bin 344 -> 1283 bytes .../mercurial-repo/.hg/store/00manifest.i | Bin 226 -> 587 bytes .../.hg/store/data/_r_e_a_d_m_e.i | Bin 157 -> 312 bytes .../mercurial-repo/.hg/store/data/~2ehgtags.i | Bin 0 -> 112 bytes spec/fixtures/mercurial-repo/.hg/store/fncache | 1 + .../mercurial-repo/.hg/store/phaseroots | 1 + spec/fixtures/mercurial-repo/.hg/store/undo | Bin 52 -> 54 bytes .../mercurial-repo/.hg/store/undo.phaseroots | 1 + spec/fixtures/mercurial-repo/.hg/undo.branch | 2 +- spec/fixtures/mercurial-repo/.hg/undo.desc | 2 +- spec/fixtures/mercurial-repo/.hg/undo.dirstate | Bin 63 -> 87 bytes spec/fixtures/mercurial-repo/.hgtags | 1 + spec/fixtures/mercurial-repo/README | 2 +- 19 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 spec/fixtures/mercurial-repo/.hg/branch create mode 100644 spec/fixtures/mercurial-repo/.hg/cache/branch2-served create mode 100644 spec/fixtures/mercurial-repo/.hg/store/data/~2ehgtags.i create mode 100644 spec/fixtures/mercurial-repo/.hg/store/undo.phaseroots create mode 100644 spec/fixtures/mercurial-repo/.hgtags diff --git a/spec/fixtures/mercurial-repo/.hg/branch b/spec/fixtures/mercurial-repo/.hg/branch new file mode 100644 index 0000000..d74528f --- /dev/null +++ b/spec/fixtures/mercurial-repo/.hg/branch @@ -0,0 +1 @@ +feature/feature-branch diff --git a/spec/fixtures/mercurial-repo/.hg/cache/branch2-served b/spec/fixtures/mercurial-repo/.hg/cache/branch2-served new file mode 100644 index 0000000..a1247cc --- /dev/null +++ b/spec/fixtures/mercurial-repo/.hg/cache/branch2-served @@ -0,0 +1,4 @@ +61118fa8988c2b2eae826f48abd1e3340dae0c6b 6 +df97b9ee89577f2da1925154472888b2b57e971e o default +19118fbb9cfe74d008dc95b4ea5a8ad66e77c2d6 o develop +61118fa8988c2b2eae826f48abd1e3340dae0c6b o feature/feature-branch diff --git a/spec/fixtures/mercurial-repo/.hg/cache/branchheads b/spec/fixtures/mercurial-repo/.hg/cache/branchheads index 205c1f1..c853e17 100644 --- a/spec/fixtures/mercurial-repo/.hg/cache/branchheads +++ b/spec/fixtures/mercurial-repo/.hg/cache/branchheads @@ -1,2 +1,4 @@ -df97b9ee89577f2da1925154472888b2b57e971e 1 +61118fa8988c2b2eae826f48abd1e3340dae0c6b 6 df97b9ee89577f2da1925154472888b2b57e971e default +19118fbb9cfe74d008dc95b4ea5a8ad66e77c2d6 develop +61118fa8988c2b2eae826f48abd1e3340dae0c6b feature/feature-branch diff --git a/spec/fixtures/mercurial-repo/.hg/cache/tags b/spec/fixtures/mercurial-repo/.hg/cache/tags index 37cc8a2..16a1321 100644 --- a/spec/fixtures/mercurial-repo/.hg/cache/tags +++ b/spec/fixtures/mercurial-repo/.hg/cache/tags @@ -1,2 +1,3 @@ -1 df97b9ee89577f2da1925154472888b2b57e971e +6 61118fa8988c2b2eae826f48abd1e3340dae0c6b bb28287c416162ff25dc683f54ea1b473ff9a535 +3c8b8d211b03c7e686049a8558e4c297104291eb 1.0.0 diff --git a/spec/fixtures/mercurial-repo/.hg/dirstate b/spec/fixtures/mercurial-repo/.hg/dirstate index 290ab068e7376703f25834beca169d3d0e1f69fc..81b6f6964bf33ac2937076dfaf41c70a92e736c2 100644 GIT binary patch literal 87 zcmYck>|ZgXM_X@QQ@+RQi;qos*YRXCU;%jy42?^G;=I9LFYJLdTac@xi?1t8SU=e7 Q`9h#DyIw|mNn(020ItUrg#Z8m literal 63 zcmcaVedoK*@Os^alLABBH99tJt(z{#fCc0+Ff=X!iu3s$yK@vsvjw?2y7;;R0BvUw A9RL6T diff --git a/spec/fixtures/mercurial-repo/.hg/last-message.txt b/spec/fixtures/mercurial-repo/.hg/last-message.txt index 7ea28ec..de5ae73 100644 --- a/spec/fixtures/mercurial-repo/.hg/last-message.txt +++ b/spec/fixtures/mercurial-repo/.hg/last-message.txt @@ -1 +1 @@ -Second commit \ No newline at end of file +Added fourth commit \ No newline at end of file diff --git a/spec/fixtures/mercurial-repo/.hg/store/00changelog.i b/spec/fixtures/mercurial-repo/.hg/store/00changelog.i index a1c5fa00ad9cac8b668e50cbe4060ecec04c658a..c34a601e8b0afb35eb726ee026062a065daf6319 100644 GIT binary patch delta 954 zcmcb?)XcRZg0Y?f1a5%IQXts|#7t1k_#X%?t~^n%Gg)+vh%a7|bCyCeRtoQ$B{d@Cd`R~sy|TCY713`{SmT;tz+P2HP9*U)kI|T>AH}q1Cw~(=AFFIBMqC zC$srUYreC;+pFyZavkFXup9e<v9L2YbFwjOY_T#kbL)~tNA^77S-s`Tkx7>ph16=Si3sMSH|(Tqux zW-V%1#lUcAzl1KxK&I_rV|#!kDD|*GaXl-@C5eLlD`xa)>#b|b_gH=Lu?g=wo@}sk zC;?35J*R=mMZop@&#s@0!JjXbcxj53-1PmgaI%L#fO(S6ukWI_uG-4*UEg&;&1_oE zm9_~J_mnZp_MK987uA$l8mir9TDw5M{rfT8we;a))zV&C*sTtdh+5_0;hF;&5 xxv*&0I>kA)bMlpc$MEg@v;9}*N4Z`9OgSzJ8XlZ+YGS%Y|2EZn#)rkRzwFC`8<9g;P7Y8M6T_tcjRgmOj(^TpZS${ z6WECJU=nCK(C%!AGstrHeKsLi4%yC|yQq5le5rW{&u$hH11m=mpkM+y+5qZv tGs7eUa}yIwLnAX&OLNO43j-sQWb-7G#AJ)))HI94M3dAMi&RSsE&$u+XNdp+ delta 6 NcmX@j@`!Q5BLE6%10?_e diff --git a/spec/fixtures/mercurial-repo/.hg/store/data/_r_e_a_d_m_e.i b/spec/fixtures/mercurial-repo/.hg/store/data/_r_e_a_d_m_e.i index b9d6efee6973dc407b15459ebeac757b19795783..fc4d00c1f2244350655ecc4e3e1829593cd814d6 100644 GIT binary patch delta 163 zcmbQsxPxiJ+HN@CR&)9TBMpJ8(Eqg8kiVa8m1;G80s158E^prZ^s=3 literal 0 HcmV?d00001 diff --git a/spec/fixtures/mercurial-repo/.hg/store/fncache b/spec/fixtures/mercurial-repo/.hg/store/fncache index fb1271b..1142a74 100644 --- a/spec/fixtures/mercurial-repo/.hg/store/fncache +++ b/spec/fixtures/mercurial-repo/.hg/store/fncache @@ -1 +1,2 @@ +data/.hgtags.i data/README.i diff --git a/spec/fixtures/mercurial-repo/.hg/store/phaseroots b/spec/fixtures/mercurial-repo/.hg/store/phaseroots index e69de29..7371ad3 100644 --- a/spec/fixtures/mercurial-repo/.hg/store/phaseroots +++ b/spec/fixtures/mercurial-repo/.hg/store/phaseroots @@ -0,0 +1 @@ +1 38d4e4277e34a2d7026f1dcccfe2c5b63ea24a05 diff --git a/spec/fixtures/mercurial-repo/.hg/store/undo b/spec/fixtures/mercurial-repo/.hg/store/undo index 0e714c8de7ebd61db92e1355733d01af6f8c024d..1b227eca720aa51920a636ab5c0d59223fc3d645 100644 GIT binary patch literal 54 zcmYdEEJ@T4a&>g^b=AvcFfumbGBC(Z%*#wmEiM5Hn3x#@1(Guo^U_mu^3#DLh6d)A FTmY*24g^b=AvcFt^|`Fvv~J%S=lxE&=il4UK^U$r*`x>8UyS=^zmcBQ5}t Cj1IW~ diff --git a/spec/fixtures/mercurial-repo/.hg/store/undo.phaseroots b/spec/fixtures/mercurial-repo/.hg/store/undo.phaseroots new file mode 100644 index 0000000..7371ad3 --- /dev/null +++ b/spec/fixtures/mercurial-repo/.hg/store/undo.phaseroots @@ -0,0 +1 @@ +1 38d4e4277e34a2d7026f1dcccfe2c5b63ea24a05 diff --git a/spec/fixtures/mercurial-repo/.hg/undo.branch b/spec/fixtures/mercurial-repo/.hg/undo.branch index 331d858..02bbe12 100644 --- a/spec/fixtures/mercurial-repo/.hg/undo.branch +++ b/spec/fixtures/mercurial-repo/.hg/undo.branch @@ -1 +1 @@ -default \ No newline at end of file +feature/feature-branch \ No newline at end of file diff --git a/spec/fixtures/mercurial-repo/.hg/undo.desc b/spec/fixtures/mercurial-repo/.hg/undo.desc index d678f64..8320ff1 100644 --- a/spec/fixtures/mercurial-repo/.hg/undo.desc +++ b/spec/fixtures/mercurial-repo/.hg/undo.desc @@ -1,2 +1,2 @@ -1 +6 commit diff --git a/spec/fixtures/mercurial-repo/.hg/undo.dirstate b/spec/fixtures/mercurial-repo/.hg/undo.dirstate index e7b7e86ae133418d99fda0945461ed62487b6420..7f80253e76638d242aee47ae0f93d13d853f3e17 100644 GIT binary patch literal 87 zcmey|u#NR&naC{3fRasLxgP#xc(2UFfCc0+Ff=X!it_|}J?jV3Y(cJ$F21fXVf|pQ Q=L>h?B2Y7nwRLbtJ*1R_O>Z`KdHFGfCc0+Ff=X!iu3v%yLbRdvjw?2y7;;R08F$G A$p8QV diff --git a/spec/fixtures/mercurial-repo/.hgtags b/spec/fixtures/mercurial-repo/.hgtags new file mode 100644 index 0000000..161d42b --- /dev/null +++ b/spec/fixtures/mercurial-repo/.hgtags @@ -0,0 +1 @@ +3c8b8d211b03c7e686049a8558e4c297104291eb 1.0.0 diff --git a/spec/fixtures/mercurial-repo/README b/spec/fixtures/mercurial-repo/README index 2ff0cc0..6afa1ed 100644 --- a/spec/fixtures/mercurial-repo/README +++ b/spec/fixtures/mercurial-repo/README @@ -1 +1 @@ -second commit +fourth commit \ No newline at end of file From 989e377a78ecbb2788e99621d31ecacbaef277c7 Mon Sep 17 00:00:00 2001 From: Esteban Date: Sun, 13 Apr 2014 21:56:33 +0200 Subject: [PATCH 6/8] Added tests for specific options --- spec/mercurial_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/mercurial_spec.rb b/spec/mercurial_spec.rb index 6e1d81d..b27bed5 100644 --- a/spec/mercurial_spec.rb +++ b/spec/mercurial_spec.rb @@ -51,6 +51,8 @@ module Downloader it "returns whether the provided options are specific" do Downloader.for_target('path', :hg => 'url').options_specific?.should.be.false Downloader.for_target('path', :hg => 'url', :revision => '').options_specific?.should.be.true + Downloader.for_target('path', :hg => 'url', :tag => '').options_specific?.should.be.true + Downloader.for_target('path', :hg => 'url', :branch => '').options_specific?.should.be.false end it "raises if it fails to download" do From ab16bb135c48a9b33a78d137d02b4448475ba628 Mon Sep 17 00:00:00 2001 From: Esteban Date: Sun, 13 Apr 2014 21:56:58 +0200 Subject: [PATCH 7/8] Added tests for specific tag and branch --- spec/mercurial_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/spec/mercurial_spec.rb b/spec/mercurial_spec.rb index b27bed5..bb8cd27 100644 --- a/spec/mercurial_spec.rb +++ b/spec/mercurial_spec.rb @@ -36,6 +36,21 @@ module Downloader downloader.download tmp_folder_with_quotes('README').read.strip.should == 'second commit' end + + it "checks out a specific tag" do + options = { :hg => fixture('mercurial-repo'), :tag => '1.0.0' } + downloader = Downloader.for_target(tmp_folder_with_quotes, options) + downloader.download + tmp_folder_with_quotes('README').read.strip.should == 'third commit' + end + + it "checks out the branch head revision" do + options = { :hg => fixture('mercurial-repo'), :branch => 'feature/feature-branch' } + downloader = Downloader.for_target(tmp_folder_with_quotes, options) + downloader.download + tmp_folder_with_quotes('README').read.strip.should == 'fourth commit' + end + end it "returns the checked out revision" do @@ -60,6 +75,27 @@ module Downloader downloader = Downloader.for_target(tmp_folder, options) lambda { downloader.download }.should.raise DownloaderError end + + it "checks out a specific tag" do + options = { :hg => fixture('mercurial-repo'), :tag => '1.0.0'} + downloader = Downloader.for_target(tmp_folder, options) + downloader.download + downloader.checkout_options.should == { + :hg => fixture('mercurial-repo'), + :revision => '3c8b8d211b03c7e686049a8558e4c297104291eb' + } + end + + it "checks out a specific branch head" do + options = { :hg => fixture('mercurial-repo'), :branch => 'feature/feature-branch'} + downloader = Downloader.for_target(tmp_folder, options) + downloader.download + downloader.checkout_options.should == { + :hg => fixture('mercurial-repo'), + :revision => '61118fa8988c2b2eae826f48abd1e3340dae0c6b' + } + end + end end end From aa750ca0de93726caf574fc6a0c75ecb74173191 Mon Sep 17 00:00:00 2001 From: Esteban Date: Sun, 13 Apr 2014 23:02:54 +0200 Subject: [PATCH 8/8] Added issues #16 and #17 to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 503bc01..ab44dbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Master +* Added support for `:tag` option in mercurial sources. [Esteban Bouza](https://github.com/estebanbouza) [#16](https://github.com/CocoaPods/cocoapods-downloader/issues/16) +* Added support for `:branch` option in mercurial sources. [Esteban Bouza](https://github.com/estebanbouza) [#17](https://github.com/CocoaPods/cocoapods-downloader/issues/17) + ## 0.4.1 * add shellescape for some path arguments in git.rb