I am trying to get the revision number of a project and save it into a variable. I know I can get the revision number by svnversion command but I'm not sure how I can store it. I am using regular windows command prompt. Basically I'm trying to do something like : set svnVersion= %svnversion% but I'm not sure how??
+1
A:
The "svn info" subcommand will tell you the revision number in your working copy.
Ken Liu
2009-03-11 17:57:06
+2
A:
To set the output of variable to the output of svnversion in a batch file, you have to do this:
for /f "delims=" %%a in ('svnversion') do @set myvar=%%a
echo %myvar%
Different approach: If you have TortoiseSVN you can also use SubWCRev.exe. See get the project revision number into my project? or Automatic SVN Revision Numbering in ASP.Net MVC
f3lix
2009-03-11 18:07:03
In a batch file you'd have to double the % signs for the 'for' variable.
Joey
2009-03-11 20:43:56
you're right. thanks. edited the answer.
f3lix
2009-03-11 20:54:46
actually I think single % is the right choice. At least that's how it works on my system
2009-03-12 18:07:14
+1
A:
in Bash (via Cigwin):
$ svn info | grep -i "Revision" | cut -d ' ' -f 2
You can then use that in a shell script to store the value in a variable.
BryanH
2009-03-11 18:09:35
I'm not sure most people run bash as their "regular windows command prompt" ;-)
Steven Robbins
2009-03-11 18:10:48
A:
Something like:
svn version > ver.txt
set /p ver= < ver.txt
del ver.txt
echo %ver%
Steven Robbins
2009-03-11 18:09:48
A:
If you need this from a remote repository (as in not checked out localy) you can do this
for /f "delims=: tokens=1,2" %%a in ('svn info %SVN_REPO_URL%') do (
if "%%a"=="Revision" (
set /a RELEASE_REVISION=%%b
)
)
I use this in my release process to grab the revision number from a tag.
StocksR
2010-03-08 10:28:53