Skip to content

Always set locale to english when running git #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions java/com/google/copybara/git/GitEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public GitEnvironment(Map<String, String> environment) {

public ImmutableMap<String, String> getEnvironment() {
Map<String, String> env = Maps.newHashMap(environment);

// Explicitly set output language to english so parsing of git's output
// succeeds independently of users default locale.
env.put("LANG", "en_US.UTF-8");

if (noGitPrompt) {
env.put("GIT_TERMINAL_PROMPT", "0");
}
Expand Down
2 changes: 1 addition & 1 deletion javatests/com/google/copybara/git/GitEnvironmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class GitEnvironmentTest {

private static final Map<String, String> environment =
ImmutableMap.<String, String>builder().put("FOO", "123").put("BAR", "456").build();
ImmutableMap.<String, String>builder().put("FOO", "123").put("BAR", "456").put("LANG", "en_US.UTF-8").build();

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is not testing the feature, right? Could you add a test case that fails without the fix and passes with it?

Thanks!!

@Test
public void testEnvironmentReturned() {
Expand Down