Gitea labels are now passed with both names and IDs to more easily support services that use one or the other.

This commit is contained in:
Jamie Greunbaum 2024-05-31 23:40:15 -04:00
parent d4d59c957c
commit d763eb48fe
3 changed files with 45 additions and 29 deletions

View File

@ -77,7 +77,7 @@ func __prepare_form_thread(callback:Callable) -> void:
assert(http_client.get_status() == HTTPClient.STATUS_BODY or http_client.get_status() == HTTPClient.STATUS_CONNECTED)
var response_string : String = __get_http_client_chunk_response(http_client)
var response_data := JSON.parse_string(response_string)
var response_data : Variant = JSON.parse_string(response_string)
if __validate_server_response(response_data) != Error.OK:
return
@ -140,18 +140,27 @@ func __send_form_data_thread(data:Dictionary, map_name:String, bug_position:Vect
for label_in:Dictionary in response_data:
if label_in["name"] == bug_label or label_in["name"] == status_label:
labels.append(label_in["id"])
(data["labels"] as Array).append_array(labels)
if data["labels"].has("version"): labels.append(data["labels"]["version"]["id"])
if data["labels"].has("hardware"): labels.append(data["labels"]["hardware"]["id"])
if data["labels"].has("os"): labels.append(data["labels"]["os"]["id"])
if data["labels"].has("component"): labels.append(data["labels"]["component"]["id"])
if data["labels"].has("severity"): labels.append(data["labels"]["severity"]["id"])
var marker_data : Dictionary = {
"map_name": map_name,
"bug_position": [bug_position.x, bug_position.y, bug_position.z],
"bug_normal": [bug_normal.x, bug_normal.y, bug_normal.z]
}
data["body"] += "\n\n" + JSON.stringify(marker_data, "", false)
var post_data : Dictionary = {
"title": data["title"],
"body": data["body"] + "\n\n" + JSON.stringify(marker_data, "", false),
"labels": labels
}
# Post issue to Gitea
api_url = __build_url_string("issues")
var post_data_string : String = JSON.stringify(data)
var post_data_string : String = JSON.stringify(post_data)
header_data = __create_header_data(post_data_string.length())
error = http_client.request(HTTPClient.METHOD_POST, api_url, header_data, post_data_string)
assert(error == Error.OK)

View File

@ -94,12 +94,16 @@ func _on_submit_button_pressed() -> void:
__description_label.remove_theme_color_override("font_color")
__description_text.remove_theme_color_override("font_color")
var labels_to_be_added : Array
var version_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.VERSION, __version_label, __version_button)
var hardware_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.HARDWARE, __hardware_label, __hardware_button)
var os_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.OS, __os_label, __os_button)
var component_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.COMPONENT, __component_label, __component_button)
var severity_error : bool = !__get_label_ids_for_submission_data(labels_to_be_added, BugbotServerAPI.BugbotTagArray.SEVERITY, __severity_label, __severity_button)
var version_tags : Array = []
var hardware_tags : Array = []
var os_tags : Array = []
var component_tags : Array = []
var severity_tags : Array = []
var version_error : bool = !__get_label_ids_for_submission_data(version_tags, BugbotServerAPI.BugbotTagArray.VERSION, __version_label, __version_button)
var hardware_error : bool = !__get_label_ids_for_submission_data(hardware_tags, BugbotServerAPI.BugbotTagArray.HARDWARE, __hardware_label, __hardware_button)
var os_error : bool = !__get_label_ids_for_submission_data(os_tags, BugbotServerAPI.BugbotTagArray.OS, __os_label, __os_button)
var component_error : bool = !__get_label_ids_for_submission_data(component_tags, BugbotServerAPI.BugbotTagArray.COMPONENT, __component_label, __component_button)
var severity_error : bool = !__get_label_ids_for_submission_data(severity_tags, BugbotServerAPI.BugbotTagArray.SEVERITY, __severity_label, __severity_button)
if summary_error or description_error or version_error or hardware_error or os_error or component_error or severity_error:
__submit_button.disabled = false
@ -108,25 +112,28 @@ func _on_submit_button_pressed() -> void:
var bug_report_form_data : Dictionary = {
"title": summary_text,
"body": description_text,
"labels": labels_to_be_added,
"labels": {},
}
if not version_tags.is_empty(): bug_report_form_data["labels"]["version"] = version_tags[0]
if not hardware_tags.is_empty(): bug_report_form_data["labels"]["hardware"] = hardware_tags[0]
if not os_tags.is_empty(): bug_report_form_data["labels"]["os"] = os_tags[0]
if not component_tags.is_empty(): bug_report_form_data["labels"]["component"] = component_tags[0]
if not severity_tags.is_empty(): bug_report_form_data["labels"]["severity"] = severity_tags[0]
__server_api._send_form_data(bug_report_form_data, map_name, bug_location, bug_rotation, __submission_response)
func __get_label_ids_for_submission_data(label_array:Array, label_group_id:int, label:Label, button:MenuButton) -> bool:
var labels : Array
func __get_label_ids_for_submission_data(tag:Array, label_group_id:int, label:Label, button:MenuButton) -> bool:
for applied_label in __label_groups[label_group_id]:
if applied_label["name"] == __severity_button.text:
labels.append(applied_label["id"])
if applied_label["name"] == button.text:
tag.append({ "name": applied_label["name"], "id": applied_label["id"] })
break
if labels.is_empty() and not (__label_groups[label_group_id] as Array).is_empty():
if tag.is_empty() and not (__label_groups[label_group_id] as Array).is_empty():
printerr("You must select a label for \"%s\"" % [label.text])
label.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR)
button.add_theme_color_override("font_color", __ERROR_TEXT_COLOUR)
return false
label_array.append_array(labels)
label.remove_theme_color_override("font_color")
button.remove_theme_color_override("font_color")
return true

