Giter Club home page Giter Club logo

diffpatch's People

Contributors

covers1624 avatar minidigger avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

diffpatch's Issues

Generates weird diffs where only a removal of the last empty line exists

I am currently using this tool in a project, and since some editors seem to be particularly annoying about messing with trailing newlines even when told not to, a feature like this would be very useful, for clarification if necessary, a trailing newline is a newline at the very end of a file, if this can't be added, a workaround suggestion would be appreciated, i'd implement it myself but this looks very complicated and i'm not sure if i would be able to ๐Ÿ˜…

UnsupportedOperationException due to toPath() call on PipePath

Logfile: https://gist.github.com/Bricktricker/67bbcf61eafe403d240060dfe798874d (from orig. reporter on The Forge Project discord)

if (outputPath.isFile()) {
Path out = outputPath.toPath();

The given lines are the root of the issue here: when OutputPath#isFile() is true, OutputPath#toPath() is called to convert the path into a Path object.
However, this causes an issue when the outputPath variable holds a PipePath: PipePath returns true for #isFile() but throws an UnsupportedOperationException for #toPath() (presumably because you cannot obtain a Path object for pipes). This causes the aforementioned crash via UnsupportedOperationException.

Although there is an if-check present before those lines, which short-circuits when the outputPath is a Pipe, this only returns and stops when the PipePath does not have a ArchiveFormat. If the PipePath does contain an ArchiveFormat, then this if-check passes and it goes straight into the aforementioned currently-crashing code.

if (outputPath.getType().isPipe() && outputPath.getFormat() == null) {
log("Err: Output detected as pipe but no format is specified.");
printHelp();
return new Result<>(-1);
}

The bug was reported via a user using ForgeGradle 4.0.14 and 4.0.15 (with 4.0.14 being the version of ForgeGradle that first switched to DiffPatch). The offending code which causes the issue is this, where a ByteArrayOutputStream with an archive format of ArchiveFormat.ZIP is given as the output path of the PatchOperation
https://github.com/MinecraftForge/ForgeGradle/blob/a74f4b155d3c41f495e4e03398ead9a95ef831f8/src/userdev/java/net/minecraftforge/gradle/userdev/MinecraftUserRepo.java#L1033-L1044

PatchOperation does not handle multiple file removals/deletions

Test Case
Relevant Stack Trace

Description:

if (e.patchedPath == null) {
return e.name.substring(0, e.name.lastIndexOf(".patch"));
} else if (e.patchedPath.startsWith("b/")) {
return e.patchedPath.substring(2);
} else if (e.patchedPath.startsWith(bPrefix)) {
return removeStart(e.patchedPath.substring(bPrefix.length()), "/");
}
return e.patchedPath;

Current logic for a removal patch falls through to e.patchedPath which will always be /dev/null.
Collectors#toMap will then throw an exception due to the duplicated file keys.

One potential solution:
Default to name if the patchedPath is either null or /dev/null
Fixing that causes a secondary issue where the target files are still created with empty contents

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.