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

Fix codeberg release endpoint #39

Merged
merged 2 commits into from
Mar 7, 2024
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
6 changes: 5 additions & 1 deletion badgers-web/src/app/codeberg/release/[owner]/[repo]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ interface Params {

export async function GET(request: NextRequest, { params: { owner, repo } }: Params) {
const release = await Codeberg.getClient().getLatestRelease({ owner, repo })
const shortestName = [release?.tag_name, release?.name]

const shortestName = (() => {
if (release === null) { return null }
return [release?.tag_name, release?.name]
.filter(Boolean)
.reduce((a, b) => a!.length < b!.length ? a : b)
})()

return await Badge.generate(request, 'release', shortestName ?? 'None', {
color: !!shortestName ? 'blue' : 'yellow'
Expand Down
1 change: 1 addition & 0 deletions badgers-worker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.wrangler/
Loading
Loading