From 6949a01969e9f992826dd67cf9e6d1efc353e1e4 Mon Sep 17 00:00:00 2001 From: mohitrajain Date: Mon, 9 Mar 2026 11:42:26 +0100 Subject: [PATCH 1/4] issue-862: remove read to operate in .envrc --- .envrc | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/.envrc b/.envrc index e3a70f900..e44b1b35c 100644 --- a/.envrc +++ b/.envrc @@ -1,29 +1,24 @@ #!/bin/bash -read -p "Do you want to setup git commit hooks? (y/Y to continue): " response -if [[ "$response" =~ ^[yY]$ ]]; then - git config core.hooksPath .git-hooks -else - git config --unset core.hooksPath -fi +nix-build $PWD/default.nix -A env --out-link .nix-env -read -p "Do you want to continue with Nix operations? (y/Y to continue): " response +PATH_add ".nix-env/bin" -if [[ "$response" =~ ^[yY]$ ]]; then - nix-build $PWD/default.nix -A env --out-link .nix-env +export LOCALHOST_PYTHON="$PWD/.nix-env/bin/python" - PATH_add ".nix-env/bin" +# source .profile from `$env`. +# This is only used to set things interpolated by nix. +# All *static* things should live inside .envrc. +[[ -f ".nix-env/.profile" ]] && source_env ".nix-env/.profile" - export LOCALHOST_PYTHON="$PWD/.nix-env/bin/python" +# allow local .envrc overrides +[[ -f .envrc.local ]] && source_env .envrc.local - # source .profile from `$env`. - # This is only used to set things interpolated by nix. - # All *static* things should live inside .envrc. - [[ -f ".nix-env/.profile" ]] && source_env ".nix-env/.profile" +# setting up .git-hooks for commit message verification +git config core.hooksPath .git-hooks - # allow local .envrc overrides - [[ -f .envrc.local ]] && source_env .envrc.local - -else - echo "Skipping Nix operations." -fi +echo "" +echo " Git Hooks has been configured. Read more about them here: https://github.com/wireapp/wire-server-deploy?tab=readme-ov-file#optional-git-commit-message-verification or locally at README.md#optional-git-commit-message-verification" +echo " If you don't want to use it, run the following command to unset it" +echo " git config --unset core.hooksPath" +echo "" From d1e53ffd0eb4c791cd168030f92760fe1c048a3d Mon Sep 17 00:00:00 2001 From: mohitrajain Date: Mon, 9 Mar 2026 11:55:22 +0100 Subject: [PATCH 2/4] issue-862: update readme.md and commit-msg to reflect new envrc behaviour --- .envrc | 3 ++- .git-hooks/commit-msg | 4 +++- README.md | 21 ++++++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.envrc b/.envrc index e44b1b35c..993994dac 100644 --- a/.envrc +++ b/.envrc @@ -18,7 +18,8 @@ export LOCALHOST_PYTHON="$PWD/.nix-env/bin/python" git config core.hooksPath .git-hooks echo "" -echo " Git Hooks has been configured. Read more about them here: https://github.com/wireapp/wire-server-deploy?tab=readme-ov-file#optional-git-commit-message-verification or locally at README.md#optional-git-commit-message-verification" +echo " Git Hooks has been configured in your current environment." +echo " Read more about them here: https://github.com/wireapp/wire-server-deploy?tab=readme-ov-file#optional-git-commit-message-verification" echo " If you don't want to use it, run the following command to unset it" echo " git config --unset core.hooksPath" echo "" diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg index 342ffa730..00714069d 100755 --- a/.git-hooks/commit-msg +++ b/.git-hooks/commit-msg @@ -16,6 +16,8 @@ if ! echo "$commit_message" | grep -E "$pattern" | grep -E "$pattern2"; then echo " refactor: wpb-1234 clean up code" echo " test: add unit tests wpb-1234" echo " chore!: WPB-1234 drop support for k8s 1.16 - add a 'BREAKING CHANGE:' statement" - echo "Read more about it here: https://www.conventionalcommits.org/en/v1.0.0/" + echo " Read more about it here: https://www.conventionalcommits.org/en/v1.0.0/" + echo " If you want to skip these commit message verification rules, run the following command to unset it" + echo " git config --unset core.hooksPath" exit 1 fi diff --git a/README.md b/README.md index 169758e7f..cd65bb9a3 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,24 @@ This repository uses a Git commit [hook](./.git-hooks/commit-msg) to enforce the - *chore!: WPB-1234 drop support for k8s 1.16 - add a 'BREAKING CHANGE:' statement* #### Activation/Deactivation: -The commit hook is optional and can be activated or deactivated using the `.envrc` script with direnv: -``` +The commit hook is optional and can be activated using the `.envrc` script with direnv as: +```bash wire-server-deploy$ direnv allow direnv: loading ~/projects/git/wire-server-deploy/.envrc -Do you want to setup git commit hooks? (y/Y to continue): +direnv: ([/usr/bin/direnv export zsh]) is taking a while to execute. Use CTRL-C to give up. +/nix/store/bbh6750da4dmnbizgwzh5q2g5z6njd81-wire-server-deploy +direnv: loading ~/projects/git/wire-server-deploy/.nix-env/.nix-env/.profile + + Git Hooks has been configured in your current environment. + Read more about them here: https://github.com/wireapp/wire-server-deploy?tab=readme-ov-file#optional-git-commit-message-verification + If you don't want to use it, run the following command to unset it + git config --unset core.hooksPath + +direnv: export +LOCALHOST_PYTHON +NIX_PATH ~PATH +``` + +The `.git-hooks` get configured when the whole `.envrc` environment is allowed. Run the following command if hooks for commit message verification aren't required: + +```bash +git config --unset core.hooksPath ``` From efec0e98535c9a7fcb2f760fc979eed36b8c5dff Mon Sep 17 00:00:00 2001 From: mohitrajain Date: Mon, 9 Mar 2026 11:58:27 +0100 Subject: [PATCH 3/4] issue-862: add changelog.d for direnv behaviour --- changelog.d/5-bug-fixes/issue-862-direnv-fix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5-bug-fixes/issue-862-direnv-fix diff --git a/changelog.d/5-bug-fixes/issue-862-direnv-fix b/changelog.d/5-bug-fixes/issue-862-direnv-fix new file mode 100644 index 000000000..4f1cf2bff --- /dev/null +++ b/changelog.d/5-bug-fixes/issue-862-direnv-fix @@ -0,0 +1 @@ +Fixed: remove read function to operate .envrc and updated the README.md From 592e2465070c918d4b991f25bf7d9193ee05edc3 Mon Sep 17 00:00:00 2001 From: mohitrajain Date: Thu, 12 Mar 2026 17:45:05 +0100 Subject: [PATCH 4/4] fix: change git-hook implementation based on envs in .envrc.local file --- .envrc | 20 ++++++++++++-------- .git-hooks/commit-msg | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.envrc b/.envrc index 993994dac..43e35e689 100644 --- a/.envrc +++ b/.envrc @@ -14,12 +14,16 @@ export LOCALHOST_PYTHON="$PWD/.nix-env/bin/python" # allow local .envrc overrides [[ -f .envrc.local ]] && source_env .envrc.local -# setting up .git-hooks for commit message verification -git config core.hooksPath .git-hooks +if [[ "$NO_GIT_HOOKS" == "TRUE" ]]; then + # setting up .git-hooks for commit message verification + git config core.hooksPath .git-hooks -echo "" -echo " Git Hooks has been configured in your current environment." -echo " Read more about them here: https://github.com/wireapp/wire-server-deploy?tab=readme-ov-file#optional-git-commit-message-verification" -echo " If you don't want to use it, run the following command to unset it" -echo " git config --unset core.hooksPath" -echo "" + echo "" + echo " Git Hooks has been configured in your current environment." + echo " Read more about them here: https://github.com/wireapp/wire-server-deploy?tab=readme-ov-file#optional-git-commit-message-verification" + echo " If you don't want to use it, then set NO_GIT_HOOKS=FALSE in file .envrc.local and re-laod the envionment by running:" + echo " direnv reload" + echo "" +else + git config --unset core.hooksPath +fi diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg index 00714069d..11e307f09 100755 --- a/.git-hooks/commit-msg +++ b/.git-hooks/commit-msg @@ -17,7 +17,7 @@ if ! echo "$commit_message" | grep -E "$pattern" | grep -E "$pattern2"; then echo " test: add unit tests wpb-1234" echo " chore!: WPB-1234 drop support for k8s 1.16 - add a 'BREAKING CHANGE:' statement" echo " Read more about it here: https://www.conventionalcommits.org/en/v1.0.0/" - echo " If you want to skip these commit message verification rules, run the following command to unset it" - echo " git config --unset core.hooksPath" + echo " If you don't want to use it, then set NO_GIT_HOOKS=FALSE in file .envrc.local and re-laod the envionment by running:" + echo " direnv reload" exit 1 fi