From 44193842fd197087441795328c6ae68dcbae8872 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Fri, 22 Jul 2022 12:04:33 +0200 Subject: [PATCH] Update Changeset Signed-off-by: Sebastian Martinez --- .../projects/SourceBrowser/Changeset.svelte | 110 ++++++------------ .../projects/SourceBrowser/FileDiff.svelte | 30 ++++- src/diff.ts | 11 +- 3 files changed, 70 insertions(+), 81 deletions(-) diff --git a/src/base/projects/SourceBrowser/Changeset.svelte b/src/base/projects/SourceBrowser/Changeset.svelte index ab0576656..cafa7b1c7 100644 --- a/src/base/projects/SourceBrowser/Changeset.svelte +++ b/src/base/projects/SourceBrowser/Changeset.svelte @@ -1,19 +1,29 @@
- {#if diff.modified.length > 0} - {diff.modified.length} file(s) changed - with - {stats.additions} addition(s) - and - {stats.deletions} deletion(s) - {/if} + {diffDescription(diff)} + with + {stats.additions} addition(s) + and + {stats.deletions} deletion(s)
-
- {#each diff.created as path (path)} -
-
-

{path}

- created -
-
dispatch("browse", path)}> - -
-
+
+ {#each diff.created as file} + {/each} - {#each diff.deleted as path (path)} -
-
-

{path}

- deleted -
-
dispatch("browse", path)}> - -
-
+ {#each diff.deleted as file} + + {/each} + {#each diff.modified as file} + {/each}
- -{#each diff.modified as file} - -{/each} diff --git a/src/base/projects/SourceBrowser/FileDiff.svelte b/src/base/projects/SourceBrowser/FileDiff.svelte index b818212e9..a1de30721 100644 --- a/src/base/projects/SourceBrowser/FileDiff.svelte +++ b/src/base/projects/SourceBrowser/FileDiff.svelte @@ -7,6 +7,7 @@ const dispatch = createEventDispatcher(); export let file: FileDiff; + export let mode: string | null = null; function collapse() { collapsed = !collapsed; @@ -111,13 +112,38 @@ .browse { display: flex; } + + .created { + color: var(--color-positive); + font-family: var(--font-family-monospace); + font-size: 0.75rem; + background-color: var(--color-positive-1); + } + .deleted { + color: var(--color-negative); + font-family: var(--font-family-monospace); + font-size: 0.75rem; + background-color: var(--color-negative-1); + } + .file-header .diff-type { + margin-left: 1rem; + padding: 0.25rem 0.5rem; + border-radius: var(--border-radius-medium); + }
-
+

{file.path}

+ {#if mode} + + {mode} + + {/if}
dispatch("browse", file.path)}> diff --git a/src/diff.ts b/src/diff.ts index 2b763b1b3..7a6e71c34 100644 --- a/src/diff.ts +++ b/src/diff.ts @@ -70,6 +70,7 @@ export type LineDiff = Addition | Deletion | Context; export interface FileDiff { path: string; diff: Changeset; + eof: EofNewLine | null; } export interface Changeset { @@ -83,9 +84,15 @@ export interface Hunk { } export interface Diff { - created: string[]; - deleted: string[]; + created: FileDiff[]; + deleted: FileDiff[]; moved: string[]; copied: string[]; modified: FileDiff[]; } + +export enum EofNewLine { + OldMissing = "oldMissing", + NewMissing = "newMissing", + BothMissing = "bothMissing", +}