dpl-releases 1.9.6.travis.2790.5 → 1.9.6.travis.2794.5

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: 6d6c8410800f848c6833f4b6641e65c9003a2d452e4a4a95c1b4d415524b2521
4
- data.tar.gz: 5cdbf024c25d3bf986adbf2c8af01490307e558f3b0a0d2788220d1a17ba12d5
3
+ metadata.gz: 592707c7749ec90af2055ddf774a71701b7b32e22b90aa266a902175ae1f2e49
4
+ data.tar.gz: e904d41da9bb1c75979d7c751b95d36fbfcd7bac0210e817cec7bc0b961775de
5
5
  SHA512:
6
- metadata.gz: 80fac2f883d65a3d2f9bb04a1f4a892943b3d11bd9ece64d71d9dbde5f57edf87c8a931210e94e484bda7913be06166e2db7bc59584993a3003b16fd241cc177
7
- data.tar.gz: c25783d5c1ef7c9476b9806eca0dab68ab0cea3edd02c9d14a0a3812c9ea09532c0411e90683fc99378ca6a61f3df3f85bdfaba4218d3f056ec140513e88a4d4
6
+ metadata.gz: b248cb537bb2255e8095026e37ff7284672b2aa97f9c726167cdbb3f780943401da5e3dfdb83b456af759ff261a512c54c7724d935f665d6c53048526af05174
7
+ data.tar.gz: f052fec7f978d44bef032f825bba7b3120a4dc2cb0fcecef36346a6f88b6f45c71e40ae07d5480bd0ad2af21fbf2b10db528ff5cb8d5ed8f6526ba4da10e9147
@@ -11,21 +11,27 @@ module DPL
11
11
  prerelease
12
12
  )
13
13
 
14
- def travis_tag
15
- # Check if $TRAVIS_TAG is unset or set but empty
16
- if context.env.fetch('TRAVIS_TAG','') == ''
17
- nil
18
- else
19
- context.env['TRAVIS_TAG']
20
- end
21
- end
14
+ attr_reader :current_tag
22
15
 
23
- def get_tag
24
- if travis_tag.nil?
25
- @tag ||= `git describe --tags --exact-match 2>/dev/null`.chomp
26
- else
27
- @tag ||= travis_tag
16
+ def current_tag
17
+ return @current_tag if @current_tag
18
+
19
+ log "Determining tag for this GitHub Release"
20
+
21
+ tag = options[:tag_name].tap { |tag| log green("Tag #{tag} set in .travis.yml") } || # first choice
22
+ if !context.env['TRAVIS_TAG'].to_s.empty?
23
+ context.env['TRAVIS_TAG'].to_s.tap { |tag| log green("Tag #{tag} set by TRAVIS_TAG (via this commit's tag)")}
24
+ else
25
+ log yellow("This commit is not tagged. Fetching tags")
26
+ context.shell "git fetch --tags"
27
+ `git describe --tags --exact-match 2>/dev/null`.chomp.tap { |tag| log green("Tag #{tag} fetched") }
28
+ end
29
+
30
+ if tag.empty?
31
+ log yellow("Unable to compute tag name. GitHub may assign a tag of the form 'untagged-*'.")
28
32
  end
33
+
34
+ tag
29
35
  end
30
36
 
31
37
  def api
@@ -65,8 +71,7 @@ module DPL
65
71
  def check_app
66
72
  log "Deploying to repo: #{slug}"
67
73
 
68
- context.shell 'git fetch --tags' if travis_tag.nil?
69
- log "Current tag is: #{get_tag}"
74
+ log "Current tag is: #{current_tag}"
70
75
  end
71
76
 
72
77
  def setup_auth
@@ -94,7 +99,7 @@ module DPL
94
99
  release_url = "https://api.github.com/repos/" + slug + "/releases/" + options[:release_number]
95
100
  else
96
101
  releases.each do |release|
97
- if release.tag_name == get_tag
102
+ if release.tag_name == current_tag
98
103
  release_url = release.rels[:self].href
99
104
  tag_matched = true
100
105
  end
@@ -103,7 +108,7 @@ module DPL
103
108
 
104
109
  #If for some reason GitHub hasn't already created a release for the tag, create one
105
110
  if tag_matched == false
106
- release_url = api.create_release(slug, get_tag, options.merge({:draft => true})).rels[:self].href
111
+ release_url = api.create_release(slug, current_tag, options.merge({:draft => true})).rels[:self].href
107
112
  end
108
113
 
109
114
  files.each do |file|
@@ -7,23 +7,21 @@ describe DPL::Provider::Releases do
7
7
  described_class.new(DummyContext.new, :api_key => '0123445789qwertyuiop0123445789qwertyuiop', :file => 'blah.txt')
8
8
  end
9
9
 
10
- describe "#travis_tag" do
11
- example "When $TRAVIS_TAG is nil" do
12
- provider.context.env['TRAVIS_TAG'] = nil
10
+ let(:a_release) { double('a_release', tag_name: 'foo', rels: {self: double('href', href: "https://")}) }
13
11
 
14
- expect(provider.travis_tag).to eq(nil)
15
- end
12
+ before { allow(provider).to receive(:log).and_return(true) }
16
13
 
17
- example "When $TRAVIS_TAG if set but empty" do
18
- provider.context.env['TRAVIS_TAG'] = nil
14
+ describe "#current_tag" do
15
+ example "When $TRAVIS_TAG is nil" do
16
+ provider.context.env['TRAVIS_TAG'] = ''
19
17
 
