Skip to content

Commit

Permalink
Merge pull request #1343 from errbit/chore/emit-version-details
Browse files Browse the repository at this point in the history
Chore/emit version details
  • Loading branch information
rud committed Nov 19, 2018
2 parents b8958da + eccad08 commit 1c75944
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ Installation
Rails applications.

* [Install MongoDB](https://www.mongodb.org/downloads)
* git clone https://github.com/errbit/errbit.git
* bundle install
* bundle exec rake errbit:bootstrap
* bundle exec rails server
* `git clone https://github.com/errbit/errbit.git`
* `bundle install`
* `bundle exec rake errbit:bootstrap`
* `bundle exec rails server`

Configuration
-------------
Expand Down
1 change: 1 addition & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def heroku_pr_review_app?
puts "-- password: #{admin_pass}"
puts ""
puts "Be sure to note down these credentials now!"
puts "\nNOTE: DEMO instance, not for production use!" if heroku_pr_review_app?

user = User.find_or_initialize_by(email: admin_email)

Expand Down
19 changes: 18 additions & 1 deletion lib/errbit/version.rb
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
6 changes: 1 addition & 5 deletions lib/tasks/errbit/bootstrap.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ require 'fileutils'

namespace :errbit do
desc "Seed and index the DB"
task :bootstrap do
Rake::Task['db:seed'].invoke
puts "\n"
Rake::Task['db:mongoid:create_indexes'].invoke
end
task bootstrap: %w(db:seed db:mongoid:create_indexes)
end
13 changes: 13 additions & 0 deletions spec/lib/errbit/version_spec.rb
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

0 comments on commit 1c75944

Please sign in to comment.