pivotal-github 0.6.4 → 0.6.5
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/README.md +10 -4
- data/lib/pivotal-github/command.rb +1 -1
- data/lib/pivotal-github/finished_command.rb +28 -0
- data/lib/pivotal-github/story_merge.rb +8 -5
- data/lib/pivotal-github/story_pull_request.rb +15 -26
- data/lib/pivotal-github/version.rb +1 -1
- data/spec/commands/FinishedCommand.rb +0 -0
- data/spec/commands/story_pull_request_spec.rb +8 -1
- metadata +4 -1
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# pivotal-github
|
2
2
|
|
3
|
-
The `pivotal-github` gem facilitates a Pivotal Tracker–GitHub workflow inspired by [Logical Reality](http://lrdesign.com/). As per usual, there are several projects (notably [git-flow](https://github.com/nvie/gitflow) and [git-pivotal](https://github.com/trydionel/git-pivotal)) that implement similar solutions, but none met my exact needs.
|
3
|
+
The `pivotal-github` gem facilitates a Pivotal Tracker–GitHub workflow inspired by the workflow used by [Logical Reality](http://lrdesign.com/). As per usual, there are several projects (notably [git-flow](https://github.com/nvie/gitflow) and [git-pivotal](https://github.com/trydionel/git-pivotal)) that implement similar solutions, but none met my exact needs.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -93,7 +93,7 @@ Additionally, `git story-pull` accepts any options valid for `git pull`.
|
|
93
93
|
$ git checkout master
|
94
94
|
$ git merge --no-ff --log 6283185-add-markdown-support
|
95
95
|
|
96
|
-
Note that this effectively changes the default merge behavior from fast-forward to no-fast-forward, which makes it possible to
|
96
|
+
Note that this effectively changes the default merge behavior from fast-forward to no-fast-forward, which makes it possible to use `git log` to see which of the commit objects together have implemented a story. As noted in [A successful Git branching model](http://nvie.com/posts/a-successful-git-branching-model/),
|
97
97
|
|
98
98
|
> The `--no-ff` flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature… Yes, it will create a few more (empty) commit objects, but the gain is much bigger that that cost.
|
99
99
|
|
@@ -101,10 +101,13 @@ In addition, the `--log` option puts the commit messages from the individual com
|
|
101
101
|
|
102
102
|
Because of the way options are chained, passing `--ff` or `--no-log` to `git story-merge` will override the `--no-ff` or `--log` flags (respectively) and thus restore the default behavior of `git merge`.
|
103
103
|
|
104
|
+
Finally, experience shows that it's easy to forget to mark a story finished when making the final commit. As a reminder, the `git story-merge` command exits with a warning if the most recent commit doesn't contain 'Finishes' or 'Delivers' (or 'Finished' or 'Delivered'). This behavior can be overriden with the `--run` option. (I wanted to use `-f` and `--force`, but those interact badly with the default `git merge` options.)
|
105
|
+
|
104
106
|
#### Options
|
105
107
|
|
106
108
|
Usage: git story-merge [options]
|
107
109
|
-d, --development BRANCH development branch (defaults to master)
|
110
|
+
-r, --run run without marking story finished
|
108
111
|
-h, --help this usage guide
|
109
112
|
|
110
113
|
Additionally, `git story-merge` accepts any options valid for `git merge`.
|
@@ -115,12 +118,15 @@ Additionally, `git story-merge` accepts any options valid for `git merge`.
|
|
115
118
|
|
116
119
|
$ git story-pull-request
|
117
120
|
|
118
|
-
|
121
|
+
By default, `git story-pull-request` issues a `git story-push` as well, just in case the local branch hasn't yet been pushed up to the remote repository. This step can be skipped with the `--skip` option.
|
122
|
+
|
123
|
+
As with `git story-merge`, by default `git story-pull-request` exits with a warning if the most recent commit doesn't finish the story.
|
119
124
|
|
120
125
|
#### Options
|
121
126
|
|
122
127
|
Usage: git story-pull-request [options]
|
123
|
-
|
128
|
+
-r, --run run without marking story finished
|
129
|
+
-s, --skip skip `git story-push`
|
124
130
|
-h, --help this usage guide
|
125
131
|
|
126
132
|
### story-open
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# By devault, command runs only when story is finished
|
2
|
+
class FinishedCommand < Command
|
3
|
+
|
4
|
+
def run!
|
5
|
+
check_finishes unless run?
|
6
|
+
system cmd
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# Checks to see if the most recent commit finishes the story
|
12
|
+
# We look for 'Finishes' or 'Delivers' and issue a warning if neither is
|
13
|
+
# in the most recent commit. (Also supports 'Finished' and 'Delivered'.)
|
14
|
+
def check_finishes
|
15
|
+
unless `git log -1` =~ /Finishe(s|d)|Deliver(s|ed)/
|
16
|
+
warning = "Warning: Unfinished story\n"
|
17
|
+
warning += "Run `git commit --amend` to add 'Finishes' or 'Delivers' "
|
18
|
+
warning += "to the commit message\n"
|
19
|
+
warning += "Use --force to override"
|
20
|
+
$stderr.puts warning
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def run?
|
26
|
+
options.run
|
27
|
+
end
|
28
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pivotal-github/command'
|
2
|
+
require 'pivotal-github/finished_command'
|
2
3
|
|
3
|
-
class StoryMerge <
|
4
|
+
class StoryMerge < FinishedCommand
|
4
5
|
|
5
6
|
def parser
|
6
7
|
OptionParser.new do |opts|
|
@@ -9,6 +10,12 @@ class StoryMerge < Command
|
|
9
10
|
"development branch (defaults to master)") do |opt|
|
10
11
|
self.options.development = opt
|
11
12
|
end
|
13
|
+
# I wanted to use '-f' and '--force', but those interact
|
14
|
+
# badly with the default `git merge` options.
|
15
|
+
opts.on("-r", "--run",
|
16
|
+
"run without marking story finished") do |opt|
|
17
|
+
self.options.run = opt
|
18
|
+
end
|
12
19
|
opts.on_tail("-h", "--help", "this usage guide") do
|
13
20
|
puts opts.to_s; exit 0
|
14
21
|
end
|
@@ -28,10 +35,6 @@ class StoryMerge < Command
|
|
28
35
|
lines.join("\n")
|
29
36
|
end
|
30
37
|
|
31
|
-
def run!
|
32
|
-
system cmd
|
33
|
-
end
|
34
|
-
|
35
38
|
private
|
36
39
|
|
37
40
|
def development_branch
|
@@ -1,13 +1,17 @@
|
|
1
1
|
require 'pivotal-github/command'
|
2
|
+
require 'pivotal-github/finished_command'
|
2
3
|
|
3
|
-
class StoryPullRequest <
|
4
|
+
class StoryPullRequest < FinishedCommand
|
4
5
|
|
5
6
|
def parser
|
6
7
|
OptionParser.new do |opts|
|
7
8
|
opts.banner = "Usage: git story-pull-request [options]"
|
8
|
-
opts.on("-
|
9
|
-
"run without marking story finished") do |
|
10
|
-
self.options.
|
9
|
+
opts.on("-r", "--run",
|
10
|
+
"run without marking story finished") do |opt|
|
11
|
+
self.options.run = opt
|
12
|
+
end
|
13
|
+
opts.on("-s", "--skip", "skip `git story-push`") do |opt|
|
14
|
+
self.options.skip = opt
|
11
15
|
end
|
12
16
|
opts.on_tail("-h", "--help", "this usage guide") do
|
13
17
|
puts opts.to_s; exit 0
|
@@ -18,18 +22,17 @@ class StoryPullRequest < Command
|
|
18
22
|
# Returns a command appropriate for executing at the command line
|
19
23
|
# I.e., 'open https://www.pivotaltracker.com/story/show/6283185'
|
20
24
|
def cmd
|
21
|
-
|
25
|
+
if skip?
|
26
|
+
"open #{uri}"
|
27
|
+
else
|
28
|
+
"git story-push && open #{uri}"
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
def uri
|
25
33
|
"#{origin_uri}/pull/new/#{story_branch}"
|
26
34
|
end
|
27
35
|
|
28
|
-
def run!
|
29
|
-
check_finishes unless force?
|
30
|
-
system cmd
|
31
|
-
end
|
32
|
-
|
33
36
|
private
|
34
37
|
|
35
38
|
# Returns the remote URI for the repository
|
@@ -38,21 +41,7 @@ class StoryPullRequest < Command
|
|
38
41
|
`git config --get remote.origin.url`.strip.chomp('.git')
|
39
42
|
end
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
# in the most recent commit. (Also supports 'Finished' and 'Delivered'.)
|
44
|
-
def check_finishes
|
45
|
-
unless `git log -1` =~ /Finishe(s|d)|Deliver(s|ed)/
|
46
|
-
warning = "Warning: Unfinished story\n"
|
47
|
-
warning += "Run `git commit --amend` to add 'Finishes' or 'Delivers' "
|
48
|
-
warning += "to the commit message\n"
|
49
|
-
warning += "Use --force to override"
|
50
|
-
$stderr.puts warning
|
51
|
-
exit 1
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def force?
|
56
|
-
options.force
|
44
|
+
def skip?
|
45
|
+
options.skip
|
57
46
|
end
|
58
47
|
end
|
File without changes
|
@@ -9,11 +9,18 @@ describe StoryPullRequest do
|
|
9
9
|
end
|
10
10
|
subject { command }
|
11
11
|
|
12
|
-
its(:cmd) { should
|
12
|
+
its(:cmd) { should =~ /open #{command.uri}/ }
|
13
|
+
its(:cmd) { should =~ /git story-push/ }
|
13
14
|
|
14
15
|
describe "command-line command" do
|
15
16
|
subject { `bin/git-story-pull-request --debug` }
|
16
17
|
it { should =~ /pull\/new/ }
|
17
18
|
it { should_not =~ /\.git/ }
|
19
|
+
it { should =~ /git story-push/ }
|
20
|
+
|
21
|
+
describe "with a skip option" do
|
22
|
+
subject { `bin/git-story-pull-request --skip --debug` }
|
23
|
+
it { should_not =~ /git story-push/ }
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pivotal-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- bin/story-open
|
39
39
|
- lib/pivotal-github.rb
|
40
40
|
- lib/pivotal-github/command.rb
|
41
|
+
- lib/pivotal-github/finished_command.rb
|
41
42
|
- lib/pivotal-github/options.rb
|
42
43
|
- lib/pivotal-github/story_commit.rb
|
43
44
|
- lib/pivotal-github/story_merge.rb
|
@@ -47,6 +48,7 @@ files:
|
|
47
48
|
- lib/pivotal-github/story_push.rb
|
48
49
|
- lib/pivotal-github/version.rb
|
49
50
|
- pivotal-github.gemspec
|
51
|
+
- spec/commands/FinishedCommand.rb
|
50
52
|
- spec/commands/command_spec.rb
|
51
53
|
- spec/commands/story_commit_spec.rb
|
52
54
|
- spec/commands/story_merge_spec.rb
|
@@ -81,6 +83,7 @@ signing_key:
|
|
81
83
|
specification_version: 3
|
82
84
|
summary: See the README for full documentation
|
83
85
|
test_files:
|
86
|
+
- spec/commands/FinishedCommand.rb
|
84
87
|
- spec/commands/command_spec.rb
|
85
88
|
- spec/commands/story_commit_spec.rb
|
86
89
|
- spec/commands/story_merge_spec.rb
|