Let a project name the versions worth keeping (fixes #127) #140
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
qwc-open/asiakirjat!140
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/version-keep-pattern"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #127. The issue had no body, so here's how I read it — say the word if you meant something else.
Interpretation
Retention already had exactly this shape, with the keep-rule hardcoded: semver tags are kept, everything else expires after N days. So this replaces the hardcoded half with a per-project regex and leaves the rest as it was.
Admin > Projects > Edit now shows:
An empty pattern means the old rule, so nothing changes for existing projects.
^v\d+\.\d+\.\d+$keeps releases and letsv1.1.0-rc1expire like any other build — the case the old rule couldn't express, since it kept every semver-shaped tag including prereleases.Safety
Deletion here is irreversible — files, database row, and search index entries — so the failure modes lean one way:
regexpis RE2, so there's no catastrophic backtracking to worry about; the cap just keeps the field a readable rule.Validation lives in
projects.ValidateVersionKeepPattern, next toValidateVisibility, so the form and the service agree.Tests
internal/handler/version_keep_pattern_test.goruns real retention over backdated versions: a pattern keepingv1.0.0whilev1.1.0-rc1and a branch build expire and a recent build survives on age; the no-pattern case behaving exactly as before; the invalid-pattern fallback; and the admin form storing, rejecting, and clearing a pattern.Full suite green.
One thing I found and did not change
Retention does not exempt a pinned version. Pin a build as latest, give the project a pattern that doesn't match it, and retention will delete it out from under the pin. That's pre-existing, not introduced here, and fixing it changes deletion behaviour beyond what #127 asked for — so I documented the sharp edge in
how-to/version-retention.mdand filed it separately rather than folding it in. Happy to fix it if you'd like the guard.Docs
New
how-to/version-retention.mdexplaining both fields together, with a table of worked patterns and a note that anchoring matters.reference/configuration.mdand the docs index link to it. Worth a Deploy Built-in Docs after merging.Assisted by Claude Opus 5.
Added a second commit (
a6bcab6) making the keep pattern default instance-wide, per your request — the description above covers only the first commit.What changed
New config option
retention.keep_pattern, shipping as^v?\d+\.\d+\.\d+$. Projects without their own pattern follow it, so "real versions" are kept everywhere by default and a project only sets its own field when it tags differently. An operator whose whole instance tags differently changes one value instead of editing every project.Worth knowing before merging
This narrows what retention keeps. The old fallback was
docs.IsSemver, whose regex is^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(.*)$— the trailing.*means it matches anything starting with an optionalvand a digit. So these counted as keepers before and expire under the new default:v1.2.3v1.2,v2v1.2.3-rc12026-01-01(dated build)Two things limit the blast radius:
nonsemver_daysstill defaults to0, so an instance that never enabled retention deletes nothing regardless; and any project can be exempted by giving it its own pattern.If your projects tag two-component releases, widen the instance default to
^v?\d+(\.\d+)*$inconfig.yaml— that keepsv1.2andv2while still expiring RCs and branch builds. There's a test pinning that widening works, andconfig.yaml.examplespells out the option.An unparseable config pattern falls back to the old permissive rule, same as a broken project pattern — deletion is irreversible, so an unusable rule keeps more rather than less.
PR #143 (stacked on this branch) fixes #141 on top.
Assisted by Claude Opus 5.