cocoapods-repo-svn 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0e85705bfb49fdd94c310abfbcb0ef1eff7656c
4
- data.tar.gz: 119a76f6e3520135405ccfd6abca17f210788314
3
+ metadata.gz: ef72244ce3690f9819e04929b626cad1550b8cc6
4
+ data.tar.gz: 5e457b5c8da32545f90a15b8b421c8635e8c8b0f
5
5
  SHA512:
6
- metadata.gz: 1b22e0739d38dc173badfb7bddd038012fbfa22c36721a93268203c617d62bab0215ae7648cf2235117dfc18f34d9fe40c9e157c04cf722e7cffa01394ea0ff4
7
- data.tar.gz: 6e5b77f1b76039e70cf8b3dc3dc64ababbe599d17eb534b2c265f1b678a4cc63ee23e6da4f07072f2b41d8727200eb9a17417359073c53042c2ac60ac117849f
6
+ metadata.gz: 3323845179ad5cd7b25cae6acf571f3e375d86c8c6792037464be0df585de19e0d1de7060642b60e05717027cf8c4e0839f501b67fac550b44aa0bd08cf8f76a
7
+ data.tar.gz: ceeb04bc980c4cf2529f43b114451c9c675c5c598a2c1452ea16808fd1018ac67e96f7f26c1a8e1fb693c55ee6e053da1629922b276d84624c62195e5e7357f1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Cocoapods::repo-svn changelog
2
2
 
3
+ # Master
4
+
5
+ * Add support for new source provider plugin hook (CocoaPods [#3792](https://github.com/CocoaPods/CocoaPods/pull/3792))
6
+
3
7
  ## 0.1.1
4
8
 
5
9
  * Migrating to new CLAide::Arguments (CocoaPods/CLAide#33)
data/README.md CHANGED
@@ -13,7 +13,9 @@ Our team had been using a in house fork of Cocoapods with svn, bzr, and hg spec-
13
13
 
14
14
  $ gem install cocoapods-repo-svn
15
15
 
16
- ## Usage
16
+ # Usage
17
+
18
+ ## Commands
17
19
 
18
20
  Add
19
21
 
@@ -27,6 +29,15 @@ Remove
27
29
 
28
30
  $ pod repo-svn remove my-svn-repo
29
31
 
32
+ ## Podfile integration
33
+
34
+ To include your sources in the install phase of your project, do the following:
35
+ ```ruby
36
+ plugin 'cocoapods-repo-svn', :sources => [
37
+ 'https://svn.myrepository.com'
38
+ ]
39
+ ```
40
+
30
41
 
31
42
  ## Contributing
32
43
 
@@ -1 +1,54 @@
1
- require 'pod/command/repo_svn'
1
+ require 'pod/command/repo_svn'
2
+ require 'svn_source'
3
+
4
+ # This pre_install hook requires cocoapods v. 0.38.0.beta.2 or higher
5
+ Pod::HooksManager.register('cocoapods-repo-svn', :source_provider) do |context, options|
6
+ Pod::UI.message 'cocoapods-repo-svn received source_provider hook'
7
+ return unless sources = options['sources']
8
+ sources.each do |url|
9
+ source = create_source_with_url(url)
10
+ update_or_add_source(source)
11
+ context.add_source(source)
12
+ end
13
+ end
14
+
15
+ # @param [Source] source The source to add or update
16
+ #
17
+ # @return [Void]
18
+ #
19
+ def update_or_add_source(source)
20
+ name = source.name
21
+ url = source.url
22
+ dir = source.repo
23
+
24
+ if dir.exist?
25
+ argv = CLAide::ARGV.new([name])
26
+ cmd = Pod::Command::RepoSvn::Update.new(argv)
27
+ else
28
+ argv = CLAide::ARGV.new([name, url])
29
+ cmd = Pod::Command::RepoSvn::Add.new(argv)
30
+ end
31
+
32
+ cmd.run()
33
+ end
34
+
35
+ # @param [String] url The URL of the SVN repository
36
+ #
37
+ # @return [String] a name for the repository
38
+ #
39
+ # For now, this uses the last component of the URL as the name
40
+ # So https://my.server.com/somedir/Specs will return Specs
41
+ def name_for_url(url)
42
+ return nil unless url
43
+ delim = '/'
44
+ components = url.split(delim)
45
+ components.last
46
+ end
47
+
48
+
49
+ def create_source_with_url(url)
50
+ name = name_for_url(url)
51
+ repos_dir = Pod::Config.instance.repos_dir
52
+ repo = repos_dir + name
53
+ Pod::SvnSource.new(repo,url)
54
+ end
@@ -37,7 +37,8 @@ module Pod
37
37
  config.repos_dir.mkpath
38
38
  Dir.chdir(config.repos_dir) do
39
39
  command = "checkout --non-interactive --trust-server-cert '#{@url}' #{@name}"
40
- !svn(command)
40
+ #!svn(command)
41
+ `svn #{command}`
41
42
  end
42
43
  SourcesManager.check_version_information(dir) #todo: TEST ME
43
44
  end
@@ -103,7 +104,8 @@ module Pod
103
104
  UI.section "Updating spec repo `#{source.name}`" do
104
105
  Dir.chdir(source.repo) do
105
106
  begin
106
- output = svn!('up --non-interactive --trust-server-cert')
107
+ #output = svn('up --non-interactive --trust-server-cert')
108
+ output = `svn up --non-interactive --trust-server-cert`
107
109
  UI.puts output if show_output && !config.verbose?
108
110
  rescue Informative => e
109
111
  UI.warn 'CocoaPods was not able to update the ' \
@@ -150,7 +152,7 @@ module Pod
150
152
  # @return [Bool] Whether the given source is a SVN repo.
151
153
  #
152
154
  def svn_repo?(dir)
153
- Dir.chdir(dir) { svn('info >/dev/null 2>&1') }
155
+ Dir.chdir(dir) { `svn info > /dev/null` }
154
156
  $?.success?
155
157
  end
156
158
  end
@@ -278,6 +280,115 @@ module Pod
278
280
  end
279
281
  end
280
282
 
283
+ #-----------------------------------------------------------------------#
284
+ #
285
+ # Pushes a podspec to the specified repo
286
+ #
287
+ # Most of this was taken directly from the CocoaPods `push` command
288
+
289
+ class Push < RepoSvn
290
+ self.summary = 'Push a podspec'
291
+
292
+ self.description = <<-DESC
293
+ Validates `NAME.podspec` or `*.podspec` in the current working dir, creates a
294
+ directory and version folder for the pod in the local copy of `REPO`
295
+ (~/.cocoapods/repos/[REPO]), copies the podspec file into the version directory,
296
+ and finally it commits the changes to `REPO`
297
+ DESC
298
+
299
+ self.arguments = [
300
+ CLAide::Argument.new('REPO', true),
301
+ CLAide::Argument.new('NAME.podspec', false)
302
+ ]
303
+
304
+ def self.options
305
+ [['--local-only', 'Does not perform the step of committing changes to REPO']].concat(super)
306
+ end
307
+
308
+ def initialize(argv)
309
+ @local_only = argv.flag?('local-only')
310
+ @repo = argv.shift_argument
311
+ @podspec = argv.shift_argument
312
+ super
313
+ end
314
+
315
+ def validate!
316
+ super
317
+ help! 'A spec-repo name is required.' unless @repo
318
+ end
319
+
320
+ def run
321
+ update_repo
322
+ add_specs_to_repo
323
+ end
324
+
325
+ # Updates the git repo against the remote.
326
+ #
327
+ # @return [void]
328
+ #
329
+ def update_repo
330
+ UI.puts "Updating the `#{@repo}' repo\n".yellow
331
+ Dir.chdir(repo_dir) { UI.puts `svn update .` }
332
+ end
333
+
334
+ def add_specs_to_repo
335
+ UI.puts "\nAdding the #{'spec'.pluralize(podspec_files.count)} to the `#{@repo}' repo\n".yellow
336
+ podspec_files.each do |spec_file|
337
+ spec = Pod::Specification.from_file(spec_file)
338
+ output_path = File.join(repo_dir, spec.name, spec.version.to_s)
339
+ if Pathname.new(output_path).exist?
340
+ message = "[Fix] #{spec}"
341
+ elsif Pathname.new(File.join(repo_dir, spec.name)).exist?
342
+ message = "[Update] #{spec}"
343
+ else
344
+ message = "[Add] #{spec}"
345
+ end
346
+
347
+ FileUtils.mkdir_p(output_path)
348
+ FileUtils.cp(spec_file, output_path)
349
+ if !@local_only
350
+ Dir.chdir(repo_dir) do
351
+ # only commit if modified
352
+ UI.puts "Committing changes"
353
+ UI.puts `svn add #{spec.name} 2> /dev/null`
354
+ UI.puts `svn commit -m "#{message}"`
355
+ end
356
+ end
357
+ end
358
+ end
359
+
360
+ private
361
+
362
+ # @return [Array<Pathname>] The path of the specifications to push.
363
+ #
364
+ def podspec_files
365
+ if @podspec
366
+ path = Pathname(@podspec)
367
+ raise Informative, "Couldn't find #{@podspec}" unless path.exist?
368
+ [path]
369
+ else
370
+ files = Pathname.glob('*.podspec{,.json}')
371
+ raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
372
+ files
373
+ end
374
+ end
375
+
376
+ # @return [Pathname] The directory of the repository.
377
+ #
378
+ def repo_dir
379
+ specs_dir = Pathname.new(File.join(config.repos_dir, @repo, 'Specs'))
380
+ dir = config.repos_dir + @repo
381
+ if specs_dir.exist?
382
+ dir = specs_dir
383
+ elsif dir.exist?
384
+ dir
385
+ else
386
+ raise Informative, "`#{@repo}` repo not found either in #{specs_dir} or #{dir}"
387
+ end
388
+ dir
389
+ end
390
+ end
391
+
281
392
  extend Executable
282
393
  executable :svn
283
394
 
@@ -1,3 +1,3 @@
1
1
  module RepoSvnExt
2
- VERSION = '1.1.0'
2
+ VERSION = '2.0.0'
3
3
  end
data/lib/svn_source.rb ADDED
@@ -0,0 +1,18 @@
1
+ module Pod
2
+ # Subclass of Pod::Source to provide support for SVN Specs repositories
3
+ #
4
+ class SvnSource < Source
5
+ # @return [String] The remote URL of the repository
6
+ #
7
+ attr_accessor :url
8
+
9
+ # @param [String] repo The name of the repository (aka. directory name)
10
+ #
11
+ # @param [String] url see {#url}
12
+ #
13
+ def initialize(repo, url)
14
+ super(repo)
15
+ @url = url
16
+ end
17
+ end
18
+ end
@@ -1,7 +1,12 @@
1
1
  require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
+ # https://github.com/clarkda/CocoaPods/blob/master/spec/functional/command/repo/add_spec.rb
4
+
3
5
  module Pod
4
6
  describe Command::RepoSvn::Add do
7
+ extend SpecHelper::Command
8
+ extend SpecHelper::TemporaryRepos
9
+
5
10
  it 'returns the proper command class' do
6
11
  Command.parse(%w( repo-svn add )).should.be.instance_of Command::RepoSvn::Add
7
12
  end
@@ -10,5 +15,11 @@ module Pod
10
15
  command = Command.parse(%w( repo-svn add ))
11
16
  lambda { command.validate! }.should.raise CLAide::InformativeError
12
17
  end
18
+
19
+ it 'adds a svn spec repo' do
20
+ set_up_test_repo
21
+ puts tmp_svn_path
22
+ run_command('repo-svn', 'add', 'private', tmp_svn_path)
23
+ end
13
24
  end
14
- end
25
+ end
@@ -12,8 +12,8 @@ module Pod
12
12
  lambda { command.validate! }.should.raise CLAide::InformativeError
13
13
  end
14
14
 
15
- it 'updates a repository' do
16
- #
17
- end
15
+ # it 'updates a repository' do
16
+ # #
17
+ # end
18
18
  end
19
- end
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,12 +4,15 @@ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
4
4
 
5
5
  require 'bundler/setup'
6
6
  require 'bacon'
7
+ require 'fileutils'
7
8
  require 'mocha-on-bacon'
8
9
  require 'pretty_bacon'
9
10
  require 'cocoapods'
10
11
 
11
12
  require 'cocoapods_plugin'
12
13
 
14
+ require 'spec_helper/command'
15
+ require 'spec_helper/temporary_repos'
13
16
  #-----------------------------------------------------------------------------#
14
17
 
15
18
  module Pod
@@ -0,0 +1,30 @@
1
+
2
+ # spec/spec_helper/command.rb
3
+
4
+ module SpecHelper
5
+ module Command
6
+ def argv(*argv)
7
+ CLAide::ARGV.new(argv)
8
+ end
9
+
10
+ def command(*argv)
11
+ argv << '--no-ansi'
12
+ Pod::Command.parse(argv)
13
+ end
14
+
15
+ def run_command(*args)
16
+ Dir.chdir(SpecHelper.temporary_directory) do
17
+ Pod::UI.output = ''
18
+ # @todo Remove this once all cocoapods has
19
+ # been converted to use the UI.puts
20
+ # config_silent = config.silent?
21
+ # config.silent = false
22
+ cmd = command(*args)
23
+ cmd.validate!
24
+ cmd.run
25
+ # config.silent = config_silent
26
+ Pod::UI.output
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,49 @@
1
+ module SpecHelper
2
+ def self.tmp_repos_path
3
+ TemporaryRepos.tmp_repos_path
4
+ end
5
+
6
+ module TemporaryRepos
7
+ extend Pod::Executable
8
+ executable :svn
9
+
10
+ # ..
11
+
12
+ def make_svn_repo
13
+ return unless !File.directory?(tmp_svn_path)
14
+ `svnadmin create #{tmp_svn_path}`
15
+ `svn import #{tmp_repos_path} file://#{tmp_svn_path} -m "import"`
16
+ end
17
+
18
+ # ..
19
+
20
+ def set_up_test_repo()
21
+ tmp_repos_path.mkpath
22
+ origin = ROOT + 'spec/fixtures/spec-repos/test-repo/'
23
+ destination = tmp_repos_path
24
+ FileUtils.cp_r(origin, destination)
25
+ make_svn_repo
26
+ end
27
+
28
+ # ..
29
+
30
+ def tmp_repos_path
31
+ SpecHelper.temporary_directory + 'cocoapods/repos/master'
32
+ end
33
+
34
+ # ..
35
+
36
+ def tmp_svn_path
37
+ SpecHelper.temporary_directory + 'svn'
38
+ end
39
+
40
+ module_function :tmp_repos_path
41
+
42
+ def self.extended(base)
43
+ base.before do
44
+ tmp_repos_path.mkpath
45
+ end
46
+ end
47
+
48
+ end
49
+ end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-repo-svn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Clark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-04 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: CocoaPod plugin to add subversion support for spec repositories
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - CHANGELOG.md
50
50
  - Gemfile
51
51
  - LICENSE
@@ -55,6 +55,7 @@ files:
55
55
  - lib/pod/command/repo_svn.rb
56
56
  - lib/repo_svn_ext.rb
57
57
  - lib/repo_svn_ext/version.rb
58
+ - lib/svn_source.rb
58
59
  - repo_svn_ext.gemspec
59
60
  - spec/command/repo-svn/add_spec.rb
60
61
  - spec/command/repo-svn/remove_spec.rb
@@ -65,7 +66,8 @@ files:
65
66
  - spec/fixtures/spec-repos/test-repo/JSONKit/999.999.999/JSONKit.podspec
66
67
  - spec/fixtures/spec-repos/test-repo/Pod+With+Plus+Signs/1.0/Pod+With+Plus+Signs.podspec
67
68
  - spec/spec_helper.rb
68
- - spec/spec_helper/svn.rb
69
+ - spec/spec_helper/command.rb
70
+ - spec/spec_helper/temporary_repos.rb
69
71
  homepage: https://github.com/clarkda/cocoapods-repo-svn
70
72
  licenses:
71
73
  - MIT
@@ -76,17 +78,17 @@ require_paths:
76
78
  - lib
77
79
  required_ruby_version: !ruby/object:Gem::Requirement
78
80
  requirements:
79
- - - '>='
81
+ - - ">="
80
82
  - !ruby/object:Gem::Version
81
83
  version: '0'
82
84
  required_rubygems_version: !ruby/object:Gem::Requirement
83
85
  requirements:
84
- - - '>='
86
+ - - ">="
85
87
  - !ruby/object:Gem::Version
86
88
  version: '0'
87
89
  requirements: []
88
90
  rubyforge_project:
89
- rubygems_version: 2.0.14
91
+ rubygems_version: 2.4.3
90
92
  signing_key:
91
93
  specification_version: 4
92
94
  summary: Subversion support for spec repository
@@ -100,4 +102,6 @@ test_files:
100
102
  - spec/fixtures/spec-repos/test-repo/JSONKit/999.999.999/JSONKit.podspec
101
103
  - spec/fixtures/spec-repos/test-repo/Pod+With+Plus+Signs/1.0/Pod+With+Plus+Signs.podspec
102
104
  - spec/spec_helper.rb
103
- - spec/spec_helper/svn.rb
105
+ - spec/spec_helper/command.rb
106
+ - spec/spec_helper/temporary_repos.rb
107
+ has_rdoc:
@@ -1,61 +0,0 @@
1
-
2
- #
3
- # https://github.com/CocoaPods/CocoaPods/blob/master/spec/spec_helper/temporary_repos.rb
4
- #
5
-
6
- module SpecHelper
7
- def self.tmp_repos_path
8
- TempSvnRepo.tmp_repos_path
9
- end
10
-
11
- module TempSvnRepo
12
- extend Pod::Executable
13
- executable :svn
14
-
15
- #
16
- # Copy test-repo to temp location and initialize local svn repository
17
- #
18
- def repo_make(name)
19
- path = repo_path(name)
20
- path.mkpath
21
- Dir.chdir(path) do
22
- `echo stuff`
23
- end
24
- path
25
- end
26
-
27
- #
28
- # @return [Pathname] The path for the repo with the given name.
29
- #
30
- def repo_path(name)
31
- tmp_repos_path + name
32
- end
33
-
34
- # Sets up a lightweight svn master repo in `tmp/cocoapods/repos/master` with the
35
- # contents of `spec/fixtures/spec-repos/test_repo`.
36
- #
37
- def set_up_test_repo
38
- # require 'fileutils'
39
- # test_repo_path.mkpath
40
- # origin = ROOT + 'spec/fixtures/spec-repos/test_repo/.'
41
- # destination = tmp_repos_path + 'master'
42
- # FileUtils.cp_r(origin, destination)
43
- # repo_make('master')
44
- end
45
-
46
- #--------------------------------------#
47
-
48
- def tmp_repos_path
49
- SpecHelper.temporary_directory + 'cocoapods/repos'
50
- end
51
-
52
- module_function :tmp_repos_path
53
-
54
- def self.extended(base)
55
- base.before do
56
- tmp_repos_path.mkpath
57
- end
58
- end
59
-
60
- end
61
- end