1

Want to get last changed revision from svn branch in batch file.

echo on
set svnUrl=%1
set releaseName=%2
set buildNumber=%3


for /f %%i in ('svn info  %svnUrl%/branches/%releaseName% -r HEAD ^| FINDSTR "^Last.Changed.Rev:"') do set revisionNumber=%%i
echo %revisionNumber%

But I'm getting word Last instead of Last Changed Rev: 10

In console for command

D:\svn info http://desktop-24i22vk:81/svn/Test/branches/TST-1 -r HEAD

I'm receiving console output:

Path: TST-1
URL: http://desktop-24i22vk:81/svn/Test/branches/TST-1
Relative URL: ^/branches/TST-1
Repository Root: http://desktop-24i22vk:81/svn/Test
Repository UUID: 57a8baac-304e-e54b-94b3-b7d049dce932
Revision: 17
Node Kind: directory
Last Changed Author: import
Last Changed Rev: 10
Last Changed Date: 2016-07-22 15:26:37 +0200 (pá, 22 čvc 2016)

I want to get last changed revision number, here it's 10. I was thinking to store whole line text Last Changed Rev: 10 to variable and then replace text to get only number. I would appreciate even other (windows batch) approaches how to get it. Thanks

2
  • 3
    See for /f syntax: for /f "tokens=4" %%i in ..... Commented Jul 22, 2016 at 16:04
  • Thanks, great solution. Commented Jul 23, 2016 at 22:03

2 Answers 2

2

The default behavior of FOR /F is to break each line into tokens, delimited by spaces and/or tabs, and return only the first token of each line. That explains why you are only getting "Last".

You could preserve the entire line by setting the delims option to nothing

for /f "delims=" %%i ...

But you don't want the entire line. You just want the last (4th) token. So ...

for /f "tokens=4" %%i ...
Sign up to request clarification or add additional context in comments.

Comments

2

May use svn info -r HEAD --show-item revision to get ONLY the Head rev as output...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.