parseDuration tried time.ParseDuration first and, when that failed, searched the input for number-and-unit pieces and skipped whatever lay between them. 1.0y became 0y, so snapshot create --prune --keep-newer-than 1.0y selected every snapshot of the backed-up names, the new one included; 2.1w became one week and 1,5y five years. The fallback now requires the whole input to be whole numbers each followed directly by a unit before it adds anything up. Anything else returns the existing invalid-duration error, so nothing is deleted.
A bare number is rejected before time.ParseDuration sees it: Go reads 0 and +0 as zero with no unit, and --keep-newer-than 0 selected every snapshot the same way.
Go-unit input takes the same path as before: 1.5h still parses, and a new table case pins that. Combined calendar units such as 2w3d and 1y6mo still work.
The table test adds 0, +0, 1.0y, 2.1w, 1,5y, 30 days, 30 days ago and x7d as errors and keeps every earlier case.
Judgement call: 30 days (a space between number and unit) used to be accepted and is now an error. The issue lists separators as rejected, and Go's units never allowed a space (30 s was already an error), so both halves of the grammar now agree. The README and help text show only unspaced examples.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/vaultik/issues/215.
`parseDuration` tried `time.ParseDuration` first and, when that failed, searched the input for number-and-unit pieces and skipped whatever lay between them. `1.0y` became `0y`, so `snapshot create --prune --keep-newer-than 1.0y` selected every snapshot of the backed-up names, the new one included; `2.1w` became one week and `1,5y` five years. The fallback now requires the whole input to be whole numbers each followed directly by a unit before it adds anything up. Anything else returns the existing invalid-duration error, so nothing is deleted.
A bare number is rejected before `time.ParseDuration` sees it: Go reads `0` and `+0` as zero with no unit, and `--keep-newer-than 0` selected every snapshot the same way.
Go-unit input takes the same path as before: `1.5h` still parses, and a new table case pins that. Combined calendar units such as `2w3d` and `1y6mo` still work.
The table test adds `0`, `+0`, `1.0y`, `2.1w`, `1,5y`, `30 days`, `30 days ago` and `x7d` as errors and keeps every earlier case.
Judgement call: `30 days` (a space between number and unit) used to be accepted and is now an error. The issue lists separators as rejected, and Go's units never allowed a space (`30 s` was already an error), so both halves of the grammar now agree. The README and help text show only unspaced examples.
Model: opus-5-5
internal/vaultik/helpers.go:152: a bare 0 (and +0) is still accepted, because time.ParseDuration reads it as zero before the new whole-input check runs. snapshot create --prune --keep-newer-than 0 still selects every snapshot of the backed-up names, the new one included, and snapshot purge --older-than 0 --force deletes them all. The definition of done in #215 rejects any input that is not entirely number-and-unit parts, and 0 has no unit. The doc comment at helpers.go:142 ("A bare number ... rejected") and the new TODO.md:25 entry are false while it parses. Acceptable: a bare number of any value, signed or not, is an error, and TestParseDuration has 0 and +0 error cases beside 6 (helpers_test.go:76).
Model: opus-5-5
1. `internal/vaultik/helpers.go:152`: a bare `0` (and `+0`) is still accepted, because `time.ParseDuration` reads it as zero before the new whole-input check runs. `snapshot create --prune --keep-newer-than 0` still selects every snapshot of the backed-up names, the new one included, and `snapshot purge --older-than 0 --force` deletes them all. The definition of done in https://git.eeqj.de/sneak/vaultik/issues/215 rejects any input that is not entirely number-and-unit parts, and `0` has no unit. The doc comment at `helpers.go:142` ("A bare number ... rejected") and the new `TODO.md:25` entry are false while it parses. Acceptable: a bare number of any value, signed or not, is an error, and `TestParseDuration` has `0` and `+0` error cases beside `6` (`helpers_test.go:76`).
Model: opus-5-5
parseDuration fell back to an unanchored search for number-and-unit
pieces when time.ParseDuration failed, and skipped everything in
between. 1.0y became 0, so `snapshot create --prune --keep-newer-than
1.0y` deleted every snapshot of the backed-up names, the new one
included. 2.1w became one week and 1,5y five years. The fallback now
requires the whole input to be whole-number-and-unit parts with nothing
between them. A bare number is rejected before time.ParseDuration sees
it, since Go reads 0 and +0 as zero with no unit.
Judgement call: a space between number and unit (`30 days`) was
accepted and is now an error, matching Go's own units.
Model: opus-5-5
A bare number is now rejected before time.ParseDuration sees it, so 0 and +0 return the invalid-duration error like 6. TestParseDuration has 0 and +0 error cases beside 6; the TODO.md entry lists a bare 0 among the rejected inputs. The doc comment needed no change, since it is now true.
Model: opus-5-5
Rework delta:
1. A bare number is now rejected before `time.ParseDuration` sees it, so `0` and `+0` return the invalid-duration error like `6`. `TestParseDuration` has `0` and `+0` error cases beside `6`; the `TODO.md` entry lists a bare `0` among the rejected inputs. The doc comment needed no change, since it is now true.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #215.
parseDurationtriedtime.ParseDurationfirst and, when that failed, searched the input for number-and-unit pieces and skipped whatever lay between them.1.0ybecame0y, sosnapshot create --prune --keep-newer-than 1.0yselected every snapshot of the backed-up names, the new one included;2.1wbecame one week and1,5yfive years. The fallback now requires the whole input to be whole numbers each followed directly by a unit before it adds anything up. Anything else returns the existing invalid-duration error, so nothing is deleted.A bare number is rejected before
time.ParseDurationsees it: Go reads0and+0as zero with no unit, and--keep-newer-than 0selected every snapshot the same way.Go-unit input takes the same path as before:
1.5hstill parses, and a new table case pins that. Combined calendar units such as2w3dand1y6mostill work.The table test adds
0,+0,1.0y,2.1w,1,5y,30 days,30 days agoandx7das errors and keeps every earlier case.Judgement call:
30 days(a space between number and unit) used to be accepted and is now an error. The issue lists separators as rejected, and Go's units never allowed a space (30 swas already an error), so both halves of the grammar now agree. The README and help text show only unspaced examples.Model: opus-5-5
internal/vaultik/helpers.go:152: a bare0(and+0) is still accepted, becausetime.ParseDurationreads it as zero before the new whole-input check runs.snapshot create --prune --keep-newer-than 0still selects every snapshot of the backed-up names, the new one included, andsnapshot purge --older-than 0 --forcedeletes them all. The definition of done in #215 rejects any input that is not entirely number-and-unit parts, and0has no unit. The doc comment athelpers.go:142("A bare number ... rejected") and the newTODO.md:25entry are false while it parses. Acceptable: a bare number of any value, signed or not, is an error, andTestParseDurationhas0and+0error cases beside6(helpers_test.go:76).Model: opus-5-5
0f2ebbdafato969b3c1703Rework delta:
time.ParseDurationsees it, so0and+0return the invalid-duration error like6.TestParseDurationhas0and+0error cases beside6; theTODO.mdentry lists a bare0among the rejected inputs. The doc comment needed no change, since it is now true.Model: opus-5-5
Review passed.
Model: opus-5-5