pivotal-brancher 0.0.3 → 0.0.4
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/lib/pivotal-brancher/cli.rb +31 -15
- data/spec/start.rb +29 -10
- metadata +4 -4
data/lib/pivotal-brancher/cli.rb
CHANGED
@@ -8,8 +8,10 @@ module PivotalBrancher
|
|
8
8
|
default_task :start
|
9
9
|
|
10
10
|
no_commands do
|
11
|
-
def story_branch_name(story)
|
12
|
-
|
11
|
+
def story_branch_name(story, ids=nil)
|
12
|
+
ids ||= [story.id]
|
13
|
+
name = story.name.split(/[:-]\s*/, 2).last.gsub(/'/, '')
|
14
|
+
(name.split(/[^\w]+/).map(&:downcase) + ids).join("_")
|
13
15
|
end
|
14
16
|
|
15
17
|
def app=(app)
|
@@ -26,22 +28,36 @@ module PivotalBrancher
|
|
26
28
|
def start
|
27
29
|
stories = app.started_stories
|
28
30
|
if stories.empty?
|
29
|
-
say "No started stories found - could be you haven't started any stories yet?"
|
30
|
-
exit
|
31
31
|
end
|
32
|
-
story = stories.shift
|
33
32
|
|
34
|
-
|
35
|
-
|
33
|
+
branch_name =
|
34
|
+
case stories.length
|
35
|
+
when 0
|
36
|
+
say "No started stories found - could be you haven't started any stories yet?"
|
37
|
+
exit
|
38
|
+
when 1
|
39
|
+
story = stories.first
|
40
|
+
say "Switching to branch for:"
|
41
|
+
say "#{story.id}: #{story.name}"
|
42
|
+
story_branch_name(story)
|
43
|
+
when (2..4)
|
44
|
+
say "There are #{stories.length} stories started"
|
45
|
+
stories.each do |story|
|
46
|
+
say " #{story.id}: #{story.name}"
|
47
|
+
end
|
48
|
+
say
|
49
|
+
branchname = story_branch_name(stories.first, stories.map(&:id))
|
50
|
+
unless yes?("Start branch named #{branchname}?")
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
branchname
|
54
|
+
else
|
55
|
+
say "You have #{stories.length} stories started - save some for later"
|
56
|
+
exit 1
|
57
|
+
end
|
36
58
|
|
37
|
-
|
38
|
-
|
39
|
-
say ""
|
40
|
-
say "Other started stories are:"
|
41
|
-
stories.each do |story|
|
42
|
-
say "#{story.id}: #{story.name}"
|
43
|
-
end
|
44
|
-
git_command = "git checkout -b #{story_branch_name(story)}"
|
59
|
+
|
60
|
+
git_command = "git checkout -b #{branch_name}"
|
45
61
|
if options.pretend?
|
46
62
|
say "Would run: #{git_command}"
|
47
63
|
else
|
data/spec/start.rb
CHANGED
@@ -8,6 +8,12 @@ describe PivotalBrancher::Cli do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
let :brancher_app do
|
12
|
+
PivotalBrancher::App.new.tap do |app|
|
13
|
+
app.stub(:started_stories).and_return(stories)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
11
17
|
let :cli do
|
12
18
|
described_class.new.tap do |cli|
|
13
19
|
cli.app = brancher_app
|
@@ -15,13 +21,28 @@ describe PivotalBrancher::Cli do
|
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
18
|
-
describe "with started stories" do
|
19
|
-
let :
|
20
|
-
|
21
|
-
|
24
|
+
describe "with two started stories" do |app|
|
25
|
+
let :stories do
|
26
|
+
[
|
27
|
+
OpenStruct.new(:id => "123456", :name => "This: is a story"),
|
28
|
+
OpenStruct.new(:id => "123457", :name => "Whereas - a tale")
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
before :each do
|
33
|
+
cli.stub(:yes? => true)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should build branch name" do
|
37
|
+
cli.should_receive(:run).with("git checkout -b is_a_story_123456_123457")
|
38
|
+
capture_stdout do
|
39
|
+
cli.start
|
22
40
|
end
|
23
41
|
end
|
42
|
+
end
|
24
43
|
|
44
|
+
|
45
|
+
describe "with started stories" do
|
25
46
|
let :stories do
|
26
47
|
[
|
27
48
|
OpenStruct.new(:id => "123456", :name => "This: is a story")
|
@@ -35,11 +56,11 @@ describe PivotalBrancher::Cli do
|
|
35
56
|
end
|
36
57
|
|
37
58
|
it "should build branch names" do
|
38
|
-
expect(cli.story_branch_name(stories.first)).to eql("
|
59
|
+
expect(cli.story_branch_name(stories.first)).to eql("is_a_story_123456")
|
39
60
|
end
|
40
61
|
|
41
62
|
it "should execute git checkout -b" do
|
42
|
-
cli.should_receive(:run).with("git checkout -b
|
63
|
+
cli.should_receive(:run).with("git checkout -b is_a_story_123456")
|
43
64
|
capture_stdout do
|
44
65
|
cli.start
|
45
66
|
end
|
@@ -47,10 +68,8 @@ describe PivotalBrancher::Cli do
|
|
47
68
|
end
|
48
69
|
|
49
70
|
describe "with no started stories" do
|
50
|
-
let :
|
51
|
-
|
52
|
-
app.stub(:started_stories).and_return([])
|
53
|
-
end
|
71
|
+
let :stories do
|
72
|
+
[]
|
54
73
|
end
|
55
74
|
|
56
75
|
it "should not execute git" do
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: pivotal-brancher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Judson Lester
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -105,7 +105,7 @@ rdoc_options:
|
|
105
105
|
- --main
|
106
106
|
- doc/README
|
107
107
|
- --title
|
108
|
-
- pivotal-brancher-0.0.
|
108
|
+
- pivotal-brancher-0.0.4 Documentation
|
109
109
|
require_paths:
|
110
110
|
- lib/
|
111
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
segments:
|
116
116
|
- 0
|
117
|
-
hash:
|
117
|
+
hash: 304253647
|
118
118
|
version: '0'
|
119
119
|
none: false
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|