From 6b641d00d467c0fe7e99b90a877d4ea93dc501af Mon Sep 17 00:00:00 2001 From: codepuncher Date: Thu, 25 Jun 2026 18:31:37 +0100 Subject: [PATCH 1/2] fix(shell): extend project_open scan to find nested-git projects WordPress projects like clinimed hold .git inside bedrock/ and trellis/ subdirectories rather than at the project root, so the depth-3 scan missed them. Add a depth-4 pass that maps sub-repo paths back to their parent project directory, with sort -u to deduplicate. Move bats submodule to repo root and add test fixtures covering this nested-git structure. --- .github/workflows/lint.yml | 2 +- .gitmodules | 4 ++-- bats | 1 + shell/aliases | 15 ++++++++++----- tests/project_open.bats | 21 ++++++++++++++++++--- 5 files changed, 32 insertions(+), 11 deletions(-) create mode 160000 bats diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2b1335a..1a4fb7d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,7 +25,7 @@ jobs: with: submodules: recursive - name: Run BATS tests - run: ./tests/bats/bin/bats tests/*.bats + run: ./bats/bin/bats tests/*.bats lua: runs-on: ubuntu-latest diff --git a/.gitmodules b/.gitmodules index a431ec9..cf39295 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ -[submodule "tests/bats"] - path = tests/bats +[submodule "bats"] + path = bats url = https://github.com/bats-core/bats-core.git [submodule "tests/test_helper/bats-support"] path = tests/test_helper/bats-support diff --git a/bats b/bats new file mode 160000 index 0000000..5a7db7a --- /dev/null +++ b/bats @@ -0,0 +1 @@ +Subproject commit 5a7db7a98951d9d89b3b5e7800037e655a93345f diff --git a/shell/aliases b/shell/aliases index cba620f..3544d70 100644 --- a/shell/aliases +++ b/shell/aliases @@ -275,11 +275,16 @@ _project_open_root() { _project_open_scan() { local root root="$(_project_open_root)" - # Projects live at // and always hold a .git, so one - # find at that fixed depth lists them; submodules sit deeper and fall out. - find "${root}" -mindepth 3 -maxdepth 3 -name '.git' 2>/dev/null | - sed 's#/\.git$##' | - LC_ALL=C sort + { + # Direct repos: root/cat/proj/.git + find "${root}" -mindepth 3 -maxdepth 3 -name '.git' 2>/dev/null | + sed 's#/\.git$##' + # Nested repos: root/cat/proj/sub/.git → root/cat/proj + # Handles WordPress projects where bedrock/trellis hold the .git instead. + # Submodules at depth 5+ are still excluded. + find "${root}" -mindepth 4 -maxdepth 4 -name '.git' 2>/dev/null | + sed 's#/[^/]*/\.git$##' + } | LC_ALL=C sort -u } _project_open_cache_file() { diff --git a/tests/project_open.bats b/tests/project_open.bats index 03fb2c4..16812c7 100644 --- a/tests/project_open.bats +++ b/tests/project_open.bats @@ -15,6 +15,7 @@ setup() { # Projects sit at // and always hold a .git. # wordpress projects carry a .git alongside their bedrock/site app dir; + # clinimed-style projects have .git only inside bedrock/trellis subdirs; # vcpkg is a nested submodule (deeper) that must be excluded from scans. mkdir -p \ "${ROOT}/mods/HoldFast/.git" \ @@ -24,7 +25,9 @@ setup() { "${ROOT}/wordpress/acme/.git" \ "${ROOT}/wordpress/acme/site" \ "${ROOT}/wordpress/beta/.git" \ - "${ROOT}/wordpress/beta/bedrock" + "${ROOT}/wordpress/beta/bedrock" \ + "${ROOT}/wordpress/clinimed/bedrock/.git" \ + "${ROOT}/wordpress/clinimed/trellis/.git" # shell/aliases sources ${HOME}/.dotfiles/shell/os.sh, so point HOME at a # temp dir whose .dotfiles symlinks to this repo. That lets the suite run @@ -46,7 +49,7 @@ teardown() { @test "scan finds category/project dirs and excludes nested submodules" { local out out="$(_project_open_scan | sed "s#^${ROOT}/##" | LC_ALL=C sort | tr '\n' ',')" - assert_equal "${out}" "misc/khuey,mods/HoldFast,wordpress/acme,wordpress/beta," + assert_equal "${out}" "misc/khuey,mods/HoldFast,wordpress/acme,wordpress/beta,wordpress/clinimed," } @test "po_refresh creates the cache file" { @@ -106,6 +109,11 @@ teardown() { assert_output "${ROOT}/wordpress/acme" } +@test "resolve maps a nested-git project (no root .git) to its path" { + run _project_open_resolve clinimed + assert_output "${ROOT}/wordpress/clinimed" +} + @test "resolve of an unknown name is empty" { run _project_open_resolve nope assert_output '' @@ -115,7 +123,7 @@ teardown() { po_refresh local out out="$(_project_open_projects | LC_ALL=C sort | tr '\n' ',')" - assert_equal "${out}" "HoldFast,acme,beta,khuey," + assert_equal "${out}" "HoldFast,acme,beta,clinimed,khuey," } @test "targets lists a project's subdirs" { @@ -164,6 +172,13 @@ teardown() { assert_equal "${dir}" "${ROOT}/wordpress/acme/site" } +@test "project_open descends into bedrock for a nested-git project" { + po_refresh + local dir + dir="$(cd / && project_open clinimed >/dev/null 2>&1 && pwd)" + assert_equal "${dir}" "${ROOT}/wordpress/clinimed/bedrock" +} + @test "project_open cds into the subdir" { po_refresh local dir From f2c953da7be6446ccb2904fc2d068452f29a3467 Mon Sep 17 00:00:00 2001 From: codepuncher Date: Thu, 25 Jun 2026 18:39:42 +0100 Subject: [PATCH 2/2] fix(tests): remove stale tests/bats gitlink left by submodule move --- tests/bats | 1 - 1 file changed, 1 deletion(-) delete mode 160000 tests/bats diff --git a/tests/bats b/tests/bats deleted file mode 160000 index 5a7db7a..0000000 --- a/tests/bats +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5a7db7a98951d9d89b3b5e7800037e655a93345f