Skip to content

Commit 3cb985f

Browse files
authored
Prepare to release v0.9.0 (errbit#1466)
* Prepare to release v0.9.0 * Use dev flag to indicate dev/release versions
1 parent 6b5c6f2 commit 3cb985f

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ coverage
2121
.ruby-version
2222
.tool-versions
2323
NOTES
24+
*.swp

lib/errbit/version.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
module Errbit
44
class Version
5+
def initialize(ver, dev = false)
6+
@version = ver
7+
@dev = dev
8+
end
9+
510
def full_version
6-
[
7-
'0.9.0',
8-
'dev',
9-
source_version
10-
].compact.join('-')
11+
full = [@version]
12+
if @dev
13+
full << "dev"
14+
full << source_version
15+
end
16+
full.compact.join('-')
1117
end
1218

1319
def source_version
@@ -16,5 +22,5 @@ def source_version
1622
end
1723
end
1824

19-
VERSION = Version.new.full_version
25+
VERSION = Version.new('0.9.0').full_version
2026
end

spec/lib/errbit/version_spec.rb

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
describe Errbit::VERSION do
2-
subject { Errbit::Version.new.full_version }
2+
let(:version) { '0.0.0' }
33

4-
it 'handles a missing commit sha' do
5-
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { nil }
6-
expect(subject).to end_with('dev')
4+
context "release version" do
5+
subject { Errbit::Version.new(version).full_version }
6+
7+
it 'generates a release version' do
8+
expect(subject).to eq(version)
9+
end
10+
11+
it 'does not use a commit sha' do
12+
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { 'abcd1234efgh56789' }
13+
expect(subject).to eq(version)
14+
end
715
end
816

9-
it 'shortens a present commit sha' do
10-
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { 'abcd1234efgh56789' }
11-
expect(subject).to end_with('dev-abcd1234')
17+
context "dev version" do
18+
subject { Errbit::Version.new(version, true).full_version }
19+
20+
it 'generates a dev version' do
21+
expect(subject).to end_with('dev')
22+
end
23+
24+
it 'handles a missing commit sha' do
25+
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { nil }
26+
expect(subject).to end_with('dev')
27+
end
28+
29+
it 'shortens a present commit sha' do
30+
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { 'abcd1234efgh56789' }
31+
expect(subject).to end_with('dev-abcd1234')
32+
end
1233
end
1334
end

0 commit comments

Comments
 (0)