Repository navigation
image diffs - #508
image diffs#508
Conversation
0de325f to
86305e5
Compare
027c191 to
bbeec6b
Compare
| * 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
ab8e36e to
d7344fa
Compare
|
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. |
|
🌔 |
joshaber
left a comment
There was a problem hiding this comment.
✨ 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.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return | ||
| } | ||
| resolve(Buffer.from(data, 'binary').toString('base64')) | ||
| }) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
This comment was marked as spam.
Sorry, something went wrong.
| public render() { | ||
| return <div className='panel' id='diff'> | ||
| <div className='image-header'> | ||
| This binary file has changed. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| readonly dispatcher: Dispatcher | ||
| } | ||
|
|
||
| export class BinaryFile extends React.Component<IBinaryFileProps, void> { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
🐨 |
| } | ||
|
|
||
| #diff .image-header { | ||
| padding: 12px 0 6px 0; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| #diff a { | ||
| text-decoration: none; | ||
| margin-left: 4px; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| padding: 12px 0 6px 0; | ||
| margin-left: auto; | ||
| margin-right: auto; | ||
| font-weight: bold; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| #diff .panel { | ||
| padding-top: 12px; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@niik thanks for the feedback - I can fold this stuff into a PR this week so we don't forget it 🤘 |

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:
ImageDiffis meaningful