Skip to content

Commit

Permalink
[FIXED JENKINS-6203] force UTF-8 when reading change log
Browse files Browse the repository at this point in the history
according to https://www.kernel.org/pub/software/scm/git/docs/git-log.html, git CLI uses UTF-8 by default to produce change log entries, so no impact on git-client.
  • Loading branch information
ndeloof committed Mar 12, 2013
1 parent 18e7998 commit cdf149a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/main/java/hudson/plugins/git/GitChangeLogParser.java
Expand Up @@ -6,8 +6,11 @@

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
Expand All @@ -32,7 +35,7 @@ public GitChangeSetList parse(AbstractBuild build, File changelogFile)

// Parse the log file into GitChangeSet items - each one is a commit

BufferedReader rdr = new BufferedReader(new FileReader(changelogFile));
BufferedReader rdr = new BufferedReader(new InputStreamReader(new FileInputStream(changelogFile), Charset.forName("UTF-8")));

try {
String line;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/git/GitSCM.java
Expand Up @@ -1288,7 +1288,7 @@ private void checkout(GitClient git, ObjectId commit, /* @Nullable */ String bra
private void computeChangeLog(GitClient git, Revision revToBuild, BuildListener listener, BuildData buildData, FilePath changelogFile, BuildChooserContext context) throws IOException, InterruptedException {
int histories = 0;

PrintStream out = new PrintStream(changelogFile.write());
PrintStream out = new PrintStream(changelogFile.write(), false, "UTF-8");
try {
for (Branch b : revToBuild.getBranches()) {
Build lastRevWas = buildChooser.prevBuildForChangelog(b.getName(), buildData, git, context);
Expand Down Expand Up @@ -1323,7 +1323,7 @@ private void computeMergeChangeLog(GitClient git, Revision revToBuild, String re
} else {
int histories = 0;

PrintStream out = new PrintStream(changelogFile.write());
PrintStream out = new PrintStream(changelogFile.write(), false, "UTF-8");
try {
for (Branch b : revToBuild.getBranches()) {
putChangelogDiffs(git, b.getName(), remoteBranch, revToBuild.getSha1().name(), out);
Expand Down

1 comment on commit cdf149a

@oleg-nenashev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of my colleagues has experienced an encoding issue after migration to 2.0 (Windows/msysgit).
Seems it may be related to this commit...

Please sign in to comment.