bundlewrap/nodes/attributes.py
Franzi 59fd245a3f
add dynamic node attribute for last apply
so we can check if something has changed in the repo since the last
apply
2023-09-01 06:16:09 +02:00

25 lines
602 B
Python

from bundlewrap.utils.ui import io
from bundlewrap.utils.scm import get_rev
from bundlewrap.utils.text import red, bold
@node_attribute
def needs_apply(node):
if node.dummy:
return False
if node.os not in node.OS_FAMILY_UNIX:
return True
try:
applied = node.run(
'cat /var/lib/bundlewrap/last_apply_commit_id',
may_fail=True,
).stdout.decode().strip()
if not applied or applied != get_rev():
return True
except Exception as e:
io.stderr(f'{red("!!!")} {bold(node.name)} {e!r}')
return False