Skip to content

fix(cli): keep bashunit init idempotent in .env - #1176

Merged
Chemaclass merged 1 commit into
mainfrom
fix/1175-init-env-idempotent
Aug 13, 2026
Merged

fix(cli): keep bashunit init idempotent in .env#1176
Chemaclass merged 1 commit into
mainfrom
fix/1175-init-env-idempotent

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1175

bashunit init comments out any existing BASHUNIT_BOOTSTRAP and appends a
fresh one — unconditionally, even when the value is unchanged. Three runs:

#BASHUNIT_BOOTSTRAP=tests/bootstrap.sh
#BASHUNIT_BOOTSTRAP=tests/bootstrap.sh
BASHUNIT_BOOTSTRAP=tests/bootstrap.sh

The scaffolded files are idempotent, so re-running init is otherwise safe and
people do it. Only .env grew — and it was the one file written without being
announced.

💡 Changes

  • Skip the rewrite when the setting already holds the intended value
  • Report each .env outcome (Created / already sets / Updated)
  • Replacing a different value still works — that is what the comment-and-append logic is for
  • Tests appended to the existing bashunit_init_test.sh, which another test depends on by name

init commented out any existing BASHUNIT_BOOTSTRAP and appended a fresh one
unconditionally, so three runs left three lines with two inert. The scaffolded
files are idempotent, so re-running init is otherwise safe and people do it --
only .env grew.

Skip the rewrite when the setting already holds the intended value, and report
each outcome: .env was the one file init wrote without announcing it, so a
review of what init touched would miss it. Replacing a different value still
works, which is what the comment-and-append logic exists for.

Closes #1175
@Chemaclass Chemaclass added the bug Something isn't working label Aug 13, 2026
@Chemaclass Chemaclass self-assigned this Aug 13, 2026
@Chemaclass
Chemaclass merged commit 2f37300 into main Aug 13, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/1175-init-env-idempotent branch August 13, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant