Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions app/client/.husky/check-staged-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,33 @@ is_client_change=$(git diff --cached --name-only | grep -c "app/client")

is_merge_commit=$(git rev-parse -q --verify MERGE_HEAD)

# Function to apply Spotless and only commit staged files
apply_spotless_and_commit_staged_files() {
staged_server_files=$(git diff --cached --name-only | grep "app/server"| sed 's|app/server/||')
mvn spotless:apply
# Check if Spotless succeeded
if [ $? -ne 0 ]; then
echo "Spotless apply failed, Please run mvn spotless:apply"
exit 1
fi
echo "$staged_server_files" | xargs git add
echo "✔ Spotless applied successfully to server files"
}

if [ "$is_merge_commit" ]; then
echo "Skipping server and client checks for merge commit"
else
if [ "$is_server_change" -ge 1 ]; then
echo "Running Spotless check ..."
echo "Applying Spotless to server files..."
pushd app/server > /dev/null
if (mvn spotless:check 1> /dev/null && popd > /dev/null) then
popd
else
echo "Spotless check failed, please run mvn spotless:apply"
exit 1
fi
apply_spotless_and_commit_staged_files
popd > /dev/null
else
echo "Skipping server side check..."
echo "Skipping server side check..."
fi

if [ "$is_client_change" -ge 1 ]; then
echo "Running client check ..."
if [ "$is_client_change" -ge 1 ]; then
echo "Running client check..."
npx lint-staged --cwd app/client
else
echo "Skipping client side check..."
Expand Down
2 changes: 0 additions & 2 deletions app/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@
<goals>
<goal>apply</goal>
</goals>
<!-- This gets triggered automatically when we run the build script -->
<phase>compile</phase>
</execution>
</executions>
</plugin>
Expand Down