View File

@ -68,18 +68,18 @@ func __initialise_project_settings() -> void:
__add_project_setting("bugbot/reporting/gitea/status_labels/show_assigned_as_in_progress", TYPE_BOOL, BugbotServerGiteaAPI.DEFAULT_SHOW_ASSIGNED_AS_IN_PROGRESS)
#endregion
#region Jira
__add_project_setting("bugbot/reporting/jira/server", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_SERVER)
__add_project_setting("bugbot/reporting/jira/REST_URI", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_REST_URI)
__add_project_setting("bugbot/reporting/jira/project_name", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_PROJECT_NAME)
__add_project_setting("bugbot/reporting/jira/email", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_EMAIL)
__add_project_setting("bugbot/reporting/jira/API_key", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_API_KEY)
__add_project_setting("bugbot/reporting/jira/bug_issue_type", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_BUG_ISSUE_TYPE)
__add_project_setting("bugbot/reporting/jira/map_name_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_MAP_NAME_FIELD)
__add_project_setting("bugbot/reporting/jira/marker_location_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_MARKER_LOCATION_FIELD)
__add_project_setting("bugbot/reporting/jira/optional_fields/department_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_DEPARTMENT_FIELD)
__add_project_setting("bugbot/reporting/jira/optional_fields/severity_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_SEVERITY_FIELD)
__add_project_setting("bugbot/reporting/jira/optional_fields/platform_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_PLATFORM_FIELD)
__add_project_setting("bugbot/reporting/jira/optional_fields/version_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_VERSION_FIELD)
#__add_project_setting("bugbot/reporting/jira/server", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_SERVER)
#__add_project_setting("bugbot/reporting/jira/REST_URI", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_REST_URI)
#__add_project_setting("bugbot/reporting/jira/project_name", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_PROJECT_NAME)
#__add_project_setting("bugbot/reporting/jira/email", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_EMAIL)
#__add_project_setting("bugbot/reporting/jira/API_key", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_API_KEY)
#__add_project_setting("bugbot/reporting/jira/bug_issue_type", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_BUG_ISSUE_TYPE)
#__add_project_setting("bugbot/reporting/jira/map_name_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_MAP_NAME_FIELD)
#__add_project_setting("bugbot/reporting/jira/marker_location_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_MARKER_LOCATION_FIELD)
#__add_project_setting("bugbot/reporting/jira/optional_fields/department_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_DEPARTMENT_FIELD)
#__add_project_setting("bugbot/reporting/jira/optional_fields/severity_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_SEVERITY_FIELD)
#__add_project_setting("bugbot/reporting/jira/optional_fields/platform_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_PLATFORM_FIELD)
#__add_project_setting("bugbot/reporting/jira/optional_fields/version_field", TYPE_STRING, BugbotServerJiraAPI.DEFAULT_VERSION_FIELD)
#endregion
#endregion