Joe Van Dyk
2006-Jul-23 18:31 UTC
[Rails] embedding subversion version information into HTML
Hi, Say I want to display the subversion release number in the footer of each page in order to track what version of a site I''m looking at. I know subversion has a substitution keyword (LastChangedRevision) that inserts the last known revision in which that file .changed. So, if I stick $LastChangedRevision$ into views/layouts/application.rhtml, it''ll show the last time that file was changed, not the current version of the repository. W hich isn''t quite what I want. Any ideas? Thanks, Joe
Jodi Showers
2006-Jul-23 18:38 UTC
[Rails] embedding subversion version information into HTML
I haven''t found a solution other than to modify the keyworded file every time I commit to svn. Love to hear another solution, but since svn only commits modified files, substitution can only happen when this file is changed. Jodi On 23-Jul-06, at 2:31 PM, Joe Van Dyk wrote:> Hi, > > Say I want to display the subversion release number in the footer of > each page in order to track what version of a site I''m looking at. > > I know subversion has a substitution keyword (LastChangedRevision) > that inserts the last known revision in which that file .changed. > > So, if I stick $LastChangedRevision$ into > views/layouts/application.rhtml, it''ll show the last time that file > was changed, not the current version of the repository. W hich isn''t > quite what I want. Any ideas? > > Thanks, > Joe > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Can you use File.open to get at the info from your .svn directory? If not, you could use open-uri to download the info from a repository. - dan -- Dan Kohn <mailto:dan@dankohn.com> <http://www.dankohn.com/> <tel:+1-415-233-1000> On Jul 23, 2006, at 11:31 AM, Joe Van Dyk wrote:> Hi, > > Say I want to display the subversion release number in the footer of > each page in order to track what version of a site I''m looking at. > > I know subversion has a substitution keyword (LastChangedRevision) > that inserts the last known revision in which that file .changed. > > So, if I stick $LastChangedRevision$ into > views/layouts/application.rhtml, it''ll show the last time that file > was changed, not the current version of the repository. W hich isn''t > quite what I want. Any ideas? > > Thanks, > Joe > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Gregory Bluvshteyn
2006-Jul-23 21:12 UTC
[Rails] embedding subversion version information into HTML
Don, I use `svn info` inside of the checked out directory and then parse results. -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Dan Kohn Sent: Sunday, July 23, 2006 5:07 PM To: rails@lists.rubyonrails.org Subject: Re: [Rails] embedding subversion version information into HTML Can you use File.open to get at the info from your .svn directory? If not, you could use open-uri to download the info from a repository. - dan -- Dan Kohn <mailto:dan@dankohn.com> <http://www.dankohn.com/> <tel:+1-415-233-1000> On Jul 23, 2006, at 11:31 AM, Joe Van Dyk wrote:> Hi, > > Say I want to display the subversion release number in the footer of > each page in order to track what version of a site I''m looking at. > > I know subversion has a substitution keyword (LastChangedRevision) > that inserts the last known revision in which that file .changed. > > So, if I stick $LastChangedRevision$ into > views/layouts/application.rhtml, it''ll show the last time that file > was changed, not the current version of the repository. W hich isn''t > quite what I want. Any ideas? > > Thanks, > Joe > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails_______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
James Adam
2006-Jul-24 08:34 UTC
[Rails] embedding subversion version information into HTML
Here''s a method we use internally: def svn_version File.new(".svn/entries").each do |x| if md = /^[\s]*url=".*tags\/REL-([\d\.-]+)/.match(x) return md[1] elsif md = /^[\s]*url=".*branches\/([^\/"]+)/.match(x) return md[1] elsif md = /^[\s]*revision="([\d]+)/.match(x) return md[1] end end return ''(unknown version)'' end .. it does some nice things if you''ve deployed from a tag or a branch, as well as just returning the raw revision number. HTH - james On 7/23/06, Gregory Bluvshteyn <monozub@acedsl.com> wrote:> Don, > > I use `svn info` inside of the checked out directory and then parse results. > > > -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Dan Kohn > Sent: Sunday, July 23, 2006 5:07 PM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] embedding subversion version information into HTML > > Can you use File.open to get at the info from your .svn directory? > If not, you could use open-uri to download the info from a repository. > > - dan > -- > Dan Kohn <mailto:dan@dankohn.com> > <http://www.dankohn.com/> <tel:+1-415-233-1000> > > > > On Jul 23, 2006, at 11:31 AM, Joe Van Dyk wrote: > > > Hi, > > > > Say I want to display the subversion release number in the footer of > > each page in order to track what version of a site I''m looking at. > > > > I know subversion has a substitution keyword (LastChangedRevision) > > that inserts the last known revision in which that file .changed. > > > > So, if I stick $LastChangedRevision$ into > > views/layouts/application.rhtml, it''ll show the last time that file > > was changed, not the current version of the repository. W hich isn''t > > quite what I want. Any ideas? > > > > Thanks, > > Joe > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- * J * ~
Bojan Mihelac
2006-Jul-24 12:25 UTC
[Rails] embedding subversion version information into HTML
Joe Van Dyk wrote:> Hi, > > Say I want to display the subversion release number in the footer of > each page in order to track what version of a site I''m looking at. > > I know subversion has a substitution keyword (LastChangedRevision) > that inserts the last known revision in which that file .changed. > > So, if I stick $LastChangedRevision$ into > views/layouts/application.rhtml, it''ll show the last time that file > was changed, not the current version of the repository. W hich isn''t > quite what I want. Any ideas? > > Thanks, > Joe > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >Hi Joe, you can create dynamically partial template when deploying with capistrano, for example add this code to deploy.rb task :after_update_code, :roles => [:web] do put(revision, "#{release_path}/app/views/layouts/_version.rhtml") end and include it in layout with Revision: <%= render_partial(''/layouts/version'')%> hope that helps you, Bojan Mihelac -- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org
Julien Schmurfy
2006-Jul-25 00:06 UTC
[Rails] Re: embedding subversion version information into HTML
Joe Van Dyk wrote:> Hi, > > Say I want to display the subversion release number in the footer of > each page in order to track what version of a site I''m looking at. > > I know subversion has a substitution keyword (LastChangedRevision) > that inserts the last known revision in which that file .changed. > > So, if I stick $LastChangedRevision$ into > views/layouts/application.rhtml, it''ll show the last time that file > was changed, not the current version of the repository. W hich isn''t > quite what I want. Any ideas? > > Thanks, > JoeYou are simply not sing the right keyword, if you want the latest revision place $Rev$ or $Revision$ somewhere in your code, the result will be: "$Rev: 552 $" One thing to keep in mind is that you need to make a change to the file where you put the "$Rev$" keyword to make it change. -- Posted via http://www.ruby-forum.com/.
Blair Zajac
2006-Jul-25 00:18 UTC
[Rails] embedding subversion version information into HTML
Joe Van Dyk wrote:> Hi, > > Say I want to display the subversion release number in the footer of > each page in order to track what version of a site I''m looking at. > > I know subversion has a substitution keyword (LastChangedRevision) > that inserts the last known revision in which that file .changed. > > So, if I stick $LastChangedRevision$ into > views/layouts/application.rhtml, it''ll show the last time that file > was changed, not the current version of the repository. W hich isn''t > quite what I want. Any ideas?You could use svnversion to crawl your working copy redirect its output into a separate file that is included in all your views or use it in a sed like command to change each of your views. http://svnbook.red-bean.com/en/1.2/svn.ref.svnversion.re.html Regards, Blair -- Blair Zajac, Ph.D. <blair@orcaware.com> Subversion training, consulting and support http://www.orcaware.com/svn/
Joe Van Dyk
2006-Jul-25 00:26 UTC
[Rails] Re: embedding subversion version information into HTML
On 7/24/06, Julien Schmurfy <schmurfy@gmail.com> wrote:> Joe Van Dyk wrote: > > Hi, > > > > Say I want to display the subversion release number in the footer of > > each page in order to track what version of a site I''m looking at. > > > > I know subversion has a substitution keyword (LastChangedRevision) > > that inserts the last known revision in which that file .changed. > > > > So, if I stick $LastChangedRevision$ into > > views/layouts/application.rhtml, it''ll show the last time that file > > was changed, not the current version of the repository. W hich isn''t > > quite what I want. Any ideas? > > > > Thanks, > > Joe > > You are simply not sing the right keyword, if you want the latest > revision place $Rev$ or $Revision$ somewhere in your code, the result > will be: "$Rev: 552 $" > One thing to keep in mind is that you need to make a change to the file > where you put the "$Rev$" keyword to make it change.$Rev$ is shorthand for $LastChangedRevision$. The problem is that I don''t want to have to update the file in order to get the repository version. I think Bojan (thanks!) has the solution. Joe