Git Product home page Git Product logo

dir-diff's People

Contributors

aochagavia avatar byron avatar dependabot-preview[bot] avatar epage avatar killercup avatar nastevens avatar peter-kehl avatar renovate[bot] avatar steveklabnik avatar wiktor-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dir-diff's Issues

0.3.0 is not available on cargo

dir-diff version: 0.3.0
rust version: 1.25.0-nightly
OS: Linux


The latest version on Cargo is 0.3.0, but it's apparently not available. I'm not sure what to do about it, but maybe it was unpublished / something went wrong when deploying? 0.2.0 installs fine.

Maybe releasing a 0.4.0 might work so the latest version on cargo points to a valid release?

More detailed error reporting

I've got my own home grown tool for diffing directories but I'd much have a reusable crate.

API Ideas:

  • Enum of LeftExists, RightExists, BothExist(Option<Difference>)
  • diff_dir_list(path, path) provides an iterator of (path, enum(None))
    • doesn't do content diffing allowing people to do custom solutions for #6
  • diff_dir(path, path) provides an iterator of (path, enum)
    • Take advantage of difference like [assert_cli](
  • assert_dir_eq!
    • provides a default policy for failing (whether it be panic on first failure or summarize the all differences)

Line-ending-agnostic diff

From https://github.com/azerupi/mdBook/pull/237#issuecomment-294225041:

Ahh, line endings are the issue here.... I made this PR on Windows, so windows stuff succeeds, but linux stuff fails. Hrm.

..... I am not sure how to fix this, given that if I change it the other way, it will fail on Windows. Hrm.

Ideas:

  • call lines() on the files and compare over the lines?
  • shell out to diff and use --strip-trailing-cr (idk the windows equivalent though)

and this should probably also be an option, not the default?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Status Checks

These updates await pending status checks. To force their creation now, click the checkbox below.

  • chore(deps): update msrv to v1.75

Detected dependencies

cargo
Cargo.toml
  • walkdir 2.0.1
github-actions
.github/workflows/audit.yml
  • actions/checkout v4
  • actions-rs/audit-check v1
  • actions/checkout v4
  • EmbarkStudios/cargo-deny-action v1
.github/workflows/ci.yml
  • actions/checkout v4
  • Swatinem/rust-cache v2
  • actions/checkout v4
  • Swatinem/rust-cache v2
  • actions/checkout v4
  • Swatinem/rust-cache v2
  • actions/checkout v4
  • Swatinem/rust-cache v2
  • actions/checkout v4
  • Swatinem/rust-cache v2
  • actions/checkout v4
  • Swatinem/rust-cache v2
  • github/codeql-action v3
.github/workflows/committed.yml
  • actions/checkout v4
.github/workflows/pre-commit.yml
  • actions/checkout v4
  • actions/setup-python v5
  • pre-commit/action v3.0.0
.github/workflows/rust-next.yml
  • actions/checkout v4
  • Swatinem/rust-cache v2
  • actions/checkout v4
  • Swatinem/rust-cache v2
.github/workflows/spelling.yml
  • actions/checkout v4
regex
.clippy.toml
  • rust 1.66
.github/workflows/ci.yml
  • rust 1.66
  • rust 1.66
  • rust 1.66
Cargo.toml
  • rust 1.66

  • Check this box to trigger a request for Renovate to run again on this repository

Will fail on large files

The code below loads both files completely into memory before comparing. For files that differ early that can be quite wasteful and it can also result in out of memory errors.

// file a is guaranteed to exist...
let a_text = read_to_vec(a)?;

// but file b is not. If we have any kind of error when loading
// it up, that's a positive result, not an actual error.
let b_text = match read_to_vec(b) {
    Ok(contents) => contents,
    Err(_) => return Ok(true),
};

if a_text != b_text {
    return Ok(true);
}

I'd propose something like

let a_reader = BufReader::new( File::open(a)? );
let b_reader = match File::open(a) {
    Ok(f) => BufReader::new(f),
    Err(_) => return Ok(true),
}

if a_reader.bytes().ne( b_reader.bytes() ) {
    return Ok(true)
}

for similar functionality. The above won't compile when I'm reading the docs right, because the Bytes iterator returns Result<u8, io::Error> and io::Error doesn't implement PartialEq but one should be able to manually iterate in lockstep like so

let mut a_bytes = a_reader.bytes();
let mut b_bytes = b_reader.bytes();
loop {
    match (a_bytes().next(), b_bytes().next()) {
        (Some(Ok(a)), Some(Ok(b))) => if a != b { return Ok(true) },
        (None, None) => break,
        _ => return Ok(true),
    }
}

Now, you're also treating any kind of error as if that would indicate a difference in the folders but there's so much that can go wrong in the world that you can't really make that decision. It's certainly true for FileNotFound but what about some network storage that loses connection for example?
I don't know how much of that ugly mess you're willing to deal with of course.

Note: All code untested. I'm not at a full fledged PC at the moment

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.