Project names are now retrieved from the project settings using a virtual function in the BugbotServerAPI class.

This commit is contained in:
Jamie Greunbaum 2024-06-04 14:24:06 -04:00
parent 1900b0aeaa
commit cfe08da56c
5 changed files with 16 additions and 7 deletions

View File

@ -76,6 +76,9 @@ func __validate_server_response(_response:Variant) -> int:
func _current_server_api() -> String: func _current_server_api() -> String:
return "" return ""
func _get_project_name() -> String:
return ""
func __build_url_string(_api_suffix:String) -> String: func __build_url_string(_api_suffix:String) -> String:
return "" return ""

View File

@ -85,7 +85,7 @@ func __prepare_form_thread(callback:Callable) -> void:
return return
var header_data : Array = __create_header_data() var header_data : Array = __create_header_data()
var product_name : String = ProjectSettings.get_setting("bugbot/reporting/bugzilla/product_name", DEFAULT_PRODUCT_NAME) var product_name : String = _get_project_name()
var api_key : String = ProjectSettings.get_setting("bugbot/reporting/bugzilla/API_key", DEFAULT_API_KEY) var api_key : String = ProjectSettings.get_setting("bugbot/reporting/bugzilla/API_key", DEFAULT_API_KEY)
var api_url : String = "product/%s?" % [product_name] var api_url : String = "product/%s?" % [product_name]
@ -215,6 +215,9 @@ func __send_form_data_thread(data:Dictionary, map_name:String, bug_position:Vect
func _current_server_api() -> String: func _current_server_api() -> String:
return "Bugzilla" return "Bugzilla"
func _get_project_name() -> String:
return ProjectSettings.get_setting("bugbot/reporting/bugzilla/product_name", DEFAULT_PRODUCT_NAME)
func __build_url_string(_api_suffix:String) -> String: func __build_url_string(_api_suffix:String) -> String:
return "/" + \ return "/" + \
ProjectSettings.get_setting("bugbot/reporting/bugzilla/REST_URI", DEFAULT_REST_URI) + \ ProjectSettings.get_setting("bugbot/reporting/bugzilla/REST_URI", DEFAULT_REST_URI) + \
@ -226,7 +229,6 @@ func __create_header_data(content_length:int = -1) -> Array:
"User-Agent: Pirulo/1.0 (Godot)", "User-Agent: Pirulo/1.0 (Godot)",
"Accept: application/json", "Accept: application/json",
] ]
header.append("Authorization: token " + ProjectSettings.get_setting("bugbot/reporting/gitea/API_key", DEFAULT_API_KEY))
if content_length >= 0: if content_length >= 0:
header.append("Content-Type: application/json") header.append("Content-Type: application/json")
header.append("Content-Length: " + String.num_uint64(content_length)) header.append("Content-Length: " + String.num_uint64(content_length))

View File

