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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6afda2b38eb992aadb2ce598dbc419e89df7c708
4
- data.tar.gz: c1125d844a6d4716c1fe44773cc861e46a5d0a59
3
+ metadata.gz: bcac5f48c7e0f0cf6700988e91ac9dbaa949050b
4
+ data.tar.gz: d51fa3318c6841aefcbc0ef09787c4758e575bab
5
5
  SHA512:
6
- metadata.gz: 229f2e6192a286d4e9994f52b4fab5950c40a23b857ea153b2216c4fbfe72bd7ad83fd070aa9b3ab0909cca44cdcef985cc8a1da862c79bd0fe1b0a0fd793536
7
- data.tar.gz: d9b22f0e08dc78f509014e86c41178a5a9d89e06f1326da100ba586910d84d0d557e8614b8091b8a961b00ee0798f577be400e6950d84b952d5a1ba77cdb969e
6
+ metadata.gz: f415a2e12db0081979a922a26b319e42762bd5dad73e2bb383281234250c1001f0d73858b731caa85cf884b5617598a3708bd78e975ba9442ad33d1342d6714b
7
+ data.tar.gz: 749e4d8213f85e8a37ac3bbf35369b6ef2dc4579ed231cc47f19120670411952e8c3a180be2ab3f41fea30c441464d047b247180a2de00059f4648003a9113f5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flash_flow (1.5.0)
4
+ flash_flow (1.5.1)
5
5
  google-api-client
6
6
  hipchat (~> 1.5)
7
7
  mail
@@ -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 issue_open?
18
+ if issue_locked?
19
19
  raise Lock::Error.new(error_message)
20
20
  else
21
- open_issue
21
+ lock_issue
22
22
 
23
23
  begin
24
24
  block.call
25
25
  ensure
26
- close_issue
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
- "#{actor} started running flash_flow #{minutes_ago} minutes ago. To manually unlock flash_flow, go here: #{issue_link} and close the issue and re-run flash_flow."
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 get_last_event
44
- Octokit.issue_events(repo, issue_id)
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 issue_open?
55
- get_last_event.event == 'reopened'
43
+ def lock_issue
44
+ Octokit.add_labels_to_an_issue(repo, issue_id, [actor, locked_label])
56
45
  end
57
46
 
58
- def open_issue
59
- Octokit.reopen_issue(repo, issue_id)
47
+ def unlock_issue
48
+ Octokit.remove_all_labels(repo, issue_id)
60
49
  end
61
50
 
62
- def close_issue
63
- Octokit.close_issue(repo, issue_id)
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
@@ -1,3 +1,3 @@
1
1
  module FlashFlow
2
- VERSION = '1.5.0'
2
+ VERSION = '1.5.1'
3
3
  end
@@ -22,22 +22,24 @@ module FlashFlow
22
22
  assert_raises(Lock::Error) { Lock::Github.new(config) }
23
23
  end
24
24
 
25
- def test_error_message_when_issue_opened
26
- @lock.stub(:issue_open?, true) do
27
- @lock.stub(:get_last_event, {actor: {login: 'anonymous'}, created_at: Time.now}) do
28
- assert_raises(FlashFlow::Lock::Error) do
29
- @lock.with_lock
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(:close_issue, true)
38
+ my_mock = Minitest::Mock.new.expect(:block_call, true).expect(:unlock_issue, true)
37
39
 
38
- @lock.stub(:issue_open?, false) do
39
- @lock.stub(:open_issue, nil) do
40
- @lock.stub(:close_issue, -> { my_mock.close_issue }) do
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 test_with_lock_closes_issue_no_matter_what
49
- my_mock = Minitest::Mock.new.expect(:some_method, true)
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(:issue_open?, false) do
52
- @lock.stub(:open_issue, nil) do
53
- @lock.stub(:close_issue, -> { my_mock.some_method }) do
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.0
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-13 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit