Hitesh P
Hitesh P

Reputation: 416

How to retrieve SVN Repository URL (only) for a file

I want to retrieve the SVN repository URL only from the file which is checked out locally. I know there is a SVN Info command, but it gives too much info along with URL. I only need the URL which I am planning to save to Clipboard on menu click. Is it possible without going into parsing the result of SVN Info command?

Upvotes: 2

Views: 1137

Answers (3)

Daniel Desmond
Daniel Desmond

Reputation: 1

I know I'm a few years late to this question, so it is possible that the APIs have changed to allow my answer.

Windows command prompt:

svn info FILENAME --show-item url

Upvotes: 0

alroc
alroc

Reputation: 28194

Another option on Windows using PowerShell:

[xml]$svninfo = svn info FILENAME --xml;
$svninfo.info.entry.url;

Or without XML:

(svn info FILENAME |select-string "\burl")[0].Line.replace("URL: ","")

The PSCX extensions have an Out-Clipboard cmdlet which will let you dump the string to the clipboard.

Upvotes: 2

Álvaro González
Álvaro González

Reputation: 146630

I don't think so. But it's quite simple to filter out. E.g., on Windows:

D:\example>svn info foo.php | findstr URL:
URL: https://www.example.com:8443/svn/foo.php

On Unix (untested):

svn info foo.php | grep URL:

Upvotes: 1

Related Questions