mirror of
https://github.com/gogs/gogs.git
synced 2026-05-28 21:30:36 +00:00
The commit diff page only ships the patch hunks, so unmodified context
between hunks is invisible. Add a per-file "Expand all lines" toggle so
the reader can pull in the full file when the surrounding code matters.
Backend:
- Migrate `repo.SingleDownload` to a new Flamego `getRepoRaw` handler.
Same URL shape (`/{owner}/{name}/raw/{ref}/{path}`) so external
consumers (`curl`, scripts) keep working. Bridged from the Macaron
router via `flamegoBridger` so the legacy path doesn't double-route
through `RepoRef` middleware. The ref segment accepts a branch, tag,
or commit SHA; commit SHAs match first (the common case from the
React diff page).
- Delete `repo.SingleDownload` and the legacy `m.Get("/raw/*", ...)`
Macaron handler. `repo.ServeBlob` stays because `internal/route/api/v1`
still uses it for the public REST API.
Frontend:
- Add an `UnfoldVertical` icon button to each file header. Click fetches
the pre + post file contents in parallel via the legacy raw URL,
calls `parseDiffFromFile` to upgrade the `FileDiffMetadata` to
`isPartial: false`, and stores the result keyed by item id.
- The `items` useMemo swaps in the upgraded `fileDiff` when present and
bumps the item `version` so Pierre's `CodeView` re-renders that file.
Set `expandUnchanged: true` globally so non-partial files immediately
render all context lines.
- Show a spinner during fetch, hide the button once expansion succeeds.
Skip the button for added/deleted files (no opposite side to expand).
- Added/deleted files preserve the old behaviour (no expansion).