Setting version number automatically
Moderator: General Moderators
Setting version number automatically
I have been defining the version number for applications that I write as a constant. Whenever I commit changes to the repository I increment the version number manually.
Is there a way to do this automatically?
Is there a way to do this automatically?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Setting version number automatically
I'm using SVN.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Setting version number automatically
I think most projects put the version number in the branch name.
(#10850)
Re: Setting version number automatically
Yeah that makes sense. I'm guessing there isn't a way to have it auto update the version number inside the code then.
Re: Setting version number automatically
Oh there is. There is a lot of information that can be updated with SVN. (You can even set your own custom Keywords)astions wrote:Yeah that makes sense. I'm guessing there isn't a way to have it auto update the version number inside the code then.
Code: Select all
svn propset --recursive svn:keywords 'URL HeadURL Author Id Revision LastChangedBy Date' .You can then put $Revision$ In your code on the page(s) that you set the properties on, and it will change every time it is commited.
But it sounds like you would just like
Code: Select all
svn propset svn:keywords 'Revision' index.php
Last edited by Zoxive on Thu Feb 14, 2008 5:40 pm, edited 1 time in total.
Re: Setting version number automatically
Awesome, I'll do some digging around and see if I can do that from within Eclipse then.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Setting version number automatically
I'm actually thinking of using Ant to manage my project. You could certainly do it with that. But it's a bit overkill. the main reason I'll be using it is because I want to have targets to generate documentation, run tests prior to packaging, and most importantly, bundle up a bunch of classes from various repositories (== pain the but).
I'd use Phing, but I already know how to use Ant and don't really have the time to spend learning what is probably less powerful.
I'd use Phing, but I already know how to use Ant and don't really have the time to spend learning what is probably less powerful.
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
Re: Setting version number automatically
I am hurt at the lack of affection for Phing. Bad Chris! 
At the moment I use Phing for nearly all my PHP projects. I got a few documentation tasks for the current version patched by the Phing team so I can now generate Docbook XHTML documentation from source completely in PHP without a single system call. That's how it's done for the PHPSpec Manual for example.
At the moment I use Phing for nearly all my PHP projects. I got a few documentation tasks for the current version patched by the Phing team so I can now generate Docbook XHTML documentation from source completely in PHP without a single system call. That's how it's done for the PHPSpec Manual for example.
Re: Setting version number automatically
I'm not familiar with Phing. Guess I'll check out the Phing. I've already got all my codebases in SVN though. I don't think I'd want to move everything over, especially if I lost the revision &|| history.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Setting version number automatically
Sorry Pádraic, I'll check it out... it's just when you already know how to use something else which is bascially intended for the same task you'll generally just stick with that 
~astions, Phing and Ant are much the same thing. They are used to manage projects... packaging up files, running tests, compiling source code etc. They're a bit like GNU "./configure + make" bundled into something much easier to use. Ant is not intended for use with PHP (it's for Java projects so knows how to compile Java code), whereas Phing was written for just that.
They're entirely independent of where you store your code so there would be no need to stop using SVN. You can probably even get Phing to checkout the code from SVN prior to packing (I know ant can).
Typically you have some build script which defines targets for "test", "compile", "package" etc and you just run:
Or something to that effect.
With ant you'll generally do something like:
The idea behind both projects is that you define how files are bundled, where they come from etc...
~astions, Phing and Ant are much the same thing. They are used to manage projects... packaging up files, running tests, compiling source code etc. They're a bit like GNU "./configure + make" bundled into something much easier to use. Ant is not intended for use with PHP (it's for Java projects so knows how to compile Java code), whereas Phing was written for just that.
They're entirely independent of where you store your code so there would be no need to stop using SVN. You can probably even get Phing to checkout the code from SVN prior to packing (I know ant can).
Typically you have some build script which defines targets for "test", "compile", "package" etc and you just run:
Code: Select all
phing packageWith ant you'll generally do something like:
Code: Select all
ant compile test #build source files and run testsRe: Setting version number automatically
Ah ok, thanks for the clarification. At this point I don't think that is something I would need, although I can see how it would be useful.
Re: Setting version number automatically
Hi Zoxive,
Thank you for your reply to this thread! You're introduction to svn:keywords have been most helpful!
I'm curious about two things:
1) How do you define your own (custom) keywords?
2) Can you describe in more detail what your script does? The one that you described, which helps update the file you're updating every ten minutes.
The reason why I ask is because I'm looking for a way to dynamically add the subversion HEAD revision number to a particular file (as opposed to the current revision number of the file, which is what the $Revision$ does). Do you know of a way to do this?
Thanks in advance!
Thank you for your reply to this thread! You're introduction to svn:keywords have been most helpful!
I'm curious about two things:
1) How do you define your own (custom) keywords?
2) Can you describe in more detail what your script does? The one that you described, which helps update the file you're updating every ten minutes.
The reason why I ask is because I'm looking for a way to dynamically add the subversion HEAD revision number to a particular file (as opposed to the current revision number of the file, which is what the $Revision$ does). Do you know of a way to do this?
Thanks in advance!
Re: Setting version number automatically
Hello phaitour,
the number of keywords SVN understands is limited, afaik.
So you simply can't define your own (custom) keywords.
When you want to dynamically add the subversion HEAD revision number to a particular file, you could use the command "svn log -q -v -rHEAD <URI>" and perform grep or some regexp's on the informations given.
And there is also Phings SvnLastRevisionTask to get the Revision Number into a property, for further processing.
the number of keywords SVN understands is limited, afaik.
So you simply can't define your own (custom) keywords.
When you want to dynamically add the subversion HEAD revision number to a particular file, you could use the command "svn log -q -v -rHEAD <URI>" and perform grep or some regexp's on the informations given.
And there is also Phings SvnLastRevisionTask to get the Revision Number into a property, for further processing.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Setting version number automatically
Are svn revision numbers really that useful in public versioning? They're quite monstrous numbers 