0

I'd like to write a script which catch a revision of the last commit and save this in a file.

I'd want to know how can I do to catch the last commit revision using svn commands.

Thanks.

kamusett
  • 1,403
  • 1
  • 12
  • 22

2 Answers2

1

How about this?

$ svn log -rHEAD $REPO | awk 'NR==2 {print substr($1,2)}'  > lastrev.txt

The $svn log -rHEAD $REPO prints the log of the HEAD revision of your repository.

The `awk 'NR==2' prints the second line of that log entry which happens to contain the revision number.

That revision number is the first field of that line, but it starts with an r. To remove the r, we usesubstr($1,2) which removes the first character of field #1. That strips away the r and leaves the rest of the revision.

Then, we redirect the output to your file.

David W.
  • 105,218
  • 39
  • 216
  • 337
0

If you are in Working Copy You can also use svnversion command which comes with subversion Check this: https://stackoverflow.com/a/579289/377854

Community
  • 1
  • 1
Bijay Rungta
  • 990
  • 9
  • 16