Top Level Namespace
Defined Under Namespace
Modules: Git
Classes: GitStart
Constant Summary
collapse
- PLUGINS =
{
'show-summary' => 'Show story summary after starting',
'pivotal' => 'PivotalTracker integration',
'rebase' => 'Rebase to default branch before finishing',
'pull-request' => 'Open pull request after finishing',
}
Instance Method Summary
collapse
Instance Method Details
#create_story(type) ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/git-start/plugins/pivotal.rb', line 105
def create_story(type)
params = {
name: ask_for('Story title'),
description: ask_for('Story description'),
requested_by_id: requester_id,
owner_ids: [@user_id],
story_type: type
}
data = @tracker.post("/projects/#{@project_id}/stories", params: params).body
TrackerApi::Resources::Story.new({ client: @client }.merge(data))
end
|
#estimate ⇒ Object
87
88
89
90
91
|
# File 'lib/git-start/plugins/pivotal.rb', line 87
def estimate
scale = @project.point_scale.gsub(',', ', ')
estimate = ask_for("This story needs an estimate first [#{scale}]")
update_story @story.id, estimate: estimate
end
|
#filter ⇒ Object
57
58
59
|
# File 'lib/git-start/plugins/pivotal.rb', line 57
def filter
"current_state:unscheduled,unstarted,rejected mywork:#{@user_initials}"
end
|
#generate_summary ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/git-start/plugins/pivotal.rb', line 44
def generate_summary
<<-MARKDOWN.gsub(/^ /, '').gsub(/\n+/, "\n\n")
# #{@story.name}
#{@story.description}
#{@story.tasks.map{ |t| " * #{t.description}" }.join("\n") rescue ''}
<#{@story.url}>
MARKDOWN
end
|
#needs_estimation? ⇒ Boolean
82
83
84
85
|
# File 'lib/git-start/plugins/pivotal.rb', line 82
def needs_estimation?
@story.estimate.nil? &&
@story.story_type == 'feature' || @project.bugs_and_chores_are_estimatable
end
|
#requester_id ⇒ Object
117
118
119
120
121
|
# File 'lib/git-start/plugins/pivotal.rb', line 117
def requester_id
question = 'Story requester initials'
initials = config('pivotal.requester', question, :local, @user_initials).upcase
user_id_of(initials)
end
|
#select_story ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/git-start/plugins/pivotal.rb', line 61
def select_story
existing_stories = stories.map do |s|
s.story_type.upcase.ljust(9) + s.name
end
new_story_types = @story_types.inject({}) do |h, (key, type)|
h.update(key => type.to_s.upcase.ljust(9) + "Create new #{type} story")
end
choice = select_one_of('Select story', existing_stories, new_story_types)
if @story_types.has_key?(choice)
@story = create_story(@story_types[choice])
else
if choice >= 0 and choice < stories.length
@story = stories[choice]
else
abort "No valid story selected."
end
end
estimate if needs_estimation?
end
|
#stories ⇒ Object
53
54
55
|
# File 'lib/git-start/plugins/pivotal.rb', line 53
def stories
@stories ||= @project.stories(filter: filter, limit: 999)
end
|
#update_story(id, attributes) ⇒ Object
93
94
95
|
# File 'lib/git-start/plugins/pivotal.rb', line 93
def update_story(id, attributes)
@tracker.put "/projects/#{@project_id}/stories/#{id}", params: attributes
end
|
#user_id_of(initials) ⇒ Object
97
98
99
100
101
102
103
|
# File 'lib/git-start/plugins/pivotal.rb', line 97
def user_id_of(initials)
membership = @project.memberships.detect{ |m| m.person.initials == initials }
if membership.nil?
abort "User with initials #{initials} not found for this project."
end
membership.person.id
end
|