From 8091be197d04c9e802d4b4956ec6bd6362536738 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Fri, 13 Jan 2023 12:30:22 +0530 Subject: [PATCH] Fixed change and property --- buildbot_transifex/webhook.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/buildbot_transifex/webhook.py b/buildbot_transifex/webhook.py index 2912dbc..6ed87d8 100644 --- a/buildbot_transifex/webhook.py +++ b/buildbot_transifex/webhook.py @@ -66,16 +66,18 @@ class TransifexHandler(BaseHookHandler): def process_translation_completed(self, payload, codebase): changes = [] translated_request = self._transform_variables(payload['project'], payload['resource']) + ts = int(time.time()) change = { - 'author': "buildbot-transifex", + 'author': author, 'branch': translated_request["branch"], + 'branch': translated_request["repository"], 'project': translated_request["project"], 'properties': { "transifex_language": payload.get("language", "None"), "transifex_event": payload.get("event", "None"), "transifex_project": payload.get("project", "None"), "transifex_resource": payload.get("resource", "None"), - "transifex_branch": "v0.6" + "transifex_branch": "translate_" + payload['language'] + "_" + str(ts) } } if codebase is not None: @@ -83,10 +85,10 @@ class TransifexHandler(BaseHookHandler): changes.insert(0, change) return changes - def _transform_variables(self, transifex_project, transifex_resource): + def _transform_variables(self, transifex_project): if transifex_project is None: raise ValueError("Unknown project %s from transifex".format(transifex_project)) - key = "{}/{}".format(transifex_project, transifex_resource) + key = transifex_project _map = self.map[key] repository = _map["repository"] project = re.sub(r'^.*/(.*?)(\.git)?$', r'\1', repository) @@ -122,16 +124,6 @@ class TransifexHandler(BaseHookHandler): request.getHeader(_HEADER_SIGNATURE)) self._verifyTransifexSignature(request, content, rendered_secret, signature, header_signature) event_type = payload.get("event", "None") - - mapped_request = self._transform_variables(payload['project'], payload['resource']) - - change["changes"] = { - "author": author, - "repository": mapped_request["repository"], - "project": mapped_request["project"], - "branch": mapped_request["branch"] - } - log.msg("Received event '{}' from transifex".format(event_type)) codebase = ""