Skip to content

Instantly share code, notes, and snippets.

@ktoso
Created November 21, 2010 18:09
Show Gist options
  • Save ktoso/708972 to your computer and use it in GitHub Desktop.
Save ktoso/708972 to your computer and use it in GitHub Desktop.

Revisions

  1. ktoso created this gist Nov 21, 2010.
    24 changes: 24 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/sh
    #
    # This hook will run the eclipse code formatter before any commit
    # to make the source look as it's supposed to look like in the repo.

    ECLIPSE_HOME=$HOME/eclipse
    STYLE_FILE=$HOME/org.eclipse.jdt.core.prefs
    echo "Running pre-commit hook: run-eclipse-formatter---------------------"
    echo "Will run eclipse formatter, using: $STYLE_FILE"
    echo "Listing folders to run formatter on… "
    code_dirs=`find . -maxdepth 3 | grep 'src/'`
    for dir in $code_dirs; do
    echo $dir;
    done;

    echo "Launching eclipse code formatter… "
    exec $ECLIPSE_HOME/eclipse \
    -nosplash \
    -application org.eclipse.jdt.core.JavaCodeFormatter \
    -verbose \
    -config $STYLE_FILE \
    $code_dirs

    echo "done---------------------------------------------------------------"