Search code examples
svntortoisesvnstatic-code-analysiscppcheck

CPP check pre commit hook for SVN


We need automatic check errors and warnings from cpp check before developer commit code in SVN, If the code is adding any new error then commit should fail. Can you please help me on how to achive this. I saw few posts for such hook but i could not find the actual code or exe for this


Solution

  • Short answer: don't do this.

    Longer answer: This is a job for a Continuous Integration server. The CI server will, after each commit, check out the latest version, do whatever it is that needs to be done (compile, run tests, etc.) and then report the results, either via dashboard or email. Then whomever is responsible for breaking the build is responsible for fixing it.

    Reason: When you're running a hook script to perform the checks you're asking about, no other commits can take place while they're running. This may take a long time and it will slow your developers down because they're waiting for commits. To do this, you'll have to check out a fresh working copy (in your hook script!), apply the diff that's being committed (I don't recall if this is even possible), then run your tests. Lots of room for error and potentially very slow.