pivotal-brancher 0.0.1 → 0.0.2
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.
- data/bin/pb +4 -0
- data/lib/pivotal-brancher/app.rb +34 -0
- data/lib/pivotal-brancher/cli.rb +47 -0
- data/lib/pivotal-brancher.rb +3 -33
- data/spec/start.rb +46 -0
- data/spec_support/all.rb +4 -0
- data/spec_support/capture.rb +17 -0
- metadata +38 -11
- data/bin/pt-start +0 -16
data/bin/pb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'valise'
|
2
|
+
require 'pivotal-tracker'
|
3
|
+
|
4
|
+
module PivotalBrancher
|
5
|
+
class App
|
6
|
+
def initialize
|
7
|
+
@files = Valise::define do
|
8
|
+
rw ".pivotal-brancher"
|
9
|
+
rw "~/.pivotal-brancher"
|
10
|
+
|
11
|
+
handle "*.yaml", :yaml, :hash_merge
|
12
|
+
end
|
13
|
+
configure_pivotal
|
14
|
+
end
|
15
|
+
|
16
|
+
def configs
|
17
|
+
@files.find("config.yaml").contents
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure_pivotal
|
21
|
+
PivotalTracker::Client.token = configs["token"]
|
22
|
+
PivotalTracker::Client.use_ssl
|
23
|
+
#RestClient.log = "stdout"
|
24
|
+
end
|
25
|
+
|
26
|
+
def project
|
27
|
+
@project = PivotalTracker::Project.find(configs["project"])
|
28
|
+
end
|
29
|
+
|
30
|
+
def started_stories
|
31
|
+
project.stories.all(:current_state => "started", :owned_by => configs["user"])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'pivotal-brancher/app'
|
3
|
+
|
4
|
+
module PivotalBrancher
|
5
|
+
class Cli < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
default_task :start
|
9
|
+
|
10
|
+
no_commands do
|
11
|
+
def story_branch_name(story)
|
12
|
+
([story.id] + story.name.split(/[^\w]+/).map(&:downcase)).join("_")
|
13
|
+
end
|
14
|
+
|
15
|
+
def app=(app)
|
16
|
+
@app = app
|
17
|
+
end
|
18
|
+
|
19
|
+
def app
|
20
|
+
@app ||= PivotalBrancher::App.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "start", "Start a branch for your first started Pivotal story"
|
25
|
+
method_options %w{pretend -p} => :boolean #ok
|
26
|
+
def start
|
27
|
+
stories = app.started_stories
|
28
|
+
story = stories.shift
|
29
|
+
|
30
|
+
say "Switching to branch for:"
|
31
|
+
say "#{story.id}: #{story.name}"
|
32
|
+
say ""
|
33
|
+
say "Other started stories are:"
|
34
|
+
stories.each do |story|
|
35
|
+
say "#{story.id}: #{story.name}"
|
36
|
+
end
|
37
|
+
git_command = "git checkout -b #{story_branch_name(story)}"
|
38
|
+
if options.pretend?
|
39
|
+
say "Would run: #{git_command}"
|
40
|
+
else
|
41
|
+
run git_command
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
CLI = Cli
|
47
|
+
end
|
data/lib/pivotal-brancher.rb
CHANGED
@@ -1,35 +1,5 @@
|
|
1
|
-
require 'valise'
|
2
|
-
require 'pivotal-tracker'
|
3
|
-
|
4
1
|
module PivotalBrancher
|
5
|
-
|
6
|
-
class App
|
7
|
-
def initialize
|
8
|
-
@files = Valise::define do
|
9
|
-
rw ".pivotal-brancher"
|
10
|
-
rw "~/.pivotal-brancher"
|
11
|
-
|
12
|
-
handle "*.yaml", :yaml, :hash_merge
|
13
|
-
end
|
14
|
-
configure_pivotal
|
15
|
-
end
|
16
|
-
|
17
|
-
def configs
|
18
|
-
@files.find("config.yaml").contents
|
19
|
-
end
|
20
|
-
|
21
|
-
def configure_pivotal
|
22
|
-
PivotalTracker::Client.token = configs["token"]
|
23
|
-
PivotalTracker::Client.use_ssl
|
24
|
-
#RestClient.log = "stdout"
|
25
|
-
end
|
26
|
-
|
27
|
-
def project
|
28
|
-
@project = PivotalTracker::Project.find(configs["project"])
|
29
|
-
end
|
30
|
-
|
31
|
-
def started_stories
|
32
|
-
project.stories.all(:current_state => "started", :owned_by => configs["user"])
|
33
|
-
end
|
34
|
-
end
|
35
2
|
end
|
3
|
+
|
4
|
+
require 'pivotal-brancher/app'
|
5
|
+
require 'pivotal-brancher/cli'
|
data/spec/start.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'pivotal-brancher'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe PivotalBrancher::Cli do
|
5
|
+
before :all do
|
6
|
+
described_class.instance_eval do
|
7
|
+
@no_commands = true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
let :cli do
|
12
|
+
described_class.new.tap do |cli|
|
13
|
+
cli.app = brancher_app
|
14
|
+
cli.stub(:run)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
let :brancher_app do
|
19
|
+
PivotalBrancher::App.new.tap do |app|
|
20
|
+
app.stub(:started_stories).and_return(stories)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
let :stories do
|
25
|
+
[
|
26
|
+
OpenStruct.new(:id => "123456", :name => "This: is a story")
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should report on stories considered" do
|
31
|
+
expect(capture_stdout do
|
32
|
+
cli.start
|
33
|
+
end).to match(/is a story/)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should build branch names" do
|
37
|
+
expect(cli.story_branch_name(stories.first)).to eql("123456_this_is_a_story")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should execute git checkout -b" do
|
41
|
+
cli.should_receive(:run).with("git checkout -b 123456_this_is_a_story")
|
42
|
+
capture_stdout do
|
43
|
+
cli.start
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec_support/all.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
def capture_stdout
|
5
|
+
begin
|
6
|
+
old_stream = $stdout
|
7
|
+
new_stream = StringIO.new
|
8
|
+
$stdout = new_stream
|
9
|
+
yield
|
10
|
+
result = $stdout.string
|
11
|
+
ensure
|
12
|
+
$stdout = old_stream
|
13
|
+
end
|
14
|
+
|
15
|
+
result
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: pivotal-brancher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Judson Lester
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
name: pivotal-tracker
|
18
18
|
version_requirements: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- -
|
20
|
+
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
segments:
|
23
23
|
- 0
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
none: false
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
segments:
|
33
33
|
- 0
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
name: valise
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
segments:
|
47
47
|
- 0
|
@@ -50,25 +50,52 @@ dependencies:
|
|
50
50
|
none: false
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
segments:
|
56
56
|
- 0
|
57
57
|
- 9
|
58
58
|
version: '0.9'
|
59
59
|
none: false
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
prerelease: false
|
62
|
+
type: :runtime
|
63
|
+
name: thor
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
- 18
|
71
|
+
version: '0.18'
|
72
|
+
none: false
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
- 18
|
80
|
+
version: '0.18'
|
81
|
+
none: false
|
60
82
|
description: ! " Some command line tools to be used in tandem with a githook for
|
61
|
-
Pivotal\n\n
|
62
|
-
|
83
|
+
Pivotal\n\n `pb start` will switch to (possibly creating) a git branch named for
|
84
|
+
your\n current highest priority started Pivotal story.\n"
|
63
85
|
email:
|
64
86
|
- nyarly@gmail.com
|
65
87
|
executables:
|
66
|
-
-
|
88
|
+
- pb
|
67
89
|
extensions: []
|
68
90
|
extra_rdoc_files: []
|
69
91
|
files:
|
92
|
+
- lib/pivotal-brancher/app.rb
|
93
|
+
- lib/pivotal-brancher/cli.rb
|
70
94
|
- lib/pivotal-brancher.rb
|
71
|
-
- bin/
|
95
|
+
- bin/pb
|
96
|
+
- spec/start.rb
|
97
|
+
- spec_support/all.rb
|
98
|
+
- spec_support/capture.rb
|
72
99
|
homepage: http://nyarly.github.com/pivotal-brancher
|
73
100
|
licenses:
|
74
101
|
- MIT
|
@@ -78,7 +105,7 @@ rdoc_options:
|
|
78
105
|
- --main
|
79
106
|
- doc/README
|
80
107
|
- --title
|
81
|
-
- pivotal-brancher-0.0.
|
108
|
+
- pivotal-brancher-0.0.2 Documentation
|
82
109
|
require_paths:
|
83
110
|
- lib/
|
84
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -87,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
114
|
- !ruby/object:Gem::Version
|
88
115
|
segments:
|
89
116
|
- 0
|
90
|
-
hash: -
|
117
|
+
hash: -369662783
|
91
118
|
version: '0'
|
92
119
|
none: false
|
93
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
data/bin/pt-start
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/bin/env ruby
|
2
|
-
require 'pivotal-brancher'
|
3
|
-
require 'pp'
|
4
|
-
|
5
|
-
app = PivotalBrancher::App.new
|
6
|
-
stories = app.started_stories
|
7
|
-
story = stories.shift
|
8
|
-
|
9
|
-
$stderr.puts "Switching to branch for:"
|
10
|
-
$stderr.puts "#{story.id}: #{story.name}"
|
11
|
-
$stderr.puts
|
12
|
-
$stderr.puts "Other started stories are:"
|
13
|
-
stories.each do |story|
|
14
|
-
$stderr.puts "#{story.id}: #{story.name}"
|
15
|
-
end
|
16
|
-
%x"git checkout -b #{([story.id] + story.name.split(/\s/).map(&:downcase)).join("_")}"
|