darrenburns / dunk

Prettier git diffs in the terminal 🎨
745 stars 15 forks source link

Throws FileNotFoundError for bare repo #10

Open sahinakkaya opened 2 years ago

sahinakkaya commented 2 years ago

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'