pre-commit-hook

Mercurial hook to disallow committing large binary files

I want to have a Mercurial hook that will run before committing a transaction that will abort the transaction if a binary file being committed is greater than 1 megabyte. I found the following code which works fine except for one problem. If my changeset involves removing a file, this hook will throw an exception. The hook (I'm using ...

help explaining precommit remove trailing whitespace script

Could someone help explain what is going on in this precommit hook? I thought changing files would cause them to be restaged. http://snipplr.com/view/28523/git-precommit-hook-to-fix-trailing-whitespace/ ...

SVN Pre-commit hook for temporarly commented out code (in java)?

It just happened to me that I commented out a line of code for testing reasons and ended up checking the code back into the repository with the commented line. E.g. I set a rule for a job in Eclipse RCP on one line. While developing a new feature I commented out this one line so the rule does not get set. After a couple of hours the n...

SVN hook script conflict

I am trying to write a pre-commit hook script that will alter a specific svn-property of a folder/file. The script looks fairly similar to the one that is documented in the svn book. I figured out how to set/change the property of a node and when executing the binding function svn.fs.commit_txn the property of the node actually gets set...

Detect a tag in hook-script SVN

Is there a way that I can detect a tag/branch in SVN? Could I find out where the commits destination is? I want to check that all externals are set to a specific version of the folder they are pointing to, I don't want to prevent commits to a tag with this script. I am writing the script with the c-python bindings. ...

Block committing changes to Microsoft Access database

Is there a way to write a hook that will run before changes are committed to an Access DB? I'm looking for a way to block changes if a specific process is currently querying the DB. ...

How to make a pre-commit hook that prevents non-UTF-8 file encodings

Is it possible to make a precommit hook for git or svn that can reject files not committed in a specific encoding? I have worked on several project where it seems to be a problem to stick to a certain file encoding (like UTF-8 for instance) ...

How do I write an error out to the client in a cmd line pre-commit hook app?

I'm writing a pre-commit hook in C# and I know I have to return 1 for failure and 0 for sucess, but I cant get it to write any message out to the client. Currently I'm using static int Main(string[] args) { var repository = args[0]; var transaction = args[1]; // TODO: do stuff and return 1 or 0 appropriately ...

git: Can I stash an untracked file without adding it to the index?

A related question How do you stash an untracked file? was answered with "track the file." This doesn't work for my particular needs, however. I'm trying to stash everything that isn't in the index with git stash save --keep-index so that I can validate the index in my pre-commit hook. The idea is from the "Testing partial commits" exa...

Can a Git hook automatically add files to the commit?

I'd like to add an automatically generated file to the same commit using a pre- or post-commit hook in Git, dependent on the files that were modified in that commit. How would I go about this? I've tried this as a pre-commit hook, but no luck: #!/bin/sh files=`git diff --cached --name-status` re="<files of importance>" if [[ $files =~...

Svn pre-commit hook to disallow svn:mergeinfo on non-root directories

I would like to use a pre-commit hook that prevents developers from setting svn:mergeinfo on non-root directories. That is, I want to enforce that svn:mergeinfo can only be set on directories like "trunk" or "branches/branchName". Developers sometimes need to be "reminded" that it's not good practice to use a subdirectory of the root a...

How to send stdout to the user when running SVN pre-commit hook

I have a pre-commit hook for SVN which run error-checker program and aborts commit in case of problems. stderr is redirected to the user initiating commit in case of problems. But I would like to send user output from the error-checker program even if no problems were found, so that the user is notified that error-checker ran and found n...

PHP codesniffer (phpcs) - how to allow override when using as part of a svn pre-commit hook?

We have a PHP 5 web application and we're currently evaluating PHP CodeSniffer in order to decide whether forcing code standards improves code quality. We use subversion for our code repository and deployment base and I have added a SVN pre-commit hook to ensure all files committed are free from coding standard smells. The hook technica...

How to automate property setting in SVN?

My subversion repository has a pre-commit hook that requires all files to have a SVN property before its commit. I am setting this property manually making each addition of files and folders a 2-step commit. How to automate this? ...

Pre-commit hooks in C# with SharpSVN

Hello Everyone, I'm new to SharpSVN (and frankly--pretty new to C# as well). I've been trying get a simple pre-commit hook working which checks for a comment. (i.e. the commit fails in the absence of a comment) There are several posts (like this one) which are related and helpful, but I have a few fundamental questions that are keepi...

Pre-commit hook for Git when Hudson build has failed

I'm trying to figure out how to write a pre-commit hook for Git that checks the status of my Hudson build. If the previous build failed, it should disallow anyone from committing without first writing a specific line, e.g. "fixed build." EDIT: The first answerer has provided one side of the coin: the Hudson API. I now need the other s...

Output log statements in commit hooks to subversion log.

I have a bunch of commit hooks to put in place on a Subversion repo and I'd really like if messages written to stdout in these hooks would appear in the subversion log. It doesn't seem like this is directed anywhere (other than perhaps /dev/null) at the moment. I'd prefer not to have to create a separate log for this information. Is it p...

git precommit hook to ensure HEAD is up to date from master repo

Hi there, I am moving my team over from an old CVS repository to using git. I was hoping to add in a precommit hook to ensure before a commit is done locally (and pushed) each person has an up to date repo. For instance, in CVS everyone would do a 'cvs up' before making changes, and then committing. I want to force it so people can't c...

Does CVS allow modification of a committed file within a pre-commit hook?

I want to run all Perl files through Perltidy automatically on each commit, so that all submitted code meets a shared formatting standard. The commitinfo pre-commit hook provides information about the committed files, allowing me to perform logging/notification, but I don't see a way to change the file before it hits the repository. Th...