Fix cli.common:diff
This commit is contained in:
parent
a51ff2a877
commit
3beff36d66
@ -6,6 +6,7 @@ from ..store import find_store, Store
|
||||
|
||||
import os
|
||||
import sys
|
||||
from typing import Optional
|
||||
import warnings
|
||||
|
||||
|
||||
@ -38,14 +39,8 @@ def print_diff(
|
||||
hashcolor = Fore.MAGENTA if use_color else ""
|
||||
|
||||
def _print_row(tag: str, entry: fs.FSEntry, level: int) -> None:
|
||||
if len(entry.versions) == 0:
|
||||
print(Fore.RED + "NOVERSIONS" + Style.RESET_ALL + entry.sha256)
|
||||
else:
|
||||
ver = entry.versions[-1]
|
||||
|
||||
relpath = entry.relpath
|
||||
|
||||
# Format relpath using filetype-based colors
|
||||
relpath = entry.relpath
|
||||
dname, fname = os.path.split(relpath)
|
||||
if fname == "": # root directory leads to empty fname here
|
||||
dirstr = filetypecolors["DIR"] + "<root>" + reset
|
||||
@ -53,6 +48,21 @@ def print_diff(
|
||||
dirstr = (
|
||||
(filetypecolors["DIR"] + dname + "/" + reset) if dname != "" else ""
|
||||
)
|
||||
|
||||
if len(entry.versions) == 0:
|
||||
print(
|
||||
Fore.RED
|
||||
+ "NOVERSIONS"
|
||||
+ Style.RESET_ALL
|
||||
+ " "
|
||||
+ ver.sha256
|
||||
+ " "
|
||||
+ dirstr
|
||||
)
|
||||
return
|
||||
else:
|
||||
ver: fs.FSEntryVersion = entry.versions[-1]
|
||||
|
||||
assert ver.filetype is not None
|
||||
fname = filetypecolors.get(str(ver.filetype), "") + fname + reset
|
||||
|
||||
@ -62,7 +72,6 @@ def print_diff(
|
||||
|
||||
relpath = dirstr + fname
|
||||
|
||||
assert entry.sha256 is not None
|
||||
hashchange = (
|
||||
(hashcolor + ver.sha256.hex() + reset + " " + changetags[tag])
|
||||
if show_hashes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user