From 52f56b1a0936f1fc7e2b0ff5132feb0c8ce01ad3 Mon Sep 17 00:00:00 2001 From: Inglonias <2125926+Inglonias@users.noreply.github.com> Date: Mon, 20 Dec 2021 08:30:08 -0500 Subject: [PATCH 1/2] Much faster changelog using the GitHub Search API --- scripts/ChangelogDialod.gd | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/ChangelogDialod.gd b/scripts/ChangelogDialod.gd index 9902da34..d74b60f7 100644 --- a/scripts/ChangelogDialod.gd +++ b/scripts/ChangelogDialod.gd @@ -2,8 +2,8 @@ extends WindowDialog const _PR_URL = { - "dda": "https://api.github.com/repos/cleverraven/cataclysm-dda/pulls", - "bn": "https://api.github.com/repos/cataclysmbnteam/Cataclysm-BN/pulls", + "dda": "https://api.github.com/search/issues?q=repo%3Acleverraven/Cataclysm-DDA", + "bn": "https://api.github.com/search/issues?q=repo%3Acataclysmbnteam/Cataclysm-BN", } @@ -26,7 +26,7 @@ func download_pull_requests(): var game_selected = _settings.read("game") var prs = _settings.read("num_prs_to_request") var url = _PR_URL[_settings.read("game")] - url += "?state=closed&sort=updated&direction=desc&per_page=" + prs + url += "+is%3Apr+is%3Amerged&per_page=" + prs var headers = ["user-agent: CatapultGodotApp"] var pat = _settings.read("github_pat") if (pat.length() == 40): @@ -55,10 +55,8 @@ func _on_PullRequests_request_completed(result, response_code, headers, body): func process_pr_data(data): var pr_array = [] - for json in data: - if json["merged_at"] == null or json["merged_at"] == "null" : - continue - var pr = PullRequest.pullrequest_from_datestring(json["merged_at"], json["title"], json["html_url"]) + for json in data["items"]: + var pr = PullRequest.pullrequest_from_datestring(json["closed_at"], json["title"], json["html_url"]) pr_array.push_back(pr) pr_array.sort_custom(PullRequest, "compare_to") var now = OS.get_datetime(true) From 08d560f0079d7d413035a1e04024ceb6b0e23533 Mon Sep 17 00:00:00 2001 From: Inglonias <2125926+Inglonias@users.noreply.github.com> Date: Mon, 20 Dec 2021 19:29:04 -0500 Subject: [PATCH 2/2] Removed GitHub PAT code from Catapult --- scripts/ChangelogDialod.gd | 5 +---- scripts/SettingsUI.gd | 5 ----- scripts/settings_manager.gd | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/scripts/ChangelogDialod.gd b/scripts/ChangelogDialod.gd index d74b60f7..7afc7761 100644 --- a/scripts/ChangelogDialod.gd +++ b/scripts/ChangelogDialod.gd @@ -28,9 +28,6 @@ func download_pull_requests(): var url = _PR_URL[_settings.read("game")] url += "+is%3Apr+is%3Amerged&per_page=" + prs var headers = ["user-agent: CatapultGodotApp"] - var pat = _settings.read("github_pat") - if (pat.length() == 40): - headers.push_back("Authorization: token " + pat) _pr_data = "Fetching recent changes from GitHub. Please wait..." _pullRequests.request(url, headers) _changelogTextBox.clear() @@ -46,7 +43,7 @@ func _on_PullRequests_request_completed(result, response_code, headers, body): _pr_data += "\n\nHTTP response code: " + str(response_code) if (json) and ("message" in json): _pr_data += "\nGitHub says: [i]%s[/i]" % json["message"] - _pr_data += "\n\nSometimes, requests will fail repeatedly due to excessive load on the server, especially for DDA. This may depend on the time of day, your location, etc. There's little anyone can do about this. If you are registered on GitHub, you can add your [url=https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token]PAT (Personal Access Token)[/url] to Catapult config file to increase the priority of your requests or bypass rate limits." + _pr_data += "\n\nPlease try again later." else: _pr_data = process_pr_data(json) _changelogTextBox.clear() diff --git a/scripts/SettingsUI.gd b/scripts/SettingsUI.gd index 7ed3f0cb..2e4e5b27 100644 --- a/scripts/SettingsUI.gd +++ b/scripts/SettingsUI.gd @@ -121,8 +121,3 @@ func _on_any_migration_checkbox_toggled(_asdf: bool) -> void: data_types.append(type) _settings.store("game_data_to_migrate", data_types) - - -func _on_lePATUse_text_changed(new_text): - if (new_text.length() == 40 or new_text.length() == 0): - _settings.store("github_pat", new_text) diff --git a/scripts/settings_manager.gd b/scripts/settings_manager.gd index fed4a64a..dc7be3c6 100644 --- a/scripts/settings_manager.gd +++ b/scripts/settings_manager.gd @@ -14,7 +14,6 @@ const _HARDCODED_DEFAULTS = { "shorten_release_names": false, "num_releases_to_request": 10, "num_prs_to_request": 50, - "github_pat": "", "ui_scale_override": 1.0, "ui_scale_override_enabled": false, "show_stock_mods": false,