Skip to content

fix(repo-hygiene): git-tree-reset prints Applied* success lines even when git commands failed #395

Description

@kyle-sexton

Summary

git-tree-reset.sh --apply prints AppliedReset: and AppliedClean: success lines unconditionally, regardless of whether the underlying git commands succeeded. The report claims success on failure.

Component

plugins/repo-hygiene/skills/clean/scripts/git-tree-reset.sh.

Root cause

184  git reset --hard "$UPSTREAM"
187  CLEAN_STDERR="$(git clean -fdx "${PRESERVE_ARGS[@]}" 2>&1 >/dev/null)"
...
192  printf 'AppliedReset: git reset --hard %s\n' "$UPSTREAM"
193  printf 'AppliedClean: git clean -fdx%s\n' ...

Lines 192–193 run even when line 184 emitted a fatal: and did nothing. The output describes the intended commands, not the actual outcome.

Evidence (this session)

Repos where the reset failed with fatal: ambiguous argument '@{u}' nonetheless printed:

AppliedReset: git reset --hard @{u}
AppliedClean: git clean -fdx (+1 preserve excludes)

An operator parsing this output (or an agent driving the script) reasonably concludes both steps succeeded — they did not (reset failed; clean ran anyway).

Impact

Silent success-on-failure. Any automation that keys off AppliedReset:/AppliedClean: to decide the repo is at a known-good state is misled. Undermines trust in the tool's own reporting.

Expected

The Applied* lines reflect real exit status: emit them only on success; on failure emit an explicit failure/Blocked: line with the captured error.

Acceptance criteria

  • Gate each Applied* print on the actual exit code of its command.
  • On failure, print a distinct failure line (and non-zero exit) instead of a success line.
  • Consistent with the companion issues (reset-failure aborts clean; unresolved-upstream blocks).

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions