tachikoma 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f618004743a16b2c9bfeab746b69f3edc0488625
4
- data.tar.gz: 13ef48e03589ed1aa6959079afdda7d303a7ba3b
3
+ metadata.gz: 5746c103a46826dd181c6f50858a3ce5badce2fb
4
+ data.tar.gz: 8c80c9dd4c8b4972210a82b0cb2fc3f71f2a6286
5
5
  SHA512:
6
- metadata.gz: 039c38ee4a88403b275e3c65044d48d2205c653f586e8a50982bcb50df012bd90559f411d462266b1eae549e163afcdd14e8cc9714ef18e045ba49e9ee9101b6
7
- data.tar.gz: 9c22939957a1abe16a6628b851e2bd488d789ad11a40ecc847e9e42d64c9a9d46211f9bd92f33aa4558db9a5aba7880084534b8841f93bcd0b9ce362f655bc1f
6
+ metadata.gz: 999cd4d63592d622f4787a3461de54f8548fe522906cd06dc1048390f1bd2167799e0d2657dc78fe610e21d202d62ce7252801a51d8534e4e3732a0c59be9492
7
+ data.tar.gz: aff163726e8d97294c200bffdb0d0eb3716ee273c0181bd7a13c106dbc5da3aefd465bea08a7be610a1c1401058ef592cff80fb372cb6b4b501b2dee8e8c19b6
data/.travis.yml CHANGED
@@ -2,9 +2,10 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - 2.1.0-preview2
5
+ - 2.1.0-rc1
6
6
  before_install:
7
7
  - gem update bundler
8
+ - gem install json
8
9
  notifications:
9
10
  email:
