mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-26 16:30:50 +01:00
Add statistics for diffs (added, deleted, modified)
Extend the diff result from the diff command to include modified, added and deleted file count and add DiffStats component to ui-components. Pushed-by: Rene Pfeuffer<rene.pfeuffer@cloudogu.com> Pushed-by: Tarik Gürsoy<tarik.guersoy@cloudogu.com> Co-authored-by: René Pfeuffer<rene.pfeuffer@cloudogu.com> Co-authored-by: Tarik Gürsoy<tarik.guersoy@cloudogu.com>
This commit is contained in:
@@ -28,8 +28,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import de.otto.edison.hal.HalRepresentation;
|
||||
import de.otto.edison.hal.Links;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import sonia.scm.repository.api.DiffResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -44,6 +46,7 @@ public class DiffResultDto extends HalRepresentation {
|
||||
|
||||
private List<FileDto> files;
|
||||
private boolean partial;
|
||||
private DiffStatisticsDto statistics;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@@ -69,6 +72,15 @@ public class DiffResultDto extends HalRepresentation {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@AllArgsConstructor
|
||||
public static class DiffStatisticsDto {
|
||||
private int added;
|
||||
private int deleted;
|
||||
private int modified;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
|
||||
public static class HunkDto {
|
||||
|
||||
@@ -43,9 +43,6 @@ import static de.otto.edison.hal.Link.link;
|
||||
import static de.otto.edison.hal.Link.linkBuilder;
|
||||
import static de.otto.edison.hal.Links.linkingTo;
|
||||
|
||||
/**
|
||||
* TODO conflicts
|
||||
*/
|
||||
class DiffResultToDiffResultDtoMapper {
|
||||
|
||||
private final ResourceLinks resourceLinks;
|
||||
@@ -108,6 +105,16 @@ class DiffResultToDiffResultDtoMapper {
|
||||
files.add(mapFile(file, result, repository, revision));
|
||||
}
|
||||
dto.setFiles(files);
|
||||
Optional<DiffResult.DiffStatistics> statistics = result.getStatistics();
|
||||
if (statistics.isPresent()) {
|
||||
DiffResult.DiffStatistics diffStatistics = statistics.get();
|
||||
DiffResultDto.DiffStatisticsDto diffStatisticsDto = new DiffResultDto.DiffStatisticsDto(
|
||||
diffStatistics.getAdded(),
|
||||
diffStatistics.getDeleted(),
|
||||
diffStatistics.getModified()
|
||||
);
|
||||
dto.setStatistics(diffStatisticsDto);
|
||||
}
|
||||
dto.setPartial(result.isPartial());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user