Skip to content

Commit

Permalink
fix [pypi] status badge when package has no 'Development Status' clas…
Browse files Browse the repository at this point in the history
…sifier (#10107)
  • Loading branch information
chris48s authored May 6, 2024
1 parent f562fe7 commit 2857d9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion services/pypi/pypi-status.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class PypiStatus extends PypiBase {
stable: 'brightgreen',
mature: 'brightgreen',
inactive: 'red',
unknown: 'lightgrey',
}[status]

return {
Expand All @@ -48,7 +49,7 @@ export default class PypiStatus extends PypiBase {
// - Development Status :: 6 - Mature
// - Development Status :: 7 - Inactive
// https://pypi.org/pypi?%3Aaction=list_classifiers
const status = parseClassifiers(
let status = parseClassifiers(
packageData,
/^Development Status :: (\d - \S+)$/,
)
Expand All @@ -57,6 +58,10 @@ export default class PypiStatus extends PypiBase {
.map(classifier => classifier.replace(/production\/stable/i, 'stable'))
.pop()

if (!status) {
status = 'Unknown'
}

return this.constructor.render({ status })
}
}
4 changes: 4 additions & 0 deletions services/pypi/pypi-status.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ t.create('status (valid, beta)')
.get('/django/2.0rc1.json')
.expectBadge({ label: 'status', message: 'beta' })

t.create('status (status not specified)')
.get('/arcgis2geojson/3.0.2.json')
.expectBadge({ label: 'status', message: 'unknown' })

t.create('status (invalid)')
.get('/not-a-package.json')
.expectBadge({ label: 'status', message: 'package or version not found' })

0 comments on commit 2857d9b

Please sign in to comment.