bard 1.7.0 → 1.7.2
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/lib/bard/github.rb +10 -4
- data/lib/bard/version.rb +1 -1
- data/spec/bard/github_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 674739cf14af03776e5f892cb47463decdc1a3a6a493ee4e62dc3528a4fe2c36
|
|
4
|
+
data.tar.gz: 5685ced74cc962121ad634d9290aeba0663373c9db052ca3480d37f29ec8ec1b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 734fe59b6c52c355168637b37685bda6a54dc05faf66db0d7758bcb00305a00069056915f433fc5359b36236896a300ac5162632872cc00e71c5bc7d730239de
|
|
7
|
+
data.tar.gz: 924afe38e6cdf1dfa179917856d172c35c1d083571d1dfbfdce53d3c45e8b15950c94c3d6131c123d529005a80ba518ae7ffb420f9eb16fa700999a7cff8e432
|
data/lib/bard/github.rb
CHANGED
|
@@ -7,6 +7,12 @@ require "bard/ci/retryable"
|
|
|
7
7
|
module Bard
|
|
8
8
|
class Github < Struct.new(:project_name)
|
|
9
9
|
include CI::Retryable
|
|
10
|
+
|
|
11
|
+
def initialize(project_name, api_key: nil)
|
|
12
|
+
super(project_name)
|
|
13
|
+
@api_key = api_key
|
|
14
|
+
end
|
|
15
|
+
|
|
10
16
|
def get path, params={}
|
|
11
17
|
request(path) do |uri|
|
|
12
18
|
uri.query = URI.encode_www_form(params)
|
|
@@ -100,9 +106,9 @@ module Bard
|
|
|
100
106
|
|
|
101
107
|
private
|
|
102
108
|
|
|
103
|
-
def
|
|
104
|
-
@
|
|
105
|
-
raw = `git ls-remote -t git@github.com:
|
|
109
|
+
def api_key
|
|
110
|
+
@api_key ||= begin
|
|
111
|
+
raw = `git ls-remote -t git@github.com:botandrosedesign/secrets`
|
|
106
112
|
raw[/github-apikey\|(.+)$/, 1]
|
|
107
113
|
end
|
|
108
114
|
end
|
|
@@ -124,7 +130,7 @@ module Bard
|
|
|
124
130
|
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
|
125
131
|
req = block.call(uri)
|
|
126
132
|
req["Accept"] = "application/vnd.github+json"
|
|
127
|
-
req["Authorization"] = "Bearer #{
|
|
133
|
+
req["Authorization"] = "Bearer #{api_key}"
|
|
128
134
|
req["X-GitHub-Api-Version"] = "2022-11-28"
|
|
129
135
|
http.request(req)
|
|
130
136
|
end
|
data/lib/bard/version.rb
CHANGED
data/spec/bard/github_spec.rb
CHANGED
|
@@ -5,7 +5,7 @@ describe Bard::Github do
|
|
|
5
5
|
let(:github) { Bard::Github.new("test-project") }
|
|
6
6
|
|
|
7
7
|
before do
|
|
8
|
-
allow(github).to receive(:`).with("git ls-remote -t git@github.com:
|
|
8
|
+
allow(github).to receive(:`).with("git ls-remote -t git@github.com:botandrosedesign/secrets").and_return("github-apikey|12345")
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
describe "#get" do
|