mirror_github 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f9f2fc1eed1e6c4e09659fa23f48240298ef89da
4
+ data.tar.gz: 28abbdba2fe7bc13af8d952a957724ed60e236d7
5
+ SHA512:
6
+ metadata.gz: 1c29536b1971bcfefc10d971e2cff6fbb3a76515312a72600ef2fcac0d7609f812eb3d7d5d738dd43fbdc9dc1b6174dca15fdd1bfa6a8aa2c065e46bc3c4d3f9
7
+ data.tar.gz: 3138948be00c511fce07b43e76de9c74394522a0142fba104a614d2162d092a2c8552e9a6886046981e064e1e8f9cbc7bbb0b621195c1cee6fede83e19b5ca0c
data/README.rdoc CHANGED
@@ -17,6 +17,8 @@ Create a mirror_github_config.yml that contains your GitHub username, password,
17
17
 
18
18
  Obviously, the user credentials you define in this file need to have access to the specified organization.
19
19
 
20
+ Note: you can [create a personal token](https://github.com/blog/1509-personal-api-tokens) instead of using your username and password. Use it for your username and leave password blank.
21
+
20
22
  Then:
21
23
 
22
24
  mirror_github --config-file=/path/to/your/mirror_github_config.yml --backup-dir=/path/to/github/mirror/directory
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require 'bundler/gem_tasks'
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
@@ -20,18 +20,31 @@ module MirrorGithub
20
20
  end
21
21
 
22
22
  # Return a list of the current repositories for an organization
23
- def repositories(limit = 100000)
23
+ def repositories(limit = 100)
24
24
  return [] unless org
25
25
 
26
- # Github defaults to paginating with 30 repos per page. This is really not what we want
27
- # when we're trying to back up all of our repos!
28
- JSON::parse(connection["orgs/#{org}/repos?per_page=#{limit}"].get).collect do |repo_hash|
29
- Repository.new(:ssh_url => repo_hash['ssh_url'],
30
- :private => repo_hash['private'],
31
- :created_at => repo_hash["created_at"],
32
- :pushed_at => repo_hash["pushed_at"],
33
- :name => repo_hash["name"])
26
+ got_results = true
27
+ page = 1
28
+ repos = []
29
+
30
+ while got_results do
31
+ # Github maxes out at 100 repos per page.
32
+ page_repos = JSON::parse(connection["orgs/#{org}/repos?per_page=#{limit}&page=#{page}"].get).collect do |repo_hash|
33
+ Repository.new(:ssh_url => repo_hash['ssh_url'],
34
+ :private => repo_hash['private'],
35
+ :created_at => repo_hash["created_at"],
36
+ :pushed_at => repo_hash["pushed_at"],
37
+ :name => repo_hash["name"])
38
+ end
39
+ if page_repos.empty?
40
+ got_results = false
41
+ else
42
+ repos += page_repos
43
+ end
44
+ page += 1
34
45
  end
46
+
47
+ repos
35
48
  end
36
49
 
37
50
 
@@ -1,3 +1,3 @@
1
1
  module MirrorGithub
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency 'rest-client'
19
19
  s.add_dependency 'json_pure'
20
20
 
21
+ s.add_development_dependency 'rake'
22
+ s.add_development_dependency 'minitest'
21
23
  s.add_development_dependency 'fakeweb'
22
24
 
23
25
  s.files = `git ls-files`.split("\n")
@@ -1,9 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
- class MirrorGithub::ConfigurationTest < Test::Unit::TestCase
3
+ class MirrorGithub::ConfigurationTest < MiniTest::Unit::TestCase
4
4
 
5
5
  def test_config_file_default
6
- assert_not_nil MirrorGithub::Configuration.config_file_path
6
+ assert MirrorGithub::Configuration.config_file_path
7
7
  end
8
8
 
9
9
  def test_loads_config_file
data/test/git_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class MirrorGithub::GitTest < Test::Unit::TestCase
3
+ class MirrorGithub::GitTest < MiniTest::Unit::TestCase
4
4
 
5
5
  def setup
6
6
  @tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp'))
@@ -14,7 +14,7 @@ class MirrorGithub::GitTest < Test::Unit::TestCase
14
14
 
15
15
  def test_initialize_raises_error_if_directory_does_not_exist
16
16
  r = MirrorGithub::Repository.new(:ssh_url => 'ssh://git@github.com:test')
17
- assert_raise RuntimeError do
17
+ assert_raises RuntimeError do
18
18
  MirrorGithub::Git.new('sdfl9ij390', r)
19
19
  end
20
20
  end
data/test/github_test.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  require 'test_helper'
2
2
  require 'fakeweb'
3
3
 
4
- class MirrorGithub::GithubTest < Test::Unit::TestCase
4
+ class MirrorGithub::GithubTest < MiniTest::Unit::TestCase
5
5
 
6
6
  def setup
7
7
  FakeWeb.allow_net_connect = false
8
8
  FakeWeb.register_uri(:get, MirrorGithub::Github.api_url, :body => "Unauthorized", :status => ["401", "Unauthorized"])
9
- FakeWeb.register_uri(:get, 'https://johnnytest:sOOperSecret@api.github.com/orgs/parent_org/repos', :body => organization_json, :content_type => "application/json")
9
+ FakeWeb.register_uri(:get, 'https://johnnytest:sOOperSecret@api.github.com/orgs/parent_org/repos?per_page=100&page=1', :body => organization_json, :content_type => "application/json")
10
+ FakeWeb.register_uri(:get, 'https://johnnytest:sOOperSecret@api.github.com/orgs/parent_org/repos?per_page=100&page=2', :body => '[]', :content_type => "application/json")
10
11
  end
11
12
 
12
13
  def teardown
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class MirrorGithub::RepositoryTest < Test::Unit::TestCase
3
+ class MirrorGithub::RepositoryTest < MiniTest::Unit::TestCase
4
4
 
5
5
  def test_initialize
6
6
  r = MirrorGithub::Repository.new(:ssh_url => "ssh_url", :private => true)
data/test/test_helper.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  $: << File.expand_path(File.dirname(__FILE__))
3
3
 
4
4
  require 'rubygems'
5
- require 'test/unit'
6
- require 'lib/mirror_github'
5
+ require 'minitest/autorun'
6
+ require 'mirror_github'
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mirror_github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Casey Dreier
@@ -10,54 +9,76 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-02-18 00:00:00.000000000 Z
12
+ date: 2013-10-18 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rest-client
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: json_pure
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
45
68
  - !ruby/object:Gem::Version
46
69
  version: '0'
47
70
  - !ruby/object:Gem::Dependency
48
71
  name: fakeweb
49
72
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
73
  requirements:
52
- - - ! '>='
74
+ - - '>='
53
75
  - !ruby/object:Gem::Version
54
76
  version: '0'
55
77
  type: :development
56
78
  prerelease: false
57
79
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
80
  requirements:
60
- - - ! '>='
81
+ - - '>='
61
82
  - !ruby/object:Gem::Version
62
83
  version: '0'
63
84
  description: Command-line library for mirroring an Organization's GitHub repositories
@@ -93,26 +114,25 @@ files:
93
114
  homepage: https://github.com/singlebrook/mirror_github
94
115
  licenses:
95
116
  - BSD
117
+ metadata: {}
96
118
  post_install_message:
97
119
  rdoc_options: []
98
120
  require_paths:
99
121
  - lib
100
122
  required_ruby_version: !ruby/object:Gem::Requirement
101
- none: false
102
123
  requirements:
103
- - - ! '>='
124
+ - - '>='
104
125
  - !ruby/object:Gem::Version
105
126
  version: '0'
106
127
  required_rubygems_version: !ruby/object:Gem::Requirement
107
- none: false
108
128
  requirements:
109
- - - ! '>='
129
+ - - '>='
110
130
  - !ruby/object:Gem::Version
111
131
  version: '0'
112
132
  requirements: []
113
133
  rubyforge_project: mirror_github
114
- rubygems_version: 1.8.23
134
+ rubygems_version: 2.0.3
115
135
  signing_key:
116
- specification_version: 3
136
+ specification_version: 4
117
137
  summary: Command-line library for mirroring an Organization's GitHub repositories
118
138
  test_files: []