• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
will have a look at another alternative for enforcing code-conventions more automatically: http://jalopy.sourceforge.net/
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic