Skip to content

image diffs - #508

Merged
joshaber merged 28 commits into
masterfrom
image-diffs-maybe
Oct 13, 2016
Merged

joshaber merged 28 commits into
masterfrom
image-diffs-maybe

Conversation

@shiftkey

@shiftkey shiftkey commented Oct 10, 2016 •

Copy link
Copy Markdown
Member

Fixes #169
Fixes #170

Fleshes out support for viewing image diffs. I won't go too deep here, as I'm sure others have their own ideas:

  • can view added/modified/deleted images (for known formats GIF/PNG/JPG) for repository
  • can view "binary file changed" as fallback
  • add some styling so content expands to fit the available space of the diff panel
  • docs docs docs
  • add some tests
  • get a better grasp on the "open in external program" options for electron and document what we can do here
  • confirm abstraction and usage for ImageDiff is meaningful

Comment thread app/src/models/diff.ts
* If the file can be represented as a visual diff
* TODO: a better abstraction than poking a property?
*/
public imageDiff: ImageDiff | undefined

This comment was marked as spam.

This comment was marked as spam.

@shiftkey shiftkey changed the title [WIP] image diffs image diffs Oct 11, 2016
@shiftkey

Copy link
Copy Markdown
Member Author

While there might be a way to lookup program associations for files and pre-emptively determine whether a file can be opened, the openExternal API only returns a boolean to indicate whether it launched a program - so to KISS I'm just going to display an error to the user.

@shiftkey

Copy link
Copy Markdown
Member Author

🌔

@joshaber joshaber self-assigned this Oct 12, 2016

@joshaber joshaber 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.

✨ Nice! ✨

It looks like there are a couple different modules we could use to try to do mime type detection more generally. It's totally fine to punt on that for now, but if so, could you open an issue for it?

} else if (file.status === FileStatus.Renamed) {
// NB: Technically this is incorrect, the best way of incorrect.
// NB: Technically this is incorrect, the best kind of incorrect.
// In order to show exactly what will end up in the commit we should

This comment was marked as spam.

}

if (file.status === FileStatus.Modified || file.status === FileStatus.Deleted) {
previous = await GitDiff.getBlobImage(repository, file)

This comment was marked as spam.

This comment was marked as spam.

return
}
resolve(Buffer.from(data, 'binary').toString('base64'))
})

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/lib/git/git-diff.ts Outdated
const setBinaryEncoding: (process: ChildProcess) => void = cb => cb.stdout.setEncoding('binary')

const blob_contents = await git(catFileArgs, repository.path, { successExitCodes, processCallback: setBinaryEncoding })
const base64Contents = Buffer.from(blob_contents.stdout, 'binary').toString('base64')

This comment was marked as spam.

Comment thread app/src/ui/diff/binary-file.tsx Outdated
public render() {
return <div className='panel' id='diff'>
<div className='image-header'>
This binary file has changed.

This comment was marked as spam.

readonly dispatcher: Dispatcher
}

export class BinaryFile extends React.Component<IBinaryFileProps, void> {

This comment was marked as spam.

@shiftkey

Copy link
Copy Markdown
Member Author

It's totally fine to punt on that for now, but if so, could you open an issue for it?

#529

@shiftkey

Copy link
Copy Markdown
Member Author

🐨

@joshaber
joshaber merged commit 463f4ce into master Oct 13, 2016
@joshaber
joshaber deleted the image-diffs-maybe branch October 13, 2016 15:57
Comment thread app/styles/ui/_diff.scss
}

#diff .image-header {
padding: 12px 0 6px 0;

This comment was marked as spam.

Comment thread app/styles/ui/_diff.scss

#diff a {
text-decoration: none;
margin-left: 4px;

This comment was marked as spam.

Comment thread app/styles/ui/_diff.scss
padding: 12px 0 6px 0;
margin-left: auto;
margin-right: auto;
font-weight: bold;

This comment was marked as spam.

Comment thread app/styles/ui/_diff.scss
}

#diff .panel {
padding-top: 12px;

This comment was marked as spam.

@shiftkey

Copy link
Copy Markdown
Member Author

@niik thanks for the feedback - I can fold this stuff into a PR this week so we don't forget it 🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants