Skip to content
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

[GithubRelease],[GithubTag] filter by prefix #8205

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
fix cleanup; fix spelling
  • Loading branch information
mvndaai committed Jul 27, 2022
commit c82a61cad8862901e6499af29868986a74915ba0
12 changes: 2 additions & 10 deletions services/github/github-tag.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ class GithubTag extends GithubAuthV4Service {
{
title: 'GitHub tag (latest SemVer filter by prefix)',
namedParams: { user: 'ros', repo: 'rosdistro' },
queryParams: { sort: 'semver', prefix: 'humble/' },
queryParams: { prefix: 'galactic' },
staticPreview: this.render({
version: '2022-07-15',
sort: 'semver',
}),
documentation,
},
Expand Down Expand Up @@ -121,13 +120,7 @@ class GithubTag extends GithubAuthV4Service {
})
}

static getLatestTag({ tags, sort, includePrereleases, prefix }) {
if (prefix) {
const tagsWithPrefix = tags.filter(tag => tag.startsWith(prefix))
if (tagsWithPrefix.length > 0) {
tags = tagsWithPrefix
}
}
static getLatestTag({ tags, sort, includePrereleases }) {
if (sort === 'semver') {
return latest(tags, { pre: includePrereleases })
}
Expand All @@ -149,7 +142,6 @@ class GithubTag extends GithubAuthV4Service {
tags,
sort,
includePrereleases,
prefix,
}),
sort,
})
Expand Down
6 changes: 3 additions & 3 deletions services/github/github-tag.tester.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Joi from 'joi'
import { isSemver, isKababYearMonthDay } from '../test-validators.js'
import { isSemver, isKebabYearMonthDay } from '../test-validators.js'
import { ServiceTester } from '../tester.js'

export const t = new ServiceTester({
Expand Down Expand Up @@ -29,8 +29,8 @@ t.create('Tag (repo not found)')
.expectBadge({ label: 'tag', message: 'repo not found' })

t.create('Tag (filter by prefix')
.get('/v/tag/ros/rosdistro.json?prefix=galactic/')
.expectBadge({ label: 'tag', message: isKababYearMonthDay })
.get('/v/tag/ros/rosdistro.json?prefix=galactic')
.expectBadge({ label: 'tag', message: isKebabYearMonthDay })
mvndaai marked this conversation as resolved.
Show resolved Hide resolved

// redirects
t.create('Tag (legacy route: tag)')
Expand Down
4 changes: 2 additions & 2 deletions services/test-validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const isCustomCompactTestTotals = makeCompactTestTotalsValidator({
skipped: '🤷',
})

const isKababYearMonthDay = Joi.string().regex(/^\d{4}-\d{2}-\d{2}$/)
const isKebabYearMonthDay = Joi.string().regex(/^\d{4}-\d{2}-\d{2}$/)

export {
isSemver,
Expand Down Expand Up @@ -189,5 +189,5 @@ export {
isCustomCompactTestTotals,
makeTestTotalsValidator,
makeCompactTestTotalsValidator,
isKababYearMonthDay,
isKebabYearMonthDay,
}