Skip to content

refactor(backup): use time.Duration for backup interval end-to-end#1150

Merged
perber merged 2 commits into
mainfrom
worktree-refactor+backup-interval-duration
Jun 9, 2026
Merged

refactor(backup): use time.Duration for backup interval end-to-end#1150
perber merged 2 commits into
mainfrom
worktree-refactor+backup-interval-duration

Conversation

@perber

@perber perber commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Replace IntervalMinutes int with Interval time.Duration in Config, migrate --git-backup-interval flag from fs.Int (minutes) to fs.Duration so operators can use duration strings like 60m or 2h, and remove the redundant interval parameter from NewScheduler so Config is the single source of truth. Negative and sub-minute values are now guarded with an explicit warning and written back to cfg.Interval so the stored config always reflects what the scheduler actually uses.

Replace IntervalMinutes int with Interval time.Duration in Config,
migrate --git-backup-interval flag from fs.Int (minutes) to fs.Duration
so operators can use duration strings like 60m or 2h, and remove the
redundant interval parameter from NewScheduler so Config is the single
source of truth. Negative and sub-minute values are now guarded with an
explicit warning and written back to cfg.Interval so the stored config
always reflects what the scheduler actually uses.
Copilot AI review requested due to automatic review settings June 9, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the git-backup scheduler configuration to use time.Duration end-to-end, making the backup interval configurable via standard Go duration strings and removing redundant interval plumbing so the repo config becomes the single source of truth for scheduling.

Changes:

  • Replace Config.IntervalMinutes int with Config.Interval time.Duration and remove the old Duration() helper.
  • Update the backup scheduler to read/normalize the interval from repo.cfg.Interval (including clamping negative and sub-minute values).
  • Migrate --git-backup-interval from an integer-minutes flag to fs.Duration, and update tests accordingly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
internal/backup/scheduler.go Scheduler now reads/normalizes repo.cfg.Interval and no longer accepts a separate interval parameter.
internal/backup/scheduler_test.go Updates scheduler tests to use Config.Interval time.Duration and new NewScheduler signature.
internal/backup/config.go Switches backup config interval to time.Duration and removes the minutes-to-duration helper.
cmd/leafwiki/main.go Updates CLI usage + flag parsing to accept duration strings for --git-backup-interval and passes duration into backup config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/leafwiki/main.go
Comment thread internal/backup/scheduler.go
Add two scheduler tests that verify the new clamping behavior:
negative intervals are set to 0 (manual-only, no ticker), and
sub-minute intervals are raised to minInterval with the corrected
value written back to cfg.Interval.
@perber
perber merged commit 4b42745 into main Jun 9, 2026
9 checks passed
@perber
perber deleted the worktree-refactor+backup-interval-duration branch June 19, 2026 16:31
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.

2 participants