backend-api #6

Merged
piair merged 107 commits from backend-api into main 2025-03-26 19:04:09 +01:00
2 changed files with 26 additions and 0 deletions
Showing only changes of commit 5f8fe4a374 - Show all commits

2
hooks/README.md Normal file
View File

@ -0,0 +1,2 @@
# 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`

24
hooks/google-java-format Executable file
View File

@ -0,0 +1,24 @@
#!/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