[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Get latest revision number for web app

From: Nathan S. Haigh <n.haigh_at_sheffield.ac.uk>
Date: 2006-06-21 18:22:09 CEST

Excellent! This works perfectly. Thanks!

Nathan

> -----Original Message-----
> From: Ryan Schmidt [mailto:subversion-2006q2@ryandesign.com]
> Sent: 21 June 2006 11:04
> To: n.haigh@sheffield.ac.uk
> Cc: users@subversion.tigris.org
> Subject: Re: Get latest revision number for web app
>
> On Jun 21, 2006, at 11:36, Nathan Haigh wrote:
>
> > I am using svn to track changes/version of a web application. I
> > would like to be able to dynamically embed the revision number of
> > the checkout code into the applications homepage using php. Does
> > anyone know if this is possible or how this could be done.
> >
> > What i have in mind is, that the code is checkout into a web
> > directory and i want the apps homepage to display that revision
> > number. In the mean time, i will continue updates on a working
> > copy, making commits until i make another release of the app and
> > check it out to the web directory again. I suppose i could just
> > manually edit the file in web directory to display the checkout
> > revision number, but this seems quite hacky.
>
> There is this FAQ entry:
>
> http://subversion.tigris.org/faq.html#version-value-in-source
>
> It's written for C programmers, but the idea is the same for any
> language: when you're ready to build or deploy your project, you run
> the "svnversion" command over the working copy, and put its output
> into a file. You can then read that file from within your application.
>
> Thisolution is ideal for compiled languages like C because such
> programmers are already used to having to run a script (the makefile)
> to turn their code into something they can run, so this is a great
> place to incorporate a call to svnversion. In interpreted languages
> like PHP, we don't have to compile, so this may seem a bit unusual to
> PHP programmers like us.
>
> In our deployed web sites, we essentially have a working copy on the
> production server which we can run "svn up" on when we want to pull
> down more-current code from the development server. Instead of
> calling "svn up" directly, consider writing a script "svnup.sh" (or
> "svnup.php" if you like) which does two things: first, it runs "svn
> up" as usual, and second, it runs "svnversion" and puts the result
> into a file "revision.txt" in a known location, which your PHP
> homepage can read in. Now you just need to train yourself to use your
> "svnup.sh" script instead of calling "svn up" yourself.
>
> In case you're thinking of trying to skip the wrapper script by
> calling "svnversion" from within the code for your homepage, I'd
> advise against that, since that would be much slower than simply
> reading in a text file.
>
> In fact, we've cheated a bit in our setup. It's a bit more
> complicated than I wrote above. We actually have a working copy of
> the last deployed tag of the project, and when we want to pull down a
> new release, we switch that working copy to the new tag. Then we
> export the working copy to a new directory named just like the tag.
> We have a script that automates all this. The trick is that when we
> make a new tag, we put the revision number into the tag name -- for
> example "1.4-7845". The web site then runs from a directory named
> "1.4-7845" and the page that wants to display the revision can simply
> extract it from its pathname. I'm not saying this is the best
> solution, or even a good one; it's just the compromise I was able to
> reach with the other programmers.

---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0625-4, 21/06/2006
Tested on: 21/06/2006 17:21:47
avast! - copyright (c) 1988-2006 ALWIL Software.
http://www.avast.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Jun 21 18:24:32 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.