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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and versions are tracked in the repo-root `VERSION` file.
- Hardened GitHub helper pass-by-name outputs against internal variable
shadowing, added a non-optional `gh_infer_repo_from_origin` error message,
and deduplicated worktree parsing loops.
- Reused shared marker validation inside `update_file_section`.

## [1.2.0] - 2026-07-04

Expand Down
14 changes: 4 additions & 10 deletions lib/bash/file/lib_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -286,20 +286,14 @@ update_file_section() {
return 0
fi

local beginning_marker_count end_marker_count
beginning_marker_count=$(grep -cxF -- "$beginning_marker" "$target_file" || true)
end_marker_count=$(grep -cxF -- "$end_marker" "$target_file" || true)
if ((beginning_marker_count != end_marker_count)); then
log_error "Asymmetric markers in '$target_file': $beginning_marker_count start, $end_marker_count end. Manual repair needed."
return 1
fi
if ((beginning_marker_count > 0)) && ! __file_section_markers_ordered__ "$target_file" "$beginning_marker" "$end_marker"; then
log_error "Misordered markers in '$target_file'. Manual repair needed."
local __file_update_beginning_marker_count __file_update_end_marker_count
if ! __file_section_marker_counts__ "$target_file" "$beginning_marker" "$end_marker" \
__file_update_beginning_marker_count __file_update_end_marker_count; then
return 1
fi

local section_exists=false
if ((beginning_marker_count > 0)); then
if ((__file_update_beginning_marker_count > 0)); then
section_exists=true
fi

Expand Down
Loading