From 6a70f5ff62198d307063344f27382e29f2191f24 Mon Sep 17 00:00:00 2001 From: "Nicolas N." Date: Thu, 5 Dec 2024 14:11:37 +0100 Subject: [PATCH] Endre fra pre-commit til pre-push (#6564) * Endre fra pre-commit til pre-push * lint-staged diff main --- .husky/{pre-commit => pre-push} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename .husky/{pre-commit => pre-push} (67%) diff --git a/.husky/pre-commit b/.husky/pre-push similarity index 67% rename from .husky/pre-commit rename to .husky/pre-push index d1da744c787..65c6a83dfaa 100755 --- a/.husky/pre-commit +++ b/.husky/pre-push @@ -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) @@ -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 @@ -30,6 +30,6 @@ if [ -n "${changedKotlinFiles-unset}" ]; then done fi -echo "🏆 Files staged" +echo "🏆 Files linted" exit 0 \ No newline at end of file