August 30, 2007
Add SVN revision number to page titles for QA
At EastMedia, we generally run a development server which gets deployed from the trunk of each projects repository on a regular basis. One way we have improved the bug reports we get as part of our QA process is asking the testers to note the revision number of the build they were looking at when the bug occurred. To make this as easy as possible, during development we include the SVN revision number in the <title> tag of every page.
The code to determine the revision number lives in application_helper.rb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
def revision @revision ||= if svn_info_from_working_copy svn_info_from_working_copy["Revision"].value else last_revision_in_log end rescue @revision = "UNKNOWN" end def svn_info_from_working_copy @svn_info ||= YAML.parse(`svn info #{RAILS_ROOT}`) end def last_revision_in_log File.readlines(RAILS_ROOT + "/../../revisions.log").last.split[3] end |
And the header RHTML looks like this:
<title>r<%= revision %> | ...Normal page title...</title> |