3

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.

Mark Biek
  • 146,731
  • 54
  • 156
  • 201
grom
  • 15,842
  • 19
  • 64
  • 67

1 Answers1

7

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.

Grant
  • 11,799
  • 13
  • 42
  • 47