git-pivotal-tracker 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/.travis.yml +3 -0
  5. data/CHANGELOG +45 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +74 -0
  8. data/LICENSE +21 -0
  9. data/Rakefile +24 -0
  10. data/VERSION +1 -0
  11. data/bin/git-accept +7 -0
  12. data/bin/git-block +7 -0
  13. data/bin/git-finish +7 -0
  14. data/bin/git-info +7 -0
  15. data/bin/git-start +8 -0
  16. data/bin/git-unblock +7 -0
  17. data/features/accept.feature +140 -0
  18. data/features/block.feature +94 -0
  19. data/features/finish.feature +119 -0
  20. data/features/info.feature +99 -0
  21. data/features/start.feature +113 -0
  22. data/features/step_definitions/steps.rb +114 -0
  23. data/features/support/dsl/assertions.rb +11 -0
  24. data/features/support/dsl/data.rb +11 -0
  25. data/features/support/dsl/pivotal.rb +76 -0
  26. data/features/support/env.rb +6 -0
  27. data/features/support/git-pivotal.rb +69 -0
  28. data/features/test_repo/origin.git/COMMIT_EDITMSG +1 -0
  29. data/features/test_repo/origin.git/HEAD +1 -0
  30. data/features/test_repo/origin.git/config +8 -0
  31. data/features/test_repo/origin.git/description +1 -0
  32. data/features/test_repo/origin.git/hooks/applypatch-msg.sample +15 -0
  33. data/features/test_repo/origin.git/hooks/commit-msg.sample +24 -0
  34. data/features/test_repo/origin.git/hooks/post-commit.sample +8 -0
  35. data/features/test_repo/origin.git/hooks/post-receive.sample +15 -0
  36. data/features/test_repo/origin.git/hooks/post-update.sample +8 -0
  37. data/features/test_repo/origin.git/hooks/pre-applypatch.sample +14 -0
  38. data/features/test_repo/origin.git/hooks/pre-commit.sample +46 -0
  39. data/features/test_repo/origin.git/hooks/pre-rebase.sample +169 -0
  40. data/features/test_repo/origin.git/hooks/prepare-commit-msg.sample +36 -0
  41. data/features/test_repo/origin.git/hooks/update.sample +128 -0
  42. data/features/test_repo/origin.git/index +0 -0
  43. data/features/test_repo/origin.git/info/exclude +6 -0
  44. data/features/test_repo/origin.git/logs/HEAD +1 -0
  45. data/features/test_repo/origin.git/logs/refs/heads/master +1 -0
  46. data/features/test_repo/origin.git/objects/0c/6f7b1384910d1a2f137590095f008a06c7e00c +0 -0
  47. data/features/test_repo/origin.git/objects/10/ecf2b7ce989f01f3f7266e712b48d9275f2635 +0 -0
  48. data/features/test_repo/origin.git/objects/a5/71d56305df09fb060f6ccb730b46080d305beb +0 -0
  49. data/features/test_repo/origin.git/refs/heads/master +1 -0
  50. data/features/test_repo/readme +1 -0
  51. data/features/unblock.feature +68 -0
  52. data/git-pivotal-tracker.gemspec +27 -0
  53. data/lib/commands/accept.rb +76 -0
  54. data/lib/commands/base.rb +128 -0
  55. data/lib/commands/block.rb +59 -0
  56. data/lib/commands/bug.rb +19 -0
  57. data/lib/commands/card.rb +32 -0
  58. data/lib/commands/chore.rb +19 -0
  59. data/lib/commands/feature.rb +19 -0
  60. data/lib/commands/finish.rb +59 -0
  61. data/lib/commands/info.rb +58 -0
  62. data/lib/commands/map.rb +10 -0
  63. data/lib/commands/pick.rb +76 -0
  64. data/lib/commands/start.rb +35 -0
  65. data/lib/commands/unblock.rb +55 -0
  66. data/lib/git-pivotal-tracker.rb +11 -0
  67. data/readme.markdown +95 -0
  68. data/spec/commands/base_spec.rb +151 -0
  69. data/spec/commands/bug_spec.rb +24 -0
  70. data/spec/commands/chore_spec.rb +24 -0
  71. data/spec/commands/feature_spec.rb +24 -0
  72. data/spec/commands/finish_spec.rb +125 -0
  73. data/spec/commands/map_spec.rb +14 -0
  74. data/spec/commands/start_spec.rb +29 -0
  75. data/spec/factories.rb +13 -0
  76. data/spec/factory.rb +26 -0
  77. data/spec/spec_helper.rb +24 -0
  78. metadata +251 -0
