From 382e5e98991ffc732458da1b75e129e081787c19 Mon Sep 17 00:00:00 2001 From: Nikolay Yurin Date: Tue, 1 Aug 2023 02:23:16 -0700 Subject: [PATCH] src/send_kcidb.py: Extract patchset hash from patchwork metadata Signed-off-by: Nikolay Yurin --- src/send_kcidb.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/send_kcidb.py b/src/send_kcidb.py index de0986994..f70de65ae 100755 --- a/src/send_kcidb.py +++ b/src/send_kcidb.py @@ -57,6 +57,16 @@ def _set_timezone(created_timestamp): created_time.timestamp(), tz=tz_utc) return created_time.isoformat() + def _get_patchset_hash(node_data): + if not node_data: + return "" + + if patchwork_metadata := node_data.get('patchwork'): + if patchwork_metadata['version'] == 1: + return patchwork_metadata['payload']['patches'][0]['hash'] + + return "" + def _run(self, context): self.log.info("Listening for events... ") self.log.info("Press Ctrl-C to stop.") @@ -76,7 +86,7 @@ def _run(self, context): 'git_commit_hash': node['revision']['commit'], 'git_repository_branch': node['revision']['branch'], 'start_time': self._set_timezone(node['created']), - 'patchset_hash': '', + 'patchset_hash': self._get_patchset_hash(node.get('data')), 'misc': { 'submitted_by': 'kernelci-pipeline' },