Skip to content

Makes the diff too large message prettier - #4050

Merged
nerdneha merged 39 commits into
masterfrom
firendly-diff-too-large
Mar 9, 2018
Merged

nerdneha merged 39 commits into
masterfrom
firendly-diff-too-large

Conversation

@iAmWillShepherd

@iAmWillShepherd iAmWillShepherd commented Feb 20, 2018 •

Copy link
Copy Markdown
Contributor

Fixes issue #3971

In addition to fixing up the diff too large message on the History tab, I've updated the layout of the Changes tab to be consistent with the History tab.

  • if the buffer is >= 268MB, display image only
  • if the buffer >= 4MB or diff is >= 500k lines, display image and "show diff" button that can be clicked on to show the diff

Reproduction Steps

Large Diff

  1. Initialize a new repository
  2. Create a file that is at least 4MB in the repo
  3. Diff should state this diff is large and give you the option to view
  4. Commit the file
  5. Go to the History tab and try to view the diff
  6. Diff should state this diff is large and give you the option to view

Not able to render

  1. Initialize a new repository
  2. Create a file that is at least 270MB in the repo
  3. Diff should state this diff cannot be rendered
  4. Commit file
  5. Go to History tab and try to view the diff
  6. Diff should state this diff cannot be rendered

Note that it may take a while for the diff to appear, #4052 addresses that issue.

Before

2018-02-19 22 12 28

After

2018-02-19 22 09 21

@iAmWillShepherd iAmWillShepherd added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Feb 20, 2018
@tierninho

Copy link
Copy Markdown
Contributor

✅ tested for UI and functionality

@nerdneha nerdneha self-assigned this Feb 21, 2018
Comment thread app/src/lib/git/diff.ts Outdated

const largeDiff = buildLargeTextDiff(output)
if (largeDiff != null) {
return largeDiff

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/ui/diff/index.tsx Outdated
}

private renderLargeText(diff: ILargeTextDiff) {
if (diff.hunks == null || diff.text == null) {

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/ui/diff/index.tsx Outdated

private renderLargeText(diff: ILargeTextDiff) {
if (diff.hunks == null || diff.text == null) {
return fatalError('Cannot render diff withouth hunks and text')

This comment was marked as spam.

Comment thread app/src/lib/git/diff.ts Outdated

/**
* Utility function that takes a buffer and outputs
* either a largeTextDiff

This comment was marked as spam.

Comment thread app/src/ui/diff/index.tsx Outdated
}

return null
private onShowLargeDiff = () => {

This comment was marked as spam.

@nerdneha

Copy link
Copy Markdown
Contributor

pulling in @niik and @donokuda here as there's a new button to show a diff if we can make it happen (i think). i'm 👍 for it

@nerdneha

Copy link
Copy Markdown
Contributor

🐝

donokuda
donokuda previously approved these changes Feb 21, 2018

@donokuda donokuda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI changes look good to me

@shiftkey shiftkey added this to the 1.1.x milestone Feb 22, 2018
nerdneha
nerdneha previously approved these changes Feb 22, 2018
@nerdneha
nerdneha dismissed their stale review February 22, 2018 10:22

trigger happy. i shouldn't approve things at night. sorry!

@iAmWillShepherd

Copy link
Copy Markdown
Contributor Author

🔢

@nerdneha nerdneha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huge improvement! adding a few more things 😅

Comment thread app/src/lib/git/diff.ts Outdated
): Promise<IDiff> {
if (!isValidBuffer(buffer)) {
// we know we can't transform this process output into a diff, so let's
// just return a placeholder for now that we can display to the user

This comment was marked as spam.

Comment thread app/src/models/diff.ts Outdated
export interface ILargeTextDiff {
readonly kind: DiffType.LargeText
/** The unified text diff - including headers and context */
readonly text?: string

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/models/diff.ts Outdated
/** The unified text diff - including headers and context */
readonly text?: string
/** The diff contents organized by hunk - how the git CLI outputs to the caller */
readonly hunks?: ReadonlyArray<DiffHunk>

This comment was marked as spam.

Comment thread app/src/ui/diff/index.tsx Outdated

return null
private showLargeDiff = () => {
this.setState({ forceShowLargeDiff: !this.state.forceShowLargeDiff })

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/ui/diff/index.tsx Outdated
case DiffType.Image:
return this.renderImage(diff)
case DiffType.LargeText: {
const largeTextDiff = diff as ILargeTextDiff

This comment was marked as spam.

This comment was marked as spam.

🐭 just cleaning some stuff up since we're here
@nerdneha

nerdneha commented Mar 3, 2018

Copy link
Copy Markdown
Contributor

🐭

Comment thread app/src/lib/git/diff.ts Outdated
*
* @param commitish A commit SHA or some other identifier that ultimately dereferences
* to a commit.
* a commit.

This comment was marked as spam.

This comment was marked as spam.

nerdneha and others added 5 commits March 5, 2018 17:42
a committish = A commit object or an object that can be recursively dereferenced _to_ a commit object

Co-Authored-By: Jed Fox <[email protected]>
@iAmWillShepherd

Copy link
Copy Markdown
Contributor Author

🔢

@iAmWillShepherd

Copy link
Copy Markdown
Contributor Author

@nerdneha I've added reproduction steps in the PR body.

Comment thread app/src/lib/git/diff.ts Outdated
* a string.
*/
const MaxDiffBufferSize = 268435441
const MaxDiffBufferSize = 268435441 //~268MB

This comment was marked as spam.

@nerdneha

nerdneha commented Mar 5, 2018

Copy link
Copy Markdown
Contributor

everything else works correctly. i tested:

  • new file < 4MB -- renders normally
  • new file @ 62MB ( > 4MB && <268MB ) -- renders with a warning but ability to show diff
  • existing file @ 62MB ( > 4MB && <268MB ) -- renders with a warning but ability to show diff
  • new file > 70MB -- renders with a warning but ability to show diff but does not render the full diff (see comment above)
  • new file with 100k characters -- renders normally
  • new file with 690k characters -- renders with a warning but ability to show diff

⚙️⚙️⚙️⚙️

@iAmWillShepherd

Copy link
Copy Markdown
Contributor Author

🔢

Comment thread app/src/lib/git/diff.ts Outdated
/**
* The longest line length we should try to display. If a diff has a line longer
* than this, we probably shouldn't attempt it.
* tha obably shouldn't attempt it.

This comment was marked as spam.

This comment was marked as spam.

@nerdneha nerdneha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm assuming you're done with edits? didn't see an emoji but here's my 👍 in case you're done

@nerdneha
nerdneha merged commit 462882d into master Mar 9, 2018
@nerdneha
nerdneha deleted the firendly-diff-too-large branch March 9, 2018 17:05
@nerdneha nerdneha mentioned this pull request Mar 26, 2018
13 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants