Skip to content

Tighten small helper contracts in stdlib and git libraries #19

@codeforester

Description

@codeforester

Context

Several smaller helper behaviors are not urgent defects, but they make the public API less tidy than it could be:

  • safe_mkdir only handles a leading -p by hand instead of using option parsing consistent with the rest of stdlib.
  • _git_pull_with_retry hardcodes two attempts.
  • git_get_current_branch changes process directory with pushd/popd even though git -C can avoid that.
  • git_get_current_branch docs say non-repo/missing directories store an empty string, but missing directories currently return nonzero.

Scope

  • Make safe_mkdir option/no-arg handling explicit and tested.
  • Add a documented way to configure git pull retry attempts, or document the fixed retry policy as intentional.
  • Refactor git_get_current_branch to avoid changing the caller's working directory where practical.
  • Align git_get_current_branch docs, return codes, and tests.

Acceptance Criteria

  • Helper contracts are documented and covered by BATS tests.
  • git_get_current_branch does not unexpectedly perturb the caller's directory stack.
  • Retry behavior is either configurable or explicitly documented.
  • Existing callers continue to work or have documented migration notes.

Validation

  • ./tests/validate.sh

Suggested Branch

enhancement/<issue>-20260618-helper-contract-cleanup

Metadata

Metadata

Assignees

Labels

enhancementNew feature or product improvement

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions