From a0df94855cd9622e37f5e6df0281f9fddcab207a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 15 Dec 2023 18:43:14 +0100 Subject: [PATCH 1/2] adapt_sync_labels_to_gh_changes initial --- .github/sync_labels.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/sync_labels.py b/.github/sync_labels.py index 97ddf039a16..13802cb48bd 100755 --- a/.github/sync_labels.py +++ b/.github/sync_labels.py @@ -141,6 +141,7 @@ def __init__(self, url, actor): self._commits = None self._commit_date = None self._bot_login = None + self._gh_version = None s = url.split('/') self._owner = s[3] @@ -235,13 +236,30 @@ def bot_login(self): """ if self._bot_login: return self._bot_login - cmd = 'gh auth status' from subprocess import run + cmd = 'gh version' + capt = run(cmd, shell=True, capture_output=True) + self._gh_version = str(capt.stdout).split('\\n')[0] + info('version: %s' % self._gh_version) + cmd = 'gh auth status' capt = run(cmd, shell=True, capture_output=True) - l = str(capt.stderr).split() - if not 'as' in l: - l = str(capt.stdout).split() - self._bot_login = l[l.index('as')+1] + errtxt = str(capt.stderr) + outtxt = str(capt.stdout) + debug('auth status err: %s' % errtxt) + debug('auth status out: %s' % outtxt) + def read_login(txt, position_mark): + for t in txt: + for p in position_mark: + # the output text has changed from as to account + # around version 2.40.0 + l = t.split() + if p in l: + return l[l.index(p)+1] + self._bot_login = read_login([errtxt, outtxt], ['account', 'as']) + if not self._bot_login: + self._bot_login = default_bot + info('Bot is unknown') + return self._bot_login if self._bot_login.endswith('[bot]'): self._bot_login = self._bot_login.split('[bot]')[0] info('Bot is %s' % self._bot_login) From a032c79142af4286edd5912d31ff2114fab0d213 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 15 Dec 2023 19:46:15 +0100 Subject: [PATCH 2/2] 36894: info('Bot is unknown') -> warning --- .github/sync_labels.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/sync_labels.py b/.github/sync_labels.py index 13802cb48bd..dbd8566c517 100755 --- a/.github/sync_labels.py +++ b/.github/sync_labels.py @@ -258,7 +258,7 @@ def read_login(txt, position_mark): self._bot_login = read_login([errtxt, outtxt], ['account', 'as']) if not self._bot_login: self._bot_login = default_bot - info('Bot is unknown') + warning('Bot is unknown') return self._bot_login if self._bot_login.endswith('[bot]'): self._bot_login = self._bot_login.split('[bot]')[0]