FriendCode / gittle

Pythonic Git for Humans
Other
732 stars 90 forks source link

No such file or directory when using modified_unstaged_files #100

Open angelandy opened 6 years ago

angelandy commented 6 years ago
print_files('Changes not staged for commit', g.modified_unstaged_files)

File "/usr/local/lib/python2.7/dist-packages/funky/funky.py", line 199, in f func(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/gittle/gittle.py", line 655, in modified_unstaged_files if os.stat(self.abspath(f)).st_mtime > timestamp OSError: [Errno 2] No such file or directory: '

if you delete a files at git . and run g.modified_unstaged_files ,that issue will occur:

source code:

    def modified_unstaged_files(self):
        timestamp = self.last_commit.commit_time
        return [
            f
            for f in self.tracked_files
            if os.stat(self.abspath(f)).st_mtime > timestamp
        ]

os.stat(self.abspath(f)).st_mtime > timestamp will catch exception becasue some file has already delete at that time.