From bbe9570983e6df9f04d5b0e5152cfcc9beff2464 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 16 Mar 2025 02:17:52 -0700 Subject: [PATCH] Show resolved URL in duplicate submission error message when relevant library-registry-submission-parser resolves redirects in the submitted URLs and validates the request for that resolved URL. One of the validations is checking whether the submitted URL is already in the repositories list. If so, the validation fails and the bot makes a comment on the pull request. In the case where the resolved URL is different from the submitted URL, this failure can be confusing, since the duplicate will not be found in a search for the submitted URL. Previously, the comment from the bot only mentioned the submitted URL. The communication about the validation failure under these conditions is hereby improved by using a different error message that explains it is the resolved URL that was found in the list, and states that URL. --- main.go | 7 ++++++- tests/test_all.py | 21 +++++++++++++++++++ .../.github/workflows/assets/accesslist.yml | 1 + .../diff.txt | 8 +++++++ .../repositories.txt | 2 ++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/testdata/resolved-already-in-library-manager/.github/workflows/assets/accesslist.yml create mode 100644 tests/testdata/resolved-already-in-library-manager/diff.txt create mode 100644 tests/testdata/resolved-already-in-library-manager/repositories.txt diff --git a/main.go b/main.go index 74a0470..75b8a23 100644 --- a/main.go +++ b/main.go @@ -390,7 +390,12 @@ func populateSubmission(submissionURL string, listPath *paths.Path, accessList [ normalizedListURLObject := normalizeURL(listURLObject) if normalizedListURLObject.String() == normalizedURLObject.String() { - submission.Error = "Submission URL is already in the Library Manager index." + normalizedSubmissionURLObject := normalizeURL(submissionURLObject) + if normalizedURLObject.String() == normalizedSubmissionURLObject.String() { + submission.Error = "Submission URL is already in the Library Manager index." + } else { + submission.Error = fmt.Sprintf("Resolved URL %s is already in the Library Manager index.", normalizedURLObject.String()) + } return submission, "", true } } diff --git a/tests/test_all.py b/tests/test_all.py index 70668f1..039c073 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -253,6 +253,27 @@ "", "http://downloads.arduino.cc/libraries/logs/github.com/arduino-libraries/Servo/", ), + ( + "resolved-already-in-library-manager", + "FooUser", + "", + "submission", + "", + [ + { + "submissionURL": "https://github.com/arduino-org/WiFi_for_UNOWiFi_rev1", + "normalizedURL": "https://github.com/arduino-libraries/WiFi_for_UNOWiFi_rev1.git", + "repositoryName": "WiFi_for_UNOWiFi_rev1", + "name": "", + "official": False, + "tag": "", + "error": "Resolved URL https://github.com/arduino-libraries/WiFi_for_UNOWiFi_rev1.git is already in" + " the Library Manager index.", + } + ], + "", + "http://downloads.arduino.cc/libraries/logs/github.com/arduino-libraries/WiFi_for_UNOWiFi_rev1/", + ), ( "type-arduino", "FooUser", diff --git a/tests/testdata/resolved-already-in-library-manager/.github/workflows/assets/accesslist.yml b/tests/testdata/resolved-already-in-library-manager/.github/workflows/assets/accesslist.yml new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/tests/testdata/resolved-already-in-library-manager/.github/workflows/assets/accesslist.yml @@ -0,0 +1 @@ +[] diff --git a/tests/testdata/resolved-already-in-library-manager/diff.txt b/tests/testdata/resolved-already-in-library-manager/diff.txt new file mode 100644 index 0000000..656f837 --- /dev/null +++ b/tests/testdata/resolved-already-in-library-manager/diff.txt @@ -0,0 +1,8 @@ +diff --git a/repositories.txt b/repositories.txt +index c080a7a..1194257 100644 +--- a/repositories.txt ++++ b/repositories.txt +@@ -1,2 +1,3 @@ ++https://github.com/arduino-org/WiFi_for_UNOWiFi_rev1 + https://github.com/arduino-libraries/WiFi_for_UNOWiFi_rev1 + https://github.com/arduino-libraries/Stepper diff --git a/tests/testdata/resolved-already-in-library-manager/repositories.txt b/tests/testdata/resolved-already-in-library-manager/repositories.txt new file mode 100644 index 0000000..7291399 --- /dev/null +++ b/tests/testdata/resolved-already-in-library-manager/repositories.txt @@ -0,0 +1,2 @@ +https://github.com/arduino-libraries/WiFi_for_UNOWiFi_rev1 +https://github.com/arduino-libraries/Stepper