From 266fb7825b5a3aecc62fc448c60aab8bcd01c5fb Mon Sep 17 00:00:00 2001
From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com>
Date: Tue, 27 Feb 2024 09:58:29 -0800
Subject: [PATCH] PTFE-1380 toggable list of options/commands to init message
(#164)
---
CHANGELOG | 4 ++++
bert_e/templates/init.md | 26 ++++++++++++++++++++++++
bert_e/tests/test_bert_e.py | 11 ++++++++++
bert_e/workflow/gitwaterflow/__init__.py | 3 ++-
4 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index a9edbd29..6f6615e1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.
+## [3.12.0] - 2024-02-26
+# Added
+- Add toggable list of options and commands to init message.
+
## [3.11.0] - 2024-01-26
# Added
- Support of merging a PR and skip the queue when it is not needed.
diff --git a/bert_e/templates/init.md b/bert_e/templates/init.md
index cdba2093..85ced5fc 100644
--- a/bert_e/templates/init.md
+++ b/bert_e/templates/init.md
@@ -16,5 +16,31 @@ I have created below the minimum set of tasks expected to be performed during
this review.
{% endif%}
+
+{% if options %}
+
+ Available options
+
+ name | description | privileged | authored
+ ------ | ------------ | ------------ |----------
+ {% for option in options -%}
+ `/{{option}}` | {{options[option].help}} | {% if options[option].privileged %} :star: {% endif %} | {% if options[option].authored %} :writing_hand: {% endif %}
+ {% endfor %}
+
+
+{% endif %}
+
+{% if commands %}
+
+ Available commands
+
+ name | description | privileged
+ ------ | ------------ | ------------
+ {% for cmd in commands -%}
+ `/{{cmd}}` | {{commands[cmd].help}} | {% if commands[cmd].privileged %} :star: {% endif %}
+ {% endfor %}
+
+{% endif %}
+
{% include 'status_report.md' %}
{% endblock %}
diff --git a/bert_e/tests/test_bert_e.py b/bert_e/tests/test_bert_e.py
index 44d4e616..af2a8dbc 100644
--- a/bert_e/tests/test_bert_e.py
+++ b/bert_e/tests/test_bert_e.py
@@ -4925,6 +4925,17 @@ def test_dependabot_pr(self):
backtrace=True
)
+ def test_init_message(self):
+ pr = self.create_pr('bugfix/TEST-00001', 'development/4.3')
+ self.handle(pr.id)
+ init_message = pr.comments[0].text
+ assert f"Hello {pr.author}" in init_message
+ # Assert init message the list of options
+ for option in self.bypass_all:
+ assert option in init_message
+ for command in ['help', 'reset']:
+ assert command in init_message
+
class TestQueueing(RepositoryTests):
"""Tests which validate all things related to the merge queue.
diff --git a/bert_e/workflow/gitwaterflow/__init__.py b/bert_e/workflow/gitwaterflow/__init__.py
index 7056f593..d4ec7fed 100644
--- a/bert_e/workflow/gitwaterflow/__init__.py
+++ b/bert_e/workflow/gitwaterflow/__init__.py
@@ -277,7 +277,8 @@ def send_greetings(job):
job.settings, job.pull_request, messages.InitMessage(
bert_e=username, author=job.pull_request.author_display_name,
status={}, active_options=job.active_options, tasks=tasks,
- frontend_url=job.bert_e.settings.frontend_url
+ frontend_url=job.bert_e.settings.frontend_url,
+ options=Reactor.get_options(), commands=Reactor.get_commands()
)
)