Reputation: 550
I have pre-commit script which is taken from internet. Most of the scripts fails on different scenario. I would like to have pre-commit script which would allow to commit only if the needs-lock property been set. Which is Lock-Modify-Unlock model.
I have enabled the auto-props in the client configuration and added * = svn:needs-lock=* property as well.
Most of the script I found check the needs-lock property during the time of Adding new Files.But this checking alone will not solve the issue. During the below mentioned scenarios we can avoid the lock mechanism.
1) The developer can take out needs-lock property during edit. 2) Property can be taken out alone without modifying the file.
In the above mentioned scenarios script fails.
All ideas are welcome.
Upvotes: 1
Views: 866
Reputation: 2430
Something like the below should work.
for y in
svnlook changed -t "$TXN" "$REPOS" |grep "^[AU]" | awk -F" " '{print $2}'
do svnlook proplist -t "$TXN" "$REPOS" "$y" >/tmp/prop.txt
if (grep -iE "needs-lock" /tmp/prop.txt)
then
if echo $y | sed 's/^.*\///' | grep -i "\."; then echo OK else
echo "Not allowed to lock the folder $y " >&2;
exit 1;
fi
fi
done
This will check whether the property is applied or not on all the files/folders before commit. In case you need to exclude folder from this, you need to add one more condition to check whether its a folder or file and proceed accordingly.
Upvotes: 1