feat(forgejo): snapshot PR diffs and files into session storage #14
No reviewers
Labels
No labels
Agent
Ignore
Agent
In Progress
Agent
Planned
Agent
Planning
Agent
Ready
Agent
Triage
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
lucas/omp-deck!14
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/f-9"
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?
forgejo_get_pr_diffnow writes the complete PR diff to session storage (local://pr-<n>@<head7>/<path>.diff). Each changed file gets its own file, with old and new line numbers in a gutter. The snapshot is pinned to the head SHA, reused on repeat calls, and comes back as a summary that lists every changed file.since_shareplacespathsand snapshots only what changed after that commit, using the compare API, raw files fetched at both SHAs, and a localgit diff --no-index.forgejo_read_file_at_refwrites the file tolocal://tree@<sha7>/<path>and returns its size and line count.forgejo_read_prno longer shows a partial file list. Both tools attach typeddetails, rendered by new web cards, and the preview gallery has a "Forgejo tools" section.Decisions
git diff --no-indexlabels deleted filesa/P a/Pand added filesb/P b/P, and keeps thea//b/dirs inrename from/tolines.diffTreesrewrites these header lines into the PR-diff shape. This is the contingency the plan allowed for; renames are still detected by-M.writeSnapshotDirchecks whether the target exists before renaming. On Linux,rename(2)silently replaces an empty directory, which a zero-file snapshot is.safeRelPathalso rejects paths that contain\.too-largerows come after the files git diffed.SnapshotLine(snapshotPathChipplus an inlineCopyButton) andINLINE_COPY_CLASSinforgejo/ui.tsx, because the defaultCopyButtonfloats over the row and only shows on hover.%,#or?are written to disk correctly, but thelocal://URLs printed for them are not encoded.Verification
bun test src/forgejoinapps/server: 171 pass, 0 fail. New tests coveranalyzeDiffChunk, octal and C-escaped path unquoting,safeRelPath,writeSnapshotDir,writeFileAtomic,renderIndex,renderInline,toDetails, anddiffTrees(added, deleted, modified, renamed, identical, and an empty old tree). ThefilterDiff,formatChangedFileandsliceNumberedLinestests are removed.bun run typecheckat the repo root: protocol, server and web all exit 0.reused: true.since_shareturnssince_sha nope not found.local://root the call returns the session-storage error.tree@<sha7>/<path>with the right line count; a bad ref returnsref "no-such-branch" not found.resolveLocalUrlToPathmapslocal://pr-8@fafd5d9/...,local://pr-8@fafd5d9.mdandlocal://tree@fafd5d9/...to the local root.ForgejoToolwithrenderToStaticMarkup. The 3-file list is open; the 12-file list is collapsed; the 35-file case shows the note with a copy button. Flags,reusedandtruncatedtags render, and both read-file cards render. There was no visual check in a browser: the managed Chromium can't start here because system libraries are missing.Closes #9