From 35f28056b606358e4a859f8c020c95a65b3980e3 Mon Sep 17 00:00:00 2001 From: Tom Rathborne Date: Thu, 10 Feb 2022 10:44:04 +0100 Subject: [PATCH] Handle changes involve None versions --- nvchecker/tools.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/nvchecker/tools.py b/nvchecker/tools.py index 8fbbbf0..2e985cb 100644 --- a/nvchecker/tools.py +++ b/nvchecker/tools.py @@ -120,13 +120,24 @@ def cmp() -> None: version = sort_version_keys[args.sort] if version(oldver) > version(newver): # type: ignore - diff['delta'] = 'old' if args.newer: continue # don't store this diff + diff['delta'] = 'old' else: diff['delta'] = 'new' differences.append(diff) + + elif oldver is None: + if args.newer: + continue # don't store this diff + diff['delta'] = 'added' + differences.append(diff) + + elif newver is None: + diff['delta'] = 'gone' + differences.append(diff) + elif args.all: differences.append(diff) @@ -152,6 +163,12 @@ def cmp() -> None: elif delta == 'old': arrow = f'{c.red}<-{c.normal}' oldc = c.red + if delta == 'added': + arrow = '++' + oldc = c.red + elif delta == 'gone': + arrow = f'{c.red}--{c.normal}' + oldc = c.green else: arrow = '==' oldc = c.green