Giter Club home page Giter Club logo

diff-rs's People

Contributors

b3rr10 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

diff-rs's Issues

Create unit-tests for printer.rs

Maybe the functions in the printer.rs module could return a String instead of printing the content, so that unit-tests can be added.
The println!(...) method would then be found on the main.rs module.
The idea is to have full code coverage in this module as well.

Parser implementation

Parser analyse a diff content and return a list of files with the changes with line numbers, the modifier marker and so on.

File:

  • commit-id?
  • modifier [modified, added, deleted]
  • filename
  • lines with linenumber

Diff Format

Show 2 columns for line numbers

When printing a diff, one should be able to look the line number of the old as well as the new file. E.g.

1 1 This line is on both files
2   This line is only on the old file
3 2 This line is on both files but in a different "line"
  3 This file is only on the new file

Fix parser for diffs with renamed files

When the diff header is renamed from..., the hunk may not have any header index..., so the parser will fail. One option is to have a default commit_id for those cases...

do_parse!(
    ... >>
    commit_id: opt!(...) >>
    .... >>
    (commit_id.unwrap_or_else(default_value))
)

Add verbosity for debugging

Add the flag -v for verbosity to see debug messages in the console. Maybe we can add 2 or three levels of verbosity (-vv and -vvv) to show different outputs.

Panic: "Error parsing file" if use as git pager

diff_rs panic if you use it as diff-pager in gitconfig:
pager = $PROJECT_DIR/diff.rs/target/release/diff_rs

Backtrace:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Error parsing file. Remaining is not empty. Remaining: \"\\u{1b}[1;33mindex 5ce557a..cd16654 100644\\u{1b}[m\\n\\u{1b}[1;33m--- a/README.md\\u{1b}[m\\n\\u{1b}[1;33m+++ b/README.md\\u{1b}[m\\n\\u{1b}[1;35m@@ -13,7 +13,7 @@\\u{1b}[m \\u{1b}[mA more beautiful and readable diff output for ...\\u{1b}[m\\n Install it in different ways:\\u{1b}[m\\n \\u{1b}[m\\n ```\\u{1b}[m\\n\\u{1b}[1;31m-cargo install diff.rs\\u{1b}[m\\n\\u{1b}[1;32m+\\u{1b}[m\\u{1b}[1;32mcargo install diff_rs\\u{1b}[m\\n ```\\u{1b}[m\\n \\u{1b}[m\\n or directly over github:\\u{1b}[m\\n\""', src/libcore/result.rs:999:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   6: rust_begin_unwind
             at src/libstd/panicking.rs:308
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::result::unwrap_failed
   9: diff_rs::parser::parse_content
  10: diff_rs::main
  11: std::rt::lang_start::{{closure}}
  12: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:293
  13: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:85
  14: std::rt::lang_start_internal
             at src/libstd/panicking.rs:272
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  15: main
  16: __libc_start_main
  17: _start

Error handling

  • All functions should return Result<...>
  • Maybe create an enum for combining error types and be able to propagate errors through the program (Enum with errors that implements From<> for every error type)
  • Replace every unwrap() with ? Example

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.