Skip to content
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

The InMemoryDiffEntry defaults diffs with UTF-8 encoding when a file could be in another encoding e.g. ISO-8859 #4237

Open
natedanner opened this issue Jun 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@natedanner
Copy link
Contributor

How are you running OpenRewrite?

Running through the Moderne SaaS.

Charset hardcoded to UTF_8:

this.oldId = inserter.insert(Constants.OBJ_BLOB, oldSource.getBytes(StandardCharsets.UTF_8)).abbreviate(40);
this.oldMode = oldMode;
this.oldPath = (relativeTo == null ? originalFilePath : relativeTo.relativize(originalFilePath)).toString().replace("\\", "/");
} else {
this.oldId = A_ZERO;
this.oldMode = FileMode.MISSING;
this.oldPath = DEV_NULL;
}
if (filePath != null) {
this.newId = inserter.insert(Constants.OBJ_BLOB, newSource.getBytes(StandardCharsets.UTF_8)).abbreviate(40);
this.newMode = newMode;
this.newPath = (relativeTo == null ? filePath : relativeTo.relativize(filePath)).toString().replace("\\", "/");

Is your project public? If so, can you share a link to it?
https://github.com/openrewrite/rewrite-kubernetes

What is the smallest, simplest way to reproduce the problem?

Related to: https://github.com/moderneinc/moderne-scm/issues/724

Diff this file that is in ISO-8859
openrewrite/rewrite-kubernetes@4ea7936
against the latest https://github.com/openrewrite/rewrite-kubernetes/blob/main/gradlew

This section in particular

  * functions;
#         * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
#           «${var#prefix}», «${var%suffix}», and «$( cmd )»;
#         * compound commands having a testable exit status, especially «case»;
#         * various built-in commands including «command», «set», and «ulimit».

What did you expect to see?

Expected to see a diff based on encoding differences but the dif is empty
e.g.
Screenshot 2024-06-07 at 11 08 38 AM

What did you see instead?

No diff.

@natedanner natedanner added the bug Something isn't working label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant