feat: endpoint customnode/installed is added

This commit is contained in:
Dr.Lt.Data
2024-12-19 18:13:10 +09:00
parent 95ee037a44
commit 9b5adfeb2c
2 changed files with 46 additions and 0 deletions

View File

@@ -308,6 +308,25 @@ class ManagedResult:
return self
def get_commit_hash(fullpath):
git_head = os.path.join(fullpath, '.git', 'HEAD')
if os.path.exists(git_head):
with open(git_head) as f:
line = f.readline()
if line.startswith("ref: "):
ref = os.path.join(fullpath, '.git', line[5:].strip())
if os.path.exists(ref):
with open(ref) as f2:
return f2.readline().strip()
else:
return "unknown"
else:
return line
return "unknown"
class UnifiedManager:
def __init__(self):
self.cnr_inactive_nodes = {} # node_id -> node_version -> fullpath