flash_flow 1.5.0 → 1.5.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/flash_flow.yml.erb.example +1 -0
- data/lib/flash_flow/lock/github.rb +25 -24
- data/lib/flash_flow/merge/release.rb +2 -0
- data/lib/flash_flow/version.rb +1 -1
- data/test/lib/lock/test_github.rb +18 -14
- 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: bcac5f48c7e0f0cf6700988e91ac9dbaa949050b
|
4
|
+
data.tar.gz: d51fa3318c6841aefcbc0ef09787c4758e575bab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f415a2e12db0081979a922a26b319e42762bd5dad73e2bb383281234250c1001f0d73858b731caa85cf884b5617598a3708bd78e975ba9442ad33d1342d6714b
|
7
|
+
data.tar.gz: 749e4d8213f85e8a37ac3bbf35369b6ef2dc4579ed231cc47f19120670411952e8c3a180be2ab3f41fea30c441464d047b247180a2de00059f4648003a9113f5
|
data/Gemfile.lock
CHANGED
data/flash_flow.yml.erb.example
CHANGED
@@ -65,6 +65,7 @@ branch_info_file: 'your/random/file'
|
|
65
65
|
# token: <%= ENV['GH_TOKEN'] %>
|
66
66
|
# repo: # Your github repo. For example, the flash_flow repo is 'flashfunders/flash_flow'
|
67
67
|
# issue_id: # Your github issue id goes here
|
68
|
+
# lock_label: # optional - default value is 'IS_LOCKED'
|
68
69
|
|
69
70
|
|
70
71
|
## We use Github as our source of truth for which branches to merge. All open pull requests that don't
|
@@ -15,15 +15,15 @@ module FlashFlow
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def with_lock(&block)
|
18
|
-
if
|
18
|
+
if issue_locked?
|
19
19
|
raise Lock::Error.new(error_message)
|
20
20
|
else
|
21
|
-
|
21
|
+
lock_issue
|
22
22
|
|
23
23
|
begin
|
24
24
|
block.call
|
25
25
|
ensure
|
26
|
-
|
26
|
+
unlock_issue
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -31,36 +31,29 @@ module FlashFlow
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def error_message
|
34
|
-
last_event = get_last_event
|
35
|
-
actor = last_event[:actor][:login]
|
36
|
-
time = last_event[:created_at]
|
37
34
|
issue_link = "https://github.com/#{repo}/issues/#{issue_id}"
|
38
|
-
minutes_ago = ((Time.now - time).to_i / 60) rescue 'unknown'
|
39
35
|
|
40
|
-
"
|
36
|
+
"flash_flow is running and locked by #{actor}. To manually unlock flash_flow, go here: #{issue_link} and remove the #{locked_label} label and re-run flash_flow."
|
41
37
|
end
|
42
38
|
|
43
|
-
def
|
44
|
-
|
45
|
-
response = Octokit.last_response
|
46
|
-
pages = response.rels[:last]
|
47
|
-
if pages
|
48
|
-
return pages.get.data.last
|
49
|
-
else
|
50
|
-
response.data.last
|
51
|
-
end
|
39
|
+
def issue_locked?
|
40
|
+
get_lock_labels.detect {|label| label[:name] == locked_label}
|
52
41
|
end
|
53
42
|
|
54
|
-
def
|
55
|
-
|
43
|
+
def lock_issue
|
44
|
+
Octokit.add_labels_to_an_issue(repo, issue_id, [actor, locked_label])
|
56
45
|
end
|
57
46
|
|
58
|
-
def
|
59
|
-
Octokit.
|
47
|
+
def unlock_issue
|
48
|
+
Octokit.remove_all_labels(repo, issue_id)
|
60
49
|
end
|
61
50
|
|
62
|
-
def
|
63
|
-
|
51
|
+
def get_lock_labels
|
52
|
+
begin
|
53
|
+
Octokit.labels_for_issue(repo, issue_id)
|
54
|
+
rescue Octokit::NotFound
|
55
|
+
[]
|
56
|
+
end
|
64
57
|
end
|
65
58
|
|
66
59
|
def verify_params!
|
@@ -86,6 +79,14 @@ module FlashFlow
|
|
86
79
|
def issue_id
|
87
80
|
config['issue_id']
|
88
81
|
end
|
82
|
+
|
83
|
+
def locked_label
|
84
|
+
config['lock_label'] || 'IS_LOCKED'
|
85
|
+
end
|
86
|
+
|
87
|
+
def actor
|
88
|
+
@user_login ||= Octokit.user.login
|
89
|
+
end
|
89
90
|
end
|
90
91
|
end
|
91
|
-
end
|
92
|
+
end
|
@@ -14,6 +14,8 @@ module FlashFlow
|
|
14
14
|
@release_branches = parse_branches(opts[:release_branches])
|
15
15
|
|
16
16
|
@data = Data::Base.new({}, Config.configuration.branch_info_file, @git, logger: logger)
|
17
|
+
|
18
|
+
@release_branches.each {|b| b.merge_order = @data.collection.get(b.ref).merge_order }
|
17
19
|
end
|
18
20
|
|
19
21
|
def run
|
data/lib/flash_flow/version.rb
CHANGED
@@ -22,22 +22,24 @@ module FlashFlow
|
|
22
22
|
assert_raises(Lock::Error) { Lock::Github.new(config) }
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
@lock.stub(:
|
27
|
-
@lock.stub(:
|
28
|
-
|
29
|
-
|
25
|
+
def test_error_message_when_issue_locked
|
26
|
+
@lock.stub(:actor, 'actor') do
|
27
|
+
@lock.stub(:issue_locked?, true) do
|
28
|
+
@lock.stub(:get_lock_labels, {name: @lock.send(:locked_label)}) do
|
29
|
+
assert_raises(FlashFlow::Lock::Error) do
|
30
|
+
@lock.with_lock
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
37
|
def test_with_lock_calls_the_block
|
36
|
-
my_mock = Minitest::Mock.new.expect(:block_call, true).expect(:
|
38
|
+
my_mock = Minitest::Mock.new.expect(:block_call, true).expect(:unlock_issue, true)
|
37
39
|
|
38
|
-
@lock.stub(:
|
39
|
-
@lock.stub(:
|
40
|
-
@lock.stub(:
|
40
|
+
@lock.stub(:issue_locked?, false) do
|
41
|
+
@lock.stub(:lock_issue, nil) do
|
42
|
+
@lock.stub(:unlock_issue, -> { my_mock.unlock_issue }) do
|
41
43
|
@lock.with_lock { my_mock.block_call }
|
42
44
|
my_mock.verify
|
43
45
|
end
|
@@ -45,12 +47,14 @@ module FlashFlow
|
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
|
-
def
|
49
|
-
my_mock = Minitest::Mock.new
|
50
|
+
def test_with_unlock_issue_no_matter_what
|
51
|
+
my_mock = Minitest::Mock.new
|
52
|
+
.expect(:some_method, true)
|
53
|
+
.expect(:actor, 'actor')
|
50
54
|
|
51
|
-
@lock.stub(:
|
52
|
-
@lock.stub(:
|
53
|
-
@lock.stub(:
|
55
|
+
@lock.stub(:issue_locked?, false) do
|
56
|
+
@lock.stub(:lock_issue, nil) do
|
57
|
+
@lock.stub(:unlock_issue, -> { my_mock.some_method }) do
|
54
58
|
assert_raises(SomeFakeError) do
|
55
59
|
@lock.with_lock { raise SomeFakeError }
|
56
60
|
my_mock.verify
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flash_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flashfunders
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|