Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 849 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I set an environment variable with the SVN revision number of a project?

#1
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??
Reply

#2
The "svn info" subcommand will tell you the revision number in your working copy.
Reply

#3
See if this help: [Change Revision Number][1]


[1]:

[To see links please register here]

Reply

#4
Something like:

svn version > ver.txt
set /p ver= < ver.txt
del ver.txt
echo %ver%
Reply

#5
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?][1] or [Automatic SVN Revision Numbering in ASP.Net MVC][2]



[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#6
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.
Reply

#7
In bash (via Cygwin):

svn info | grep -i "Revision" | cut -d ' ' -f 2

You can then use that in a bash shell script to store the value in a variable.
Reply

#8
Here is an alternative that uses a pipe to findstr to get a single line:

FOR /F "tokens=2" %%G IN ('svn info ^| findstr /B Revision:') DO SET SVN_REVISION=%%G
echo SVN_REVISION: %SVN_REVISION%

FOR /F "tokens=2" %%G IN ('svn info ^| findstr /B URL:') DO SET SVN_URL=%%G
echo SVN_URL: %SVN_URL%
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through