aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes experience with pre/post-commit hook to enforce code-conventions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "experience with pre/post-commit hook to enforce code-conventions" Watch "experience with pre/post-commit hook to enforce code-conventions" New topic
Author

experience with pre/post-commit hook to enforce code-conventions

manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
hi,

i think code conventions (members order, code formatting) quite important. we use checkstyle but never the less there is often code in source control which is not structured as opposed. through this comparing and merging between source control is often a pain (you cannot really see the "real" semantic differences, when methods order and formatting are different).
such inconsistencies in my opinion are often lead by error prone manual interaction (manually sorting members and reformatting code) before doing a commit.

to avoid manual interaction i want to use pre or post commit hooks which are changing java source files to be checked in.
never the less i feel a bit uncomfortable with interfering into the source checkin-process. has anybody made experience (positive/negative) which such commit hooks?

thanks.


aldana software engineering blog & .more
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

You didn't mention which VCS you're using - as far as I could tell, Subversion doesn't support this. CVS does, and it has been used in a number of open-source C/C++ code archives I've run across.


Customer surveys are for companies who didn't pay proper attention to begin with.
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
oh, yes sorry, forgot to mention. i do use subversion. it supports pre and post commit hooks. but as you said it seems that subversion does not support access to committed files in these hooks (what makes we wonder a bit, for this feature could be handy).

now i remember too that it was only possible with CVS (i did already some checks with CVS before we migrated to subversion).

regarding code-conventions, it is really annoying that eclipse does not offer a dialog similar to IntelliJ, where you get asked whether your code should be reformatted inside commit-dialog.
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
will have a look at another alternative for enforcing code-conventions more automatically: http://jalopy.sourceforge.net/
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

I highly recommend Jalopy. It's very flexible and does just about as good a job as any purely automated cleanup utility can.

While Eclipse may not volunteer to clean up before committing (at least without a custom plug-in), you can easily run formatting on an entire source tree. Just select the file(s) in the navigation pane and do a right-menu "Format".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: experience with pre/post-commit hook to enforce code-conventions