pivotal-integration 1.6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +202 -0
- data/NOTICE +2 -0
- data/README.md +331 -0
- data/bin/pivotal +81 -0
- data/lib/pivotal-integration/command/assign.rb +50 -0
- data/lib/pivotal-integration/command/base.rb +63 -0
- data/lib/pivotal-integration/command/command.rb +20 -0
- data/lib/pivotal-integration/command/comment.rb +31 -0
- data/lib/pivotal-integration/command/configuration.rb +129 -0
- data/lib/pivotal-integration/command/estimate.rb +53 -0
- data/lib/pivotal-integration/command/finish.rb +50 -0
- data/lib/pivotal-integration/command/info.rb +30 -0
- data/lib/pivotal-integration/command/label.rb +33 -0
- data/lib/pivotal-integration/command/mark.rb +44 -0
- data/lib/pivotal-integration/command/new.rb +52 -0
- data/lib/pivotal-integration/command/open.rb +31 -0
- data/lib/pivotal-integration/command/prepare-commit-msg.sh +26 -0
- data/lib/pivotal-integration/command/release.rb +54 -0
- data/lib/pivotal-integration/command/start.rb +82 -0
- data/lib/pivotal-integration/command/switch.rb +44 -0
- data/lib/pivotal-integration/util/git.rb +280 -0
- data/lib/pivotal-integration/util/label.rb +72 -0
- data/lib/pivotal-integration/util/shell.rb +36 -0
- data/lib/pivotal-integration/util/story.rb +170 -0
- data/lib/pivotal-integration/util/util.rb +20 -0
- data/lib/pivotal-integration/version-update/gradle.rb +64 -0
- data/lib/pivotal-integration/version-update/version_update.rb +20 -0
- data/lib/pivotal_integration.rb +18 -0
- data/spec/git-pivotal-tracker-integration/command/assign_spec.rb +55 -0
- data/spec/git-pivotal-tracker-integration/command/base_spec.rb +38 -0
- data/spec/git-pivotal-tracker-integration/command/configuration_spec.rb +119 -0
- data/spec/git-pivotal-tracker-integration/command/finish_spec.rb +45 -0
- data/spec/git-pivotal-tracker-integration/command/label_spec.rb +44 -0
- data/spec/git-pivotal-tracker-integration/command/mark_spec.rb +49 -0
- data/spec/git-pivotal-tracker-integration/command/release_spec.rb +57 -0
- data/spec/git-pivotal-tracker-integration/command/start_spec.rb +55 -0
- data/spec/git-pivotal-tracker-integration/util/git_spec.rb +235 -0
- data/spec/git-pivotal-tracker-integration/util/label_spec.rb +193 -0
- data/spec/git-pivotal-tracker-integration/util/shell_spec.rb +52 -0
- data/spec/git-pivotal-tracker-integration/util/story_spec.rb +158 -0
- data/spec/git-pivotal-tracker-integration/version-update/gradle_spec.rb +74 -0
- metadata +241 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'command'
|
17
|
+
require_relative 'configuration'
|
18
|
+
require_relative '../util/git'
|
19
|
+
require_relative '../util/story'
|
20
|
+
require 'pivotal-tracker'
|
21
|
+
|
22
|
+
# An abstract base class for all commands
|
23
|
+
# @abstract Subclass and override {#run} to implement command functionality
|
24
|
+
class PivotalIntegration::Command::Base
|
25
|
+
# Common initialization functionality for all command classes. This
|
26
|
+
# enforces that:
|
27
|
+
# * the command is being run within a valid Git repository
|
28
|
+
# * the user has specified their Pivotal Tracker API token
|
29
|
+
# * all communication with Pivotal Tracker will be protected with SSL
|
30
|
+
# * the user has configured the project id for this repository
|
31
|
+
def initialize(options = {})
|
32
|
+
@options = options
|
33
|
+
@repository_root = PivotalIntegration::Util::Git.repository_root
|
34
|
+
@configuration = PivotalIntegration::Command::Configuration.new
|
35
|
+
|
36
|
+
PivotalTracker::Client.token = @configuration.api_token
|
37
|
+
PivotalTracker::Client.use_ssl = true
|
38
|
+
|
39
|
+
@project = PivotalTracker::Project.find @configuration.project_id
|
40
|
+
end
|
41
|
+
|
42
|
+
# The main entry point to the command's execution
|
43
|
+
# @abstract Override this method to implement command functionality
|
44
|
+
def run(*arguments)
|
45
|
+
raise NotImplementedError
|
46
|
+
end
|
47
|
+
|
48
|
+
def story
|
49
|
+
if @options[:story_id]
|
50
|
+
@configuration.project.stories.find(@options[:story_id])
|
51
|
+
else
|
52
|
+
@configuration.story
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class << self
|
57
|
+
attr_reader :description
|
58
|
+
|
59
|
+
def desc(text)
|
60
|
+
@description = text
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative '../../pivotal_integration'
|
17
|
+
|
18
|
+
# A module encapsulating the commands for the project
|
19
|
+
module PivotalIntegration::Command
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
require 'pivotal-tracker'
|
18
|
+
|
19
|
+
# The class that encapsulates assigning current Pivotal Tracker Story to a user
|
20
|
+
class PivotalIntegration::Command::Comment < PivotalIntegration::Command::Base
|
21
|
+
desc "Add a comment to the current story"
|
22
|
+
|
23
|
+
def run(*arguments)
|
24
|
+
comment = arguments.first
|
25
|
+
abort "A comment must be provided." unless comment
|
26
|
+
|
27
|
+
print "Adding comment to story ##{story.id}... "
|
28
|
+
PivotalIntegration::Util::Story.add_comment(story, comment)
|
29
|
+
puts 'OK'
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'command'
|
17
|
+
require_relative '../util/git'
|
18
|
+
require 'highline/import'
|
19
|
+
require 'pivotal-tracker'
|
20
|
+
|
21
|
+
# A class that exposes configuration that commands can use
|
22
|
+
class PivotalIntegration::Command::Configuration
|
23
|
+
|
24
|
+
# Returns the user's Pivotal Tracker API token. If this token has not been
|
25
|
+
# configured, prompts the user for the value. The value is checked for in
|
26
|
+
# the _inherited_ Git configuration, but is stored in the _global_ Git
|
27
|
+
# configuration so that it can be used across multiple repositories.
|
28
|
+
#
|
29
|
+
# @return [String] The user's Pivotal Tracker API token
|
30
|
+
def api_token
|
31
|
+
api_token = PivotalIntegration::Util::Git.get_config KEY_API_TOKEN, :inherited
|
32
|
+
|
33
|
+
if api_token.empty?
|
34
|
+
api_token = ask('Pivotal API Token (found at https://www.pivotaltracker.com/profile): ').strip
|
35
|
+
PivotalIntegration::Util::Git.set_config KEY_API_TOKEN, api_token, :global
|
36
|
+
puts
|
37
|
+
end
|
38
|
+
|
39
|
+
api_token
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns the Pivotal Tracker project id for this repository. If this id
|
43
|
+
# has not been configuration, prompts the user for the value. The value is
|
44
|
+
# checked for in the _inherited_ Git configuration, but is stored in the
|
45
|
+
# _local_ Git configuration so that it is specific to this repository.
|
46
|
+
#
|
47
|
+
# @return [String] The repository's Pivotal Tracker project id
|
48
|
+
def project_id
|
49
|
+
project_id = PivotalIntegration::Util::Git.get_config KEY_PROJECT_ID, :inherited
|
50
|
+
|
51
|
+
if project_id.empty?
|
52
|
+
project_id = choose do |menu|
|
53
|
+
menu.prompt = 'Choose project associated with this repository: '
|
54
|
+
|
55
|
+
PivotalTracker::Project.all.sort_by { |project| project.name }.each do |project|
|
56
|
+
menu.choice(project.name) { project.id }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
PivotalIntegration::Util::Git.set_config KEY_PROJECT_ID, project_id, :local
|
61
|
+
puts
|
62
|
+
end
|
63
|
+
|
64
|
+
project_id
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns the Pivotal Tracker project for this repository. If it is not
|
68
|
+
# configured yet, prompts the user for the value.
|
69
|
+
#
|
70
|
+
# @return [PivotalTracker::Project] The repository's Pivotal Tracker project
|
71
|
+
def project
|
72
|
+
PivotalTracker::Project.find project_id
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns the Pivotal Tracker user id for this repository. If this id
|
76
|
+
# has not been configuration, prompts the user for the value. The value is
|
77
|
+
# checked for in the _inherited_ Git configuration, but is stored in the
|
78
|
+
# _local_ Git configuration so that it is specific to this repository.
|
79
|
+
#
|
80
|
+
# @return [String] The repository's Pivotal Tracker user id
|
81
|
+
def user
|
82
|
+
user = PivotalIntegration::Util::Git.get_config KEY_USER, :inherited
|
83
|
+
|
84
|
+
if user.empty?
|
85
|
+
user = choose do |menu|
|
86
|
+
menu.prompt = 'Choose your user name associated with this repository: '
|
87
|
+
|
88
|
+
PivotalTracker::Project.all.map{ |p| p.memberships.all.map(&:name) }.flatten.uniq.each do |owner|
|
89
|
+
menu.choice(owner) { owner }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
PivotalIntegration::Util::Git.set_config KEY_USER, user.inspect, :local
|
94
|
+
end
|
95
|
+
|
96
|
+
user
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns the story associated with the current development branch
|
100
|
+
#
|
101
|
+
# @return [PivotalTracker::Story] the story associated with the current development branch
|
102
|
+
def story
|
103
|
+
story_id = PivotalIntegration::Util::Git.get_config KEY_STORY_ID, :branch
|
104
|
+
if story_id.empty?
|
105
|
+
abort("You need to be on started story branch to do this!")
|
106
|
+
else
|
107
|
+
project.stories.find(story_id)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Stores the story associated with the current development branch
|
112
|
+
#
|
113
|
+
# @param [PivotalTracker::Story] story the story associated with the current development branch
|
114
|
+
# @return [void]
|
115
|
+
def story=(story)
|
116
|
+
PivotalIntegration::Util::Git.set_config KEY_STORY_ID, story.id, :branch
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
KEY_API_TOKEN = 'pivotal.api-token'.freeze
|
122
|
+
|
123
|
+
KEY_USER = 'pivotal.user'.freeze
|
124
|
+
|
125
|
+
KEY_PROJECT_ID = 'pivotal.project-id'.freeze
|
126
|
+
|
127
|
+
KEY_STORY_ID = 'pivotal-story-id'.freeze
|
128
|
+
|
129
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
|
18
|
+
# The class that encapsulates starting a Pivotal Tracker Story
|
19
|
+
class PivotalIntegration::Command::Estimate < PivotalIntegration::Command::Base
|
20
|
+
desc "Assign an estimate to the current story"
|
21
|
+
|
22
|
+
def run(*arguments)
|
23
|
+
score = arguments.first
|
24
|
+
|
25
|
+
unless score
|
26
|
+
case story.estimate
|
27
|
+
when -1
|
28
|
+
puts "Story is currently unestimated."
|
29
|
+
else
|
30
|
+
puts "Story is currently estimated #{story.estimate}."
|
31
|
+
end
|
32
|
+
|
33
|
+
score = self.class.collect_estimation(@configuration.project)
|
34
|
+
end
|
35
|
+
|
36
|
+
case score
|
37
|
+
when -1
|
38
|
+
print 'Changing to unestimated... '
|
39
|
+
else
|
40
|
+
print "Changing estimation to #{score}... "
|
41
|
+
end
|
42
|
+
|
43
|
+
PivotalIntegration::Util::Story.estimate(story, score)
|
44
|
+
puts 'OK'
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.collect_estimation(project)
|
48
|
+
possible_scores = project.point_scale.split(',')
|
49
|
+
score = -1
|
50
|
+
score = ask("Choose an estimation for this story [#{possible_scores.join(', ')}, enter for none]: ") until possible_scores.include?(score) or score.blank?
|
51
|
+
score.blank? ? -1 : score
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
|
18
|
+
# The class that encapsulates finishing a Pivotal Tracker Story
|
19
|
+
class PivotalIntegration::Command::Finish < PivotalIntegration::Command::Base
|
20
|
+
desc "Finish working on a story"
|
21
|
+
|
22
|
+
# Finishes a Pivotal Tracker story by doing the following steps:
|
23
|
+
# * Check that the pending merge will be trivial
|
24
|
+
# * Merge the development branch into the root branch
|
25
|
+
# * Delete the development branch
|
26
|
+
# * Push changes to remote
|
27
|
+
#
|
28
|
+
# @return [void]
|
29
|
+
def run(*arguments)
|
30
|
+
no_complete = arguments.delete('--no-complete')
|
31
|
+
no_delete = arguments.delete('--no-delete')
|
32
|
+
no_merge = arguments.delete('--no-merge')
|
33
|
+
pull_request = arguments.delete('--pull-request') || PivotalIntegration::Util::Git.finish_mode == :pull_request
|
34
|
+
|
35
|
+
if pull_request
|
36
|
+
PivotalIntegration::Util::Git.push PivotalIntegration::Util::Git.branch_name
|
37
|
+
PivotalIntegration::Util::Git.create_pull_request(@configuration.story)
|
38
|
+
PivotalIntegration::Util::Story.mark(@configuration.story, :finished)
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
42
|
+
unless no_merge
|
43
|
+
PivotalIntegration::Util::Git.trivial_merge?
|
44
|
+
PivotalIntegration::Util::Git.merge(@configuration.story, no_complete, no_delete)
|
45
|
+
end
|
46
|
+
|
47
|
+
PivotalIntegration::Util::Git.push PivotalIntegration::Util::Git.branch_name
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
require 'pivotal-tracker'
|
18
|
+
|
19
|
+
# The class that encapsulates assigning current Pivotal Tracker Story to a user
|
20
|
+
class PivotalIntegration::Command::Info < PivotalIntegration::Command::Base
|
21
|
+
desc "Get information on the current story"
|
22
|
+
|
23
|
+
def run(*arguments)
|
24
|
+
if story
|
25
|
+
PivotalIntegration::Util::Story.pretty_print story
|
26
|
+
else
|
27
|
+
abort "No story currently selected."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
require_relative '../util/label'
|
18
|
+
require 'pivotal-tracker'
|
19
|
+
|
20
|
+
MODES = %w(add remove list once)
|
21
|
+
|
22
|
+
# The class that encapsulates starting a Pivotal Tracker Story
|
23
|
+
class PivotalIntegration::Command::Label < PivotalIntegration::Command::Base
|
24
|
+
desc "Manage labels for the current story"
|
25
|
+
|
26
|
+
# Adds labels for active story.
|
27
|
+
# @return [void]
|
28
|
+
def run(mode, *labels)
|
29
|
+
abort "You need to specify mode first [#{MODES}], e.g. 'git label add to_qa'" unless MODES.include? mode
|
30
|
+
|
31
|
+
PivotalIntegration::Util::Label.send(mode, story, *labels)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
require 'pivotal-tracker'
|
18
|
+
|
19
|
+
# The class that encapsulates assigning current Pivotal Tracker Story to a user
|
20
|
+
class PivotalIntegration::Command::Mark < PivotalIntegration::Command::Base
|
21
|
+
desc "Mark the current story with a given state"
|
22
|
+
|
23
|
+
STATES = %w(unstarted started finished delivered rejected accepted)
|
24
|
+
|
25
|
+
# Assigns story to user.
|
26
|
+
# @return [void]
|
27
|
+
def run(*arguments)
|
28
|
+
state = arguments.first
|
29
|
+
state = choose_state if state.nil? or !STATES.include?(state)
|
30
|
+
|
31
|
+
PivotalIntegration::Util::Story.mark(story, state)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def choose_state
|
37
|
+
choose do |menu|
|
38
|
+
menu.prompt = 'Choose story state from above list: '
|
39
|
+
STATES.each do |state|
|
40
|
+
menu.choice(state)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
require 'pivotal-tracker'
|
18
|
+
|
19
|
+
# The class that encapsulates starting a Pivotal Tracker Story
|
20
|
+
class PivotalIntegration::Command::New < PivotalIntegration::Command::Base
|
21
|
+
desc "Create a new story"
|
22
|
+
|
23
|
+
STORY_TYPES = %w(feature bug chore release)
|
24
|
+
def run(*arguments)
|
25
|
+
options = self.class.collect_type_and_name(arguments)
|
26
|
+
|
27
|
+
puts
|
28
|
+
print 'Creating new story on Pivotal Tracker... '
|
29
|
+
PivotalIntegration::Util::Story.new(@configuration.project, *options)
|
30
|
+
puts 'OK'
|
31
|
+
end
|
32
|
+
|
33
|
+
class << self
|
34
|
+
def collect_type_and_name(arguments)
|
35
|
+
type = STORY_TYPES.include?(arguments.first.try(:downcase)) ? arguments.shift : choose_type
|
36
|
+
type = type.downcase.to_sym
|
37
|
+
|
38
|
+
name = arguments.shift || ask('Provide a name for the new story: ')
|
39
|
+
|
40
|
+
[name, type]
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def choose_type
|
46
|
+
choose do |menu|
|
47
|
+
menu.prompt = 'What type of story do you want to create: '
|
48
|
+
STORY_TYPES.each { |type| menu.choice(type.titleize) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
require 'pivotal-tracker'
|
18
|
+
require 'launchy'
|
19
|
+
|
20
|
+
# The class that encapsulates assigning current Pivotal Tracker Story to a user
|
21
|
+
class PivotalIntegration::Command::Open < PivotalIntegration::Command::Base
|
22
|
+
desc "Open the current story or project in a web browser."
|
23
|
+
|
24
|
+
def run(*arguments)
|
25
|
+
if arguments.first.try(:downcase) == 'project'
|
26
|
+
Launchy.open "https://www.pivotaltracker.com/s/projects/#{story.project_id}"
|
27
|
+
else
|
28
|
+
Launchy.open story.url
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
# Git Pivotal Tracker Integration
|
3
|
+
# Copyright (c) 2013 the original author or authors.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
CURRENT_BRANCH=$(git branch | grep "*" | sed "s/* //")
|
18
|
+
STORY_ID=$(git config branch.$CURRENT_BRANCH.pivotal-story-id)
|
19
|
+
|
20
|
+
if [[ $2 != "commit" && -n $STORY_ID ]]; then
|
21
|
+
ORIG_MSG_FILE="$1"
|
22
|
+
TEMP=$(mktemp /tmp/git-XXXXX)
|
23
|
+
|
24
|
+
(printf "\n\n[#$STORY_ID] " ; cat "$1") > "$TEMP"
|
25
|
+
cat "$TEMP" > "$ORIG_MSG_FILE"
|
26
|
+
fi
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Git Pivotal Tracker Integration
|
2
|
+
# Copyright (c) 2013 the original author or authors.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require_relative 'base'
|
17
|
+
require_relative '../version-update/gradle'
|
18
|
+
|
19
|
+
# The class that encapsulates releasing a Pivotal Tracker Story
|
20
|
+
class PivotalIntegration::Command::Release < PivotalIntegration::Command::Base
|
21
|
+
desc "Create a release for a story"
|
22
|
+
|
23
|
+
# Releases a Pivotal Tracker story by doing the following steps:
|
24
|
+
# * Update the version to the release version
|
25
|
+
# * Create a tag for the release version
|
26
|
+
# * Update the version to the new development version
|
27
|
+
# * Push tag and changes to remote
|
28
|
+
#
|
29
|
+
# @param [String, nil] filter a filter for selecting the release to start. This
|
30
|
+
# filter can be either:
|
31
|
+
# * a story id
|
32
|
+
# * +nil+
|
33
|
+
# @return [void]
|
34
|
+
def run(filter)
|
35
|
+
story = PivotalIntegration::Util::Story.select_story(@project, filter.nil? ? 'release' : filter, 1)
|
36
|
+
PivotalIntegration::Util::Story.pretty_print story
|
37
|
+
|
38
|
+
updater = [
|
39
|
+
PivotalIntegration::VersionUpdate::Gradle.new(@repository_root)
|
40
|
+
].find { |candidate| candidate.supports? }
|
41
|
+
|
42
|
+
current_version = updater.current_version
|
43
|
+
release_version = ask("Enter release version (current: #{current_version}): ")
|
44
|
+
next_version = ask("Enter next development version (current: #{current_version}): ")
|
45
|
+
|
46
|
+
updater.update_version release_version
|
47
|
+
PivotalIntegration::Util::Git.create_release_tag release_version, story
|
48
|
+
updater.update_version next_version
|
49
|
+
PivotalIntegration::Util::Git.create_commit "#{next_version} Development", story
|
50
|
+
|
51
|
+
PivotalIntegration::Util::Git.push PivotalIntegration::Util::Git.branch_name, "v#{release_version}"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|