Skip to content

Add submission repository name to output #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ type request struct {

// submissionType is the type of the data for each individual library submitted in the request.
type submissionType struct {
SubmissionURL string `json:"submissionURL"` // Library repository URL as submitted by user. Used to identify the submission to the user.
NormalizedURL string `json:"normalizedURL"` // Submission URL in the standardized format that will be used in the index entry.
Name string `json:"name"` // Library name.
Official bool `json:"official"` // Whether the library is official.
Tag string `json:"tag"` // Name of the submission repository's latest tag, which is used as the basis for the index entry and validation.
Error string `json:"error"` // Error message.
SubmissionURL string `json:"submissionURL"` // Library repository URL as submitted by user. Used to identify the submission to the user.
NormalizedURL string `json:"normalizedURL"` // Submission URL in the standardized format that will be used in the index entry.
RepositoryName string `json:"repositoryName"` // Name of the submission's repository.
Name string `json:"name"` // Library name.
Official bool `json:"official"` // Whether the library is official.
Tag string `json:"tag"` // Name of the submission repository's latest tag, which is used as the basis for the index entry and validation.
Error string `json:"error"` // Error message.
}

// Command line flags.
Expand Down Expand Up @@ -265,6 +266,8 @@ func populateSubmission(submissionURL string, listPath *paths.Path) (submissionT
panic(err)
}

submission.RepositoryName = strings.TrimSuffix(paths.New(normalizedURLObject.Path).Base(), ".git")

// Check if the URL is already in the index.
listLines, err := listPath.ReadFileAsLines()
for _, listURL := range listLines {
Expand Down
14 changes: 14 additions & 0 deletions test/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
{
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing",
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing.git",
"repositoryName": "ArduinoCloudThing",
"name": "ArduinoCloudThing",
"official": True,
"tag": "1.7.3",
Expand All @@ -51,6 +52,7 @@
{
"submissionURL": "foo",
"normalizedURL": "",
"repositoryName": "",
"name": "",
"official": False,
"tag": "",
Expand All @@ -67,6 +69,7 @@
{
"submissionURL": "http://httpstat.us/404",
"normalizedURL": "",
"repositoryName": "",
"name": "",
"official": False,
"tag": "",
Expand All @@ -83,6 +86,7 @@
{
"submissionURL": "https://example.com",
"normalizedURL": "https://example.com/",
"repositoryName": "",
"name": "",
"official": False,
"tag": "",
Expand All @@ -101,6 +105,7 @@
{
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing/releases",
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing/releases.git",
"repositoryName": "",
"name": "",
"official": False,
"tag": "",
Expand All @@ -118,6 +123,7 @@
{
"submissionURL": "https://github.com/arduino-libraries/Servo",
"normalizedURL": "https://github.com/arduino-libraries/Servo.git",
"repositoryName": "Servo",
"name": "",
"official": False,
"tag": "",
Expand All @@ -134,6 +140,7 @@
{
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing",
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing.git",
"repositoryName": "ArduinoCloudThing",
"name": "ArduinoCloudThing",
"official": True,
"tag": "1.7.3",
Expand All @@ -150,6 +157,7 @@
{
"submissionURL": "https://github.com/Azure/azure-iot-arduino-utility",
"normalizedURL": "https://github.com/Azure/azure-iot-arduino-utility.git",
"repositoryName": "azure-iot-arduino-utility",
"name": "AzureIoTUtility",
"official": False,
"tag": "v1.5.0",
Expand All @@ -166,6 +174,7 @@
{
"submissionURL": "https://github.com/adafruit/Adafruit_TinyFlash",
"normalizedURL": "https://github.com/adafruit/Adafruit_TinyFlash.git",
"repositoryName": "Adafruit_TinyFlash",
"name": "Adafruit TinyFlash",
"official": False,
"tag": "1.0.4",
Expand All @@ -182,6 +191,7 @@
{
"submissionURL": "https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library",
"normalizedURL": "https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library.git",
"repositoryName": "SparkFun_Ublox_Arduino_Library",
"name": "SparkFun u-blox Arduino Library",
"official": False,
"tag": "v1.8.11",
Expand All @@ -199,6 +209,7 @@
{
"submissionURL": "https://github.com/arduino/cloud-examples",
"normalizedURL": "https://github.com/arduino/cloud-examples.git",
"repositoryName": "cloud-examples",
"name": "",
"official": True,
"tag": "",
Expand All @@ -217,6 +228,7 @@
{
"submissionURL": "https://github.com/arduino-libraries/WiFiLink-Firmware",
"normalizedURL": "https://github.com/arduino-libraries/WiFiLink-Firmware.git",
"repositoryName": "WiFiLink-Firmware",
"name": "",
"official": True,
"tag": "1.0.1",
Expand All @@ -233,6 +245,7 @@
{
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing",
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing.git",
"repositoryName": "ArduinoCloudThing",
"name": "ArduinoCloudThing",
"official": True,
"tag": "1.7.3",
Expand All @@ -241,6 +254,7 @@
{
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing",
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing.git",
"repositoryName": "ArduinoCloudThing",
"name": "ArduinoCloudThing",
"official": True,
"tag": "1.7.3",
Expand Down