Skip to content

Commit 63fdfa0

Browse files
refactor(8a5b-e07b): remove ticket_find_open_children from ticket-lib.sh
Story ca17-acad: cleanup — function replaced by batch_close_operations in ticket-unblock.py. No callers remain. Tests removed; equivalent coverage exists in test_ticket_unblock.py::test_batch_close_finds_open_children. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1516586 commit 63fdfa0

File tree

2 files changed

+0
-143
lines changed

2 files changed

+0
-143
lines changed

plugins/dso/scripts/ticket-lib.sh

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -250,47 +250,3 @@ state = json.loads(sys.argv[1])
250250
print(state.get('status', ''))
251251
" "$state_json"
252252
}
253-
254-
# ticket_find_open_children <tracker_dir> <parent_id>
255-
# Lists all open (non-closed) child ticket IDs of a given parent ticket.
256-
# Outputs one ticket ID per line. Exits 0 even if no children are found.
257-
# Computes REDUCER path internally from BASH_SOURCE — does NOT rely on caller-set globals.
258-
#
259-
# Args:
260-
# tracker_dir: path to .tickets-tracker worktree (passed by caller)
261-
# parent_id: ticket ID of the parent to search for children of
262-
ticket_find_open_children() {
263-
local tracker_dir="$1"
264-
local parent_id="$2"
265-
266-
# Resolve REDUCER path relative to this script's location
267-
local lib_dir
268-
lib_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
269-
local reducer="$lib_dir/ticket-reducer.py"
270-
271-
if [ ! -d "$tracker_dir" ]; then
272-
echo "Error: tracker directory not found: $tracker_dir" >&2
273-
return 1
274-
fi
275-
276-
# Scan all subdirectories in tracker_dir, run reducer on each, filter by parent_id
277-
local ticket_dir ticket_id state_json
278-
for ticket_dir in "$tracker_dir"/*/; do
279-
[ -d "$ticket_dir" ] || continue
280-
ticket_id="$(basename "$ticket_dir")"
281-
282-
state_json=$(python3 "$reducer" "$ticket_dir" 2>/dev/null) || continue
283-
[ -z "$state_json" ] && continue
284-
285-
python3 -c "
286-
import json, sys
287-
state = json.loads(sys.argv[1])
288-
parent_id = sys.argv[2]
289-
ticket_id = sys.argv[3]
290-
if state.get('parent_id') == parent_id and state.get('status') != 'closed':
291-
print(ticket_id)
292-
" "$state_json" "$parent_id" "$ticket_id"
293-
done
294-
295-
return 0
296-
}

tests/scripts/test-ticket-health-guards.sh

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
#
55
# Specifically tests:
66
# - ticket_read_status() — reads compiled ticket status from reducer
7-
# - ticket_find_open_children() — lists open child tickets of a given parent
8-
#
9-
# All test functions MUST FAIL until ticket-lib.sh is updated to add these functions.
107
#
118
# Usage: bash tests/scripts/test-ticket-health-guards.sh
12-
# Returns: exit non-zero (RED) until ticket-lib.sh implements the helper functions.
139

1410
# NOTE: -e is intentionally omitted — test functions return non-zero by design
1511
# (they assert against unimplemented features). -e would abort the runner.
@@ -125,99 +121,4 @@ test_ticket_read_status_returns_current_status() {
125121
}
126122
test_ticket_read_status_returns_current_status
127123

128-
# ── Test 2: ticket_find_open_children lists open children of a parent ──────────
129-
echo "Test 2: ticket_find_open_children() function exists and lists open child tickets"
130-
test_ticket_find_open_children_lists_children() {
131-
_snapshot_fail
132-
133-
# Source ticket-lib.sh to check if ticket_find_open_children is defined
134-
# RED: ticket_find_open_children does not exist in ticket-lib.sh yet
135-
local fn_exists=0
136-
(source "$TICKET_LIB" 2>/dev/null && declare -f ticket_find_open_children >/dev/null 2>&1) || fn_exists=$?
137-
138-
if [ "$fn_exists" -ne 0 ]; then
139-
# Function does not exist — assert failure to mark RED
140-
assert_eq "ticket_find_open_children function exists in ticket-lib.sh" "exists" "missing"
141-
assert_pass_if_clean "test_ticket_find_open_children_lists_children"
142-
return
143-
fi
144-
145-
local repo
146-
repo=$(_make_test_repo)
147-
local tracker_dir="$repo/.tickets-tracker"
148-
149-
# Create a parent ticket (epic)
150-
local parent_id
151-
parent_id=$(_create_ticket "$repo" epic "Parent epic ticket")
152-
153-
if [ -z "$parent_id" ]; then
154-
assert_eq "parent ticket created" "non-empty" "empty"
155-
assert_pass_if_clean "test_ticket_find_open_children_lists_children"
156-
return
157-
fi
158-
159-
# Create two child tickets under the parent
160-
local child1_id child2_id
161-
child1_id=$(_create_child_ticket "$repo" "$parent_id" "Child ticket 1")
162-
child2_id=$(_create_child_ticket "$repo" "$parent_id" "Child ticket 2")
163-
164-
if [ -z "$child1_id" ] || [ -z "$child2_id" ]; then
165-
# If child creation with --parent is not yet implemented, the test must
166-
# still fail RED (children can't be detected if they can't be created).
167-
assert_eq "child tickets created with parent" "non-empty" "empty: child1=$child1_id child2=$child2_id"
168-
assert_pass_if_clean "test_ticket_find_open_children_lists_children"
169-
return
170-
fi
171-
172-
# Call ticket_find_open_children: should list both children (both are open)
173-
local children_out
174-
local children_exit=0
175-
children_out=$(
176-
(cd "$repo" && source "$TICKET_LIB" && ticket_find_open_children "$tracker_dir" "$parent_id")
177-
) || children_exit=$?
178-
179-
# Assert: exits 0
180-
assert_eq "ticket_find_open_children: exits 0" "0" "$children_exit"
181-
182-
# Assert: output contains child1_id
183-
if echo "$children_out" | grep -qF "$child1_id"; then
184-
assert_eq "ticket_find_open_children: lists child1" "has-child1" "has-child1"
185-
else
186-
assert_eq "ticket_find_open_children: lists child1" "has-child1" "missing: $children_out"
187-
fi
188-
189-
# Assert: output contains child2_id
190-
if echo "$children_out" | grep -qF "$child2_id"; then
191-
assert_eq "ticket_find_open_children: lists child2" "has-child2" "has-child2"
192-
else
193-
assert_eq "ticket_find_open_children: lists child2" "has-child2" "missing: $children_out"
194-
fi
195-
196-
# Now close child1 and verify it no longer appears in open children
197-
_transition_ticket "$repo" "$child1_id" "open" "closed"
198-
199-
local children_after
200-
local children_after_exit=0
201-
children_after=$(
202-
(cd "$repo" && source "$TICKET_LIB" && ticket_find_open_children "$tracker_dir" "$parent_id")
203-
) || children_after_exit=$?
204-
205-
# Assert: closed child1 is NOT in open children list
206-
if echo "$children_after" | grep -qF "$child1_id"; then
207-
assert_eq "ticket_find_open_children: excludes closed child1" "excludes-child1" "still-includes-child1"
208-
else
209-
assert_eq "ticket_find_open_children: excludes closed child1" "excludes-child1" "excludes-child1"
210-
fi
211-
212-
# Assert: open child2 still appears
213-
if echo "$children_after" | grep -qF "$child2_id"; then
214-
assert_eq "ticket_find_open_children: still lists open child2" "has-child2" "has-child2"
215-
else
216-
assert_eq "ticket_find_open_children: still lists open child2" "has-child2" "missing: $children_after"
217-
fi
218-
219-
assert_pass_if_clean "test_ticket_find_open_children_lists_children"
220-
}
221-
test_ticket_find_open_children_lists_children
222-
223124
print_summary

0 commit comments

Comments
 (0)