I wrote a pre-commit hook that checks if trunk version.txt file is updated compared with version.txt in tag. When I run the script in console everything is fine, but when I try to commit I've got this
Authentication realm: http://localhost:80 Subversion Repository Password for 'www-data': svn: E070014: Unable to connect to a repository at URL 'http://localhost/svn/myrepo2/tags'
And also this if --force-interactive is off
svn: E215004: Authentication failed and interactive prompting is disabled; see the --force-interactive option
I checked everything step-by-step and it seems like thats the line that causes the problem:
tag=$(svn list /some/path/tags --force-interactive | sort -n | tail -n 1 )
Is there any alternative to svn ls to check the latest tag or the files within folder tags?
#!/bin/bash
#get latest tag
tag=$(svn ls /some/path/tags --force-interactive | sort -n | tail -n 1)
#get content of file from the latest tag
fileFromTag=$(svn cat /some/path/tags/$tag/version.txt)
#get content of file from trunk
file=$(svn cat some/path/trunk/version.txt)
#compare current file with file from latest tag
if [ "$fileFromTag" == "$file" ]
then
echo "Update version.txt"
exit 1
fi
And here's the repository structure
tags/
1.1.0/
version.txt
1.1.3/
version.txt
1.1.5/
version.txt
1.1.6/
version.txt
1.2.0/
version.txt
rel_1.0/
version.txt
trunk/
version.txt
The error means that the svn
client does not authenticate to the server and there are no cached credentials. But the main problem is the commands that you run in your hook script:
svn
command-line client to svnlook
.svn
command-line client in hooks, use the file:// URLs instead of HTTP(S) URLs. The hook runs locally on the same computer with your repositories and the server, so it makes sense to access the repos directly.