mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-28 01:10:49 +01:00
Add missing change types to diff statistics
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
- type: added
|
||||
description: In diffs, Copied and renamed files are now on display if they are available
|
||||
@@ -87,6 +87,14 @@ public interface DiffResult extends Iterable<DiffFile> {
|
||||
* number of deleted files in a diff
|
||||
*/
|
||||
int deleted;
|
||||
/**
|
||||
* number of renamed files in a diff
|
||||
*/
|
||||
int renamed;
|
||||
/**
|
||||
* number of copy files in a diff
|
||||
*/
|
||||
int copied;
|
||||
}
|
||||
|
||||
@Value
|
||||
|
||||
@@ -196,20 +196,18 @@ public class GitDiffResult implements DiffResult {
|
||||
int addCounter = 0;
|
||||
int modifiedCounter = 0;
|
||||
int deletedCounter = 0;
|
||||
int renameCounter = 0;
|
||||
int copyCounter = 0;
|
||||
for (DiffEntry diffEntry : diffEntries) {
|
||||
switch (diffEntry.getChangeType()) {
|
||||
case ADD:
|
||||
++addCounter;
|
||||
break;
|
||||
case MODIFY:
|
||||
++modifiedCounter;
|
||||
break;
|
||||
case DELETE:
|
||||
++deletedCounter;
|
||||
break;
|
||||
case ADD -> ++addCounter;
|
||||
case MODIFY -> ++modifiedCounter;
|
||||
case DELETE -> ++deletedCounter;
|
||||
case RENAME -> ++renameCounter;
|
||||
case COPY -> ++copyCounter;
|
||||
}
|
||||
}
|
||||
DiffStatistics stats = new DiffStatistics(addCounter, modifiedCounter, deletedCounter);
|
||||
DiffStatistics stats = new DiffStatistics(addCounter, modifiedCounter, deletedCounter,renameCounter,copyCounter);
|
||||
return Optional.of(stats);
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,8 @@ public class GitDiffResultCommandTest extends AbstractGitCommandTestBase {
|
||||
assertThat(diffResult.getStatistics()).get().extracting("deleted").isEqualTo(1);
|
||||
assertThat(diffResult.getStatistics()).get().extracting("modified").isEqualTo(1);
|
||||
assertThat(diffResult.getStatistics()).get().extracting("added").isEqualTo(0);
|
||||
assertThat(diffResult.getStatistics()).get().extracting("renamed").isEqualTo(0);
|
||||
assertThat(diffResult.getStatistics()).get().extracting("copied").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -49,6 +49,23 @@ const DiffStatistics: FC<DiffStatisticsProps> = ({ data }) => {
|
||||
values={{ newFiles: data.added, modified: data.modified, deleted: data.deleted }}
|
||||
components={{ tag: <Tag size={"normal"} rounded={true} className={"mx-1"} /> }}
|
||||
></Trans>
|
||||
{data.renamed > 0 && (
|
||||
<Trans
|
||||
t={t}
|
||||
i18nKey="changesets.showRenamedFiles"
|
||||
values={{ renamed: data.renamed }}
|
||||
components={{ tag: <Tag size={"normal"} rounded={true} className={"mx-1"} /> }}
|
||||
></Trans>
|
||||
)}
|
||||
{data.copied > 0 && (
|
||||
<Trans
|
||||
t={t}
|
||||
i18nKey="changesets.showCopiedFiles"
|
||||
values={{ copied: data.copied }}
|
||||
components={{ tag: <Tag size={"normal"} rounded={true} className={"mx-1"} /> }}
|
||||
></Trans>
|
||||
)}
|
||||
<span className="ml-1">{t("changesets.showFiles")}</span>
|
||||
</DiffStatisticsContainer>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -55,6 +55,8 @@ export type Statistics = {
|
||||
added: number;
|
||||
deleted: number;
|
||||
modified: number;
|
||||
renamed: number;
|
||||
copied: number;
|
||||
};
|
||||
|
||||
export type FileTree = {
|
||||
|
||||
@@ -271,7 +271,10 @@
|
||||
"activateWhitespace": "Whitespace-Änderungen einblenden",
|
||||
"moreDiffsAvailable": "Es sind weitere Diffs verfügbar",
|
||||
"loadMore": "Weitere laden",
|
||||
"showModifiedFiles": "<tag>{{newFiles}}</tag> hinzugefügte, <tag>{{modified}}</tag> geänderte, <tag>{{deleted}}</tag> gelöschte Dateien",
|
||||
"showModifiedFiles": "<tag>{{newFiles}}</tag> hinzugefügte, <tag>{{modified}}</tag> geänderte, <tag>{{deleted}}</tag> gelöschte",
|
||||
"showRenamedFiles": ", <tag>{{renamed}}</tag> umbenannte",
|
||||
"showCopiedFiles": ", <tag>{{copied}}</tag> kopierte",
|
||||
"showFiles": "Dateien",
|
||||
"diffTreeTitle": "Diff-Liste"
|
||||
},
|
||||
"changeset": {
|
||||
|
||||
@@ -272,6 +272,9 @@
|
||||
"moreDiffsAvailable": "There are more diffs available",
|
||||
"loadMore": "Load more",
|
||||
"showModifiedFiles": "<tag>{{newFiles}}</tag> added, <tag>{{modified}}</tag> modified, <tag>{{deleted}}</tag> deleted",
|
||||
"showRenamedFiles": ", <tag>{{renamed}}</tag> renamed",
|
||||
"showCopiedFiles": ", <tag>{{copied}}</tag> copied",
|
||||
"showFiles": "files",
|
||||
"diffTreeTitle": "Diff-List"
|
||||
},
|
||||
"changeset": {
|
||||
|
||||
@@ -81,6 +81,8 @@ public class DiffResultDto extends HalRepresentation {
|
||||
private int added;
|
||||
private int deleted;
|
||||
private int modified;
|
||||
private int renamed;
|
||||
private int copied;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -128,7 +128,9 @@ class DiffResultToDiffResultDtoMapper {
|
||||
DiffResultDto.DiffStatisticsDto diffStatisticsDto = new DiffResultDto.DiffStatisticsDto(
|
||||
diffStatistics.getAdded(),
|
||||
diffStatistics.getDeleted(),
|
||||
diffStatistics.getModified()
|
||||
diffStatistics.getModified(),
|
||||
diffStatistics.getRenamed(),
|
||||
diffStatistics.getCopied()
|
||||
);
|
||||
dto.setStatistics(diffStatisticsDto);
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ class DiffResultToDiffResultDtoMapperTest {
|
||||
@Test
|
||||
void shouldMapStatistics() {
|
||||
DiffResult result = createResult();
|
||||
when(result.getStatistics()).thenReturn(of(new DiffResult.DiffStatistics(1, 2, 3)));
|
||||
when(result.getStatistics()).thenReturn(of(new DiffResult.DiffStatistics(1, 2, 3, 4, 5)));
|
||||
when(result.getDiffTree()).thenReturn(of(DiffResult.DiffTreeNode.createRootNode()));
|
||||
|
||||
DiffResultDto.DiffStatisticsDto dto = mapper.mapForIncoming(REPOSITORY, result, "feature/some", "master").getStatistics();
|
||||
@@ -189,6 +189,8 @@ class DiffResultToDiffResultDtoMapperTest {
|
||||
assertThat(dto.getAdded()).isEqualTo(1);
|
||||
assertThat(dto.getModified()).isEqualTo(2);
|
||||
assertThat(dto.getDeleted()).isEqualTo(3);
|
||||
assertThat(dto.getRenamed()).isEqualTo(4);
|
||||
assertThat(dto.getCopied()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -206,13 +208,13 @@ class DiffResultToDiffResultDtoMapperTest {
|
||||
|
||||
DiffResultDto.DiffTreeNodeDto expectedTree = new DiffResultDto.DiffTreeNodeDto("", Map.of(
|
||||
"a.txt", new DiffResultDto.DiffTreeNodeDto("a.txt", Map.of(), Optional.of(DiffFile.ChangeType.MODIFY)),
|
||||
"b.txt", new DiffResultDto.DiffTreeNodeDto("b.txt", Map.of(),Optional.of(DiffFile.ChangeType.DELETE)),
|
||||
"b.txt", new DiffResultDto.DiffTreeNodeDto("b.txt", Map.of(), Optional.of(DiffFile.ChangeType.DELETE)),
|
||||
"victory", new DiffResultDto.DiffTreeNodeDto("victory", Map.of(
|
||||
"road", new DiffResultDto.DiffTreeNodeDto("road", Map.of(
|
||||
"c.txt", new DiffResultDto.DiffTreeNodeDto("c.txt", Map.of(), Optional.of(DiffFile.ChangeType.ADD)),
|
||||
"d.txt", new DiffResultDto.DiffTreeNodeDto("d.txt", Map.of(), Optional.of(DiffFile.ChangeType.RENAME))
|
||||
),Optional.empty())
|
||||
),Optional.empty()),
|
||||
), Optional.empty())
|
||||
), Optional.empty()),
|
||||
"indigo", new DiffResultDto.DiffTreeNodeDto("indigo", Map.of(
|
||||
"plateau", new DiffResultDto.DiffTreeNodeDto("plateau", Map.of(
|
||||
"e.txt", new DiffResultDto.DiffTreeNodeDto("e.txt", Map.of(), Optional.of(DiffFile.ChangeType.COPY))
|
||||
|
||||
Reference in New Issue
Block a user