Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2678efb
commit db11b19
Showing
2 changed files
with
39 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
# "Ascertain" the revision we're running (so named so it'll come before | ||
# the cache initializer, which uses this info). | ||
|
||
def determine_revision | ||
# Note the revision number we're running, and a | ||
# more-informative string containing it. | ||
revision_path = File.dirname(__FILE__) + "/../../REVISION" | ||
begin | ||
digits = 8 | ||
if File.exist? revision_path | ||
mod_date = File.mtime(revision_path) | ||
full_number = File.read(revision_path).strip | ||
number = full_number[0...digits] | ||
extra = mod_date.strftime("%H:%M %a, %b %d %Y").gsub(" 0"," ") | ||
else | ||
if File.exist?(".git") | ||
full_number = `git log -1`.split(" ")[1] | ||
number = full_number[0...digits] | ||
extra = `git branch`.split("\n").grep(/^\*/)[0].split(' ')[-1] | ||
else | ||
# We don't use --xml anymore, because CentOS's svn doesn't have it. | ||
number = `svn info`.grep(%r"^Revision: ")[0].split(" ")[1] | ||
extra = '' | ||
end | ||
end | ||
rescue | ||
number = '???' | ||
extra = '' | ||
end | ||
details = "#{Rails.env} #{number} #{extra} #{Socket.gethostname}" | ||
return full_number, number, details | ||
end | ||
|
||
FULL_SOURCE_REVISION_NUMBER, SOURCE_REVISION_NUMBER, SOURCE_REVISION_DETAILS = determine_revision | ||
|
||
# Add this to the environment too, so it'll be visible in Hoptoad | ||
ENV["SOURCE_REVISION_DETAILS"] = SOURCE_REVISION_DETAILS |