Lazy commit on <function hostname at 0x7f34f8dfcc20>.

This commit is contained in:
James Downie 2025-06-29 20:43:35 +10:00
parent a9aedfe190
commit 1cd8113839

View File

@ -9,6 +9,10 @@ import json
import time
from pathlib import Path
def rm(p):
if os.path.exists(p):
os.remove(p)
def filepath(f):
ret = os.path.join(os.environ.get("XDG_CACHE_HOME"), f"repo.{f}")
return ret
@ -61,13 +65,13 @@ def perform_action(action, key, item, silent = False):
if not silent:
print("{0} {1}...".format(lbl, key))
output = execute_command(cmd)
os.remove(filepath("status"))
rm(filepath("status"))
elif action == "sync":
if not silent:
print("{0} {1}...".format(lbl, key))
perform_action("pull", key, item, silent=True)
perform_action("push", key, item, silent=True)
os.remove(filepath("status"))
rm(filepath("status"))
elif action == "lcs":
if not silent:
print("{0} {1}...".format(lbl, key))
@ -75,7 +79,7 @@ def perform_action(action, key, item, silent = False):
perform_action("lc", key, item, silent=True)
perform_action("pull", key, item, silent=True)
perform_action("push", key, item, silent=True)
os.remove(filepath("status"))
rm(filepath("status"))
elif action == "lc":
cmd = "git -C \"{0}\" status --porcelain".format(os.path.expanduser(item["path"]))
output = execute_command(cmd).split("\n")
@ -85,7 +89,7 @@ def perform_action(action, key, item, silent = False):
output = execute_command(cmd)
cmd = "git -C \"{0}\" commit -m \"Lazy commit on {1}.\"".format(os.path.expanduser(item["path"]), hostname)
output = execute_command(cmd)
os.remove(filepath("status"))
rm(filepath("status"))
return output
if __name__ == "__main__":