-
Notifications
You must be signed in to change notification settings - Fork 999
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1343 from errbit/chore/emit-version-details
Chore/emit version details
- Loading branch information
Showing
5 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Errbit | ||
VERSION = '0.8.0-dev' | ||
class Version | ||
def full_version | ||
[ | ||
'0.8.0', | ||
'dev', | ||
source_version | ||
].compact.join('-') | ||
end | ||
|
||
def source_version | ||
source_version = ENV['SOURCE_VERSION'] | ||
source_version[0...8] if source_version.present? | ||
end | ||
end | ||
|
||
VERSION = Version.new.full_version | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
describe Errbit::VERSION do | ||
subject { Errbit::Version.new.full_version } | ||
|
||
it 'handles a missing commit sha' do | ||
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { nil } | ||
expect(subject).to end_with('dev') | ||
end | ||
|
||
it 'shortens a present commit sha' do | ||
allow(ENV).to receive(:[]).with('SOURCE_VERSION') { 'abcd1234efgh56789' } | ||
expect(subject).to end_with('dev-abcd1234') | ||
end | ||
end |