diff options
| author | Daniel Smith <daniel.smith@qt.io> | 2024-07-24 11:03:06 +0200 |
|---|---|---|
| committer | Daniel Smith <daniel.smith@qt.io> | 2024-07-24 11:04:35 +0200 |
| commit | d6752d1912619a52b44dbbe9ef3714386c98a01c (patch) | |
| tree | 0b2400252230dfd6707db2738ebbf83c0b699696 /gerrit_api.py | |
Initial Commit of Qt Binary Size Bot
Task-number: QTQAINFRA-6459
Change-Id: I50887b05bd7f11119092ba284082aacc3062ee19
Diffstat (limited to 'gerrit_api.py')
| -rw-r--r-- | gerrit_api.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gerrit_api.py b/gerrit_api.py new file mode 100644 index 0000000..356e3e6 --- /dev/null +++ b/gerrit_api.py @@ -0,0 +1,28 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +""" Gerrit API wrapper module for Qt purposes """ +from pygerrit2.rest import GerritRestAPI + + +class GerritApiException(Exception): + """ Exception class """ + + +# pylint: disable=R0903 +class GerritApi(): + """ Gerrit API wrapper class for Qt purposes """ + + def __init__(self, gerrit_server) -> None: + self._server_url = 'https://' + gerrit_server + + def get_coin_task_id(self, sha) -> str: + """ Fetches COIN task id from gerrit review comments """ + client = GerritRestAPI(url=self._server_url) + + messages = client.get('changes/' + sha + '/messages') + + for message in messages: + if "Continuous Integration: Passed" in message["message"]: + return message["message"].split("tasks/", 1)[1].split("\n")[0] + + raise GerritApiException(f'Gerrit comment from COIN not found from {messages}') |
