From 537af83c344420994a6a34dd18623f132398d062 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Wed, 6 Sep 2023 17:44:25 -0400 Subject: [PATCH] Only set safe.directory on Cygwin (which needs it) This stops setting the current directory as an explicit safe directory on CI for non-Windows systems, where this is not needed because the repository has the ownership Git expects. The step name is updated accordingly to reflect its now narrower purpose. This also adds shell quoting to $(pwd) in the Cygwin workflow. In practice, on CI, the path is very unlikely to contain whitespace, but double-quoting $ expansions on which splitting and globbing are unwanted is more robust and better expresses intent. This also has the benefit that users who use the CI workflows as a guide to commands they run locally, where on Windows they may very well have spaces somewhere in this absolute path, will use a correct command. --- .github/workflows/cygwin-test.yml | 6 +++--- .github/workflows/pythonpackage.yml | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cygwin-test.yml b/.github/workflows/cygwin-test.yml index 6ba63f019..618bec405 100644 --- a/.github/workflows/cygwin-test.yml +++ b/.github/workflows/cygwin-test.yml @@ -12,7 +12,7 @@ jobs: SHELLOPTS: igncr TMP: "/tmp" TEMP: "/tmp" - + steps: - name: Force LF line endings run: git config --global core.autocrlf input @@ -24,8 +24,8 @@ jobs: packages: python39 python39-pip python39-virtualenv git - name: Tell git to trust this repo shell: bash.exe -eo pipefail -o igncr "{0}" - run: | - /usr/bin/git config --global --add safe.directory $(pwd) + run: | + /usr/bin/git config --global --add safe.directory "$(pwd)" /usr/bin/git config --global protocol.file.allow always - name: Install dependencies and prepare tests shell: bash.exe -eo pipefail -o igncr "{0}" diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 68988f2a7..bc50cab29 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -52,9 +52,8 @@ jobs: set -x mypy -p git - - name: Tell git to trust this repo - run: | - /usr/bin/git config --global --add safe.directory $(pwd) + - name: Tell git to allow file protocol even for submodules + run: | /usr/bin/git config --global protocol.file.allow always - name: Test with pytest