Skip to content

refactor: Extract shared drop-in file creation from EnableFeature and DisableFeature#108

Merged
bketelsen merged 1 commit intomainfrom
yeti/improve-8631
Mar 31, 2026
Merged

refactor: Extract shared drop-in file creation from EnableFeature and DisableFeature#108
bketelsen merged 1 commit intomainfrom
yeti/improve-8631

Conversation

@frostyardyeti
Copy link
Copy Markdown
Contributor

@frostyardyeti frostyardyeti Bot commented Mar 31, 2026

In updex/features.go, EnableFeature (lines 112-136) and DisableFeature (lines 263-287) contain near-identical code for creating the drop-in directory, writing the drop-in file, and handling dry-run logging. The only difference is the content written (Enabled=true vs Enabled=false).

Both blocks:

  1. Build dropInDir and dropInFile paths identically
  2. Log "Would create drop-in" in dry-run mode
  3. Call os.MkdirAll + os.WriteFile with identical error handling
  4. Set result.DropIn and log success

Extract a helper like writeFeatureDropIn(name string, enabled bool, dryRun bool) (string, error) to consolidate this logic and reduce the duplication.


Automated improvement by yeti improvement-identifier

…sableFeature

Both methods contained near-identical code for creating the drop-in
directory, writing the drop-in file, and handling dry-run logging.
The only difference was the content (Enabled=true vs Enabled=false).
Extract a shared writeFeatureDropIn method to consolidate this logic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bketelsen bketelsen merged commit 9806ffb into main Mar 31, 2026
7 checks passed
@bketelsen bketelsen deleted the yeti/improve-8631 branch March 31, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant