Merge branch 'main' of ssh://git.homelabbrisbane.com.au:2222/jdownie/shed
This commit is contained in:
commit
a86c1b6f70
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
BIN
jdownie/logo/beakerSquare.png
Normal file
BIN
jdownie/logo/beakerSquare.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
@ -43,7 +43,7 @@ def to_keycap(ch: str) -> str:
|
|||||||
|
|
||||||
def indicators(props, ind = "tl"):
|
def indicators(props, ind = "tl"):
|
||||||
tl = "\U0001F7E2"
|
tl = "\U0001F7E2"
|
||||||
if props["ab"]["push"] + props["ab"]["pull"] > 0:
|
if "ab" in props.keys() and ( props["ab"]["push"] + props["ab"]["pull"] > 0 ):
|
||||||
tl = "\U0001F7E1"
|
tl = "\U0001F7E1"
|
||||||
if props["n"] > 0:
|
if props["n"] > 0:
|
||||||
tl = "\U0001F534"
|
tl = "\U0001F534"
|
||||||
@ -52,10 +52,15 @@ def indicators(props, ind = "tl"):
|
|||||||
down_keycap = "\U0001F53D" # "\u2B07\uFE0F"
|
down_keycap = "\U0001F53D" # "\u2B07\uFE0F"
|
||||||
status_digit = "#" if props["n"] > 9 else str(props["n"] % 10)
|
status_digit = "#" if props["n"] > 9 else str(props["n"] % 10)
|
||||||
status_indicator = f"{to_keycap(status_digit)}{unstaged}"
|
status_indicator = f"{to_keycap(status_digit)}{unstaged}"
|
||||||
push_digit = "#" if props["ab"]["push"] > 9 else str(props["ab"]["push"] % 10)
|
push_digit = "?"
|
||||||
push_indicator = f"{to_keycap(push_digit)}{up_keycap}"
|
push_indicator = " "
|
||||||
pull_digit = "#" if props["ab"]["pull"] > 9 else str(props["ab"]["pull"] % 10)
|
pull_digit = "?"
|
||||||
pull_indicator = f"{to_keycap(pull_digit)}{down_keycap}"
|
pull_indicator = " "
|
||||||
|
if "ab" in props.keys():
|
||||||
|
push_digit = "#" if props["ab"]["push"] > 9 else str(props["ab"]["push"] % 10)
|
||||||
|
push_indicator = f"{to_keycap(push_digit)}{up_keycap}"
|
||||||
|
pull_digit = "#" if props["ab"]["pull"] > 9 else str(props["ab"]["pull"] % 10)
|
||||||
|
pull_indicator = f"{to_keycap(pull_digit)}{down_keycap}"
|
||||||
ret = "?"
|
ret = "?"
|
||||||
if ind == "tl":
|
if ind == "tl":
|
||||||
ret = f"{tl}"
|
ret = f"{tl}"
|
||||||
@ -119,6 +124,7 @@ def isFossil(cfg):
|
|||||||
|
|
||||||
def perform_action(action, key, item, silent = False):
|
def perform_action(action, key, item, silent = False):
|
||||||
output = None
|
output = None
|
||||||
|
hn = hostname()
|
||||||
lbl = "{0}ing".format(action).title()
|
lbl = "{0}ing".format(action).title()
|
||||||
if os.path.exists(os.path.expanduser(item["path"])):
|
if os.path.exists(os.path.expanduser(item["path"])):
|
||||||
if action in list([ "pull", "push", "fetch" ]):
|
if action in list([ "pull", "push", "fetch" ]):
|
||||||
@ -157,7 +163,7 @@ def perform_action(action, key, item, silent = False):
|
|||||||
cwd = Path(os.path.expanduser(item["path"]))
|
cwd = Path(os.path.expanduser(item["path"]))
|
||||||
cmd = f"fossil addremove ."
|
cmd = f"fossil addremove ."
|
||||||
output = execute_command(cmd, cwd=cwd)
|
output = execute_command(cmd, cwd=cwd)
|
||||||
cmd = f"fossil commit -m \"Lazy commit on {hostname}\""
|
cmd = f"fossil commit -m \"Lazy commit on {hn}\""
|
||||||
output = execute_command(cmd, cwd=cwd)
|
output = execute_command(cmd, cwd=cwd)
|
||||||
else:
|
else:
|
||||||
cmd = "git -C \"{0}\" status --porcelain".format(os.path.expanduser(item["path"]))
|
cmd = "git -C \"{0}\" status --porcelain".format(os.path.expanduser(item["path"]))
|
||||||
@ -166,7 +172,7 @@ def perform_action(action, key, item, silent = False):
|
|||||||
print("Lazy committing {0}...".format(key))
|
print("Lazy committing {0}...".format(key))
|
||||||
cmd = "git -C \"{0}\" add .".format(os.path.expanduser(item["path"]))
|
cmd = "git -C \"{0}\" add .".format(os.path.expanduser(item["path"]))
|
||||||
output = execute_command(cmd)
|
output = execute_command(cmd)
|
||||||
cmd = "git -C \"{0}\" commit -m \"Lazy commit on {1}.\"".format(os.path.expanduser(item["path"]), hostname)
|
cmd = "git -C \"{0}\" commit -m \"Lazy commit on {1}.\"".format(os.path.expanduser(item["path"]), hn)
|
||||||
output = execute_command(cmd)
|
output = execute_command(cmd)
|
||||||
rm(filepath("status"))
|
rm(filepath("status"))
|
||||||
return output
|
return output
|
||||||
@ -207,17 +213,20 @@ if __name__ == "__main__":
|
|||||||
path = os.path.expanduser( cfg[k]["path"] )
|
path = os.path.expanduser( cfg[k]["path"] )
|
||||||
if os.path.exists( path ):
|
if os.path.exists( path ):
|
||||||
n = 0
|
n = 0
|
||||||
|
props = dict()
|
||||||
|
props["key"] = k
|
||||||
if isFossil(cfg[k]):
|
if isFossil(cfg[k]):
|
||||||
cwd = os.path.expanduser(cfg[k]["path"])
|
cwd = os.path.expanduser(cfg[k]["path"])
|
||||||
cmd = "fossil json status"
|
cmd = "fossil json status"
|
||||||
output = json.loads(execute_command(cmd))
|
output = json.loads(execute_command(cmd, cwd=cwd))
|
||||||
n = len(output["payload"]["files"])
|
n = len(output["payload"]["files"])
|
||||||
cmd = "fossil extras"
|
cmd = "fossil extras"
|
||||||
n = n + len(execute_command(cmd).split("\n"))
|
lines = execute_command(cmd, cwd=cwd).split("\n")
|
||||||
|
for line in lines:
|
||||||
|
if len(line.strip()) > 0:
|
||||||
|
n = n + 1
|
||||||
else:
|
else:
|
||||||
cmd = "git -C \"{0}\" status --porcelain=2 --branch".format( path )
|
cmd = "git -C \"{0}\" status --porcelain=2 --branch".format( path )
|
||||||
props = dict()
|
|
||||||
props["key"] = k
|
|
||||||
lines = execute_command(cmd).split("\n")
|
lines = execute_command(cmd).split("\n")
|
||||||
for line in lines:
|
for line in lines:
|
||||||
m = re.match(r"# branch\.(\S+)\s+(.+)$", line)
|
m = re.match(r"# branch\.(\S+)\s+(.+)$", line)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user