Compare commits
No commits in common. "e3393c8834c7a24267b8d4835efce8227f7922b3" and "c5e7736a16dff9c386da236355bc07ff2e62877c" have entirely different histories.
e3393c8834
...
c5e7736a16
@ -1,2 +0,0 @@
|
||||
# Useful hooks in this project
|
||||
To use, just add the content of the wanted hook in `.git/hook/pre-commit`. You may need to use `chmod +x pre-commit`
|
@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Path to the Google Java Formatter JAR
|
||||
FORMATTER_JAR="$HOME/.local/share/java/google-java-format.jar"
|
||||
|
||||
# Download the Google Java Formatter JAR if it doesn't exist
|
||||
if [ ! -f "$FORMATTER_JAR" ]; then
|
||||
echo "Downloading Google Java Formatter..."
|
||||
mkdir -p "$(dirname "$FORMATTER_JAR")"
|
||||
curl -L -o "$FORMATTER_JAR" https://github.com/google/google-java-format/releases/download/v1.20.0/google-java-format-1.20.0-all-deps.jar
|
||||
fi
|
||||
|
||||
# Format all staged Java files
|
||||
STAGED_JAVA_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep "\.java$")
|
||||
|
||||
if [ -n "$STAGED_JAVA_FILES" ]; then
|
||||
echo "Formatting Java files..."
|
||||
java -jar "$FORMATTER_JAR" --skip-sorting-imports --skip-reflowing-long-strings --aosp --replace $STAGED_JAVA_FILES
|
||||
|
||||
# Re-stage the formatted files
|
||||
git add $STAGED_JAVA_FILES
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user