import typer import cson import os import sys import shutil diff = typer.Typer(name="diff") @diff.command() def cmp(shallow: bool = typer.Option(True, "-s", "--shallow")): """ Compare Active Working Directory and latest commit on the same branch """ ignore = [".sing"] if os.path.isfile(".signore"): ignore.extend(open(".signore").readlines()) config = cson.load(open(os.path.join(".sing", "system", "branchcf.cson"))) masterb = config["current_branch"] if shallow: for i in os.listdir(os.path.join(".sing", "branches", masterb)): if not os.path.exists(i) and not i in ignore: print(f"- {i}") else: if not i in ignore: if shutil.disk_usage( os.path.join(".sing", "branches", masterb, i) ) > shutil.disk_usage(i): print(f"+++ {i}") elif shutil.disk_usage( os.path.join(".sing", "branches", masterb, i) ) < shutil.disk_usage(i): print(f"--- {i}") else: print(f"=== {i}") for i in os.listdir(): if ( not os.path.exists(os.path.join(".sing", "branches", masterb, i)) and not i in ignore ): print(f"+ {i}")