<p>I was wondering if anyone here had some experience writing this type of script and if they could give me some pointers.</p>

<p>I would like to modify this <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook" rel="nofollow noreferrer">script</a> to validate that the check-in file does not have a Carriage Return in the EOL formatting. The EOL format is CR LF in Windows and LF in Unix. When a User checks-in code with the Windows format. It does not compile in Unix anymore. I know this can be done on the client side but I need to have this validation done on the server side. To achieve this, I need to do the following:</p>

<p>1) Make sure the file I check is not a binary, I dont know how to do this with svnlook, should I check the mime:type of the file? The <a href="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html" rel="nofollow noreferrer">Red Book</a> does not indicate this clearly or I must have not seen it.</p>

<p>2) I would like to run the <a href="http://linux.about.com/od/commands/l/blcmdl1_dos2uni.htm" rel="nofollow noreferrer">dos2unix</a> command to validate that the file has the correct EOL format. I would compare the output of the dos2unix command against the original file. If there is a diff between both, I give an error message to the client and cancel the check-in.</p>

<p>I would like your comments/feedback on this approach.</p>

[{'answer_id': 48575, 'author': 'Stephen Johnson', 'author_id': 5063, 'author_profile': 'https://Stackoverflow.com/users/5063', 'pm_score': 1, 'selected': False, 'text': '<p>What exactly are you trying to do?</p>\n\n<p>Of course, there are numerous places to learn about svn pre-commit hooks (e.g. <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook" rel="nofollow noreferrer"> here </a>, <a href="http://www.windley.com/archives/2008/08/using_a_precommit_hook_to_check_puppet_syntax.shtml" rel="nofollow noreferrer"> here</a>, and in the <a href="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html" rel="nofollow noreferrer">Red Book</a>) but it depends what you\'re trying to do and what is available on your system.  </p>\n\n<p>Can you be more specific? </p>\n'}, {'answer_id': 50507, 'author': 'Stephen Johnson', 'author_id': 5063, 'author_profile': 'https://Stackoverflow.com/users/5063', 'pm_score': 3, 'selected': True, 'text': '<p>I think you can avoid a commit hook script in this case by using the <code>svn:eol-style</code> property as described in the SVNBook:</p>\n\n<ul>\n<li><p><a href="http://svnbook.red-bean.com/en/1.7/svn.advanced.props.file-portability.html#svn.advanced.props.special.eol-style" rel="nofollow noreferrer">End-of-Line Character Sequences</a></p></li>\n<li><p><a href="http://svnbook.red-bean.com/en/1.7/svn.ref.properties.html" rel="nofollow noreferrer">Subversion Properties</a></p></li>\n</ul>\n\n<p>This way SVN can worry about your line endings for you.</p>\n\n<p>Good luck!</p>\n'}]
['https://Stackoverflow.com/questions/48562', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5060/']