Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine if a directory is part of a Subversion working copy?

Tags:

svn

I have a script that copies some files into a project. Such a project is usually a Subversion working copy, but not always. If it is a working copy, I want to add the files to Subversion automatically. But how do I know that the directory is part of a Subversion working copy? So far I checked for a .svn sub-folder, but that doesn't work with Subversion 1.7. I just need to know if svn add files... will work, no other data needs to be extracted.

like image 962
holger Avatar asked Aug 24 '11 08:08

holger


2 Answers

Just run svn status. You'll get a message like the following if the it's not a working copy:

svn: warning: '.' is not a working copy

Edit: If you are concerned about the recursive nature of svn status you can limit the depth by (depending on the version of the client) either

svn status --depth=empty

or

svn status --non-recusive

(The latter format is listed as obsolete in recent versions of the client).

like image 61
borrible Avatar answered Oct 30 '22 19:10

borrible


You can use the svn info property and then pipe to just get the url as follows:

svn info -R | FIND "URL:" >urlText

then load this output into another variable and you could work with it like:

set /p urlRepo= <urlText
del urlText
like image 23
Baz1nga Avatar answered Oct 30 '22 18:10

Baz1nga