Question

I want to ran the following script on text files that are being committed:

# Send the commands H and w to ed
# ed will append newline if the file does not end in one
printf "%s\n" H w | ed -s $1

# Strip trailing whitespace
sed -i 's/[ \t]*$//g' $1

# Convert tabs to 4 spaces
sed -i -r "s/\t/    /g" $1

I see subversion has a start-commit and pre-commit hooks but I can't follow the documentation about how I could process the text files with the above script.

Was it helpful?

Solution

You mean change the text file before it's committed? You can (I'm not sure how), but it's generally not a good idea, as it doesn't tell the client about the change, so the local copies become void on a commit.

What I would do is block the commit (non zero exit), and give an error message as to why you don't want that revision to go through.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top