assisted_workflow 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/assisted_workflow/cli.rb +23 -13
- data/lib/assisted_workflow/git.rb +3 -2
- data/lib/assisted_workflow/pivotal.rb +24 -8
- data/lib/assisted_workflow/version.rb +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Assisted Workflow (aw)
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/assisted_workflow.png)](http://badge.fury.io/rb/assisted_workflow) [![Code Climate](https://codeclimate.com/github/flaviogranero/assisted_workflow.png)](https://codeclimate.com/github/flaviogranero/assisted_workflow)
|
4
|
+
|
3
5
|
AW is a CLI tool to automate software development workflows based on github pull requests.
|
4
6
|
|
5
7
|
* [Github Workflow](http://scottchacon.com/2011/08/31/github-flow.html)
|
@@ -16,33 +16,37 @@ class AssistedWorkflow::CLI < Thor
|
|
16
16
|
copy_file "awconfig.local.tt", LOCAL_CONFIG
|
17
17
|
if File.exists?(".git")
|
18
18
|
copy_file "commit-msg.tt", ".git/hooks/commit-msg"
|
19
|
+
chmod ".git/hooks/commit-msg", "a+x"
|
19
20
|
else
|
20
21
|
raise AssistedWorkflow::Error, ".git folder not found"
|
21
22
|
end
|
22
23
|
say "set your own configuration editing the .awconfig files or running:", :green
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
say_command "$ aw config pivotal.fullname='Flavio Granero' --global"
|
25
|
+
say_command "$ aw config pivotal.token=MYPIVOTALTOKEN --global"
|
26
|
+
say_command "$ aw config github.token=MYGITHUBOAUTHTOKEN --global"
|
27
|
+
say_command "$ aw config pivotal.project_id=00001"
|
27
28
|
end
|
28
29
|
|
29
30
|
desc "start [STORY_ID]", "Start the pivotal story and create a new branch to receive the changes"
|
31
|
+
method_option :all, :type => :boolean, :default => false, :aliases => "-a", :desc => "Show started and pending stories when no story_id is provided"
|
32
|
+
method_option :estimate, :type => :numeric, :aliases => "-e", :desc => "Sets the story estimate when starting"
|
30
33
|
def start(story_id=nil)
|
31
34
|
check_awfile!
|
32
35
|
story = pivotal.find_story(story_id)
|
33
36
|
if story.nil?
|
34
|
-
stories = pivotal.pending_stories
|
37
|
+
stories = pivotal.pending_stories(:include_started => options[:all])
|
35
38
|
print_title "pending stories"
|
36
|
-
print_table(pivotal.display_values(stories))
|
39
|
+
print_table(pivotal.display_values(stories, :show_state => options[:all]))
|
37
40
|
say "start a story using:", :green
|
38
|
-
|
41
|
+
say_command "$ aw start [STORY_ID]"
|
39
42
|
else
|
43
|
+
say_status "starting story", story.name
|
44
|
+
pivotal.start_story(story, :estimate => options[:estimate])
|
45
|
+
print_wrapped story.description, :indent => 2
|
40
46
|
say "creating the feature branch"
|
41
47
|
git.create_story_branch(story)
|
42
|
-
say "starting story: #{story.name}"
|
43
|
-
pivotal.start_story(story)
|
44
48
|
say "after commiting your changes, submit a pull request using:", :green
|
45
|
-
|
49
|
+
say_command "$ aw submit"
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
@@ -58,10 +62,10 @@ class AssistedWorkflow::CLI < Thor
|
|
58
62
|
say "submiting the new pull request"
|
59
63
|
pr = github.create_pull_request(git.repository, git.current_branch, story)
|
60
64
|
say "finishing the story"
|
61
|
-
pivotal.finish_story(story)
|
65
|
+
pivotal.finish_story(story, :note => pr._links.html.href)
|
62
66
|
say "new pull request: #{pr._links.html.href}", :yellow
|
63
67
|
say "after pull request approval, remove the feature branch using:", :green
|
64
|
-
|
68
|
+
say_command "$ aw finish"
|
65
69
|
else
|
66
70
|
raise AssistedWorkflow::Error, "story not found, make sure a feature branch in active"
|
67
71
|
end
|
@@ -76,7 +80,7 @@ class AssistedWorkflow::CLI < Thor
|
|
76
80
|
say "removing local and remote feature branches"
|
77
81
|
git.remove_branch
|
78
82
|
say "well done! check your next stories using:", :green
|
79
|
-
|
83
|
+
say_command "$ aw start"
|
80
84
|
else
|
81
85
|
say "this branch is not merged into master yet", :yellow
|
82
86
|
end
|
@@ -144,6 +148,12 @@ class AssistedWorkflow::CLI < Thor
|
|
144
148
|
say "-" * title.length, :green
|
145
149
|
end
|
146
150
|
|
151
|
+
def say_command(command)
|
152
|
+
with_padding do
|
153
|
+
say command
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
147
157
|
def check_awfile!
|
148
158
|
raise AssistedWorkflow::Error, "#{awfile} does not exist.\nmake sure you run `$ aw setup` in your project folder." unless File.exist?(awfile)
|
149
159
|
end
|
@@ -60,7 +60,7 @@ module AssistedWorkflow
|
|
60
60
|
# removes current branch and his remote version
|
61
61
|
def remove_branch
|
62
62
|
branch = current_branch
|
63
|
-
git "push origin :#{branch}"
|
63
|
+
git "push origin :#{branch}", :raise_error => false
|
64
64
|
git "checkout master"
|
65
65
|
git "branch -D #{branch}"
|
66
66
|
end
|
@@ -68,9 +68,10 @@ module AssistedWorkflow
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def git(command, options = {})
|
71
|
+
options = {:raise_error => true}.merge(options)
|
71
72
|
puts "git #{command}" unless options[:silent] == true
|
72
73
|
result = %x{git #{command}}.chomp
|
73
|
-
|
74
|
+
if $? != 0 && options[:raise_error]
|
74
75
|
msg = ["git command error", options[:error]].compact.join(": ")
|
75
76
|
raise GitError, msg
|
76
77
|
end
|
@@ -27,21 +27,37 @@ module AssistedWorkflow
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def start_story(story)
|
31
|
-
story.
|
30
|
+
def start_story(story, options = {})
|
31
|
+
update_story! story, options.merge(:current_state => "started")
|
32
32
|
end
|
33
33
|
|
34
|
-
def finish_story(story)
|
35
|
-
story
|
34
|
+
def finish_story(story, options = {})
|
35
|
+
if update_story! story, :current_state => finished_state(story)
|
36
|
+
story.notes.create(:text => options[:note]) if options[:note]
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
|
-
def pending_stories
|
39
|
-
|
40
|
+
def pending_stories(options = {})
|
41
|
+
states = ["unstarted"]
|
42
|
+
states << "started" if options[:include_started]
|
43
|
+
@project.stories.all(:state => states, :owned_by => @username, :limit => 5)
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_story!(story, attributes)
|
47
|
+
if story
|
48
|
+
story.update(attributes)
|
49
|
+
raise AssistedWorkflow::Error, story.errors.first.to_s if story.errors.any?
|
50
|
+
true
|
51
|
+
end
|
40
52
|
end
|
41
53
|
|
42
|
-
def display_values(stories)
|
54
|
+
def display_values(stories, options = {})
|
43
55
|
stories.map do |story|
|
44
|
-
[
|
56
|
+
if options[:show_state]
|
57
|
+
[story.id, story.current_state, story.name]
|
58
|
+
else
|
59
|
+
[story.id, story.estimate, story.name]
|
60
|
+
end
|
45
61
|
end
|
46
62
|
end
|
47
63
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assisted_workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|