GithubHelp home page GithubHelp logo

dunk's People

Contributors

1ace avatar cmarqu avatar darrenburns 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dunk's Issues

Support wrapping long lines

While we SHOULD be using black to limit the length of our lines, it doesn't mean we do in every project :)

Fails when a project has a dirty submodule

Here is a minimum example the causes the crash:

cd /tmp
mkdir dunk-submodule-fail
cd dunk-submodule-fail
git init
mkdir this-is-submodule
cd this-is-submodule
git init 
echo "test" > myfile.txt && git add --all && git commit -m "initial-sub"
cd ..
# git submodule add ./this-is-submodule # not actually needed.
git add --all && git commit -m "initial-parent"

# have an uncommitted changed file in the submodule
echo "breaking change" > this-is-submodule/myfile.txt

git diff | dunk  

traceback

Traceback (most recent call last):
  File "/home/user/.local/bin/dunk", line 8, in <module>
    sys.exit(main())
  File "/home/user/.local/pipx/venvs/dunk/lib/python3.10/site-packages/dunk/dunk.py", line 119, in main
    target_code = target_file.read_text()
  File "/usr/lib/python3.10/pathlib.py", line 1134, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.10/pathlib.py", line 1119, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
IsADirectoryError: [Errno 21] Is a directory: '/tmp/dunk-submodule-fail/this-is-submodule'

Broken Pipe error when piping a long diff to less and quitting

To reproduce: get a very long diff, pipe the output of dunk to less or another pager, and quit without reading the entire thing.

python -c "print('line\n' * 1000)" > tmp
git add tmp
git diff HEAD | dunk | less -R  # Exit pager without scrolling

# ...
# BrokenPipeError: [Errno 32] Broken pipe

The desired behavior would be to either 1) completely ignore broken pipe errors or 2) catch broken pipe errors and print a one-liner to stderr. I would much prefer the first one.

Thank you so much for the project btw ๐Ÿ˜„

Throws FileNotFoundError for bare repo

When I try to view diff for a bare repo, it throws FileNotFoundError.

To reproduce:

โฏ cd
โฏ git init --bare my_bare_repo
Initialized empty Git repository in /home/***/my_bare_repo/
โฏ alias bare="/usr/bin/git --git-dir=$HOME/my_bare_repo --work-tree=$HOME"
โฏ bare config --local status.showUntrackedFiles no
โฏ mkdir -p ~/.config/test_dir
โฏ touch ~/.config/test_dir/test_file
โฏ bare add ~/.config/test_dir/test_file
โฏ echo hello > ~/.config/test_dir/test_file
โฏ bare diff | dunk
                                                             1 file added
                                                   +1 โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” -0

โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ– Added .config/test_dir/test_file (1 additions, 0 removals) โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–
โ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒ @@ -0,0 +1,1 @@  โ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒโ•ฒ
  1                                                                  1 hello
โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”โ–”
                                                                                                                    /// dunk 0.4.0a0
โฏ cd .config
โฏ bare diff | dunk
                                                             1 file added
                                                   +1 โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” -0

โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ– Added .config/test_dir/test_file (1 additions, 0 removals) โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–โ–
Traceback (most recent call last):
  File "/home/***/.local/bin//dunk", line 8, in <module>
    sys.exit(main())
  File "/home/***/.local/pipx/venvs/dunk/lib/python3.10/site-packages/dunk/dunk.py", line 119, in main
    target_code = target_file.read_text()
  File "/usr/lib/python3.10/pathlib.py", line 1132, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.10/pathlib.py", line 1117, in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
FileNotFoundError: [Errno 2] No such file or directory: '/home/***/.config/.config/test_dir/test_file'

Refactor for use in other Python tools?

This tool looks amazing ๐Ÿคฉ

Any chance of a slight refactor so that I can import it into my tool and use it to render diffs that I already have as strings? At the moment it looks like the stdin is hard-coded..

Stack trace: RuntimeError: generator raised StopIteration

$ pipx install dunk
  installed package dunk 0.4.0a0, installed using Python 3.10.4
  These apps are now globally available
    - dunk
done! โœจ ๐ŸŒŸ โœจ
$ git clone [email protected]:darrenburns/dunk.git
Cloning into 'dunk'...
remote: Enumerating objects: 129, done.
remote: Counting objects: 100% (129/129), done.
remote: Compressing objects: 100% (84/84), done.
remote: Total 129 (delta 52), reused 98 (delta 34), pack-reused 0
Receiving objects: 100% (129/129), 46.59 KiB | 11.65 MiB/s, done.
Resolving deltas: 100% (52/52), done.
$ cd dunk
$ git show 53acb8e | dunk

...lots of normal dunk content...

Traceback (most recent call last):
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/syntax.py", line 458, in tokens_to_spans
    _token_type, token = next(tokens)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/danielh/.local/bin/dunk", line 8, in <module>
    sys.exit(main())
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/dunk/dunk.py", line 352, in main
    source_syntax_lines: List[List[Segment]] = console.render_lines(
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/console.py", line 1334, in render_lines
    lines = list(
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/segment.py", line 291, in split_and_crop_lines
    for segment in segments:
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/console.py", line 1299, in render
    for render_output in iter_render:
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/syntax.py", line 554, in __rich_console__
    text = self.highlight(code, self.line_range)
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/syntax.py", line 470, in highlight
    text.append_tokens(tokens_to_spans())
  File "/Users/danielh/.local/pipx/venvs/dunk/lib/python3.9/site-packages/rich/text.py", line 969, in append_tokens
    for content, style in tokens:
RuntimeError: generator raised StopIteration

Tested on macOS 12.3.1 with python 3.9.12 and ubuntu 22.04 with python 3.10.4, both installed via pipx.

Improved git dunk alias

I would suggest to use

git config --global alias.dunk '!git_dunk() { git diff $* | dunk; }; git_dunk'

instead of the alias in the README as this allows git dunk to be used in the same way as git diff, i.e. it enables git dunk abcde or git dunk abcde 12345

Error in non-root git dir

FileNotFoundError raised when executing git diff | dunk in non-root git dir, It works in root git dir.
image

Colorblind improvements

I'm using iTerm2, and pretty much every color scheme I have available makes it challenging to see the removed lines. Even the screenshot that is currently in the README is quite challenging to see removed lines in.

I think that having preset color schemes that are available via args would be a good way to handle this. EG: git diff | dunk --colors=protanopic or something.

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.