diff mbox series

[yocto-autobuilder-helper] scripts/getproperties.py: Add script to return revision/branch information

Message ID 20250926153936.24324-1-richard.purdie@linuxfoundation.org
State New
Headers show
Series [yocto-autobuilder-helper] scripts/getproperties.py: Add script to return revision/branch information | expand

Commit Message

Richard Purdie Sept. 26, 2025, 3:39 p.m. UTC
Rather than calling git commands directly, put these into a script so that
different branches of the helper can handle returning this information in
different ways and from different sources.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 scripts/getproperties.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100755 scripts/getproperties.py
diff mbox series

Patch

diff --git a/scripts/getproperties.py b/scripts/getproperties.py
new file mode 100755
index 0000000..5f396a9
--- /dev/null
+++ b/scripts/getproperties.py
@@ -0,0 +1,15 @@ 
+#!/usr/bin/env python3
+
+import json
+import subprocess
+import sys
+
+builddir = sys.argv[1]
+
+jsonprops = {}
+jsonprops['yp_build_revision'] =  subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=builddir).decode('utf-8').strip()
+jsonprops['yp_build_branch'] = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=builddir).decode('utf-8').strip()
+
+print(json.dumps(jsonprops, indent=4, sort_keys=True))
+
+