@ -190,6 +190,9 @@ func __send_form_data_thread(data:Dictionary, map_name:String, bug_position:Vect
func _current_server_api() -> String: func _current_server_api() -> String:
return "Gitea" return "Gitea"
func _get_project_name() -> String:
return ProjectSettings.get_setting("bugbot/reporting/gitea/repo_name", DEFAULT_REPO_NAME)
func __build_url_string(_api_suffix:String) -> String: func __build_url_string(_api_suffix:String) -> String:
return "/" + \ return "/" + \
ProjectSettings.get_setting("bugbot/reporting/gitea/base_URL", DEFAULT_BASE_URL) + \ ProjectSettings.get_setting("bugbot/reporting/gitea/base_URL", DEFAULT_BASE_URL) + \

View File

@ -36,10 +36,9 @@ func __return_list_of_bugs_thread(map_name:String, callback:Callable) -> void:
__bugbot_server_thread.call_deferred("wait_to_finish") __bugbot_server_thread.call_deferred("wait_to_finish")
return return
var project_name : String = ProjectSettings.get_setting("bugbot/reporting/jira/project_name", DEFAULT_PROJECT_NAME)
var url_string : String = "api/2/search" var url_string : String = "api/2/search"
var post_data : Dictionary = { var post_data : Dictionary = {
"jql": "project=\"%s\"" % [project_name], "jql": "project=\"%s\"" % [server_data.project_name],
"fields": ["summary", "description", "issuetype", "status"] "fields": ["summary", "description", "issuetype", "status"]
} }
if not server_data.map_name_field_key.is_empty(): post_data["fields"].append(server_data.map_name_field_key) if not server_data.map_name_field_key.is_empty(): post_data["fields"].append(server_data.map_name_field_key)
@ -152,7 +151,6 @@ func __send_form_data_thread(data:Dictionary, map_name:String, bug_position:Vect
__bugbot_server_thread.call_deferred("wait_to_finish") __bugbot_server_thread.call_deferred("wait_to_finish")
return return
var project_name : String = ProjectSettings.get_setting("bugbot/reporting/jira/project_name", DEFAULT_PROJECT_NAME)
var bug_issue_type : String = ProjectSettings.get_setting("bugbot/reporting/jira/bug_issue_type", DEFAULT_BUG_ISSUE_TYPE) var bug_issue_type : String = ProjectSettings.get_setting("bugbot/reporting/jira/bug_issue_type", DEFAULT_BUG_ISSUE_TYPE)
var marker_location : String = "%.4f,%.4f,%.4f:%.4f,%.4f,%.4f" % [bug_position.x, bug_position.y, bug_position.z, bug_normal.x, bug_normal.y, bug_normal.z] var marker_location : String = "%.4f,%.4f,%.4f:%.4f,%.4f,%.4f" % [bug_position.x, bug_position.y, bug_position.z, bug_normal.x, bug_normal.y, bug_normal.z]
var post_data : Dictionary = { var post_data : Dictionary = {
@ -207,6 +205,9 @@ func __send_form_data_thread(data:Dictionary, map_name:String, bug_position:Vect
func _current_server_api() -> String: func _current_server_api() -> String:
return "Jira" return "Jira"
func _get_project_name() -> String:
return ProjectSettings.get_setting("bugbot/reporting/jira/project_name", DEFAULT_PROJECT_NAME)
func __build_url_string(_api_suffix:String) -> String: func __build_url_string(_api_suffix:String) -> String:
return "/" + \ return "/" + \
ProjectSettings.get_setting("bugbot/reporting/jira/REST_URI", DEFAULT_REST_URI) + \ ProjectSettings.get_setting("bugbot/reporting/jira/REST_URI", DEFAULT_REST_URI) + \
@ -331,7 +332,7 @@ func __get_server_data(http_client:HTTPClient, header_data:Array) -> BugbotJiraS
if __validate_server_response(project_response) != Error.OK: if __validate_server_response(project_response) != Error.OK:
return return
server_data.project_name = ProjectSettings.get_setting("bugbot/reporting/jira/project_name", DEFAULT_PROJECT_NAME) server_data.project_name = _get_project_name()
for project:Dictionary in project_response: for project:Dictionary in project_response:
if project["name"] == server_data.project_name: if project["name"] == server_data.project_name:
server_data.project_id = project["id"] server_data.project_id = project["id"]

View File

@ -53,7 +53,7 @@ func fill_tags(tag_list:Array):
printerr("Invalid tag array format.") printerr("Invalid tag array format.")
return return
__product_name.text = ProjectSettings.get_setting("application/config/name", __DEFAULT_PRODUCT_NAME) __product_name.text = __server_api._get_project_name()
__fill_item_list(__version_button, BugbotServerAPI.BugbotTagArray.VERSION) __fill_item_list(__version_button, BugbotServerAPI.BugbotTagArray.VERSION)
__fill_item_list(__hardware_button, BugbotServerAPI.BugbotTagArray.HARDWARE) __fill_item_list(__hardware_button, BugbotServerAPI.BugbotTagArray.HARDWARE)
__fill_item_list(__os_button, BugbotServerAPI.BugbotTagArray.OS) __fill_item_list(__os_button, BugbotServerAPI.BugbotTagArray.OS)