@@ -0,0 +1,119 @@
1
+ Feature: git finish
2
+
3
+ In order to finish the card for the current topic branch you can issue the following
4
+ commands:
5
+
6
+ git finish
7
+ git finish <options>
8
+
9
+ Supported options:
10
+ -k <api_key> - specify the Pivotal API key to use. Overrides configuration.
11
+ -p <project_id> - specify the Pivotal project id to use. Overrides configuration.
12
+
13
+ This will do the following:
14
+ * mark the card as finished in Pivotal
15
+ * push the topic branch to origin
16
+ * switch to 'acceptance' integration branch, run git pull, then merge in topic branch
17
+ * push 'acceptance' integration branch
18
+
19
+ Related git configuration settings:
20
+ * pivotal.acceptance-branch - this is where finished cards are merged. Defaults to acceptance.
21
+
22
+ Background:
23
+ Given I have a started Pivotal Tracker feature
24
+ And I am on the "CURRENT_CARD-feature" branch
25
+
26
+ Scenario: Executing with no settings
27
+ When I run `git-finish`
28
+ Then the output should contain:
29
+ """
30
+ Pivotal Tracker API Token and Project ID are required
31
+ """
32
+ And the exit status should be 1
33
+
34
+ Scenario: Executing with inline settings
35
+ When I run `git-finish -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT`
36
+ Then the output should contain:
37
+ """
38
+ Marking Story CURRENT_CARD as finished...
39
+ Pushing CURRENT_CARD-feature to origin
40
+ Pulling acceptance...
41
+ Merging CURRENT_CARD-feature into acceptance
42
+ Pushing acceptance to origin
43
+ Now on acceptance.
44
+ """
45
+ And I should be on the "acceptance" branch
46
+
47
+ Scenario: Executing with git configuration
48
+ Given a file named ".gitconfig" with:
49
+ """
50
+ [pivotal]
51
+ api-token = PIVOTAL_API_KEY
52
+ full-name = PIVOTAL_USER
53
+ project-id = PIVOTAL_TEST_PROJECT
54
+ """
55
+ When I run `git-finish -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT`
56
+ Then the output should contain:
57
+ """
58
+ Marking Story CURRENT_CARD as finished...
59
+ Pushing CURRENT_CARD-feature to origin
60
+ Pulling acceptance...
61
+ Merging CURRENT_CARD-feature into acceptance
62
+ Pushing acceptance to origin
63
+ Now on acceptance.
64
+ """
65
+ And I should be on the "acceptance" branch
66
+
67
+ Scenario: Executing from a misnamed branch
68
+ Given I am on the "missing-an-id" branch
69
+ When I run `git-finish -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT`
70
+ Then the output should contain:
71
+ """
72
+ Branch name must contain a Pivotal Tracker story id
73
+ """
74
+ And the exit status should be 1
75
+
76
+ Scenario: Specifying an integration branch in Git configuration
77
+ Given I have a "develop" branch
78
+ And a file named ".gitconfig" with:
79
+ """
80
+ [pivotal]
81
+ api-token = PIVOTAL_API_KEY
82
+ full-name = PIVOTAL_USER
83
+ acceptance-branch = develop
84
+ project-id = PIVOTAL_TEST_PROJECT
85
+ """
86
+ When I run `git-finish -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT`
87
+ Then the output should contain:
88
+ """
89
+ Marking Story CURRENT_CARD as finished...
90
+ Pushing CURRENT_CARD-feature to origin
91
+ Pulling develop...
92
+ Merging CURRENT_CARD-feature into develop
93
+ Pushing develop to origin
94
+ Now on develop.
95
+ """
96
+ And I should be on the "develop" branch
97
+
98
+ Scenario: Closing chore stories
99
+ Given I have a started Pivotal Tracker chore
100
+ And I am on the "CURRENT_CARD-chore" branch
101
+ And a file named ".gitconfig" with:
102
+ """
103
+ [pivotal]
104
+ api-token = PIVOTAL_API_KEY
105
+ full-name = PIVOTAL_USER
106
+ project-id = PIVOTAL_TEST_PROJECT
107
+ """
108
+ When I run `git-finish -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT`
109
+ Then the output should contain:
110
+ """
111
+ Marking Story CURRENT_CARD as finished...
112
+ Pushing CURRENT_CARD-chore to origin
113
+ Pulling acceptance...
114
+ Merging CURRENT_CARD-chore into acceptance
115
+ Pushing acceptance to origin
116
+ Now on acceptance.
117
+ """
118
+ And I should be on the "acceptance" branch
119
+
@@ -0,0 +1,99 @@
1
+ Feature: git info
2
+
3
+ In order to get information about a specific card you can issue one of the following
4
+ commands:
5
+
6
+ git info
7
+ git info <options>
8
+ git info <card_id>
9
+ git info <card_id> <options>
10
+
11
+ Supported options:
12
+ --comments - displays comments for the card
13
+ -k <api_key> - specify the Pivotal API key to use. Overrides configuration.
14
+ -p <project_id> - specify the Pivotal project id to use. Overrides configuration.
15
+ -D - do not prompt for user input, use recommended values by default.
16
+
17
+ Background:
18
+ Given I have a Pivotal Tracker feature named "Test Story" with description "This is the description!"
19
+ And I am on the "CURRENT_CARD-feature" branch
20
+
21
+ Scenario: Executing with no settings
22
+ When I run `git-info`
23
+ Then the output should contain:
24
+ """
25
+ Pivotal Tracker API Token and Project ID are required
26
+ """
27
+ And the exit status should be 1
28
+
29
+ Scenario: Grabbing info about current topic branch
30
+ Given I have configured the Git repos for Pivotal
31
+ When I run `git-info`
32
+ Then the output should contain:
33
+ """
34
+ Story: Test Story
35
+ URL: http://www.pivotaltracker.com/story/show/CURRENT_CARD
36
+ State: not accepted
37
+ Description:
38
+ This is the description!
39
+ """
40
+
41
+ Scenario: Supplying Pivotal configuration via command line arguments
42
+ When I run `git-info -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT -n "PIVOTAL_USER" -D`
43
+ Then the output should contain:
44
+ """
45
+ Story: Test Story
46
+ URL: http://www.pivotaltracker.com/story/show/CURRENT_CARD
47
+ State: not accepted
48
+ Description:
49
+ This is the description!
50
+ """
51
+
52
+ Scenario: Grabbing info about a specific card in question topic branch
53
+ Given I have a Pivotal Tracker chore named "Test Chore" with description "The chore description!"
54
+ And I have configured the Git repos for Pivotal
55
+ When I run `git-info CURRENT_CARD`
56
+ Then the output should contain:
57
+ """
58
+ Story: Test Chore
59
+ URL: http://www.pivotaltracker.com/story/show/CURRENT_CARD
60
+ State: not accepted
61
+ Description:
62
+ The chore description!
63
+ """
64
+
65
+ Scenario: Grabbing info when the card has labels
66
+ Given I have a Pivotal Tracker chore named "Test Chore" with description "The chore description!"
67
+ And the chore is labeled "foo, bar, baz"
68
+ And I have configured the Git repos for Pivotal
69
+ When I run `git-info CURRENT_CARD`
70
+ Then the output should contain:
71
+ """
72
+ Story: Test Chore
73
+ URL: http://www.pivotaltracker.com/story/show/CURRENT_CARD
74
+ Labels: bar, baz, foo
75
+ State: not accepted
76
+ Description:
77
+ The chore description!
78
+ """
79
+
80
+ Scenario: Requesting comments on a card using --comments
81
+ Given I have a Pivotal Tracker chore named "Test Chore" with description "The chore description!"
82
+ And the "PIVOTAL_USER" commented on the card "Well, this looks mighty fine!"
83
+ And I have configured the Git repos for Pivotal
84
+ When I run `git-info CURRENT_CARD --comments`
85
+ Then the output should contain "Comments:"
86
+ And the output should contain "Well, this looks mighty fine!"
87
+ And the output should contain "PIVOTAL_USER"
88
+
89
+ Scenario: Grabbing info when not on a topic branch and not supplying a card id
90
+ Given I have configured the Git repos for Pivotal
91
+ And I am on the "foo" branch
92
+ Then I should be on the "foo" branch
93
+ When I run `git-info`
94
+ Then the output should contain:
95
+ """
96
+ No story id was supplied and you aren't on a topic branch!
97
+ """
98
+
99
+
@@ -0,0 +1,113 @@
1
+ Feature: git start
2
+
3
+ In order to start the next available card in the project you can issue the following
4
+ commands:
5
+
6
+ git start <options>
7
+ git start <card_type> <options>
8
+
9
+ Supported options:
10
+ -k <api_key> - specify the Pivotal API key to use. Overrides configuration.
11
+ -p <project_id> - specify the Pivotal project id to use. Overrides configuration.
12
+ -D - do not prompt for user input, use recommended values by default.
13
+
14
+ This will check out a topic branch for the card and place you on it.
15
+
16
+ Scenario Outline: Executing with no settings
17
+ When I run `<command>`
18
+ Then the output should contain:
19
+ """
20
+ Pivotal Tracker API Token and Project ID are required
21
+ """
22
+ And the exit status should be 1
23
+
24
+ Examples:
25
+ | command |
26
+ | git-start bug |
27
+ | git-start chore |
28
+ | git-start feature |
29
+
30
+ Scenario: Starting the next feature when it is unestimated
31
+ Given I have an unestimated Pivotal Tracker feature
32
+ And I have configured the Git repos for Pivotal
33
+ When I run `git-start feature -D`
34
+ Then the output should contain:
35
+ """
36
+ Stories in the started state must be estimated.
37
+ """
38
+ And the exit status should be 1
39
+
40
+ # Assumption: that chores can be started without being estimated in Pivotal
41
+ Scenario: Starting the next chore when it is unestimated
42
+ Given I have an unestimated Pivotal Tracker chore
43
+ And I have configured the Git repos for Pivotal
44
+ When I run `git-start chore -D`
45
+ Then the output should contain "Switched to a new branch 'CURRENT_CARD-chore'"
46
+ And I should be on the "CURRENT_CARD-chore" branch
47
+ And card CURRENT_CARD is marked is started in Pivotal Tracker
48
+
49
+ # Assumption: that estimating bugs in Pivotal is turned off
50
+ Scenario: Starting the next bug when it is unestimated
51
+ Given I have an unestimated Pivotal Tracker bug
52
+ And I have configured the Git repos for Pivotal
53
+ When I run `git-start bug -D`
54
+ Then the output should contain "Switched to a new branch 'CURRENT_CARD-bugfix'"
55
+ And I should be on the "CURRENT_CARD-bugfix" branch
56
+ And card CURRENT_CARD is marked is started in Pivotal Tracker
57
+
58
+ Scenario Outline: Starting the next estimated card interactively (without -D option)
59
+ Given I have a Pivotal Tracker <card_type>
60
+ And I have configured the Git repos for Pivotal
61
+ When I run `git-start <card_type>` interactively
62
+ And I type "a_purple_<card_type>"
63
+ Then the output should contain "Switched to a new branch 'CURRENT_CARD-a_purple_<card_type>'"
64
+ And I should be on the "CURRENT_CARD-a_purple_<card_type>" branch
65
+ And card CURRENT_CARD is marked is started in Pivotal Tracker
66
+
67
+ Examples:
68
+ | card_type |
69
+ | bug |
70
+ | chore |
71
+ | feature |
72
+
73
+ Scenario Outline: Starting the next estimated card using configured defaults (with -D option)
74
+ Given I have a Pivotal Tracker <card_type>
75
+ And I have configured the Git repos for Pivotal
76
+ When I run `git-start <card_type> -D`
77
+ Then the output should contain "Switched to a new branch 'CURRENT_CARD-<card_type><branch_suffix>'"
78
+ And I should be on the "CURRENT_CARD-<card_type><branch_suffix>" branch
79
+ And card CURRENT_CARD is marked is started in Pivotal Tracker
80
+
81
+ Examples:
82
+ | card_type | branch_suffix |
83
+ | bug | fix |
84
+ | chore | |
85
+ | feature | |
86
+
87
+ Scenario Outline: Starting a specific card
88
+ Given I have a Pivotal Tracker <card_type>
89
+ And I have configured the Git repos for Pivotal
90
+ When I run `git-start CURRENT_CARD -D`
91
+ Then the output should contain "Switched to a new branch 'CURRENT_CARD-<card_type><branch_suffix>'"
92
+ And I should be on the "CURRENT_CARD-<card_type><branch_suffix>" branch
93
+ And card CURRENT_CARD is marked is started in Pivotal Tracker
94
+
95
+ Examples:
96
+ | card_type | branch_suffix |
97
+ | bug | fix |
98
+ | chore | |
99
+ | feature | |
100
+
101
+ Scenario Outline: Supplying Pivotal configuration via command line arguments
102
+ Given I have a Pivotal Tracker <card_type>
103
+ And I have configured the Git repos for Pivotal with bogus information
104
+ When I run `git-start <card_type> -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT -n "PIVOTAL_USER" -D`
105
+ Then the output should contain "Switched to a new branch 'CURRENT_CARD-<card_type><branch_suffix>'"
106
+ And I should be on the "CURRENT_CARD-<card_type><branch_suffix>" branch
107
+ And card CURRENT_CARD is marked is started in Pivotal Tracker
108
+
109
+ Examples:
110
+ | card_type | branch_suffix |
111
+ | bug | fix |
112
+ | chore | |
113
+ | feature | |
@@ -0,0 +1,114 @@
1
+ STORY_TYPE = /feature|bug|chore|release/
2
+ STORY_STATE = /unscheduled|unstarted|started|finished|delivered|accepted|rejected/
3
+
4
+ Transform /PIVOTAL|CURRENT/ do |placeholder|
5
+ placeholder.
6
+ gsub("PIVOTAL_API_KEY", "80f3c308cfdfbaa8f5a21aa524081690").
7
+ gsub("PIVOTAL_TEST_PROJECT", "516377").
8
+ gsub("PIVOTAL_USER", "Robotic Zach").
9
+ gsub("CURRENT_CARD", current_card.id.to_s)
10
+ end
11
+
12
+ Given "I debug" do
13
+ require 'pry'
14
+ binding.pry
15
+ end
16
+
17
+ Given /^I have configured the Git repos for Pivotal$/ do
18
+ step %|a file named ".gitconfig" with:|, <<-EOT.gsub!(/^\s+\S/, '')
19
+ |[pivotal]
20
+ | api-token = PIVOTAL_API_KEY
21
+ | full-name = PIVOTAL_USER
22
+ | acceptance-branch = acceptance
23
+ | integration-branch = master
24
+ | project-id = PIVOTAL_TEST_PROJECT
25
+ EOT
26
+ end
27
+
28
+ Given /^I have configured the Git repos for Pivotal with bogus information$/ do
29
+ step %|a file named ".gitconfig" with:|, <<-EOT.gsub!(/^\s+\S/, '')
30
+ |[pivotal]
31
+ | api-token = badtoken
32
+ | full-name = Bad Joe
33
+ | integration-branch = whoknows
34
+ | project-id = something
35
+ | remote = origin
36
+ EOT
37
+ end
38
+
39
+ Given /^the "([^"]+)" commented on the card "([^"]+)"$/ do |author, text|
40
+ comment_on_story :author => author, :text => text
41
+ end
42
+
43
+ Given /^the (#{STORY_TYPE}|card) is labeled "([^"]+)"$/ do |type, labels|
44
+ update_test_story :labels => labels
45
+ end
46
+
47
+ Given /^I have a(?:n)? (#{STORY_STATE})?\s?Pivotal Tracker (#{STORY_TYPE})$/ do |status, type|
48
+ options = {}
49
+ options[:current_state] = status if status
50
+ create_test_story type, options
51
+ end
52
+
53
+ Given /^I have a(?:n)? unestimated \s?Pivotal Tracker (#{STORY_TYPE})$/ do |type|
54
+ options = { :estimate => -1 }
55
+ create_test_story type, options
56
+ end
57
+
58
+ Given /^I have a(?:n)? (#{STORY_STATE})?\s?Pivotal Tracker (#{STORY_TYPE}) named "([^"]+)" with description "([^"]+)"$/ do |status, type, name, description|
59
+ options = { :name => name, :description => description }
60
+ options[:current_state] = status if status
61
+ create_test_story type, options
62
+ end
63
+
64
+ Given /the card is a (#{STORY_TYPE})/ do |type|
65
+ update_test_story :story_type => type
66
+ end
67
+
68
+ Given /the (#{STORY_TYPE}) is unestimated/ do |type|
69
+ update_test_story :estimate => -1
70
+ end
71
+
72
+ Given /the (#{STORY_TYPE}) is (#{STORY_STATE})/ do |type, state|
73
+ update_test_story :current_state => state
74
+ end
75
+
76
+ Given /^I am on the "([^"]*)" branch$/ do |branch|
77
+ `git checkout -b #{branch} > /dev/null 2>&1`
78
+ end
79
+
80
+ Given /^I have a "([^"]*)" branch$/ do |branch|
81
+ `git branch #{branch} > /dev/null 2>&1`
82
+ end
83
+
84
+ When /^the current card is refreshed$/ do
85
+ refresh_current_card!
86
+ end
87
+
88
+ Then /^the card CURRENT_CARD should (not )?have the "([^"]*)" label$/ do |negate, label|
89
+ if negate
90
+ current_card.labels.to_s.should_not include(label)
91
+ else
92
+ current_card.labels.to_s.should include(label)
93
+ end
94
+ end
95
+
96
+ Then /^the card CURRENT_CARD should have the comment by "([^"]*)":$/ do |author, str|
97
+ current_card.notes.all.last.tap do |note|
98
+ note.author.should eq(author)
99
+ note.text.should include(str)
100
+ end
101
+ end
102
+
103
+ Then /^the card CURRENT_CARD should not have the comment:$/ do |str|
104
+ current_card.notes.all.detect{ |n| n.text.include?(str) }.should be_nil
105
+ end
106
+
107
+
108
+ Then /^I should be on the "([^"]*)" branch$/ do |branch|
109
+ current_branch.should == branch
110
+ end
111
+
112
+ Then /^card (CURRENT_\w+) is marked is started in Pivotal Tracker$/ do |card_id|
113
+ assert_card_is_started(card_id)
114
+ end
@@ -0,0 +1,11 @@
1
+ module GitPivotal
2
+ module FeatureHelpers
3
+ module Assertions
4
+ def assert_card_is_started(id)
5
+ pivotal_project.stories.find(id).current_state.should eq("started")
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ World(GitPivotal::FeatureHelpers::Assertions)