Commit ecb7f48a authored by Anastasios Poimenidis's avatar Anastasios Poimenidis
Browse files

fix: introduce spotless apply pre-commit hook

parent 16845a13
Loading
Loading
Loading
Loading
Loading

.githooks/pre-commit

0 → 100755
+28 −0
Changes for .githooks/pre-commit: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/sh

REPO_ROOT="$(git rev-parse --show-toplevel)"

STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep '\.java$' | sed "s|^|$REPO_ROOT/|" | paste -sd, -)

if [ -z "$STAGED_FILES" ]; then
    exit 0
fi

echo "Running Spotless format check..." >&2

# Run spotless and route stdout/stderr so IntelliJ's UI modal captures it
OUTPUT=$(./mvnw spotless:check -DspotlessFiles="$STAGED_FILES" 2>&1)
STATUS=$?

if [ $STATUS -ne 0 ]; then
    echo "" >&2
    echo "==========================================================" >&2
    echo "❌ Spotless check failed! Unformatted code detected:" >&2
    echo "$OUTPUT" | grep -E "(\[ERROR\]|violations)" >&2
    echo "💡 Fix by running: ./mvnw spotless:apply" >&2
    echo "==========================================================" >&2
    echo "" >&2
    exit 1
fi

exit 0
 No newline at end of file
+24 −0
Changes for pom.xml: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -181,6 +181,30 @@
                <artifactId>spotless-maven-plugin</artifactId>
            </plugin>

            <!-- 2. Exec Plugin (this is the one that has the 'exec' goal) -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.5.0</version>
                <executions>
                    <execution>
                        <id>configure-git-hooks</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>git</executable>
                            <arguments>
                                <argument>config</argument>
                                <argument>core.hooksPath</argument>
                                <argument>.githooks</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
+0 −1
Changes for src/main/java/org/etsi/osl/hypo/api/fabric/kafka/FabricAuthCreds.java: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -8,6 +8,5 @@ public class FabricAuthCreds {

    private String networkControllerId;
    private String username;

    @ToString.Exclude private String password;
}