Closed dpc closed 5 years ago
Sure. The scope of the library will probably be the following:
Compare two tokenized slices of bytes (struct Tokenization
) and emit the set of shared tokens (struct Snake
) in the longest common subsequence of the two slices (the function diff
).
The user of the library will have to
As diffr only consumes bytes (actually a stream of hunks), I think that directory diff is out of scope for this (but should not be that painful to add).
Plus, because nothing is text-specific at the moment, I do not intend to introduce anything in that direction (people commit non-utf8 code all the time, we should not be bound to it).
Can you think of anything else that could be extracted to library code?
I'm totally ignorant about diff
ing. All I know is just how to look at the diff output and annoy other developers but pointing out all the tiny unimportant mundane mistakes they made.
About the scope: if you think something shouldn't be in the scope of diffr
that's all fine. But please point potential users to other crates that might play well together with diffr
by implementing the other bits. :)
You probably want something to walk a directory tree to find the changed files (something like walkdir) and once you know the set of changed files, code from this repository should generate the diff data for you.
For additional information about diffs in general, the Myers algorithm linked on the README will contain all that you need. I will add comments as I extract some code to a lib crate as well.
Hi @dpc,
I published diffr-lib with reusable bits from diffr.
Let me know if there is anything I can do to help you improve cargo-crev
:)
I'll get to this eventually. I think we can close this for now. Thanks a lot!
In upcoming release
cargo-crev
will havecargo crev diff
command. Underneath it callsdiff -r <src> <dst>
on two directories. I was thinking ... "I'll start with this, and switch to some library later". And now I see reddit post aboutdiffr
. :)Anyway... Please split this crate in two (or more) parts: one binary and library. This way I can just import it, and not rely on
diff
binary (plus the better formatting, nice!). If you had some examples / other crates for actually generatingdiff
between directories, that would be awesome too.