Skip to content

Commit

Permalink
Endre fra pre-commit til pre-push (#6564)
Browse files Browse the repository at this point in the history
* Endre fra pre-commit til pre-push

* lint-staged diff main
  • Loading branch information
Watercolours authored Dec 5, 2024
1 parent cf5f449 commit 6a70f5f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .husky/pre-commit → .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cd ./apps/etterlatte-saksbehandling-ui
yarn lint-staged --cwd ./client
yarn lint-staged --cwd ./server
yarn lint-staged --diff origin/main --cwd ./client
yarn lint-staged --diff origin/main --cwd ./server

changedKotlinFiles=$(git diff --name-only --cached | grep '\.kt[s"]\?$' || true)
changedKotlinFiles=$(git diff --name-only --cached main | grep '\.kt[s"]\?$' || true)

if [ -n "${changedKotlinFiles-unset}" ]; then
kotlinversion=$(ktlint -v)
Expand All @@ -16,11 +16,11 @@ if [ -n "${changedKotlinFiles-unset}" ]; then

#store the result of the commit in a variable and split into array items with newline
cd ../../
committedFiles=$(git diff --name-only --cached --diff-filter=d)
committedFiles=$(git diff --name-only --cached main --diff-filter=d)
files=$(echo $committedFiles | tr ";" "\\n")

# https://github.com/pinterest/ktlint pre-commit hook
git diff --name-only --cached | grep '\.kt[s"]\?$' | xargs ktlint -F
git diff --name-only --cached main | grep '\.kt[s"]\?$' | xargs ktlint -F
echo "✍️ Formatted kotlin files"

#replay items in the commits array and add only those files
Expand All @@ -30,6 +30,6 @@ if [ -n "${changedKotlinFiles-unset}" ]; then
done
fi

echo "🏆 Files staged"
echo "🏆 Files linted"

exit 0

0 comments on commit 6a70f5f

Please sign in to comment.