Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "webdiff"
version = "1.3.0b1"
version = "1.3.0b2"
description = "Two-column web-based git difftool"
license = "Apache-2.0"
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions testdata/jsondiffs/left/ospd5.summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":8503055,"num_reps":5505497728300038000000,"elapsed_s":27775981.582439058,"failures":["sredetiltnapsres","stngeiaedrlpsdes","gresenapdtilsres","dresenalstipares","gresenalstipares","gresenalstipores","dresenilstapares","dresenilstapores","dresenilstapures","gressnaletipdres","gntseaieslrdopes","sttseiaenrlpsges","plsdeaiertnrsges","plsteaiertnrsges","psldeaiertnrsges","spldeaiertnrsges","spldeiaetrntsges","splseaiertnrsdes","splseaiertnrsges","slpseaierntrsdes","slpseaierntrsges","slpseaiertnrsges","slpseiaerntrsdes","dresenapstilares","gresenapstilares","gresenapstilores","dplcseainrtngies","dresenilgtapsres","stndeiaenrlpsges","stngeiaenrlpsges","gsedtnileratspes","slpseaierntrgdes","gntseaieplrdseas","gntseaieplrdsees","plcdeaiertnrsges","dplseaiertnrsges","mplseaiertnrsges","sresetipdnalsges","plcseaiertnrsges","dlpseaiertnrsges","gredenalstipares","gredenalstipores","hsebetalsripgnes","hsedetalsripgnes","tsebetalsripgnes","tsedetalsripgnes"],"elim_level":[0,15455,177058,5063716,76688548,461765945,746413471,1341313341,1163044169,683351596,332798842,146849412,75414967,51931121],"secs_by_level":[3674055.3433500067,410511.63218999945,1173934.825350049,3012839.132659852,5235705.436329976,4241101.513749921,4354658.159489981,2102788.1823800365,669439.2463199788,109737.61249999885,25531.954199997952,4647.2012399998175,1373.4651100000929],"bounds":[17529004948,13770052786,11002135202,8716185865,6917888192,5476876187,4192563351,3051811248,2128082619,1431049972,956438815,668040946,500412197],"depth":[0,19950,615593,14344534,148852615,670318189,1798495841,2584907222,2213849795,1122244756,511943456,205264471,96606475,62028585],"boards_to_test":16527857205,"init_nodes":21169090330328,"total_nodes":216126848966789,"tree_bytes":426388045692928,"total_bytes":574688434585600,"n_bound":9429491482,"n_force":2101423756,"max_multi":1312378509,"bound_secs":[0,26.31909999999997,762.3841000000707,13895.171989995355,96300.35142999486,278184.6050899924,509398.4086700136,489545.5812600387,261858.04687000782,96741.63683000114,42098.825499994186,16502.548799997923,8129.411579999221,6838.873439999473],"test_secs":859209.9650399276,"best_board":[3827,"splseaiertnrsges"]}
144 changes: 144 additions & 0 deletions testdata/jsondiffs/right/ospd5.summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"id": 8503055,
"num_reps": 5505497728300038000000,
"elapsed_s": 27775981.582439058,
"failures": [
"sredetiltnapsres",
"stngeiaedrlpsdes",
"gresenapdtilsres",
"dresenalstipares",
"gresenalstipares",
"gresenalstipores",
"dresenilstapares",
"dresenilstapores",
"dresenilstapures",
"gressnaletipdres",
"gntseaieslrdopes",
"sttseiaenrlpsges",
"plsdeaiertnrsges",
"plsteaiertnrsges",
"psldeaiertnrsges",
"spldeaiertnrsges",
"spldeiaetrntsges",
"splseaiertnrsdes",
"splseaiertnrsges",
"slpseaierntrsdes",
"slpseaierntrsges",
"slpseaiertnrsges",
"slpseiaerntrsdes",
"dresenapstilares",
"gresenapstilares",
"gresenapstilores",
"dplcseainrtngies",
"dresenilgtapsres",
"stndeiaenrlpsges",
"stngeiaenrlpsges",
"gsedtnileratspes",
"slpseaierntrgdes",
"gntseaieplrdseas",
"gntseaieplrdsees",
"plcdeaiertnrsges",
"dplseaiertnrsges",
"mplseaiertnrsges",
"sresetipdnalsges",
"plcseaiertnrsges",
"dlpseaiertnrsges",
"gredenalstipares",
"gredenalstipores",
"hsebetalsripgnes",
"hsedetalsripgnes",
"tsebetalsripgnes",
"tsedetalsripgnes"
],
"elim_level": [
0,
15455,
177058,
5063716,
76688548,
461765945,
746413471,
1341313341,
1163044169,
683351596,
332798842,
146849412,
75414967,
51931121
],
"secs_by_level": [
3674055.3433500067,
410511.63218999945,
1173934.825350049,
3012839.132659852,
5235705.436329976,
4241101.513749921,
4354658.159489981,
2102788.1823800365,
669439.2463199788,
109737.61249999885,
25531.954199997952,
4647.2012399998175,
1373.4651100000929
],
"bounds": [
17529004948,
13770052786,
11002135202,
8716185865,
6917888192,
5476876187,
4192563351,
3051811248,
2128082619,
1431049972,
956438815,
668040946,
500412197
],
"depth": [
0,
19950,
615593,
14344534,
148852615,
670318189,
1798495841,
2584907222,
2213849795,
1122244756,
511943456,
205264471,
96606475,
62028585
],
"boards_to_test": 16527857205,
"init_nodes": 21169090330328,
"total_nodes": 216126848966789,
"tree_bytes": 426388045692928,
"total_bytes": 574688434585600,
"n_bound": 9429491482,
"n_force": 2101423756,
"max_multi": 1312378509,
"bound_secs": [
0,
26.31909999999997,
762.3841000000707,
13895.171989995355,
96300.35142999486,
278184.6050899924,
509398.4086700136,
489545.5812600387,
261858.04687000782,
96741.63683000114,
42098.825499994186,
16502.548799997923,
8129.411579999221,
6838.873439999473
],
"test_secs": 859209.9650399276,
"best_board": [
3827,
"splseaiertnrsges"
]
}
4 changes: 2 additions & 2 deletions testdata/jsondiffs/right/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
/* Note that this file isn't really JSON! It's JSONC. */
"compilerOptions": {
/* Note that this file isn't really JSON! */

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "ESNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
/* Specify library files to be included in the compilation. */
"lib": [
"es2021",
"es2021",
"dom"
] ,
// "allowJs": true, /* Allow javascript files to be compiled. */
Expand Down
35 changes: 22 additions & 13 deletions ts/CodeDiffContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {DiffOptions, encodeDiffOptions} from './diff-options';
import {GitDiffOptions, gitDiffOptionsToFlags} from './diff-options';
import {CodeDiff, PatchOptions} from './codediff/codediff';
import {guessLanguageUsingContents, guessLanguageUsingFileName} from './codediff/language';
import {GitConfig} from './options';
Expand Down Expand Up @@ -53,18 +53,19 @@ export interface ImageDiffData {
}

// A "no changes" sign which only appears when applicable.
export function NoChanges(props: {filePair: FilePair}) {
const {filePair} = props;
export function NoChanges(props: {filePair: FilePair; isEqualAfterNormalization: boolean}) {
const {filePair, isEqualAfterNormalization} = props;
let msg = null;
if (filePair.no_changes) {
return <div className="no-changes">(File content is identical)</div>;
msg = <>(File content is identical)</>;
} else if (isEqualAfterNormalization) {
msg = <>(File content is identical after normalization)</>;
} else if (filePair.is_image_diff && filePair.are_same_pixels) {
return (
<div className="no-changes">
Pixels are the same, though file content differs (perhaps the headers are different?)
</div>
msg = (
<>Pixels are the same, though file content differs (perhaps the headers are different?)</>
);
}
return null;
return msg ? <div className="no-changes">{msg}</div> : null;
}

// Either side can be empty (i.e. an add or a delete), in which case getOrNull resolves to null.
Expand All @@ -84,7 +85,7 @@ async function getOrNull(side: string, path: string, normalizeJSON: boolean) {

export interface CodeDiffContainerProps {
filePair: FilePair;
diffOptions: Partial<DiffOptions>;
diffOptions: Partial<GitDiffOptions>;
normalizeJSON: boolean;
}

Expand All @@ -96,6 +97,8 @@ export function CodeDiffContainer(props: CodeDiffContainerProps) {
>();

React.useEffect(() => {
// It would be more correct to set contents=undefined here to get a loading state,
// but this produces an unnecessary flash for rapid transitions.
const getDiff = async () => {
const response = await fetch(`/diff/${filePair.idx}`, {
method: 'POST',
Expand All @@ -104,7 +107,7 @@ export function CodeDiffContainer(props: CodeDiffContainerProps) {
'Content-Type': 'application/json',
},
body: JSON.stringify({
options: encodeDiffOptions(diffOptions),
options: gitDiffOptionsToFlags(diffOptions),
normalize_json: normalizeJSON,
}),
});
Expand All @@ -127,6 +130,10 @@ export function CodeDiffContainer(props: CodeDiffContainerProps) {
});
}, [filePair, diffOptions, normalizeJSON]);

const isEqualAfterNormalization = React.useMemo(() => {
return !filePair.no_changes && normalizeJSON && contents && contents.before == contents.after;
}, [contents, filePair.no_changes, normalizeJSON]);

return (
<div>
<div key={filePair.idx}>
Expand All @@ -136,6 +143,7 @@ export function CodeDiffContainer(props: CodeDiffContainerProps) {
contentsBefore={contents.before}
contentsAfter={contents.after}
diffOps={contents.diffOps}
isEqualAfterNormalization={!!isEqualAfterNormalization}
/>
) : (
'Loading…'
Expand All @@ -150,6 +158,7 @@ interface FileDiffProps {
contentsBefore: string | null;
contentsAfter: string | null;
diffOps: DiffRange[];
isEqualAfterNormalization: boolean;
}

function extractFilename(path: string) {
Expand All @@ -164,7 +173,7 @@ function lengthOrZero(data: unknown[] | string | null | undefined) {
}

function FileDiff(props: FileDiffProps) {
const {filePair, contentsBefore, contentsAfter, diffOps} = props;
const {filePair, contentsBefore, contentsAfter, diffOps, isEqualAfterNormalization} = props;
const pathBefore = filePair.a;
const pathAfter = filePair.b;
// build the diff view and add it to the current DOM
Expand Down Expand Up @@ -201,7 +210,7 @@ function FileDiff(props: FileDiffProps) {

return (
<div className="diff">
<NoChanges filePair={filePair} />
<NoChanges filePair={filePair} isEqualAfterNormalization={isEqualAfterNormalization} />
<CodeDiff
beforeText={contentsBefore}
afterText={contentsAfter}
Expand Down
Loading