Skip to content

ISSUE #1375 - Improve svn provider english outputs#1376

Open
belingueres wants to merge 2 commits into
apache:masterfrom
belingueres:ISSUE-1375
Open

ISSUE #1375 - Improve svn provider english outputs#1376
belingueres wants to merge 2 commits into
apache:masterfrom
belingueres:ISSUE-1375

Conversation

@belingueres

Copy link
Copy Markdown

Force unset the LC_ALL env var in SvnCommandLineUtils class.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses ISSUE #1375 by normalizing the locale-related environment used for svn command execution in the svnexe provider, aiming to make command outputs more consistently parseable regardless of the user/system locale.

Changes:

  • Add a CommandlineFactory hook to allow tests to intercept Commandline creation.
  • Update getBaseSvnCommandLine(...) to unset LC_ALL and set LC_MESSAGES to C.
  • Add a unit test to verify the intended locale environment variables are applied.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java Adds a configurable Commandline factory and applies locale environment normalization for SVN command lines.
maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtilsTest.java Adds a test that injects a custom Commandline to assert LC_ALL/LC_MESSAGES are set as expected.
Comments suppressed due to low confidence (1)

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java:121

  • The locale env vars are set inside the same try/catch as addSystemEnvironment(). If addSystemEnvironment() throws, the catch block will skip setting LC_ALL/LC_MESSAGES, which undermines the purpose of this change (locale normalization). Set LC_* outside the try/catch so they’re applied even when system env cannot be loaded.
        try {
            cl.addSystemEnvironment();
            // ISSUE-1375: ensure that LC_ALL is unset to avoid locale issues with svn command output parsing
            // (setting just LC_ALL=C goes too far, since it would imply that LC_CTYPE=C, which would cause
            // svn to output non-ASCII chars in an unreadable way.)
            cl.addEnvironment("LC_ALL", "");
            cl.addEnvironment("LC_MESSAGES", "C");
        } catch (Exception e) {
            // Do nothing
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 114 to 118
// ISSUE-1375: ensure that LC_ALL is unset to avoid locale issues with svn command output parsing
// (setting just LC_ALL=C goes too far, since it would imply that LC_CTYPE=C, which would cause
// svn to output non-ASCII chars in an unreadable way.)
cl.addEnvironment("LC_ALL", "");
cl.addEnvironment("LC_MESSAGES", "C");
Comment on lines +78 to +80
public static void setCommandlineFactory(CommandlineFactory factory) {
commandlineFactory = (factory != null) ? factory : DEFAULT_FACTORY;
}
Comment on lines +64 to +66
* Active factory. Replaced only in tests; never {@code null}.
*/
private static CommandlineFactory commandlineFactory = DEFAULT_FACTORY;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The factory is meant just for testing. Not really to be used in multi-threaded executions.

Comment on lines +143 to +146
// ISSUE-1375: ensure that LC_ALL is unset and LC_MESSAGES is set to C to avoid locale issues with svn command
// output parsing
void testGetBaseSvnCommandLineLcAllIsSetToC() throws Exception {
Map<String, String> capturedEnvVarsMap = new HashMap<String, String>();
Comment on lines +53 to +56
@FunctionalInterface
public interface CommandlineFactory {
Commandline create();
}

@kwin kwin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @belingueres, can you look at the comments from Copilot?

@belingueres

Copy link
Copy Markdown
Author

@kwin do you want me to squash the new commit?

@kwin

kwin commented Jun 9, 2026

Copy link
Copy Markdown
Member

No need to squash, I can do during merge.

Force unset the LC_ALL env var in SvnCommandLineUtils class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants