Skip to content

Commit 9fad1c5

Browse files
authored
fix: configure targeted DMC path resolution (#313)
1 parent 8684d61 commit 9fad1c5

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/homeboy.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ homeboy_dmc_command_json() {
111111
resolve)
112112
homeboy_json_array bash "$SCRIPT_DIR/scripts/homeboy-dmc-resolve.sh" "${wp_argv[@]}" datamachine-code workspace worktree get '{handle}' --format=json "${wp_flags[@]}"
113113
;;
114+
resolve_path)
115+
homeboy_json_array bash "$SCRIPT_DIR/scripts/homeboy-dmc-resolve.sh" "${wp_argv[@]}" datamachine-code workspace worktree get '{path}' --format=json "${wp_flags[@]}"
116+
;;
114117
ensure)
115118
# DMC derives the canonical handle from repo + branch and validates the
116119
# task/base intent before returning the checkout to Homeboy.
@@ -129,8 +132,9 @@ homeboy_dmc_command_json() {
129132
}
130133

131134
homeboy_dmc_worktree_provider_json() {
132-
printf '{"enabled":true,"kind":"command","apply_enabled":true,"commands":{"resolve":%s,"resolve_not_found_exit_codes":[42],"ensure":%s,"list":%s,"cleanup_preview":%s,"cleanup_apply":%s},"list_result_mapping":{"items":"$","handle":"$.handle","path":"$.path","branch":"$.branch","dirty":"$.safety.dirty","unpushed":"$.safety.unpushed","primary":"$.safety.primary"}}' \
135+
printf '{"enabled":true,"kind":"command","apply_enabled":true,"commands":{"resolve":%s,"resolve_path":%s,"resolve_not_found_exit_codes":[42],"ensure":%s,"list":%s,"cleanup_preview":%s,"cleanup_apply":%s},"list_result_mapping":{"items":"$","handle":"$.handle","path":"$.path","branch":"$.branch","dirty":"$.safety.dirty","unpushed":"$.safety.unpushed","primary":"$.safety.primary"}}' \
133136
"$(homeboy_dmc_command_json resolve)" \
137+
"$(homeboy_dmc_command_json resolve_path)" \
134138
"$(homeboy_dmc_command_json ensure)" \
135139
"$(homeboy_dmc_command_json list)" \
136140
"$(homeboy_dmc_command_json cleanup_preview)" \

tests/homeboy-dmc-provider.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ line = open(sys.argv[1], encoding="utf-8").read().strip()
7878
_, payload = line.split("|", 1)
7979
commands = json.loads(payload)["commands"]
8080
expected_resolve = ["bash", f"{sys.argv[2]}/scripts/homeboy-dmc-resolve.sh", "studio", "wp", "datamachine-code", "workspace", "worktree", "get", "{handle}", "--format=json", f"--path={sys.argv[3]}"]
81+
expected_resolve_path = ["bash", f"{sys.argv[2]}/scripts/homeboy-dmc-resolve.sh", "studio", "wp", "datamachine-code", "workspace", "worktree", "get", "{path}", "--format=json", f"--path={sys.argv[3]}"]
8182
expected_ensure = ["studio", "wp", "datamachine-code", "workspace", "worktree", "add", "{repo}", "{head}", "--base-branch={base}", "--task-url={task_url}", "--format=json", f"--path={sys.argv[3]}"]
8283
if commands.get("resolve_not_found_exit_codes") != [42]:
8384
raise SystemExit("FAIL: DMC typed-not-found classification must be exactly [42]")
8485
if commands.get("resolve") != expected_resolve:
8586
raise SystemExit(f"FAIL: DMC resolve adapter mapping mismatch: {commands.get('resolve')!r}")
87+
if commands.get("resolve_path") != expected_resolve_path:
88+
raise SystemExit(f"FAIL: DMC path resolve adapter mapping mismatch: {commands.get('resolve_path')!r}")
8689
if commands.get("ensure") != expected_ensure:
8790
raise SystemExit(f"FAIL: DMC ensure mapping mismatch: {commands.get('ensure')!r}")
8891
PY
@@ -185,6 +188,7 @@ configure_homeboy_dmc_worktree_provider > "$TMP/dry-run.log"
185188

186189
assert_contains "homeboy config set /worktree_providers/dmc '{\"enabled\":true,\"kind\":\"command\",\"apply_enabled\":true" "$TMP/dry-run.log"
187190
assert_contains "\"resolve\":[\"bash\",\"$SCRIPT_DIR/scripts/homeboy-dmc-resolve.sh\",\"studio\",\"wp\",\"datamachine-code\",\"workspace\",\"worktree\",\"get\",\"{handle}\",\"--format=json\",\"--path=$SITE_PATH\"]" "$TMP/dry-run.log"
191+
assert_contains "\"resolve_path\":[\"bash\",\"$SCRIPT_DIR/scripts/homeboy-dmc-resolve.sh\",\"studio\",\"wp\",\"datamachine-code\",\"workspace\",\"worktree\",\"get\",\"{path}\",\"--format=json\",\"--path=$SITE_PATH\"]" "$TMP/dry-run.log"
188192
assert_contains "\"resolve_not_found_exit_codes\":[42]" "$TMP/dry-run.log"
189193
assert_contains "\"ensure\":[\"studio\",\"wp\",\"datamachine-code\",\"workspace\",\"worktree\",\"add\",\"{repo}\",\"{head}\",\"--base-branch={base}\",\"--task-url={task_url}\",\"--format=json\",\"--path=$SITE_PATH\"]" "$TMP/dry-run.log"
190194
assert_contains "\"list\":[\"studio\",\"wp\",\"datamachine-code\",\"workspace\",\"worktree\",\"list\",\"--with-status\",\"--format=json\",\"--path=$SITE_PATH\"]" "$TMP/dry-run.log"

0 commit comments

Comments
 (0)