t1k 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/t1k/command.rb +9 -0
- data/lib/t1k/commands/branch.rb +11 -0
- data/lib/t1k/commands/commit.rb +2 -6
- data/lib/t1k/commands/pull_request.rb +23 -0
- data/lib/t1k/commands/ship.rb +34 -7
- data/lib/t1k/commands/sink.rb +31 -6
- data/lib/t1k/commands/validate.rb +2 -2
- data/lib/t1k/repository.rb +9 -3
- data/lib/t1k/version.rb +1 -1
- data/lib/t1k.rb +1 -0
- data/resources/T1000 +5 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/kernel.rb +9 -1
- data/spec/t1k/commands/branch_spec.rb +7 -0
- data/spec/t1k/commands/commit_spec.rb +9 -1
- data/spec/t1k/commands/hack_spec.rb +9 -0
- data/spec/t1k/commands/pull_request_spec.rb +26 -0
- data/spec/t1k/commands/ship_spec.rb +21 -0
- data/spec/t1k/commands/validate_spec.rb +24 -0
- data/spec/t1k_spec.rb +56 -4
- data/t1k.gemspec +4 -2
- metadata +37 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c00fb15bd08b42750f3e4e1d68d2880ba7cee574
|
4
|
+
data.tar.gz: 9607d5c8562fad145232fd20bb49b4552e737bf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de69ffb11d0ecfc37b6b7be7a7978bf932bd3e67c32fc56f9ea77b61dabca50fc3ea8c626cda77b31a0b227f35ec9f04ddb5572b74651c9c0edea0a58d4d3e9a
|
7
|
+
data.tar.gz: ef59f6ef62749d076a5d1271f41f4307fd3b18466612a7b2efe56f2f196e360315d2748d17adcfc6a27559b21e660c0c38daabd47fafbba342234e9184913d7c
|
data/lib/t1k/command.rb
CHANGED
@@ -4,6 +4,7 @@ require 't1k/commands/hack'
|
|
4
4
|
require 't1k/commands/commit'
|
5
5
|
require 't1k/commands/sink'
|
6
6
|
require 't1k/commands/ship'
|
7
|
+
require 't1k/commands/pull_request'
|
7
8
|
|
8
9
|
module T1k
|
9
10
|
class CLI < Clive
|
@@ -70,5 +71,13 @@ module T1k
|
|
70
71
|
opt :v, :version, 'Display the current version' do
|
71
72
|
puts T1k::VERSION
|
72
73
|
end
|
74
|
+
|
75
|
+
desc 'Send your code to remote branch. Not to master'
|
76
|
+
command :pr do
|
77
|
+
|
78
|
+
action do
|
79
|
+
Commands::PullRequest.run
|
80
|
+
end
|
81
|
+
end
|
73
82
|
end
|
74
83
|
end
|
data/lib/t1k/commands/commit.rb
CHANGED
@@ -7,13 +7,9 @@ module T1k
|
|
7
7
|
text_close = ''
|
8
8
|
|
9
9
|
raise "Message can't be blank. Use --no-message to ignore this rule." if message.empty? && !no_message
|
10
|
-
branch =
|
10
|
+
branch = T1k::Commands::Branch.actual_branch
|
11
11
|
|
12
|
-
text_close = close ? 'close
|
13
|
-
|
14
|
-
if close
|
15
|
-
text_close = 'close '
|
16
|
-
end
|
12
|
+
text_close = close ? 'close' : 'ref'
|
17
13
|
|
18
14
|
text_add = add ? 'a' : ''
|
19
15
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module T1k
|
2
|
+
module Commands
|
3
|
+
class PullRequest
|
4
|
+
|
5
|
+
def self.run
|
6
|
+
T1k::Commands::Sink.run
|
7
|
+
|
8
|
+
branch = T1k::Commands::Branch.actual_branch
|
9
|
+
pull = `git push origin #{branch.strip}`
|
10
|
+
self.open_browser pull
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.open_browser pull
|
14
|
+
return 1 if pull.nil?
|
15
|
+
match = pull.match( /(https:\/\/[a-zA-Z].*=1)/)
|
16
|
+
if match
|
17
|
+
uri = match[0]
|
18
|
+
system "open #{uri}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/t1k/commands/ship.rb
CHANGED
@@ -3,13 +3,40 @@ module T1k
|
|
3
3
|
class Ship
|
4
4
|
|
5
5
|
def self.run
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
T1k.setup_credentials
|
7
|
+
|
8
|
+
default_remote_branch = T1k::Repository.default_remote_branch
|
9
|
+
branch = T1k::Commands::Branch.actual_branch.strip
|
10
|
+
|
11
|
+
if default_remote_branch == :master
|
12
|
+
commands_if_master(branch)
|
13
|
+
elsif default_remote_branch == :branch
|
14
|
+
commands_if_branch(branch)
|
15
|
+
else
|
16
|
+
puts "Invalid default_remote_branch"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.commands_if_master(branch)
|
21
|
+
[ "git checkout master",
|
22
|
+
"git pull --rebase",
|
23
|
+
"git merge #{branch}",
|
24
|
+
"git commit -v",
|
25
|
+
"git push origin master"
|
26
|
+
].each do |cmd|
|
27
|
+
system cmd
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.commands_if_branch(branch)
|
32
|
+
[ "git checkout #{branch}",
|
33
|
+
"git pull --rebase",
|
34
|
+
"git commit -v",
|
35
|
+
"git push origin #{branch}"
|
36
|
+
].each do |cmd|
|
37
|
+
system cmd
|
38
|
+
end
|
12
39
|
end
|
13
40
|
end
|
14
41
|
end
|
15
|
-
end
|
42
|
+
end
|
data/lib/t1k/commands/sink.rb
CHANGED
@@ -2,12 +2,37 @@ module T1k
|
|
2
2
|
module Commands
|
3
3
|
class Sink
|
4
4
|
def self.run
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
T1k.setup_credentials
|
6
|
+
|
7
|
+
default_remote_branch = T1k::Repository.default_remote_branch
|
8
|
+
branch = T1k::Commands::Branch.actual_branch
|
9
|
+
|
10
|
+
if default_remote_branch == :master
|
11
|
+
commands_if_master(branch)
|
12
|
+
elsif default_remote_branch == :branch
|
13
|
+
commands_if_branch(branch)
|
14
|
+
else
|
15
|
+
puts "Invalid default_remote_branch"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.commands_if_master(branch)
|
20
|
+
[ "git checkout master",
|
21
|
+
"git pull --rebase origin master",
|
22
|
+
"git checkout #{branch.strip}",
|
23
|
+
"git rebase master #{branch.strip}"
|
24
|
+
].each do |cmd|
|
25
|
+
system cmd
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.commands_if_branch(branch)
|
30
|
+
[ "git checkout #{branch}",
|
31
|
+
"git pull --rebase",
|
32
|
+
].each do |cmd|
|
33
|
+
system cmd
|
34
|
+
end
|
10
35
|
end
|
11
36
|
end
|
12
37
|
end
|
13
|
-
end
|
38
|
+
end
|
data/lib/t1k/repository.rb
CHANGED
@@ -1,21 +1,27 @@
|
|
1
1
|
module T1k
|
2
2
|
class Repository
|
3
|
+
PERMITTEDS_BRANCH_NAME = [
|
4
|
+
:branch, :master
|
5
|
+
]
|
3
6
|
|
4
|
-
|
5
|
-
|
7
|
+
mattr_accessor :adapter
|
6
8
|
@@adapter = nil
|
7
9
|
|
10
|
+
cattr_accessor :default_remote_branch
|
11
|
+
@@default_remote_branch = ""
|
12
|
+
|
8
13
|
def self.setup &block
|
9
14
|
self.adapter.setup(&block) if block_given?
|
10
15
|
end
|
11
16
|
|
12
17
|
def self.adapter=(adapter_name)
|
13
|
-
raise "Invalid adapter name. Adapter name must
|
18
|
+
raise "Invalid adapter name. Adapter name must either :master or :branch." unless adapter_name.class.eql?(Symbol)
|
14
19
|
@@adapter = "T1k::Repositories::#{adapter_name.to_s.classify}".constantize
|
15
20
|
end
|
16
21
|
|
17
22
|
def self.default_repository
|
18
23
|
@@adapter
|
19
24
|
end
|
25
|
+
|
20
26
|
end
|
21
27
|
end
|
data/lib/t1k/version.rb
CHANGED
data/lib/t1k.rb
CHANGED
data/resources/T1000
CHANGED
@@ -19,6 +19,11 @@ T1k.setup do |config|
|
|
19
19
|
# c.password = "#{ENV['BITBUCKET_PWD']}"
|
20
20
|
# end
|
21
21
|
|
22
|
+
# config.repository.default_remote_branch = :master
|
23
|
+
# or
|
24
|
+
# config.repository.default_remote_branch = :branch
|
25
|
+
# |-> this option disables direct merge on origin master
|
26
|
+
|
22
27
|
# Setup Trello board credentials
|
23
28
|
#
|
24
29
|
# Trello APP_DEVELOPER_KEY: https://trello.com/app-key
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/kernel.rb
CHANGED
@@ -2,6 +2,14 @@ require 'clive'
|
|
2
2
|
|
3
3
|
module Kernel
|
4
4
|
def system(cmd)
|
5
|
-
puts "#{cmd}
|
5
|
+
puts "#{cmd}".green.bold
|
6
|
+
end
|
7
|
+
|
8
|
+
def `(cmd)
|
9
|
+
if cmd == "git branch | grep '*' | awk '{print $2}'"
|
10
|
+
'branch_name'
|
11
|
+
else
|
12
|
+
puts "#{cmd}".green.bold
|
13
|
+
end
|
6
14
|
end
|
7
15
|
end
|
@@ -14,6 +14,14 @@ describe T1k::Commands::Commit do
|
|
14
14
|
expect { T1k::Commands::Commit.run( message, close, add, no_message) }.to raise_error("Message can't be blank. Use --no-message to ignore this rule.")
|
15
15
|
end
|
16
16
|
|
17
|
+
|
18
|
+
it "does not raise an exception" do
|
19
|
+
message = ""
|
20
|
+
no_message = true
|
21
|
+
|
22
|
+
expect { T1k::Commands::Commit.run( message, close, add, no_message) }.to_not raise_error("Message can't be blank. Use --no-message to ignore this rule.")
|
23
|
+
end
|
24
|
+
|
17
25
|
it "it have to skip circle ci when is not a close commit" do
|
18
26
|
close = false
|
19
27
|
expect_any_instance_of(Kernel).to receive(:system).with("git commit -m '[ref#branch_name] teste'")
|
@@ -23,7 +31,7 @@ describe T1k::Commands::Commit do
|
|
23
31
|
|
24
32
|
it "have to close the issue when close=true is passed" do
|
25
33
|
close = true
|
26
|
-
expect_any_instance_of(Kernel).to receive(:system).with("git commit -m '[close
|
34
|
+
expect_any_instance_of(Kernel).to receive(:system).with("git commit -m '[close#branch_name] teste'")
|
27
35
|
|
28
36
|
T1k::Commands::Commit.run( msg, close, add, no_message)
|
29
37
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe T1k::Commands::PullRequest do
|
4
|
+
subject { T1k::Commands::PullRequest }
|
5
|
+
context '#run' do
|
6
|
+
it 'have to sink' do
|
7
|
+
expect(T1k::Commands::Sink).to receive(:run)
|
8
|
+
|
9
|
+
subject.run
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'have to push code to new branch' do
|
13
|
+
[
|
14
|
+
"git checkout master",
|
15
|
+
"git pull --rebase origin master",
|
16
|
+
"git checkout branch_name",
|
17
|
+
"git rebase master branch_name",
|
18
|
+
"git push origin branch_name"
|
19
|
+
].each do |cmd|
|
20
|
+
allow_any_instance_of(Kernel).to receive(:system).with( cmd )
|
21
|
+
end
|
22
|
+
|
23
|
+
subject.run
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe T1k::Commands::Ship do
|
4
|
+
describe '#self.run' do
|
5
|
+
|
6
|
+
it "should checkout to master" do
|
7
|
+
|
8
|
+
[
|
9
|
+
"git checkout master",
|
10
|
+
"git pull --rebase",
|
11
|
+
"git merge branch_name",
|
12
|
+
"git commit -v",
|
13
|
+
"git push origin master"
|
14
|
+
].each do |cmd|
|
15
|
+
allow_any_instance_of(Kernel).to receive(:system).with( cmd )
|
16
|
+
end
|
17
|
+
|
18
|
+
T1k::Commands::Ship.run
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module T1k
|
3
|
+
module Repositories
|
4
|
+
class Repo
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe T1k::Commands::Validate do
|
10
|
+
context "repository" do
|
11
|
+
it 'does have return the default repository' do
|
12
|
+
expect(T1k::Repository).to receive(:default_repository)
|
13
|
+
|
14
|
+
T1k::Commands::Validate.default_repository
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'does have valid keys' do
|
18
|
+
T1k::Repository.adapter = :repo
|
19
|
+
expect(T1k::Commands::Validate.default_repository).to receive(:valid_keys?)
|
20
|
+
|
21
|
+
T1k::Commands::Validate.valid_keys_on_repository?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/t1k_spec.rb
CHANGED
@@ -1,11 +1,63 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe T1k do
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
context '' do
|
6
|
+
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
context '#self.setup_credentials' do
|
10
|
+
context 'read a config file' do
|
11
|
+
context 'with valid data' do
|
12
|
+
|
13
|
+
before do
|
14
|
+
T1k.setup do |config|
|
15
|
+
config.repository.adapter = :bitbucket
|
16
|
+
end
|
17
|
+
|
18
|
+
subject.setup_credentials
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'on repository' do
|
22
|
+
it 'sets default_repository' do
|
23
|
+
expect(T1k::Repository.default_repository).to_not be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'default_repository should be Bitbucket' do
|
27
|
+
expect(T1k::Repository.default_repository).to eq(T1k::Repositories::Bitbucket)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'adapter should be Bitbucket' do
|
31
|
+
expect(T1k::Repository.adapter).to eq(T1k::Repositories::Bitbucket)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'on tracker' do
|
36
|
+
it 'adapter is trello' do
|
37
|
+
subject.setup_credentials
|
38
|
+
expect(T1k::Tracker.adapter).to eq(T1k::Trackers::Trello)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with invalid data' do
|
45
|
+
it 'returns a error for repository' do
|
46
|
+
expect {
|
47
|
+
T1k.setup do |config|
|
48
|
+
config.repository.adapter = :invalid
|
49
|
+
end
|
50
|
+
}.to raise_error(NameError)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
it 'returns a error for tracker' do
|
55
|
+
expect {
|
56
|
+
T1k.setup do |config|
|
57
|
+
config.tracker.adapter = :invalid
|
58
|
+
end
|
59
|
+
}.to raise_error(NameError)
|
60
|
+
end
|
61
|
+
end
|
10
62
|
end
|
11
63
|
end
|
data/t1k.gemspec
CHANGED
@@ -19,8 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = ["t1k"]
|
20
20
|
spec.require_paths = ["lib", "resources"]
|
21
21
|
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.9'
|
23
|
-
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'bundler' , '~> 1.9'
|
23
|
+
spec.add_development_dependency 'rake' , '~> 10.0'
|
24
|
+
spec.add_development_dependency 'simplecov' , '~>0.11.2'
|
25
|
+
spec.add_development_dependency 'pry'
|
24
26
|
|
25
27
|
spec.add_dependency 'ruby-trello' , '~> 1.2.1'
|
26
28
|
spec.add_dependency 'github_api' , '~> 0.12'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: t1k
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Maia
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -40,6 +40,34 @@ dependencies:
|
|
40
40
|
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '10.0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: simplecov
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.11.2
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.11.2
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: pry
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
43
71
|
- !ruby/object:Gem::Dependency
|
44
72
|
name: ruby-trello
|
45
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,9 +159,11 @@ files:
|
|
131
159
|
- ./bin/t1k
|
132
160
|
- ./lib/t1k.rb
|
133
161
|
- ./lib/t1k/command.rb
|
162
|
+
- ./lib/t1k/commands/branch.rb
|
134
163
|
- ./lib/t1k/commands/commit.rb
|
135
164
|
- ./lib/t1k/commands/hack.rb
|
136
165
|
- ./lib/t1k/commands/init.rb
|
166
|
+
- ./lib/t1k/commands/pull_request.rb
|
137
167
|
- ./lib/t1k/commands/ship.rb
|
138
168
|
- ./lib/t1k/commands/sink.rb
|
139
169
|
- ./lib/t1k/commands/validate.rb
|
@@ -149,7 +179,12 @@ files:
|
|
149
179
|
- ./resources/T1000
|
150
180
|
- ./spec/spec_helper.rb
|
151
181
|
- ./spec/support/kernel.rb
|
182
|
+
- ./spec/t1k/commands/branch_spec.rb
|
152
183
|
- ./spec/t1k/commands/commit_spec.rb
|
184
|
+
- ./spec/t1k/commands/hack_spec.rb
|
185
|
+
- ./spec/t1k/commands/pull_request_spec.rb
|
186
|
+
- ./spec/t1k/commands/ship_spec.rb
|
187
|
+
- ./spec/t1k/commands/validate_spec.rb
|
153
188
|
- ./spec/t1k_spec.rb
|
154
189
|
- ./t1k.gemspec
|
155
190
|
- README.md
|