diff --git a/.gitignore b/.gitignore index db2900f71a9..19d075c15fd 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,6 @@ chef/tmp/* # .procfile .procfile + +# exclude our git version file for now +config/version.rb diff --git a/config/application.rb b/config/application.rb index 85723bf2180..99591b5147e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,7 +1,9 @@ require File.expand_path('../boot', __FILE__) +# our version info can be missing, we will do our best to figure it out +require File.expand_path('../version', __FILE__) rescue nil require 'rails/all' -require "redis-store" # HACK +require 'redis-store' # HACK # Plugin related stuff require './lib/discourse_plugin_registry' @@ -50,7 +52,7 @@ module Discourse # config.i18n.default_locale = :de # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" + config.encoding = 'utf-8' # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 61d320aa42b..9635256f3fd 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,3 +1,16 @@ # Definitely change this when you deploy to production. Ours is replaced by jenkins. -Discourse::Application.config.secret_token = "47f5390004bf6d25bb97083fb98e7cc133ab450ba814dd19638a78282b4ca291" +# This token is used to secure sessions, we don't mind shipping with one to ease test and debug, +# however, the stock one should never be used in production, people will be able to crack +# session cookies. +# + +# Discourse::Application.config.secret_token = "SET_SECRET_HERE" + +# delete all lines below in production +if Rails.env.test? || Rails.env.development? + Discourse::Application.config.secret_token = "47f5390004bf6d25bb97083fb98e7cc133ab450ba814dd19638a78282b4ca291" +else + raise "You must set a secret token in config/initializers/secret_token.rb" +end + diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake new file mode 100644 index 00000000000..2ee206d4a8f --- /dev/null +++ b/lib/tasks/build.rake @@ -0,0 +1,8 @@ +desc "stamp the current build with the git hash placed in version.rb" +task "build:stamp" => :environment do + git_version = `git rev-parse HEAD`.strip + File.open(Rails.root.to_s + '/config/version.rb', 'w') do |f| + f.write("$git_version = #{git_version.inspect}\n") + end + puts "Stamped current build with #{git_version}" +end