20
- expect(provider.travis_tag).to eq(nil)
18
+ expect(provider.current_tag).to eq('')
21
19
  end
22
20
 
23
21
  example "When $TRAVIS_TAG if set" do
24
22
  provider.context.env['TRAVIS_TAG'] = "foo"
25
23
 
26
- expect(provider.travis_tag).to eq("foo")
24
+ expect(provider.current_tag).to eq("foo")
27
25
  end
28
26
  end
29
27
 
@@ -94,11 +92,9 @@ describe DPL::Provider::Releases do
94
92
 
95
93
  describe "#check_app" do
96
94
  example "Without $TRAVIS_TAG" do
97
- allow(provider).to receive(:travis_tag).and_return(nil)
98
95
  allow(provider).to receive(:slug).and_return("foo/bar")
99
- allow(provider).to receive(:get_tag).and_return("foo")
96
+ allow(provider).to receive(:current_tag).and_return("foo")
100
97
 
101
- expect(provider.context).to receive(:shell).with("git fetch --tags")
102
98
  expect(provider).to receive(:log).with("Deploying to repo: foo/bar")
103
99
  expect(provider).to receive(:log).with("Current tag is: foo")
104
100
 
@@ -106,7 +102,7 @@ describe DPL::Provider::Releases do
106
102
  end
107
103
 
108
104
  example "With $TRAVIS_TAG" do
109
- allow(provider).to receive(:travis_tag).and_return("bar")
105
+ allow(provider).to receive(:current_tag).and_return("bar")
110
106
  allow(provider).to receive(:slug).and_return("foo/bar")
111
107
 
112
108
  expect(provider.context).not_to receive(:shell).with("git fetch --tags")
@@ -117,21 +113,6 @@ describe DPL::Provider::Releases do
117
113
  end
118
114
  end
119
115
 
120
- describe "#get_tag" do
121
- example "Without $TRAVIS_TAG" do
122
- allow(provider).to receive(:travis_tag).and_return(nil)
123
- allow(provider).to receive(:`).and_return("bar")
124
-
125
- expect(provider.get_tag).to eq("bar")
126
- end
127
-
128
- example "With $TRAVIS_TAG" do
129
- allow(provider).to receive(:travis_tag).and_return("foo")
130
-
131
- expect(provider.get_tag).to eq("foo")
132
- end
133
- end
134
-
135
116
  describe "#check_auth" do
136
117
  example "With proper permissions" do
137
118
  allow_message_expectations_on_nil
@@ -159,7 +140,7 @@ describe DPL::Provider::Releases do
159
140
  provider.options.update(:file => ["test/foo.bar", "bar.txt"])
160
141
 
161
142
  allow(provider).to receive(:releases).and_return([""])
162
- allow(provider).to receive(:get_tag).and_return("v0.0.0")
143
+ allow(provider).to receive(:current_tag).and_return("v0.0.0")
163
144
  expect(File).to receive(:file?).with("test/foo.bar").and_return(true)
164
145
  expect(File).to receive(:file?).with("bar.txt").and_return(true)
165
146
 
@@ -187,7 +168,7 @@ describe DPL::Provider::Releases do
187
168
  provider.options.update(:file => ["test/foo.bar", "bar.txt"])
188
169
 
189
170
  allow(provider).to receive(:releases).and_return([""])
190
- allow(provider).to receive(:get_tag).and_return("v0.0.0")
171
+ allow(provider).to receive(:current_tag).and_return("v0.0.0")
191
172
  expect(File).to receive(:file?).with("test/foo.bar").and_return(true)
192
173
  expect(File).to receive(:file?).with("bar.txt").and_return(true)
193
174
 
@@ -216,7 +197,7 @@ describe DPL::Provider::Releases do
216
197
  provider.options.update(:overwrite => true)
217
198
 
218
199
  allow(provider).to receive(:releases).and_return([""])
219
- allow(provider).to receive(:get_tag).and_return("v0.0.0")
200
+ allow(provider).to receive(:current_tag).and_return("v0.0.0")
220
201
  expect(File).to receive(:file?).with("exists.txt").and_return(true)
221
202
 
222
203
  provider.releases.map do |release|
@@ -242,12 +223,12 @@ describe DPL::Provider::Releases do
242
223
 
243
224
  provider.options.update(:file => ["test/foo.bar", "bar.txt"])
244
225
 
245
- allow(provider).to receive(:releases).and_return([""])
226
+ allow(provider).to receive(:releases).and_return([a_release])
246
227
  expect(File).to receive(:file?).with("test/foo.bar").and_return(true)
247
228
  expect(File).to receive(:file?).with("bar.txt").and_return(true)
248
229
 
249
230
  provider.releases.map do |release|
250
- allow(release).to receive(:tag_name).and_return("foo")
231
+ allow(release).to receive(:current_tag).and_return("foo")
251
232
  allow(release).to receive(:rels).and_return({:self => nil})
252
233
  allow(release.rels[:self]).to receive(:href)
253
234
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl-releases
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.6.travis.2790.5
4
+ version: 1.9.6.travis.2794.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-26 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dpl
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.9.6.travis.2790.5
19
+ version: 1.9.6.travis.2794.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.9.6.travis.2790.5
26
+ version: 1.9.6.travis.2794.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: octokit
29
29
  requirement: !ruby/object:Gem::Requirement