Skip to content

Instantly share code, notes, and snippets.

View muthuraj57's full-sized avatar

Muthuraj muthuraj57

View GitHub Profile
#!/bin/bash
set -e
# Ref: https://blog.jdriven.com/2020/11/formatting-in-pre-commit-hook/
# command taken from https://github.com/JLLeitschuh/ktlint-gradle task addKtlintFormatGitPreCommitHook
filesToFormat="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.kts|\.java|\.kt/ { print $2}')"
echo "files to format $filesToFormat"
for sourceFilePath in $filesToFormat; do