Skip to content

Instantly share code, notes, and snippets.

@jhedev
Last active August 29, 2015 13:58
Show Gist options
  • Save jhedev/9970801 to your computer and use it in GitHub Desktop.
Save jhedev/9970801 to your computer and use it in GitHub Desktop.

Revisions

  1. jhedev revised this gist Apr 4, 2014. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions pre-commit running hlint
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    # Taken from https://github.com/HIPERFIT/L0Language/blob/master/git-hooks/pre-commit

    fail() {
    echo "Aborting commit due to verification errors."
    echo "If you disagree, use git commit --no-verify."
    exit 1
    }

    hlintable() {
    ! egrep -q '{-# LANGUAGE.*QuasiQuotes' $1
    }
  2. jhedev created this gist Apr 4, 2014.
    22 changes: 22 additions & 0 deletions pre-commit running hlint
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Taken from https://github.com/HIPERFIT/L0Language/blob/master/git-hooks/pre-commit

    hlintable() {
    ! egrep -q '{-# LANGUAGE.*QuasiQuotes' $1
    }

    l0_hlint() {
    # Some hlint-suggestions are terrible, so ignore them here.
    hlint -i "Reduce duplication" -i "Use import/export shortcut" "$@"
    }

    # Run hlint on changed files.
    for file in $(git diff-index --cached --name-only HEAD | egrep '\.l?hsc?$'); do
    if [ -f $file ]; then
    if hlintable $file; then
    echo "Checking $file with hlint:"
    if ! l0_hlint "$file"; then
    fail
    fi
    fi
    fi
    done