Skip to content

Commit

Permalink
Show content diff for conflicted files (#3522)
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiad200 authored Jun 20, 2022
1 parent 946e3e9 commit a21c0fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 11 additions & 2 deletions webui/src/lib/components/repository/ObjectsDiff.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const ObjectsDiff = ({diffType, repoId, leftRef, rightRef, path}) => {
let right;
switch (diffType) {
case 'changed':
case 'conflict':
left = useAPI(async () => objects.getStat(repoId, leftRef, path),
[repoId, leftRef, path]);
right = useAPI(async () => objects.getStat(repoId, rightRef, path),
Expand All @@ -27,8 +28,6 @@ export const ObjectsDiff = ({diffType, repoId, leftRef, rightRef, path}) => {
left = useAPI(async () => objects.getStat(repoId, leftRef, path),
[repoId, leftRef, path]);
break;
case 'conflict':
return <Error error={"Conflict in " + path + "; fix conflicts and then view content diff."}/>;
default:
return <Error error={"Unsupported diff type " + diffType}/>;
}
Expand Down Expand Up @@ -93,6 +92,8 @@ function validateDiffInput(left, right, diffType) {
case 'removed':
if (!left) return <Error error={"Invalid diff input: left hand-side is missing"}/>;
break;
case 'conflict':
return <Error error={"Conflicting file: both source and destination file were changed"}/>;
default:
return <Error error={"Unknown diff type: " + diffType}/>;
}
Expand All @@ -115,7 +116,13 @@ const DiffSizeReport = ({leftSize, rightSize, diffType}) => {
let size;
switch (diffType) {
case 'changed':
case 'conflict': // conflict will compare left and right. further details: https://github.com/treeverse/lakeFS/issues/3269
size = leftSize - rightSize;
if (size === 0) {
return <div>
<span className="unchanged">identical file size</span>
</div>;
}
if (size < 0) {
size = -size;
label = "added";
Expand All @@ -132,6 +139,8 @@ const DiffSizeReport = ({leftSize, rightSize, diffType}) => {
default:
return <Error error={"Unknown diff type: " + diffType}/>;
}


return <div>
<span className={label}>{label} </span>
<span className={"diff-size"}>{humanSize(size)}</span>
Expand Down
2 changes: 1 addition & 1 deletion webui/src/lib/components/repository/changes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const TreeEntryRow = ({entry, relativeTo = "", leaf = false, dirExpanded,
pathSection = <Link href={onNavigate(entry)}>{pathSection}</Link>
}
const rowActions = []
if (onClickExpandDiff && entry.type !== 'conflict') {
if (onClickExpandDiff) {
rowActions.push(new RowAction(<FileDiffIcon/>, diffExpanded ? "Hide changes" : "Show changes", diffExpanded, onClickExpandDiff))
}
if (!leaf) {
Expand Down
5 changes: 5 additions & 0 deletions webui/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@
font-weight: bold;
}

.table .leaf-entry-row .objects-diff .unchanged {
color: var(--color-fg-conflict);
font-weight: bold;
}

.table .leaf-entry-row .objects-diff .diff-size {
font-weight: bold;
}
Expand Down

0 comments on commit a21c0fc

Please sign in to comment.