pivotal-github 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -17
- data/lib/pivotal-github/command.rb +29 -1
- data/lib/pivotal-github/finished_command.rb +3 -3
- data/lib/pivotal-github/story_commit.rb +0 -28
- data/lib/pivotal-github/story_merge.rb +18 -10
- data/lib/pivotal-github/story_pull_request.rb +2 -2
- data/lib/pivotal-github/version.rb +1 -1
- data/spec/commands/story_merge_spec.rb +29 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5672ce3f4df8fdbdea49b112f1537d6ade0700c6
|
4
|
+
data.tar.gz: d6e4d7f5c7ad72b974eeebac0dc39e641b6f556c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 023d5468e238d7ebc8f4e82c1d029fb59ee2cf19bc2030ee9ed5ba010dd3e9feb36c819bfcb9c8ad4f064f0fe8db7ad28cf46a956353f387c003c6933e315d7f
|
7
|
+
data.tar.gz: bf5acac1a04b0844c5594dbea15361c9b7b6c61307521d3dc8fe2876ec2344eaf920a3efcf6faf677a68b1b2ad815938432c9322b6f6616ed41bdada7807d5fe
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ The full set of commands is as follows:
|
|
25
25
|
For example, when on a branch called `add-markdown-support-62831853`, the `git story-commit` command automatically adds `[#62831853]` to the commit message:
|
26
26
|
|
27
27
|
$ git story-commit -am "Add foo bars"
|
28
|
-
|
28
|
+
[add-markdown-support-62831853 6f56414] Add foo bars
|
29
29
|
|
30
30
|
The commit message is multiline and includes the story id:
|
31
31
|
|
@@ -62,7 +62,7 @@ Either the `-f` flag or the `-d` flag can be combined with other flags, yielding
|
|
62
62
|
`git story commit` supports multiple story numbers as well. For example, with a branch called `add-things-62831853-31415926`, we could deliver both stories as follows:
|
63
63
|
|
64
64
|
$ git story-commit -dam "Remove baz quuxes"
|
65
|
-
|
65
|
+
[add-things-62831853-31415926 7g56429] Remove baz quuxes
|
66
66
|
|
67
67
|
The message here is
|
68
68
|
|
@@ -72,38 +72,39 @@ The message here is
|
|
72
72
|
|
73
73
|
#### Options
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
75
|
+
$ git story-commit -h
|
76
|
+
Usage: git story-commit [options]
|
77
|
+
-m, --message MESSAGE add a commit message (including story #)
|
78
|
+
-f, --finish mark story as finished
|
79
|
+
-d, --deliver mark story as delivered
|
80
|
+
-a, --all commit all changed files
|
81
|
+
-h, --help this usage guide
|
82
82
|
|
83
83
|
Additionally, `git story-commit` accepts any options valid for `git commit`. (`git story-commit` supports the `-a` flag even though that's a valid option to `git commit` so that the compound flag in `git story-commit -am "message"` works.)
|
84
84
|
|
85
85
|
### git story-merge
|
86
86
|
|
87
|
-
`git story-merge` merges the current branch into `master
|
87
|
+
`git story-merge` merges the current branch into the target branch (defaults to `master`). On a branch called `add-markdown-support-62831853`, `git story-merge` is equivalent to the following:
|
88
88
|
|
89
89
|
$ git checkout master
|
90
|
-
$ git merge --no-ff --log add-markdown-support-62831853
|
90
|
+
$ git merge --no-ff --log add-markdown-support-62831853 -m "#[62831853]"
|
91
91
|
|
92
92
|
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/),
|
93
93
|
|
94
94
|
> 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 than that cost.
|
95
95
|
|
96
|
-
|
96
|
+
The `--log` option puts the commit messages from the individual commits in the merge message, while the `-m` flag adds the story id to the commit (optionally marking it finished or delivered with the `-f` or `-d` flag, respectively). Including the story id arranges for the merge commit itself to appear in the activity log at Pivotal Tracker, which is especially useful for viewing the full diff represented by the story.
|
97
97
|
|
98
98
|
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`.
|
99
99
|
|
100
|
-
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', 'Delivered', 'Fixes', or 'Fixed'). This behavior can be overriden with the `--
|
100
|
+
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', 'Delivered', 'Fixes', or 'Fixed'). This behavior can be overriden with the `--override` option.
|
101
101
|
|
102
102
|
#### Options
|
103
103
|
|
104
|
-
Usage: git story-merge [options]
|
105
|
-
-
|
106
|
-
|
104
|
+
Usage: git story-merge [branch] [options]
|
105
|
+
-o, --override override unfinished story warning
|
106
|
+
-f, --finish mark story as finished
|
107
|
+
-d, --deliver mark story as delivered
|
107
108
|
-h, --help this usage guide
|
108
109
|
|
109
110
|
Additionally, `git story-merge` accepts any options valid for `git merge`.
|
@@ -121,7 +122,7 @@ As with `git story-merge`, by default `git story-pull-request` exits with a warn
|
|
121
122
|
#### Options
|
122
123
|
|
123
124
|
Usage: git story-pull-request [options]
|
124
|
-
|
125
|
+
-o, --override override unfinished story warning
|
125
126
|
-h, --help this usage guide
|
126
127
|
|
127
128
|
### story-open
|
@@ -14,7 +14,7 @@ class Command
|
|
14
14
|
def parse
|
15
15
|
self.known_options = Options::known_options(parser, args)
|
16
16
|
self.unknown_options = Options::unknown_options(parser, args)
|
17
|
-
parser.parse(known_options)
|
17
|
+
parser.parse!(known_options)
|
18
18
|
end
|
19
19
|
|
20
20
|
def parser
|
@@ -40,6 +40,26 @@ class Command
|
|
40
40
|
story_ids.first
|
41
41
|
end
|
42
42
|
|
43
|
+
# Returns the message for the story id(s) and action (if any).
|
44
|
+
def message
|
45
|
+
if finish?
|
46
|
+
label = "Finishes #{message_ids}"
|
47
|
+
elsif deliver?
|
48
|
+
label = "Delivers #{message_ids}"
|
49
|
+
else
|
50
|
+
label = message_ids
|
51
|
+
end
|
52
|
+
"[#{label}]"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns the story ids formatted for story commits.
|
56
|
+
# For single-id stories, this is just the number preceded by '#', as in
|
57
|
+
# '#62831853'. For multiple-id stories, each story id is precede by '#', as in
|
58
|
+
# '#62831853 #31415926'
|
59
|
+
def message_ids
|
60
|
+
story_ids.map { |id| "##{id}" }.join(' ')
|
61
|
+
end
|
62
|
+
|
43
63
|
# Runs a command.
|
44
64
|
# If the argument array contains '--debug', returns the command that would
|
45
65
|
# have been run.
|
@@ -77,4 +97,12 @@ class Command
|
|
77
97
|
exit 1
|
78
98
|
end
|
79
99
|
end
|
100
|
+
|
101
|
+
def finish?
|
102
|
+
options.finish
|
103
|
+
end
|
104
|
+
|
105
|
+
def deliver?
|
106
|
+
options.deliver
|
107
|
+
end
|
80
108
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class FinishedCommand < Command
|
3
3
|
|
4
4
|
def run!
|
5
|
-
check_finishes unless
|
5
|
+
check_finishes unless override?
|
6
6
|
system cmd
|
7
7
|
end
|
8
8
|
|
@@ -26,7 +26,7 @@ class FinishedCommand < Command
|
|
26
26
|
!!(`git log -1`.match(/Finishe(s|d)|Deliver(s|ed)|Fixe(s|d) #\d+/i))
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
options.
|
29
|
+
def override?
|
30
|
+
options.override
|
31
31
|
end
|
32
32
|
end
|
@@ -24,26 +24,6 @@ class StoryCommit < Command
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
# Returns the message for the story id(s) and action (if any).
|
28
|
-
def message
|
29
|
-
if finish?
|
30
|
-
label = "Finishes #{message_ids}"
|
31
|
-
elsif deliver?
|
32
|
-
label = "Delivers #{message_ids}"
|
33
|
-
else
|
34
|
-
label = message_ids
|
35
|
-
end
|
36
|
-
"[#{label}]"
|
37
|
-
end
|
38
|
-
|
39
|
-
# Returns the story ids formatted for story commits.
|
40
|
-
# For single-id stories, this is just the number preceded by '#', as in
|
41
|
-
# '#62831853'. For multiple-id stories, each story id is precede by '#', as in
|
42
|
-
# '#62831853 #31415926'
|
43
|
-
def message_ids
|
44
|
-
story_ids.map { |id| "##{id}" }.join(' ')
|
45
|
-
end
|
46
|
-
|
47
27
|
# Returns a command appropriate for executing at the command line.
|
48
28
|
# We take care to insert the story number and, if necessary, an indication
|
49
29
|
# that the commit finishes the story.
|
@@ -62,14 +42,6 @@ class StoryCommit < Command
|
|
62
42
|
|
63
43
|
private
|
64
44
|
|
65
|
-
def finish?
|
66
|
-
options.finish
|
67
|
-
end
|
68
|
-
|
69
|
-
def deliver?
|
70
|
-
options.deliver
|
71
|
-
end
|
72
|
-
|
73
45
|
def message?
|
74
46
|
!options.message.nil?
|
75
47
|
end
|
@@ -5,13 +5,17 @@ class StoryMerge < FinishedCommand
|
|
5
5
|
|
6
6
|
def parser
|
7
7
|
OptionParser.new do |opts|
|
8
|
-
opts.banner = "Usage: git story-merge [options]"
|
9
|
-
opts.on("-
|
10
|
-
|
11
|
-
self.options.development = opt
|
8
|
+
opts.banner = "Usage: git story-merge [branch] [options]"
|
9
|
+
opts.on("-o", "--override", "override unfinished story warning") do |opt|
|
10
|
+
self.options.override = opt
|
12
11
|
end
|
13
|
-
opts.on("-f", "--
|
14
|
-
self.options.
|
12
|
+
opts.on("-f", "--finish", "mark story as finished") do |opt|
|
13
|
+
self.options.finish = opt
|
14
|
+
self.options.override = opt
|
15
|
+
end
|
16
|
+
opts.on("-d", "--deliver", "mark story as delivered") do |opt|
|
17
|
+
self.options.deliver = opt
|
18
|
+
self.options.override = opt
|
15
19
|
end
|
16
20
|
opts.on_tail("-h", "--help", "this usage guide") do
|
17
21
|
puts opts.to_s; exit 0
|
@@ -24,8 +28,9 @@ class StoryMerge < FinishedCommand
|
|
24
28
|
# git checkout master
|
25
29
|
# git merge --no-ff <story branch>
|
26
30
|
def cmd
|
27
|
-
lines = ["git checkout #{
|
28
|
-
c = [
|
31
|
+
lines = ["git checkout #{target_branch}"]
|
32
|
+
c = ["git merge --no-ff --log"]
|
33
|
+
c << %(-m "#{message}")
|
29
34
|
c << argument_string(unknown_options) unless unknown_options.empty?
|
30
35
|
c << story_branch
|
31
36
|
lines << c.join(' ')
|
@@ -34,7 +39,10 @@ class StoryMerge < FinishedCommand
|
|
34
39
|
|
35
40
|
private
|
36
41
|
|
37
|
-
|
38
|
-
|
42
|
+
# Returns the name of the branch to be merged into.
|
43
|
+
# If there is anything left in the known options after parsing,
|
44
|
+
# that's the merge branch. Otherwise, it's master.
|
45
|
+
def target_branch
|
46
|
+
self.known_options.first || 'master'
|
39
47
|
end
|
40
48
|
end
|
@@ -6,8 +6,8 @@ class StoryPullRequest < FinishedCommand
|
|
6
6
|
def parser
|
7
7
|
OptionParser.new do |opts|
|
8
8
|
opts.banner = "Usage: git story-pull-request [options]"
|
9
|
-
opts.on("-
|
10
|
-
self.options.
|
9
|
+
opts.on("-o", "--override", "override unfinished story warning") do |opt|
|
10
|
+
self.options.override = opt
|
11
11
|
end
|
12
12
|
opts.on_tail("-h", "--help", "this usage guide") do
|
13
13
|
puts opts.to_s; exit 0
|
@@ -17,23 +17,45 @@ describe StoryMerge do
|
|
17
17
|
|
18
18
|
describe "with no options" do
|
19
19
|
its(:cmd) { should match /git checkout master/ }
|
20
|
-
its(:cmd)
|
20
|
+
its(:cmd) do
|
21
|
+
msg = Regexp.escape("[##{command.story_id}]")
|
22
|
+
branch = command.story_branch
|
23
|
+
should match /git merge --no-ff --log -m "#{msg}" #{branch}/
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "with the finish option" do
|
28
|
+
let(:command) { StoryMerge.new(['-f']) }
|
29
|
+
its(:cmd) do
|
30
|
+
msg = Regexp.escape("[Finishes ##{command.story_id}]")
|
31
|
+
branch = command.story_branch
|
32
|
+
should match /git merge --no-ff --log -m "#{msg}" #{branch}/
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "with the delivers option" do
|
37
|
+
let(:command) { StoryMerge.new(['-d']) }
|
38
|
+
its(:cmd) do
|
39
|
+
msg = Regexp.escape("[Delivers ##{command.story_id}]")
|
40
|
+
branch = command.story_branch
|
41
|
+
should match /git merge --no-ff --log -m "#{msg}" #{branch}/
|
42
|
+
end
|
21
43
|
end
|
22
44
|
|
23
45
|
describe "with a custom development branch" do
|
24
|
-
let(:command) { StoryMerge.new(['
|
25
|
-
its(:cmd) { should match /git checkout
|
46
|
+
let(:command) { StoryMerge.new(['development']) }
|
47
|
+
its(:cmd) { should match /git checkout development/ }
|
26
48
|
end
|
27
49
|
|
28
50
|
describe "with some unknown options" do
|
29
|
-
let(:command) { StoryMerge.new(['
|
51
|
+
let(:command) { StoryMerge.new(['development', '-o', '-a', '-z', '--foo']) }
|
30
52
|
it_should_behave_like "story-merge with known options"
|
31
53
|
its(:cmd) { should match /-a -z --foo/ }
|
32
54
|
end
|
33
55
|
|
34
56
|
describe "command-line command" do
|
35
|
-
subject { `bin/git-story-merge --debug
|
36
|
-
it { should match /git checkout
|
37
|
-
it { should match /git merge --no-ff --log
|
57
|
+
subject { `bin/git-story-merge --debug development` }
|
58
|
+
it { should match /git checkout development/ }
|
59
|
+
it { should match /git merge --no-ff --log/ }
|
38
60
|
end
|
39
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pivotal-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hartl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Add commands for Pivotal Tracker-GitHub integration
|
14
14
|
email:
|