mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-08 16:42:10 +01:00
Fix character encoding in diffs (#2046)
Fixes encodings in diff results. The is especially necessary for Windows systems. Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
2
gradle/changelog/diff_encoding.yaml
Normal file
2
gradle/changelog/diff_encoding.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- type: fixed
|
||||
description: Character encoding in diffs ([#2046](https://github.com/scm-manager/scm-manager/pull/2046))
|
||||
@@ -36,6 +36,7 @@ import sonia.scm.repository.spi.DiffCommandRequest;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Set;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -111,7 +112,7 @@ public final class DiffCommandBuilder extends AbstractDiffCommandBuilder<DiffCom
|
||||
public String getContent() throws IOException {
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
getDiffResult().accept(baos);
|
||||
return baos.toString();
|
||||
return baos.toString(StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import sonia.scm.repository.api.Hunk;
|
||||
import javax.inject.Inject;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -184,7 +185,7 @@ public class GitDiffResultCommand extends AbstractGitCommand implements DiffResu
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); DiffFormatter formatter = new DiffFormatter(baos)) {
|
||||
formatter.setRepository(repository);
|
||||
formatter.format(entry);
|
||||
return baos.toString();
|
||||
return baos.toString(StandardCharsets.UTF_8);
|
||||
} catch (IOException ex) {
|
||||
throw new InternalRepositoryException(GitDiffResultCommand.this.repository, "failed to format diff entry", ex);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
}
|
||||
document.head.appendChild(linkElement);
|
||||
</script>
|
||||
<script id="dacs" src="https://download.digiaccess.org/digiaccess" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
|
||||
Reference in New Issue
Block a user