Skip to content

Commit

Permalink
Display changed files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Damnae committed Apr 9, 2024
1 parent df0b73f commit e54becf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
15 changes: 9 additions & 6 deletions src/common/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,18 @@ export interface DataSourceCompareFile

export interface DataSourceCompare
{
AddedFiles: DataSourceCompareFile[]
RemovedFiles: DataSourceCompareFile[]
Added: DataSourceCompareFile[]
Removed: DataSourceCompareFile[]
Changed: DataSourceCompareFile[]
}

export async function retrieveCompare(fromCommit:string, toCommit:string) : Promise<DataSourceCompare>
{
const compare:DataSourceCompare =
{
AddedFiles: [],
RemovedFiles: [],
Added: [],
Removed: [],
Changed:[],
}
await compareProcessTree(compare, fromCommit, toCommit, 'Config/ConfigAbility')
await compareProcessTree(compare, fromCommit, toCommit, 'Config/ConfigGlobalModifier')
Expand All @@ -246,8 +248,9 @@ async function compareProcessTree(compare:DataSourceCompare, fromCommit:string,
const filesTo = to.filter(fileFilter)

const convert = (f:DataSourceTreeItem) => <DataSourceCompareFile>{ Path: `${path}/${f.path}` }
compare.AddedFiles = compare.AddedFiles.concat(filesTo.filter(f => !filesFrom.some(f2 => f.path == f2.path)).map(convert))
compare.RemovedFiles = compare.RemovedFiles.concat(filesFrom.filter(f => !filesTo.some(f2 => f.path == f2.path)).map(convert))
compare.Added = compare.Added.concat(filesTo.filter(f => !filesFrom.some(f2 => f.path == f2.path)).map(convert))
compare.Removed = compare.Removed.concat(filesFrom.filter(f => !filesTo.some(f2 => f.path == f2.path)).map(convert))
compare.Changed = compare.Changed.concat(filesFrom.filter(f => filesTo.some(f2 => f.path == f2.path && f.sha != f2.sha)).map(convert))
}

function getHeaders(accept?:string)
Expand Down
13 changes: 9 additions & 4 deletions src/views/pages/changes/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@
</h2>

<LoadingArea :loading="loading">
<h3>{{ compare.AddedFiles.length }} Added</h3>
<template v-for="file in compare.AddedFiles">
<h3>{{ compare.Added.length }} Added</h3>
<template v-for="file in compare.Added">
<FileItem :commitId="commitId" :file="file" />
</template>

<h3>{{ compare.RemovedFiles.length }} Removed</h3>
<template v-for="file in compare.RemovedFiles">
<h3>{{ compare.Removed.length }} Removed</h3>
<template v-for="file in compare.Removed">
<FileItem :commitId="fromCommitId" :file="file" />
</template>

<h3>{{ compare.Changed.length }} Changed</h3>
<template v-for="file in compare.Changed">
<FileItem :commitId="commitId" :file="file" />
</template>
</LoadingArea>

</template>
Expand Down

0 comments on commit e54becf

Please sign in to comment.