Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions shell/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ _project_open_scan() {
# Submodules at depth 5+ are still excluded.
find "${root}" -mindepth 4 -maxdepth 4 -name '.git' 2>/dev/null |
sed 's#/[^/]*/\.git$##'
# Plain WordPress installs with no project-level repo (only the theme is
# versioned): root/cat/proj/site/wp-config.php → root/cat/proj
find "${root}" -mindepth 4 -maxdepth 4 -type f -path '*/site/wp-config.php' 2>/dev/null |
sed 's#/site/wp-config\.php$##'
} | LC_ALL=C sort -u
}

Expand Down
20 changes: 17 additions & 3 deletions tests/project_open.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ setup() {
"${ROOT}/wordpress/beta/.git" \
"${ROOT}/wordpress/beta/bedrock" \
"${ROOT}/wordpress/itineris/bedrock/.git" \
"${ROOT}/wordpress/itineris/trellis/.git"
"${ROOT}/wordpress/itineris/trellis/.git" \
"${ROOT}/wordpress/plain/site/wp-content/themes/plain/.git"
touch "${ROOT}/wordpress/plain/site/wp-config.php"

# 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
Expand All @@ -45,7 +47,7 @@ teardown() {
@test "scan finds category/project dirs and excludes itineris 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,wordpress/itineris,"
assert_equal "${out}" "misc/khuey,mods/HoldFast,wordpress/acme,wordpress/beta,wordpress/itineris,wordpress/plain,"
}

@test "po_refresh creates the cache file" {
Expand Down Expand Up @@ -110,6 +112,11 @@ teardown() {
assert_output "${ROOT}/wordpress/itineris"
}

@test "resolve maps a plain wordpress site (no project .git) to its path" {
run _project_open_resolve plain
assert_output "${ROOT}/wordpress/plain"
}

@test "resolve of an unknown name is empty" {
run _project_open_resolve nope
assert_output ''
Expand All @@ -119,7 +126,7 @@ teardown() {
po_refresh
local out
out="$(_project_open_projects | LC_ALL=C sort | tr '\n' ',')"
assert_equal "${out}" "HoldFast,acme,beta,itineris,khuey,"
assert_equal "${out}" "HoldFast,acme,beta,itineris,khuey,plain,"
}

@test "targets lists a project's subdirs" {
Expand Down Expand Up @@ -168,6 +175,13 @@ teardown() {
assert_equal "${dir}" "${ROOT}/wordpress/acme/site"
}

@test "project_open descends into site for a plain wordpress site" {
po_refresh
local dir
dir="$(cd / && project_open plain >/dev/null 2>&1 && pwd)"
assert_equal "${dir}" "${ROOT}/wordpress/plain/site"
}

@test "project_open descends into bedrock for a itineris-git project" {
po_refresh
local dir
Expand Down
Loading