Skip to content

Commit ba3bf80

Browse files
authored
Merge pull request #29 from per1234/repository-name
Add submission repository name to output
2 parents 467c457 + 8557bfb commit ba3bf80

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

main.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ type request struct {
6969

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

8081
// Command line flags.
@@ -265,6 +266,8 @@ func populateSubmission(submissionURL string, listPath *paths.Path) (submissionT
265266
panic(err)
266267
}
267268

269+
submission.RepositoryName = strings.TrimSuffix(paths.New(normalizedURLObject.Path).Base(), ".git")
270+
268271
// Check if the URL is already in the index.
269272
listLines, err := listPath.ReadFileAsLines()
270273
for _, listURL := range listLines {

test/test_all.py

+14
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
{
3636
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing",
3737
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing.git",
38+
"repositoryName": "ArduinoCloudThing",
3839
"name": "ArduinoCloudThing",
3940
"official": True,
4041
"tag": "1.7.3",
@@ -51,6 +52,7 @@
5152
{
5253
"submissionURL": "foo",
5354
"normalizedURL": "",
55+
"repositoryName": "",
5456
"name": "",
5557
"official": False,
5658
"tag": "",
@@ -67,6 +69,7 @@
6769
{
6870
"submissionURL": "http://httpstat.us/404",
6971
"normalizedURL": "",
72+
"repositoryName": "",
7073
"name": "",
7174
"official": False,
7275
"tag": "",
@@ -83,6 +86,7 @@
8386
{
8487
"submissionURL": "https://example.com",
8588
"normalizedURL": "https://example.com/",
89+
"repositoryName": "",
8690
"name": "",
8791
"official": False,
8892
"tag": "",
@@ -101,6 +105,7 @@
101105
{
102106
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing/releases",
103107
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing/releases.git",
108+
"repositoryName": "",
104109
"name": "",
105110
"official": False,
106111
"tag": "",
@@ -118,6 +123,7 @@
118123
{
119124
"submissionURL": "https://github.com/arduino-libraries/Servo",
120125
"normalizedURL": "https://github.com/arduino-libraries/Servo.git",
126+
"repositoryName": "Servo",
121127
"name": "",
122128
"official": False,
123129
"tag": "",
@@ -134,6 +140,7 @@
134140
{
135141
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing",
136142
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing.git",
143+
"repositoryName": "ArduinoCloudThing",
137144
"name": "ArduinoCloudThing",
138145
"official": True,
139146
"tag": "1.7.3",
@@ -150,6 +157,7 @@
150157
{
151158
"submissionURL": "https://github.com/Azure/azure-iot-arduino-utility",
152159
"normalizedURL": "https://github.com/Azure/azure-iot-arduino-utility.git",
160+
"repositoryName": "azure-iot-arduino-utility",
153161
"name": "AzureIoTUtility",
154162
"official": False,
155163
"tag": "v1.5.0",
@@ -166,6 +174,7 @@
166174
{
167175
"submissionURL": "https://github.com/adafruit/Adafruit_TinyFlash",
168176
"normalizedURL": "https://github.com/adafruit/Adafruit_TinyFlash.git",
177+
"repositoryName": "Adafruit_TinyFlash",
169178
"name": "Adafruit TinyFlash",
170179
"official": False,
171180
"tag": "1.0.4",
@@ -182,6 +191,7 @@
182191
{
183192
"submissionURL": "https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library",
184193
"normalizedURL": "https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library.git",
194+
"repositoryName": "SparkFun_Ublox_Arduino_Library",
185195
"name": "SparkFun u-blox Arduino Library",
186196
"official": False,
187197
"tag": "v1.8.11",
@@ -199,6 +209,7 @@
199209
{
200210
"submissionURL": "https://github.com/arduino/cloud-examples",
201211
"normalizedURL": "https://github.com/arduino/cloud-examples.git",
212+
"repositoryName": "cloud-examples",
202213
"name": "",
203214
"official": True,
204215
"tag": "",
@@ -217,6 +228,7 @@
217228
{
218229
"submissionURL": "https://github.com/arduino-libraries/WiFiLink-Firmware",
219230
"normalizedURL": "https://github.com/arduino-libraries/WiFiLink-Firmware.git",
231+
"repositoryName": "WiFiLink-Firmware",
220232
"name": "",
221233
"official": True,
222234
"tag": "1.0.1",
@@ -233,6 +245,7 @@
233245
{
234246
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing",
235247
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing.git",
248+
"repositoryName": "ArduinoCloudThing",
236249
"name": "ArduinoCloudThing",
237250
"official": True,
238251
"tag": "1.7.3",
@@ -241,6 +254,7 @@
241254
{
242255
"submissionURL": "https://github.com/arduino-libraries/ArduinoCloudThing",
243256
"normalizedURL": "https://github.com/arduino-libraries/ArduinoCloudThing.git",
257+
"repositoryName": "ArduinoCloudThing",
244258
"name": "ArduinoCloudThing",
245259
"official": True,
246260
"tag": "1.7.3",

0 commit comments

Comments
 (0)