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
51 changes: 29 additions & 22 deletions devloop
Original file line number Diff line number Diff line change
Expand Up @@ -1771,23 +1771,24 @@ next_pass_from_track() {

maybe_enter_worktree() {
local shell_path old_pwd
if [ "$ENTER_WORKTREE" != true ]; then return; fi
if [ "$USE_TUI" != true ]; then return; fi
if [ ! -t 0 ] || [ ! -t 1 ]; then return; fi
if [ -z "$WORKTREE_REPO" ] || [ -z "$SOURCE_REPO" ]; then return; fi
if [ "$WORKTREE_REPO" = "$SOURCE_REPO" ]; then return; fi
if [ ! -d "$WORKTREE_REPO" ]; then return; fi
if ! will_enter_worktree_shell; then return; fi

shell_path="${SHELL:-/bin/sh}"
old_pwd="$PWD"
printf '\n' >&2
ui_status_line "ok" "worktree shell" "$WORKTREE_REPO"
printf '%s\n' "exit the shell to return to devloop's final status" >&2
cd "$WORKTREE_REPO" || return
"$shell_path" -i
cd "$old_pwd" || return
}

will_enter_worktree_shell() {
[ "$ENTER_WORKTREE" = true ] || return 1
[ "$USE_TUI" = true ] || return 1
[ -t 0 ] && [ -t 1 ] || return 1
[ -n "$WORKTREE_REPO" ] && [ -n "$SOURCE_REPO" ] || return 1
[ "$WORKTREE_REPO" != "$SOURCE_REPO" ] || return 1
[ -d "$WORKTREE_REPO" ] || return 1
}

run_command() {
local report_format="html"
local strict=true
Expand Down Expand Up @@ -3948,27 +3949,33 @@ title_from_slug() {

print_result() {
printf '\n'
result_line "result" "$STATUS"
result_line "passes" "$PASSES / $MAX"
result_line "coder" "$(agent_label "$CODER")"
result_line "reviewer" "$(agent_label "$REVIEWER")"
result_line "branch" "$FINAL_BRANCH"
result_line "commit" "${FINAL_COMMIT:-none}"
if [ -n "$PULL_REQUEST" ]; then result_line "pr" "$PULL_REQUEST"; fi
if [ "$WORKTREE_REPO" != "$SOURCE_REPO" ]; then result_line "worktree" "$WORKTREE_REPO"; fi
result_line "report" "$(display_path "$REPORT")"
result_line "track" "$(display_path "$TRACK")"
printf 'devloop %s\n\n' "$STATUS"
result_line "Passes" "$PASSES / $MAX"
result_line "Agents" "$(agent_label "$CODER") -> $(agent_label "$REVIEWER")"
result_line "Branch" "$FINAL_BRANCH"
result_line "Commit" "${FINAL_COMMIT:-none}"
if [ "$WORKTREE_REPO" != "$SOURCE_REPO" ]; then result_line "Worktree" "$WORKTREE_REPO"; fi
printf '\nOpen Next\n'
if [ -n "$PULL_REQUEST" ]; then result_line "PR" "$PULL_REQUEST"; fi
result_line "Report" "$(display_path "$REPORT")"
result_line "Track" "$(display_path "$TRACK")"
if will_enter_worktree_shell; then
printf '\nShell\n'
printf ' Exit the shell to return to devloop.\n'
fi
}

result_line() {
local label="$1:"
local label="$1"
local value="$2"
printf '%-10s%s\n' "$label" "$value"
printf ' %-10s %s\n' "$label" "$value"
}

display_path() {
local file="$1"
if [ "$WORKTREE_REPO" != "$SOURCE_REPO" ]; then
if will_enter_worktree_shell; then
printf '%s\n' "$file"
elif [ "$WORKTREE_REPO" != "$SOURCE_REPO" ]; then
printf '%s/%s\n' "$WORKTREE_REPO" "$file"
else
printf '%s\n' "$file"
Expand Down
14 changes: 11 additions & 3 deletions scripts/devloop_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1451,8 +1451,15 @@ if ! accept_output="$(run_loop "$loop_repo" "e2e-accept" accept 1 2>&1)"; then
fail "accept loop failed"
fi
contains "$accept_output" "accepted" "accept loop"
accept_worktree="$(printf '%s\n' "$accept_output" | sed -nE 's/^worktree:[[:space:]]+//p')"
accept_worktree="$(printf '%s\n' "$accept_output" | sed -nE 's/^[[:space:]]*Worktree[[:space:]]+//p')"
[[ -f "$accept_worktree/result.txt" ]] || fail "accept loop did not write result"
contains "$accept_output" "Open Next" "accept loop"
if ! printf '%s\n' "$accept_output" | grep -F "Report" | grep -F "$accept_worktree/.devloop/reports/e2e-accept.html" >/dev/null; then
fail "accept loop missing worktree-qualified report path"
fi
if ! printf '%s\n' "$accept_output" | grep -F "Track" | grep -F "$accept_worktree/.devloop/tracks/e2e-accept.md" >/dev/null; then
fail "accept loop missing worktree-qualified track path"
fi
contains "$(cat "$accept_worktree/.devloop/logs/e2e-accept-r1-verify.log")" "verify pass" "verify hook"
contains "$(run_repo_main "$loop_repo" status)" "e2e-accept" "status command"
contains "$(run_repo_main "$loop_repo" clean --dry-run)" "skip:" "clean skips accepted"
Expand Down Expand Up @@ -1493,7 +1500,8 @@ if ! pr_accept_output="$(run_loop "$pr_repo" "e2e-pr-accept" accept 1 "--create-
fail "PR accept loop failed"
fi
contains "$pr_accept_output" "accepted" "PR accept loop"
contains "$pr_accept_output" "pr:" "PR accept loop"
contains "$pr_accept_output" "Open Next" "PR accept loop"
contains "$pr_accept_output" "PR https://github.com/satyaborg/devloop/pull/123" "PR accept loop"
create_line="$(grep -n 'gh pr create' "$pr_log" | cut -d: -f1 | head -n 1)"
review_line="$(grep -n 'agent reviewer 1' "$pr_log" | cut -d: -f1 | head -n 1)"
[[ -n "$create_line" && -n "$review_line" && "$create_line" -lt "$review_line" ]] || fail "PR was not created before reviewer pass 1"
Expand Down Expand Up @@ -1705,7 +1713,7 @@ if ! no_changes_output="$(run_loop "$loop_repo" "e2e-no-changes" no-changes 1 2>
fail "no changes loop failed"
fi
contains "$no_changes_output" "accepted" "no changes loop"
contains "$no_changes_output" "commit: none" "no changes loop"
contains "$no_changes_output" "Commit none" "no changes loop"
ok "e2e no changes"

loop_repo="$work/loop-dirty"
Expand Down
Loading