10
11
  - ogataken@gmail.com
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 4.0.3
2
+
3
+ Features:
4
+
5
+ - Fix trailing slash in identify url (#71, @sanemat)
6
+ - Add Tachikoma::Exception (#73, @sanemat)
7
+ - All `git clone` and `git push` requests use github authentication token (#77, @sanemat)
8
+ - Deprecate `type: private` (#77, @sanemat)
9
+
1
10
  ## 4.0.2 (2013-12-20)
2
11
 
3
12
  Features:
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ group :development, :test do
8
8
  gem 'rspec-core', git: 'https://github.com/rspec/rspec-core.git', branch: 'master'
9
9
  # https://github.com/rspec/rspec-mocks/pull/467
10
10
  gem 'rspec-mocks', git: 'https://github.com/rspec/rspec-mocks.git', branch: 'master'
11
+ gem 'coveralls', require: false
11
12
  end
12
13
 
13
14
  gem 'oj'
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/tachikoma.png)](http://badge.fury.io/rb/tachikoma)
4
4
  [![Build Status](https://api.travis-ci.org/sanemat/tachikoma.png?branch=master)](https://travis-ci.org/sanemat/tachikoma)
5
5
  [![Code Climate](https://codeclimate.com/github/sanemat/tachikoma.png)](https://codeclimate.com/github/sanemat/tachikoma)
6
+ [![Coverage Status](https://coveralls.io/repos/sanemat/tachikoma/badge.png?branch=master)](https://coveralls.io/r/sanemat/tachikoma)
6
7
 
7
8
  Daily Pull Requester with bundle/carton update. [Actual pull request](https://github.com/mrtaddy/fenix-knight/pull/25)
8
9
 
data/lib/tachikoma.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'tachikoma/version'
2
2
  require 'tachikoma/settings'
3
+ require 'tachikoma/exception'
3
4
 
4
5
  # Namespace of tachikoma
5
6
  module Tachikoma
@@ -42,7 +42,8 @@ module Tachikoma
42
42
  @url = @configure['url']
43
43
  @type = @configure['type']
44
44
  @base_remote_branch = @configure['base_remote_branch']
45
- @authorized_url = authorized_url_with_type(@url, @type, @github_token, @github_account)
45
+ @authorized_compare_url = authorized_compare_url_with_type(@url, @type, @github_token, @github_account)
46
+ @authorized_base_url = authorized_base_url_with_type(@url, @type, @github_token, @github_account)
46
47
  @timestamp_format = @configure['timestamp_format']
47
48
  @readable_time = Time.now.utc.strftime(@timestamp_format)
48
49
  @parallel_option = bundler_parallel_option(Bundler::VERSION, @configure['bundler_parallel_number'])
@@ -62,11 +63,7 @@ module Tachikoma
62
63
 
63
64
  def fetch
64
65
  clean
65
- if @type == 'private'
66
- sh "git clone #{@authorized_url} #{Tachikoma.repos_path.to_s}/#{@build_for}"
67
- else
68
- sh "git clone #{@url} #{Tachikoma.repos_path.to_s}/#{@build_for}"
69
- end
66
+ sh "git clone #{@authorized_base_url} #{Tachikoma.repos_path.to_s}/#{@build_for}"
70
67
  end
71
68
 
72
69
  def bundle
@@ -80,7 +77,7 @@ module Tachikoma
80
77
  sh 'bundle update'
81
78
  sh 'git add Gemfile.lock'
82
79
  sh %Q!git commit -m "Bundle update #{@readable_time}"! do; end # ignore exitstatus
83
- sh "git push #{@authorized_url} feature/bundle-#{@readable_time}"
80
+ sh "git push #{@authorized_compare_url} feature/bundle-#{@readable_time}"
84
81
  end
85
82
  end
86
83
  end
@@ -95,7 +92,7 @@ module Tachikoma
95
92
  sh 'git add carton.lock' if File.exist?('carton.lock')
96
93
  sh 'git add cpanfile.snapshot' if File.exist?('cpanfile.snapshot')
97
94
  sh %Q!git commit -m "Carton update #{@readable_time}"! do; end # ignore exitstatus
98
- sh "git push #{@authorized_url} feature/carton-#{@readable_time}"
95
+ sh "git push #{@authorized_compare_url} feature/carton-#{@readable_time}"
99
96
  end
100
97
  end
101
98
 
@@ -112,15 +109,31 @@ module Tachikoma
112
109
  "TOKEN_#{build_for}".gsub(/-/, '_').upcase
113
110
  end
114
111
 
115
- def authorized_url_with_type(fetch_url, type, github_token, github_account)
112
+ def authorized_compare_url_with_type(fetch_url, type, github_token, github_account)
116
113
  uri = URI.parse(fetch_url)
117
114
  case type
118
115
  when 'fork'
119
116
  %Q!#{uri.scheme}://#{github_token}:x-oauth-basic@#{uri.host}#{path_for_fork(uri.path, github_account)}!
120
- when 'shared', 'private'
117
+ when 'shared'
118
+ "#{uri.scheme}://#{github_token}:x-oauth-basic@#{uri.host}#{uri.path}"
119
+ when 'private'
120
+ warn '[DEPRECATION] `type: private` is deprecated. Please use `type: fork` or `type: shared` instead.'
121
+ "#{uri.scheme}://#{github_token}:x-oauth-basic@#{uri.host}#{uri.path}"
122
+ else
123
+ raise InvalidType, "Invalid type #{type}"
124
+ end
125
+ end
126
+
127
+ def authorized_base_url_with_type(fetch_url, type, github_token, github_account)
128
+ uri = URI.parse(fetch_url)
129
+ case type
130
+ when 'fork', 'shared'
131
+ "#{uri.scheme}://#{github_token}:x-oauth-basic@#{uri.host}#{uri.path}"
132
+ when 'private'
133
+ warn '[DEPRECATION] `type: private` is deprecated. Please use `type: fork` or `type: shared` instead.'
121
134
  "#{uri.scheme}://#{github_token}:x-oauth-basic@#{uri.host}#{uri.path}"
122
135
  else
123
- raise "Invalid type #{type}"
136
+ raise InvalidType, "Invalid type #{type}"
124
137
  end
125
138
  end
126
139
 
@@ -132,16 +145,20 @@ module Tachikoma
132
145
  case type
133
146
  when 'fork'
134
147
  github_account
135
- when 'shared', 'private'
136
- uri = URI.parse(fetch_url)
137
- uri.path.sub(%r!/([^/]+)/.*!) { $1 }
148
+ when 'shared'
149
+ URI.parse(fetch_url).path.split('/', 3)[1]
150
+ when 'private'
151
+ warn '[DEPRECATION] `type: private` is deprecated. Please use `type: fork` or `type: shared` instead.'
152
+ URI.parse(fetch_url).path.split('/', 3)[1]
138
153
  else
139
- raise "Invalid type #{type}"
154
+ raise InvalidType, "Invalid type: #{type}"
140
155
  end
141
156
  end
142
157
 
143
158
  def repository_identity(url)
144
- %r!((?:[^/]*?)/(?:[^/]*?))(?:\.git)?$!.match(url)[1]
159
+ project_name, user_name, _ = url.split('/').reverse
160
+ project_name_identity = project_name.split('.git').first
161
+ user_name + '/' + project_name_identity
145
162
  end
146
163
 
147
164
  def bundler_parallel_option(bundler_version, parallel_number)
data/lib/tachikoma/cli.rb CHANGED
@@ -4,6 +4,8 @@ module Tachikoma
4
4
  class CLI < Thor
5
5
  include Thor::Actions
6
6
 
7
+ map %w(-v --version) => :version
8
+
7
9
  desc 'init', 'Initialize files'
8
10
  def init
9
11
  require 'fileutils'
@@ -36,6 +38,11 @@ module Tachikoma
36
38
  puts 'You might want to see README!'
37
39
  end
38
40
 
41
+ desc 'version', 'Display Tachikoma gem version'
42
+ def version
43
+ puts Tachikoma::VERSION
44
+ end
45
+
39
46
  def self.help(shell, *)
40
47
  list = printable_tasks
41
48
 
@@ -0,0 +1,4 @@
1
+ module Tachikoma
2
+ class Exception < StandardError; end
3
+ end
4
+ class InvalidType < Tachikoma::Exception; end
@@ -1,4 +1,4 @@
1
1
  # Version of tachikoma
2
2
  module Tachikoma
3
- VERSION = '4.0.2'
3
+ VERSION = '4.0.3'
4
4
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
1
4
  # This file was generated by the `rspec --init` command. Conventionally, all
2
5
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
6
  # Require this file using `require "spec_helper"` to ensure that it is only
@@ -45,4 +45,154 @@ YAML
45
45
  Tachikoma::Application.run 'carton'
46
46
  end
47
47
  end
48
+
49
+ describe '#bundler_parallel_option' do
50
+ subject { described_class.new }
51
+
52
+ context 'bundler does not support parallel' do
53
+ let(:bundler_version) { '1.3.5' }
54
+ let(:parallel_number) { 3 }
55
+ it 'returns nil' do
56
+ expect(subject.bundler_parallel_option(bundler_version, parallel_number)).to be_nil
57
+ end
58
+ end
59
+
60
+ context 'bundler supports parallel' do
61
+ let(:bundler_version) { '1.5.0' }
62
+
63
+ context 'parallel less than 1' do
64
+ let(:parallel_number) { 1 }
65
+ it 'returns nil' do
66
+ expect(subject.bundler_parallel_option(bundler_version, parallel_number)).to be_nil
67
+ end
68
+ end
69
+
70
+ context 'parallel above 1' do
71
+ let(:parallel_number) { 3 }
72
+ let(:parallel_option) { "--jobs=#{parallel_number}" }
73
+ it 'returns parallel option' do
74
+ expect(subject.bundler_parallel_option(bundler_version, parallel_number)).to eq parallel_option
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ describe '#repository_identity' do
81
+ subject { described_class.new }
82
+ let(:identity) { 'example1/example2' }
83
+
84
+ context 'https with .git' do
85
+ let(:url) { 'https://github.com/example1/example2.git' }
86
+ it { expect(subject.repository_identity(url)).to eq identity }
87
+ end
88
+ context 'https without .git' do
89
+ let(:url) { 'https://github.com/example1/example2' }
90
+ it { expect(subject.repository_identity(url)).to eq identity }
91
+ end
92
+ context 'https with trail slash' do
93
+ let(:url) { 'https://github.com/example1/example2/' }
94
+ it { expect(subject.repository_identity(url)).to eq identity }
95
+ end
96
+ end
97
+
98
+ describe '#target_repository_user' do
99
+ subject { described_class.new }
100
+ let(:url) { 'https://github.com/example/example2.git' }
101
+ let(:repos_user) { 'example' }
102
+ let(:github_user) { 'me' }
103
+
104
+ context 'valid type' do
105
+ context 'fork' do
106
+ let(:type) { 'fork' }
107
+ it { expect(subject.target_repository_user(type, url, github_user)).to eq github_user }
108
+ end
109
+ context 'shared' do
110
+ let(:type) { 'shared' }
111
+ it { expect(subject.target_repository_user(type, url, github_user)).to eq repos_user }
112
+ end
113
+ context 'private' do
114
+ let(:type) { 'private' }
115
+ it { expect(subject.target_repository_user(type, url, github_user)).to eq repos_user }
116
+ end
117
+ end
118
+
119
+ context 'invalid type' do
120
+ let(:type) { 'invalid' }
121
+ it { expect { subject.target_repository_user(type, url, github_user) }.to raise_error(InvalidType) }
122
+ end
123
+ end
124
+
125
+ describe '#authorized_compare_url_with_type' do
126
+ subject { described_class.new.authorized_compare_url_with_type(base_url, type, token, account) }
127
+ let(:token) { 'token' }
128
+
129
+ context 'valid type' do
130
+ context 'fork' do
131
+ let(:base_url) { 'https://github.com/can-not-write/example2.git' }
132
+ let(:account) { 'readonly' }
133
+ let(:type) { 'fork' }
134
+ let(:authorized_compare_url) { 'https://token:x-oauth-basic@github.com/readonly/example2.git' }
135
+ it { is_expected.to eq authorized_compare_url }
136
+ end
137
+ context 'shared' do
138
+ let(:base_url) { 'https://github.com/writable/example2.git' }
139
+ let(:account) { 'me' }
140
+ let(:type) { 'shared' }
141
+ let(:authorized_compare_url) { 'https://token:x-oauth-basic@github.com/writable/example2.git' }
142
+ it { is_expected.to eq authorized_compare_url }
143
+ end
144
+ context 'private' do
145
+ let(:base_url) { 'https://github.com/writable/example2.git' }
146
+ let(:account) { 'me' }
147
+ let(:type) { 'private' }
148
+ let(:authorized_compare_url) { 'https://token:x-oauth-basic@github.com/writable/example2.git' }
149
+ it { is_expected.to eq authorized_compare_url }
150
+ end
151
+ end
152
+
153
+ context 'invalid type' do
154
+ let(:base_url) { 'https://github.com/writable/example2.git' }
155
+ let(:account) { 'me' }
156
+ let(:type) { 'invalid' }
157
+ # FIXME: Use `is_expected` ?
158
+ it { expect { subject }.to raise_error(InvalidType) }
159
+ end
160
+ end
161
+
162
+ describe '#authorized_base_url_with_type' do
163
+ subject { described_class.new.authorized_base_url_with_type(base_url, type, token, account) }
164
+ let(:token) { 'token' }
165
+
166
+ context 'valid type' do
167
+ context 'fork' do
168
+ let(:base_url) { 'https://github.com/can-not-write/example2.git' }
169
+ let(:account) { 'readonly' }
170
+ let(:type) { 'fork' }
171
+ let(:authorized_base_url) { 'https://token:x-oauth-basic@github.com/can-not-write/example2.git' }
172
+ it { is_expected.to eq authorized_base_url }
173
+ end
174
+ context 'shared' do
175
+ let(:base_url) { 'https://github.com/writable/example2.git' }
176
+ let(:account) { 'me' }
177
+ let(:type) { 'shared' }
178
+ let(:authorized_base_url) { 'https://token:x-oauth-basic@github.com/writable/example2.git' }
179
+ it { is_expected.to eq authorized_base_url }
180
+ end
181
+ context 'private' do
182
+ let(:base_url) { 'https://github.com/writable/example2.git' }
183
+ let(:account) { 'me' }
184
+ let(:type) { 'private' }
185
+ let(:authorized_base_url) { 'https://token:x-oauth-basic@github.com/writable/example2.git' }
186
+ it { is_expected.to eq authorized_base_url }
187
+ end
188
+ end
189
+
190
+ context 'invalid type' do
191
+ let(:base_url) { 'https://github.com/writable/example2.git' }
192
+ let(:account) { 'me' }
193
+ let(:type) { 'invalid' }
194
+ # FIXME: Use `is_expected` ?
195
+ it { expect { subject }.to raise_error(InvalidType) }
196
+ end
197
+ end
48
198
  end
metadata CHANGED
@@ -1,131 +1,131 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tachikoma
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-20 00:00:00.000000000 Z
11
+ date: 2013-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
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: '0'
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: :runtime
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
  - !ruby/object:Gem::Dependency
42
42
  name: octokit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2'
48
- - - <
48
+ - - "<"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '3'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '2'
58
- - - <
58
+ - - "<"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '3'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: json
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: thor
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '>='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: bundler
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ~>
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '1.3'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - ~>
100
+ - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '1.3'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: dotenv
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - '>='
114
+ - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: rspec
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - '>='
121
+ - - ">="
122
122
  - !ruby/object:Gem::Version
123
123
  version: 3.0.0.beta
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - '>='
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: 3.0.0.beta
131
131
  description: Interval pull requester with bundle/carton update.
@@ -136,11 +136,11 @@ executables:
136
136
  extensions: []
137
137
  extra_rdoc_files: []
138
138
  files:
139
- - .env.example
140
- - .gitignore
141
- - .rspec
142
- - .rubocop.yml
143
- - .travis.yml
139
+ - ".env.example"
140
+ - ".gitignore"
141
+ - ".rspec"
142
+ - ".rubocop.yml"
143
+ - ".travis.yml"
144
144
  - CHANGELOG.md
145
145
  - Gemfile
146
146
  - LICENSE.txt
@@ -152,6 +152,7 @@ files:
152
152
  - lib/tachikoma.rb
153
153
  - lib/tachikoma/application.rb
154
154
  - lib/tachikoma/cli.rb
155
+ - lib/tachikoma/exception.rb
155
156
  - lib/tachikoma/settings.rb
156
157
  - lib/tachikoma/tasks.rb
157
158
  - lib/tachikoma/templates/.gitignore
@@ -177,17 +178,17 @@ require_paths:
177
178
  - lib
178
179
  required_ruby_version: !ruby/object:Gem::Requirement
179
180
  requirements:
180
- - - '>='
181
+ - - ">="
181
182
  - !ruby/object:Gem::Version
182
183
  version: '0'
183
184
  required_rubygems_version: !ruby/object:Gem::Requirement
184
185
  requirements:
185
- - - '>='
186
+ - - ">="
186
187
  - !ruby/object:Gem::Version
187
188
  version: '0'
188
189
  requirements: []
189
190
  rubyforge_project:
190
- rubygems_version: 2.0.14
191
+ rubygems_version: 2.2.0
191
192
  signing_key:
192
193
  specification_version: 4
193
194
  summary: Update gem frequently gets less pain. Let's doing bundle update as a habit!