fa-harness-tools 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9184fa096f94f549bf7f851ed9e7c97e7c3e919791d2972ace243642403d82d3
4
- data.tar.gz: 6b40fe369961e86a94dcd2e6cdefe8f3522f86a6d27b6fb6cc9880bc9214e226
3
+ metadata.gz: a3cee0250f6a943fb938d11c0e118f53d26ea03be5edb7e8f8fc7fb0f73e154e
4
+ data.tar.gz: 030ab9dac48945eac8366a8cfcbafecc4bbbeebc5dc16254f97bfa3cfdb26368
5
5
  SHA512:
6
- metadata.gz: 45d9f3a130ef9f2caadb2e5d62f33d9e2234627ad71f215414cfccba0e86ed6d493f927931969b95e8bb55ac9f70f914ac3a445b0e2e4f2ad85d19c41ca60418
7
- data.tar.gz: f57aef9c5cd44cdd09abe8b4cbb2c0c9884589f57b0c0f67764c515681317f87ce9bc31084f2132b9008862e57300720480a9231d8e605cd7e3ed15eb5513f04
6
+ metadata.gz: 3f00171760572605f0282595bc852bf20181768464dd9811051cb71a6658daa9692bdb77c46dbb180eca6c982b17736cf0f4c24e89cf6fba60fcddd379d81a08
7
+ data.tar.gz: 863db5b6b4230a1d2fedd00ab20f05d830fb682bc9b4947f1e4bdd69429dfa90ba637fac2afabd6cd7c8c7b71271e6a53346593325e46a0c7c6377453c86e7bd
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fa-harness-tools (1.0.3)
4
+ fa-harness-tools (1.0.4)
5
5
  octokit (~> 4.0)
6
6
  tzinfo (~> 2.0)
7
7
  tzinfo-data (~> 1.0)
@@ -22,9 +22,12 @@ module FaHarnessTools
22
22
  #
23
23
  # @return [Array[Hash]] Array of tag data hash, or [] if none
24
24
  def all_deploy_tags(prefix:, environment:)
25
+ @octokit.auto_paginate = true
25
26
  @octokit.tags(owner_repo).find_all do |tag|
26
27
  tag[:name].start_with?("#{prefix}-#{environment}-")
27
28
  end
29
+ ensure
30
+ @octokit.auto_paginate = false
28
31
  end
29
32
 
30
33
  # Return the last (when sorted) tag starting "harness-deploy-ENV-"
@@ -55,14 +58,14 @@ module FaHarnessTools
55
58
  #
56
59
  # @return [Bool] True is <ancestor> is ancestor of <commit>
57
60
  def is_ancestor_of?(ancestor, commit)
58
- !!@octokit.commits(owner_repo, commit).find { |c| c[:sha] == ancestor }
61
+ !!find_commit(commit) { |c| c[:sha] == ancestor }
59
62
  end
60
63
 
61
64
  # Checks if <commit> is on branch <branch>
62
65
  #
63
66
  # @return [Bool] True is <commit> is on <branch>
64
67
  def branch_contains?(branch, commit)
65
- !!@octokit.commits(owner_repo, branch).find { |c| c[:sha] == commit }
68
+ !!find_commit(branch) { |c| c[:sha] == commit }
66
69
  end
67
70
 
68
71
  # Creates a Git tag
@@ -73,5 +76,19 @@ module FaHarnessTools
73
76
  @octokit.create_ref(owner_repo, "tags/#{tag}", commit_sha)
74
77
  @octokit.create_tag(owner_repo, tag, message, commit_sha, *args)
75
78
  end
79
+
80
+ private
81
+
82
+ # Paginate over commits from a given sha/branch, and exit early if the
83
+ # supplied block matches
84
+ def find_commit(sha_or_branch, &block)
85
+ result = @octokit.commits(owner_repo, sha_or_branch).find(&block)
86
+ response = @octokit.last_response
87
+ until result || !response.rels[:next]
88
+ response = response.rels[:next].get
89
+ result = response.data.find(&block)
90
+ end
91
+ result
92
+ end
76
93
  end
77
94
  end
@@ -1,3 +1,3 @@
1
1
  module FaHarnessTools
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fa-harness-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - FreeAgent
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-12 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit