dpl 1.8.12.travis.1286.4 → 1.8.12.travis.1291.4
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 +8 -8
- data/README.md +1 -0
- data/lib/dpl/provider/releases.rb +18 -10
- data/spec/provider/releases_spec.rb +28 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2NhMzg0NmUyYjI1OGY4Y2E5MTAwMGMxMjNlMzNlMDkwNGIxNDRmZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTFlMDdjZmIwMDZmNDdiZTZiNDI5NjgyN2ExNTUwNTA1NGM2YWRhNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTQ3ZTg2OTRmMTgzMWJjZTQ5ZjJhMDQ0MTYyNmQ2N2E5NTYyMzQ4YWY4YjVm
|
10
|
+
NzY5YTYwYjkyMTdiNTk1ZDRiMzhlNDcwMGQ1OWM1MjliZjJiMmQ2NjQ5NGM2
|
11
|
+
MTA2NjViODgyODY4NGQ4ZGNiOGZhNjk0ZDVmNmM2NzA3NjBmMzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmU5NGNiNjkwMTVlMzFlNWFlMDgyMDIxNWQwY2E5YmZkNGU3NjA1YmEyMTg2
|
14
|
+
OTBlZDQ2OWMwMmZmZGFhOWI3YzczYmMzNTVhMjdmMzBhZGE2NzJhZGQ4MTcz
|
15
|
+
ODlkZDZhNjk1MDYwZTM1MzczMzAzODA5NmRmNWRkYWNkYzI3MTM=
|
data/README.md
CHANGED
@@ -526,6 +526,7 @@ You first need to create an [Atlas account](https://atlas.hashicorp.com/account/
|
|
526
526
|
* **repo**: GitHub Repo. Defaults to git repo's name.
|
527
527
|
* **file**: File to upload to GitHub Release.
|
528
528
|
* **file_glob**: If files should be interpreted as globs (\* and \*\* wildcards). Defaults to false.
|
529
|
+
* **overwrite**: If files with the same name should be overwritten. Defaults to false.
|
529
530
|
* **release-number**: Overide automatic release detection, set a release manually.
|
530
531
|
|
531
532
|
Additionally, options can be passed to [Octokit](https://github.com/octokit/octokit.rb) client.
|
@@ -100,27 +100,35 @@ module DPL
|
|
100
100
|
end
|
101
101
|
|
102
102
|
files.each do |file|
|
103
|
-
|
103
|
+
existing_url = nil
|
104
104
|
filename = Pathname.new(file).basename.to_s
|
105
105
|
api.release(release_url).rels[:assets].get.data.each do |existing_file|
|
106
106
|
if existing_file.name == filename
|
107
|
-
|
107
|
+
existing_url = existing_file.url
|
108
108
|
end
|
109
109
|
end
|
110
|
-
if
|
111
|
-
|
110
|
+
if !existing_url
|
111
|
+
upload_file(file, filename, release_url)
|
112
|
+
elsif existing_url && options[:overwrite]
|
113
|
+
log "#{filename} already exists, overwriting."
|
114
|
+
api.delete_release_asset(existing_url)
|
115
|
+
upload_file(file, filename, release_url)
|
112
116
|
else
|
113
|
-
|
114
|
-
if content_type.empty?
|
115
|
-
# Specify the default content type, as it is required by GitHub
|
116
|
-
content_type = "application/octet-stream"
|
117
|
-
end
|
118
|
-
api.upload_asset(release_url, file, {:name => filename, :content_type => content_type})
|
117
|
+
log "#{filename} already exists, skipping."
|
119
118
|
end
|
120
119
|
end
|
121
120
|
|
122
121
|
api.update_release(release_url, {:draft => false}.merge(options))
|
123
122
|
end
|
123
|
+
|
124
|
+
def upload_file(file, filename, release_url)
|
125
|
+
content_type = MIME::Types.type_for(file).first.to_s
|
126
|
+
if content_type.empty?
|
127
|
+
# Specify the default content type, as it is required by GitHub
|
128
|
+
content_type = "application/octet-stream"
|
129
|
+
end
|
130
|
+
api.upload_asset(release_url, file, {:name => filename, :content_type => content_type})
|
131
|
+
end
|
124
132
|
end
|
125
133
|
end
|
126
134
|
end
|
@@ -196,7 +196,7 @@ describe DPL::Provider::Releases do
|
|
196
196
|
allow(provider.api).to receive(:release)
|
197
197
|
allow(provider.api.release).to receive(:rels).and_return({:assets => nil})
|
198
198
|
allow(provider.api.release.rels[:assets]).to receive(:get).and_return({:data => [""]})
|
199
|
-
allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([double(:name => "foo.bar"), double(:name => "foo.foo")])
|
199
|
+
allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([double(:name => "foo.bar", :url => 'foo-bar-url'), double(:name => "foo.foo", :url => 'foo-foo-url')])
|
200
200
|
|
201
201
|
expect(provider.api).to receive(:upload_asset).with(anything, "bar.txt", {:name=>"bar.txt", :content_type=>"text/plain"})
|
202
202
|
expect(provider).to receive(:log).with("foo.bar already exists, skipping.")
|
@@ -205,6 +205,33 @@ describe DPL::Provider::Releases do
|
|
205
205
|
provider.push_app
|
206
206
|
end
|
207
207
|
|
208
|
+
example "When Release Exists and has Files but overwrite flag is true" do
|
209
|
+
allow_message_expectations_on_nil
|
210
|
+
|
211
|
+
provider.options.update(:file => ["exists.txt"])
|
212
|
+
provider.options.update(:overwrite => true)
|
213
|
+
|
214
|
+
allow(provider).to receive(:releases).and_return([""])
|
215
|
+
allow(provider).to receive(:get_tag).and_return("v0.0.0")
|
216
|
+
|
217
|
+
provider.releases.map do |release|
|
218
|
+
allow(release).to receive(:tag_name).and_return("v0.0.0")
|
219
|
+
allow(release).to receive(:rels).and_return({:self => nil})
|
220
|
+
allow(release.rels[:self]).to receive(:href)
|
221
|
+
end
|
222
|
+
|
223
|
+
allow(provider.api).to receive(:release)
|
224
|
+
allow(provider.api.release).to receive(:rels).and_return({:assets => nil})
|
225
|
+
allow(provider.api.release.rels[:assets]).to receive(:get).and_return({:data => [""]})
|
226
|
+
allow(provider.api.release.rels[:assets].get).to receive(:data).and_return([double(:name => "exists.txt", :url => "release-url")])
|
227
|
+
|
228
|
+
expect(provider.api).to receive(:delete_release_asset).with("release-url").and_return(true)
|
229
|
+
expect(provider.api).to receive(:upload_asset).with(anything, "exists.txt", {:name=>"exists.txt", :content_type=>"text/plain"})
|
230
|
+
expect(provider.api).to receive(:update_release).with(anything, hash_including(:draft => false))
|
231
|
+
|
232
|
+
provider.push_app
|
233
|
+
end
|
234
|
+
|
208
235
|
example "When Release Doesn't Exist" do
|
209
236
|
allow_message_expectations_on_nil
|
210
237
|
|