[lang]

Present Perfect

Personal
Projects
Packages
Patches
Presents
Linux

Picture Gallery
Present Perfect

Subversion pre-commit checks

Filed under: General — Thomas @ 22:54

2007-07-02
22:54

Now that we have one web developer on Linux and one on Windows, I get to experience first-hand the pain of EOL markers.  On the one hand I'm trying to teach my guys why it makes sense to use a VCS (and how it is better than FTP even though it's more complicated), but on the other hand it takes a while for anyone to notice that when the Windows guy commits something, the whole file has been changed and nobody knows what happened in the commit.

And obviously I figure this out the first time I want to use svnmerge to merge from trunk to a deployment branch.

It seems like Subversion could have made this a lot simpler from the get-go.

But anyway, after some Googling I realize I need the following things:

  • set svn:eol-style property to native on all "text" files (DONE)
  • set up svn client-side configurations for everyone to automatically set these properties
  • get a pre-commit check to make sure that these things are set as needed (see the warning in this section) It is nice of the Subversion book to tell us what we should do.  But surely you could have given us a simple script to do the right thing ?

So, plea for help - any of you nice hackers out there have a decent client-side configuration file and a matching pre-commit hook to check ?

5 Comments »

  1. Also, make sure you’re all using the same character encoding. I suggest UTF-8, since that works very nicely in modern GNU/Linux. It’s not so nice in Windows though, it seems. (Where I work, the RHEL environment where the web apps runs tries to use UTF-8 all the way, but the Windows-using Java developers always seem to manage to produce web apps that fails to run in that environemnt, because their text editors and Java stacks defaults to ISO-8859-1.)

    Comment by Alexander Boström — 2007-07-03 @ 05:13

  2. Hope you make it available for others if you found a solution. I would appreciate it, too.

    Comment by Kai — 2007-07-03 @ 10:25

  3. Hi Thomas,

    Yeah common problems indeed :)

    I have this in pre-commit:

    # Check for case problems…
    $REPOS/hooks/case-insensitive.py “$REPOS” “$TXN” || exit 1

    # Check for correctly set mime types…
    $REPOS/hooks/check-mime-type.pl “$REPOS” “$TXN” || exit 1

    # We require a decent log entry…
    if ! $SVNLOOK log -t “$TXN” “$REPOS” | grep “[a-zA-Z0-9]” >/dev/null; then
    echo “Empty log message not allowed” >/dev/stderr
    exit 1
    fi

    Using scripts from the svn contrib section:
    http://subversion.tigris.org/tools_contrib.html

    Maybe this is something you can use…

    Comment by Skion — 2007-07-03 @ 12:41

  4. Why not have everyone on the windows side of things run dos2unix on their files before committing? In any case, diffing before committing should show you that your EOL are different, usually showing you that your whole file has changed. This is the case, unless they are using tortoise svn client, which does not show you EOL differences by default. I believe there is an option in the preferences to change this behavior.

    Comment by Alvaro — 2007-07-03 @ 13:21

  5. You have a pre-commit sample in the contrib folder that are close enough to what you’re looking for: http://svn.collab.net/viewvc/svn/trunk/contrib/hook-scripts/pre-lock-require-needs-lock.py?view=markup

    Have look also to the ‘enforcer’ script, as it simplifies a lot writing pre-commit tests :)

    Comment by anmar — 2007-07-04 @ 09:21

RSS feed for comments on this post. TrackBack URL

Leave a comment

picture