Check that an svn repository url does not exist

Solution 1:

Instead of checking for return strings I would just check for the return code:

both

svn ls REPOSITORY/PATH

and

svn info REPOSITORY/PATH

return 0 if all went fine, and 1 if things went wrong; you can quickly check it out:

echo $?

so in a bash script just do something like:

error=$?
if [ $error -ne 0 ]; then
      YOUR ERROR HANDLING
fi

works like a treat!

Solution 2:

You can just use

svn ls https://developernetwork.repo.net/svn/Projects/Calculator/

It will tell you if the repository(directory) exist or not.

Update

for directories with many files use:

svn ls http://server/svn/foo --depth empty

Solution 3:

To receive information about any existing repository (e.g. for possibly enriching an error message) you could also use

svn info https://developernetwork.repo.net/svn/Projects/Calculator/

For a non-existing project it will just return

svn: Could not open the requested SVN filesystem

Solution 4:

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)

projects=$(svn ls https://developernetwork.repo.net/svn/Projects/)

then check your project folder exists. Remember to add / after your project name.

projectName="Calculator/"
for i in $projects; do 
    if [ "$i" == "$projectName/" ];
        then
        echo Project Exist
        else
        echo Project does not exist
    fi
done 

simple.