I am writing a script which will add a new project in the repository, based on the name supplied by the user. Part of this involves checking that an url with the same name does not already exist on the repository.
In the repository, all the projects of our team are stored in
https://developernetwork.repo.net/svn/Projects/
Let's say that the user wants to call the project "Calculator" and runs the script. In this case, we need to ensure that the following does not already exist in the repository
https://developernetwork.repo.net/svn/Projects/Calculator/
Is there an svn command which I can use to accomplish that? Unfortunately I cannot see an appropriate command I can use in the svn documentation (http://svnbook.red-bean.com/en/1.0/svn-book.html) at all.
I face the above problem and i tried all the way. not work for me.. if we access svn with a path not in svn it's failed with error and the shell script will break.
Instead of accessing unknown path, what i did is get the directory list of parent folder and check whether matching one contain or not.
Get all the projects form your Parent directory (if you want to find a specific tags then your parent directory path should be
https://developernetwork.repo.net/svn/Projects/Calculator/tags
)then check your project folder exists. Remember to add
/
after your project name.simple.
Like @A Scott says, the
echo $?
can't be used to know wether the URL is correct (I'm on Mac OS 10.11 and SVN client 1.9.5).For potential future readers, i use this workaround :
Instead of checking for return strings I would just check for the return code:
both
and
return 0 if all went fine, and 1 if things went wrong; you can quickly check it out:
so in a bash script just do something like:
works like a treat!
To receive information about any existing repository (e.g. for possibly enriching an error message) you could also use
For a non-existing project it will just return
I'd have commented on an existing answer but I don't have sufficient reputation.
I wanted to find if a file had been imported successfully or not so I tried "svn info" and "svn ls" with "echo $?". I could only get a zero/non-zero return code when I used "svn ls": "svn info" always returned zero.
This was with subversion 1.5.5 on Redhat RHEL6.
You can just use
It will tell you if the repository(directory) exist or not.
Update
for directories with many files use: