Skip to content

Commit 3896f79

Browse files
committed
fix: repository detection
1 parent 4e21d50 commit 3896f79

2 files changed

Lines changed: 32 additions & 14 deletions

File tree

main.go

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ type PackageListResponse struct {
1414
PackageNames []string `json:"packageNames"`
1515
}
1616

17+
type PackageVersion struct {
18+
Source struct {
19+
URL string `json:"url"`
20+
} `json:"source"`
21+
Time string `json:"time"`
22+
}
23+
1724
type PackageDetailsResponse struct {
1825
Package struct {
19-
Versions map[string]struct {
20-
Source struct {
21-
URL string `json:"url"`
22-
} `json:"source"`
23-
} `json:"versions"`
26+
Versions map[string]PackageVersion `json:"versions"`
2427
} `json:"package"`
2528
}
2629

@@ -130,19 +133,34 @@ func main() {
130133
continue
131134
}
132135

133-
for _, version := range packageDetails.Package.Versions {
134-
log.Printf("Package: %s, Repository: %s\n", packageName, version.Source.URL)
135-
if strings.Contains(version.Source.URL, "github.com") {
136-
extension, commitTime := checkShopwareExtensionFile(version.Source.URL, githubClient)
136+
var latestVersion *PackageVersion
137+
var latestTime time.Time
138+
139+
for _, versionData := range packageDetails.Package.Versions {
140+
parsedTime, err := time.Parse(time.RFC3339, versionData.Time)
141+
if err != nil {
142+
log.Printf("Failed to parse time for package version: %s, error: %v", versionData.Time, err)
143+
continue
144+
}
145+
146+
if latestVersion == nil || parsedTime.After(latestTime) {
147+
latestTime = parsedTime
148+
latestVersion = &versionData
149+
}
150+
}
151+
152+
if latestVersion != nil {
153+
log.Printf("Package: %s, Repository: %s\n", packageName, latestVersion.Source.URL)
154+
if strings.Contains(latestVersion.Source.URL, "github.com") {
155+
extension, commitTime := checkShopwareExtensionFile(latestVersion.Source.URL, githubClient)
137156
if extension {
138157
packageData[packageName] = &ShopwareExtensionMetadata{
139-
RepositoryUrl: version.Source.URL,
158+
RepositoryUrl: latestVersion.Source.URL,
140159
Ref: detailsURL,
141160
LatestCommitTime: commitTime,
142161
}
143162
}
144163
}
145-
break // Assuming you want one repository URL per package
146164
}
147165
}
148166

shopware_extensions_v1.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"latestCommitTime": 1709473117
8282
},
8383
"frosh/platform-html-minify": {
84-
"repositoryUrl": "https://github.com/FriendsOfShopware/FroshPlatformHtmlMinifier.git",
84+
"repositoryUrl": "https://github.com/FriendsOfShopware/FroshPlatformHtmlMinify.git",
8585
"ref": "https://packagist.org/packages/frosh/platform-html-minify.json",
8686
"latestCommitTime": 1741096857
8787
},
@@ -143,7 +143,7 @@
143143
"nuonic/plugin-installer": {
144144
"repositoryUrl": "https://github.com/nuonic-digital/plugin-installer.git",
145145
"ref": "https://packagist.org/packages/nuonic/plugin-installer.json",
146-
"latestCommitTime": 1741395202
146+
"latestCommitTime": 1741468457
147147
},
148148
"payone-gmbh/shopware-6": {
149149
"repositoryUrl": "https://github.com/PAYONE-GmbH/shopware-6.git",
@@ -206,5 +206,5 @@
206206
"latestCommitTime": 1740863916
207207
}
208208
},
209-
"generatedAt": 1741467861
209+
"generatedAt": 1741469213
210210
}

0 commit comments

Comments
 (0)