octopolo 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.markdown +33 -0
- data/README.markdown +4 -0
- data/lib/octopolo/config.rb +4 -0
- data/lib/octopolo/git.rb +30 -2
- data/lib/octopolo/jira/story_commenter.rb +10 -2
- data/lib/octopolo/scripts/new_branch.rb +8 -1
- data/lib/octopolo/version.rb +1 -1
- data/spec/octopolo/config_spec.rb +10 -0
- data/spec/octopolo/git_spec.rb +12 -8
- data/spec/octopolo/scripts/new_branch_spec.rb +25 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1180ea8ecff06b1794c95afb8691c7577f9223c9
|
4
|
+
data.tar.gz: 1a5a2e430cfb10351f755df6c2614723f72872b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a21ed3bc2ce58fe993ec7212c78a71bb3598e5e3b88387ff9531ca4d28c467c32c8eb6277dfb1723f0e22a7f13bee03c8b24f5ef57e203ac3f6385ea4ccd5d0d
|
7
|
+
data.tar.gz: 11a8c5346bcd00e22bc3f1a257993aaa736f4d87a1d86c838001da4188b2ff9611dc6c120b4460e8b0eba4ec838a921f972ba36760b5fbb04daf3f353feabb2d
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.4
|
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
#### v1.3.0
|
2
|
+
* IS-4641-spring-cleaning-jira-bomb
|
3
|
+
|
4
|
+
> newzac: Zach Serre, Carl Allen: https://github.com/sportngin/octopolo/pull/84
|
5
|
+
|
6
|
+
* Spring Cleaning IS-4644 Enable use of auto-merging resolver
|
7
|
+
|
8
|
+
> newzac: Carl Allen, Andy Fleener: https://github.com/sportngin/octopolo/pull/83
|
9
|
+
|
10
|
+
* Reserved branch warning
|
11
|
+
|
12
|
+
> Mykola, Brian Bergstrom: Matt Krieger: https://github.com/sportngin/octopolo/pull/82
|
13
|
+
|
14
|
+
* Exit with a status code of 1. Could also use abort, I guess
|
15
|
+
|
16
|
+
> AJ Stuyvenberg: Brian Bergstrom: https://github.com/sportngin/octopolo/pull/81
|
17
|
+
|
18
|
+
* Don't raise on missing config file
|
19
|
+
|
20
|
+
> Chris Arcand: Andy Fleener, Pete Anderson: https://github.com/sportngin/octopolo/pull/80
|
21
|
+
|
22
|
+
* Remove unwanted CLI output from tests
|
23
|
+
|
24
|
+
> Chris Arcand: : https://github.com/sportngin/octopolo/pull/79
|
25
|
+
|
26
|
+
* Use an rbenv/chruby compatible ruby-version
|
27
|
+
|
28
|
+
> Chris Arcand: Andy Fleener: https://github.com/sportngin/octopolo/pull/78
|
29
|
+
|
30
|
+
* Remove and ignore .DS_Store
|
31
|
+
|
32
|
+
> Chris Arcand: : https://github.com/sportngin/octopolo/pull/77
|
33
|
+
|
1
34
|
#### v1.2.1
|
2
35
|
#### v1.2.0
|
3
36
|
* View PR in Browser
|
data/README.markdown
CHANGED
@@ -47,6 +47,10 @@ another named branch) into your current branch.
|
|
47
47
|
|
48
48
|
sync-branch
|
49
49
|
sync-branch some-other-branch
|
50
|
+
#### Automatic Merge Conflict Resolution
|
51
|
+
|
52
|
+
Optionally you can add the line `merge_resolver: <path/to/script>` to the `.octopolo.yml` to
|
53
|
+
have Octopolo try to resolve conflicts automatically via a script upon merge failure.
|
50
54
|
|
51
55
|
#### Review Changes In Releases
|
52
56
|
|
data/lib/octopolo/config.rb
CHANGED
@@ -44,6 +44,10 @@ module Octopolo
|
|
44
44
|
@github_repo || raise(MissingRequiredAttribute, "GitHub Repo is required")
|
45
45
|
end
|
46
46
|
|
47
|
+
def merge_resolver
|
48
|
+
@merge_resolver
|
49
|
+
end
|
50
|
+
|
47
51
|
def user_notifications
|
48
52
|
if [NilClass, Array, String].include?(@user_notifications.class)
|
49
53
|
Array(@user_notifications) if @user_notifications
|
data/lib/octopolo/git.rb
CHANGED
@@ -6,6 +6,8 @@ module Octopolo
|
|
6
6
|
NO_BRANCH = "(no branch)"
|
7
7
|
DEFAULT_DIRTY_MESSAGE = "Your Git index is not clean. Commit, stash, or otherwise clean up the index before continuing."
|
8
8
|
DIRTY_CONFIRM_MESSAGE = "Your Git index is not clean. Do you want to continue?"
|
9
|
+
RESERVED_BRANCH_MESSAGE = "Please choose another name for your new branch."
|
10
|
+
RESERVED_BRANCH_CONFIRM_MESSAGE = "Your new branch may be misidentified as a reserved branch based on its name. Do you want to continue?"
|
9
11
|
# we use date-based tags, so look for anything starting with a 4-digit year
|
10
12
|
RELEASE_TAG_FILTER = /^\d{4}.*/
|
11
13
|
RECENT_TAG_LIMIT = 9
|
@@ -17,6 +19,11 @@ module Octopolo
|
|
17
19
|
STAGING_PREFIX = "staging"
|
18
20
|
QAREADY_PREFIX = "qaready"
|
19
21
|
|
22
|
+
# To check if the new branch's name starts with one of these
|
23
|
+
RESERVED_BRANCH_PREFIXES = [ DEPLOYABLE_PREFIX, STAGING_PREFIX, QAREADY_PREFIX ]
|
24
|
+
|
25
|
+
@resolver_used = nil
|
26
|
+
|
20
27
|
include CLIWrapper
|
21
28
|
extend CLIWrapper # add class-level .cli and .cli= methods
|
22
29
|
|
@@ -64,8 +71,8 @@ module Octopolo
|
|
64
71
|
# Public: Determine if current_branch is reserved
|
65
72
|
#
|
66
73
|
# Returnsa boolean value
|
67
|
-
def self.reserved_branch?
|
68
|
-
!(
|
74
|
+
def self.reserved_branch?(branch=current_branch)
|
75
|
+
!(branch =~ /^(?:#{Git::RESERVED_BRANCH_PREFIXES.join('|')})/).nil?
|
69
76
|
end
|
70
77
|
|
71
78
|
# Public: Check out the given branch name
|
@@ -114,6 +121,7 @@ module Octopolo
|
|
114
121
|
yield
|
115
122
|
else
|
116
123
|
alert_dirty_index message
|
124
|
+
exit 1
|
117
125
|
end
|
118
126
|
end
|
119
127
|
|
@@ -126,11 +134,30 @@ module Octopolo
|
|
126
134
|
raise DirtyIndex
|
127
135
|
end
|
128
136
|
|
137
|
+
def self.alert_reserved_branch(message)
|
138
|
+
cli.say " "
|
139
|
+
cli.say message
|
140
|
+
cli.say " "
|
141
|
+
cli.say "Here's the list of the reserved branch prefixes:"
|
142
|
+
cli.say RESERVED_BRANCH_PREFIXES.join(" ")
|
143
|
+
cli.say " "
|
144
|
+
raise ReservedBranch
|
145
|
+
end
|
146
|
+
|
129
147
|
# Public: Merge the given remote branch into the current branch
|
130
148
|
def self.merge(branch_name)
|
131
149
|
Git.if_clean do
|
132
150
|
Git.fetch
|
133
151
|
perform "merge --no-ff origin/#{branch_name}", :ignore_non_zero => true
|
152
|
+
unless Git.clean?
|
153
|
+
if @resolver_used.nil? && Octopolo.config.merge_resolver
|
154
|
+
%x(#{Octopolo.config.merge_resolver})
|
155
|
+
@resolver_used = true
|
156
|
+
if Git.clean?
|
157
|
+
merge(branch_name)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
134
161
|
raise MergeFailed unless Git.clean?
|
135
162
|
Git.push
|
136
163
|
end
|
@@ -279,5 +306,6 @@ module Octopolo
|
|
279
306
|
MergeFailed = Class.new(StandardError)
|
280
307
|
NoBranchOfType = Class.new(StandardError)
|
281
308
|
DirtyIndex = Class.new(StandardError)
|
309
|
+
ReservedBranch = Class.new(StandardError)
|
282
310
|
end
|
283
311
|
end
|
@@ -14,12 +14,20 @@ module Octopolo
|
|
14
14
|
jira_config.password = config.jira_password
|
15
15
|
jira_config.uri = config.jira_url
|
16
16
|
end
|
17
|
-
|
17
|
+
begin
|
18
|
+
self.issue = Jiralicious::Issue.find issue_id
|
19
|
+
rescue => e
|
20
|
+
puts "Error: Invalid Jira Issue #{issue_id}"
|
21
|
+
end
|
18
22
|
self.comment = comment
|
19
23
|
end
|
20
24
|
|
21
25
|
def perform
|
22
|
-
|
26
|
+
begin
|
27
|
+
issue.comments.add(comment)
|
28
|
+
rescue => e
|
29
|
+
puts "Error: Failed to comment on Jira Issue #{issue_id}"
|
30
|
+
end
|
23
31
|
end
|
24
32
|
end
|
25
33
|
end
|
@@ -6,6 +6,7 @@ module Octopolo
|
|
6
6
|
class NewBranch
|
7
7
|
include ConfigWrapper
|
8
8
|
include GitWrapper
|
9
|
+
include CLIWrapper
|
9
10
|
|
10
11
|
attr_accessor :new_branch_name
|
11
12
|
attr_accessor :source_branch_name
|
@@ -22,7 +23,13 @@ module Octopolo
|
|
22
23
|
# Public: Perform the script
|
23
24
|
def execute
|
24
25
|
raise ArgumentError unless new_branch_name
|
25
|
-
git.
|
26
|
+
if !git.reserved_branch?(new_branch_name) || cli.ask_boolean(Git::RESERVED_BRANCH_CONFIRM_MESSAGE)
|
27
|
+
git.new_branch(new_branch_name, source_branch_name)
|
28
|
+
else
|
29
|
+
message = Git::RESERVED_BRANCH_MESSAGE
|
30
|
+
git.alert_reserved_branch message
|
31
|
+
exit 1
|
32
|
+
end
|
26
33
|
end
|
27
34
|
|
28
35
|
# Public: Provide a default value if none is given
|
data/lib/octopolo/version.rb
CHANGED
@@ -82,6 +82,16 @@ module Octopolo
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
context "#merge_resolver" do
|
86
|
+
it "is nil by default" do
|
87
|
+
Config.new.merge_resolver.should == nil
|
88
|
+
end
|
89
|
+
|
90
|
+
it "returns a string if it has a value" do
|
91
|
+
Config.new(merge_resolver: "/opt/resolver.sh").merge_resolver.should == "/opt/resolver.sh"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
85
95
|
context "#user_notifications" do
|
86
96
|
it "is nil by default" do
|
87
97
|
Config.new.user_notifications.should == nil
|
data/spec/octopolo/git_spec.rb
CHANGED
@@ -153,9 +153,11 @@ module Octopolo
|
|
153
153
|
Git.should_receive(:alert_dirty_index).with(Git::DEFAULT_DIRTY_MESSAGE)
|
154
154
|
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
156
|
+
expect do
|
157
|
+
Git.if_clean do
|
158
|
+
Math.log 1
|
159
|
+
end
|
160
|
+
end.to raise_error(SystemExit)
|
159
161
|
end
|
160
162
|
|
161
163
|
it "prints a custom message if git index is not clean and user responds no" do
|
@@ -164,9 +166,11 @@ module Octopolo
|
|
164
166
|
Math.should_not_receive(:log)
|
165
167
|
Git.should_receive(:alert_dirty_index).with(custom_message)
|
166
168
|
|
167
|
-
|
168
|
-
|
169
|
-
|
169
|
+
expect do
|
170
|
+
Git.if_clean custom_message do
|
171
|
+
Math.log 1
|
172
|
+
end
|
173
|
+
end.to raise_error(SystemExit)
|
170
174
|
end
|
171
175
|
end
|
172
176
|
|
@@ -192,7 +196,7 @@ module Octopolo
|
|
192
196
|
Git.should_receive(:if_clean).and_yield
|
193
197
|
Git.should_receive(:fetch)
|
194
198
|
Git.should_receive(:perform).with("merge --no-ff origin/#{branch_name}", :ignore_non_zero => true)
|
195
|
-
Git.should_receive(:clean?) { true }
|
199
|
+
Git.should_receive(:clean?).twice { true }
|
196
200
|
Git.should_receive(:push)
|
197
201
|
|
198
202
|
Git.merge branch_name
|
@@ -202,7 +206,7 @@ module Octopolo
|
|
202
206
|
Git.should_receive(:if_clean).and_yield
|
203
207
|
Git.should_receive(:fetch)
|
204
208
|
Git.should_receive(:perform).with("merge --no-ff origin/#{branch_name}", :ignore_non_zero => true)
|
205
|
-
Git.should_receive(:clean?) { false }
|
209
|
+
Git.should_receive(:clean?).twice { false }
|
206
210
|
Git.should_not_receive(:push)
|
207
211
|
|
208
212
|
expect { Git.merge branch_name }.to raise_error(Git::MergeFailed)
|
@@ -6,13 +6,14 @@ module Octopolo
|
|
6
6
|
describe NewBranch do
|
7
7
|
let(:config) { stub(:config, :deploy_branch => "production") }
|
8
8
|
let(:git) { stub(:Git) }
|
9
|
+
let(:cli) { stub(:Cli) }
|
9
10
|
let(:new_branch_name) { stub(:string) }
|
10
11
|
let(:custom_source_branch) { stub(:string) }
|
11
12
|
|
12
13
|
subject { NewBranch }
|
13
14
|
|
14
15
|
before do
|
15
|
-
NewBranch.any_instance.stub(:config => config, :git => git)
|
16
|
+
NewBranch.any_instance.stub(:config => config, :git => git, :cli => cli)
|
16
17
|
end
|
17
18
|
|
18
19
|
context "::execute" do
|
@@ -22,15 +23,36 @@ module Octopolo
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
+
|
27
|
+
context "with reserved new branch name" do
|
28
|
+
it "exits when aborted" do
|
29
|
+
allow(git).to receive(:reserved_branch?) { true }
|
30
|
+
allow(cli).to receive(:ask_boolean) { false }
|
31
|
+
allow(cli).to receive(:say).with(anything)
|
32
|
+
git.should_receive(:alert_reserved_branch)
|
33
|
+
expect { subject.execute(new_branch_name) }.to raise_error(SystemExit)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "proceeds when confirmed" do
|
37
|
+
allow(git).to receive(:reserved_branch?) { true }
|
38
|
+
allow(cli).to receive(:ask_boolean) { true }
|
39
|
+
allow(cli).to receive(:say).with(anything)
|
40
|
+
git.should_receive(:new_branch).with(new_branch_name, "production")
|
41
|
+
subject.execute(new_branch_name)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with only new branch name given" do
|
26
46
|
it "delegates to Git.new_branch" do
|
47
|
+
allow(git).to receive(:reserved_branch?) { false }
|
27
48
|
git.should_receive(:new_branch).with(new_branch_name, "production")
|
28
49
|
subject.execute(new_branch_name)
|
29
50
|
end
|
30
51
|
end
|
31
52
|
|
32
|
-
context "with
|
53
|
+
context "with new and source branch names given" do
|
33
54
|
it "delegates to Git.new_branch" do
|
55
|
+
allow(git).to receive(:reserved_branch?) { false }
|
34
56
|
git.should_receive(:new_branch).with(new_branch_name, custom_source_branch)
|
35
57
|
subject.execute(new_branch_name, custom_source_branch)
|
36
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopolo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Byrne
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gli
|
@@ -193,6 +193,7 @@ extra_rdoc_files: []
|
|
193
193
|
files:
|
194
194
|
- ".gitignore"
|
195
195
|
- ".ruby-gemset"
|
196
|
+
- ".ruby-version"
|
196
197
|
- ".soyuz.yml"
|
197
198
|
- ".travis.yml"
|
198
199
|
- CHANGELOG.markdown
|
@@ -332,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
333
|
version: '0'
|
333
334
|
requirements: []
|
334
335
|
rubyforge_project:
|
335
|
-
rubygems_version: 2.4.
|
336
|
+
rubygems_version: 2.4.8
|
336
337
|
signing_key:
|
337
338
|
specification_version: 4
|
338
339
|
summary: A set of GitHub workflow scripts to provide a smooth development process
|