Repository navigation
feat(native): preview a pull request's images and edited Markdown on the Pulls screen - #897
Merged
Merged
Conversation
…the Pulls screen /blob reads an object the clone lacks from GitHub's contents API, the way FileLines does, and the new PullRequestMergeBase RPC names the commit a pull request's old side stands on, computed locally when the clone holds both tips. The window asks it once per head for every image card. ReadFileAt reads a file whole at a revision, so an edited Markdown file renders at the head.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Pulls screen's Files tab drew a changed image as "Binary file" and offered the Markdown preview only for an added file, because
/blobandReadFileread only what the clone holds. Both now reach a pull request's commits./blobreads an object the clone lacks from GitHub's contents API, the wayFileLinesalready does; a commit the clone holds is always read locally. The before side stands on the newproject.PullRequestMergeBaseRPC: the tips come from GitHub, and the merge base is computed withgit merge-basewhen the clone holds both, else asked of the compare API.baseRefOidis not used, since it is the base branch's tip and goes wrong once the base moves.mergeBaseMemo), and asks again only for a new head or after a failure.project.ReadFileAt(local object first, GitHub otherwise, ReadFile's size and binary refusals).docs/ceilings.mdandCHANGELOG.mdmove with it.Two native tests changed because their contract changed:
TestBinaryFilesOpenWhenTheyHaveAPreviewasserted an image in a pull request starts collapsed since the clone held neither side, andTestMarkdownPreviewIsOfferedWhereTheNewVersionIsReadableasserted an edited file in a pull request has no preview.Test plan
gofmt,go vet ./...,go test ./...(new tests for the GitHub fallback, local-only reads, size cap, merge base local/compare/unreadable,ReadFileAt)gofmt,go vet ./...,go test ./...;mergeBaseMemotests under-race -count=20docs/media/og.pngread from this clone and from an empty clone with only the remote, same bytes on each path