Skip to content

Commit 595fa30

Browse files
committed
fix: fall back to tags when release tag is not semver-like
1 parent e5fb26c commit 595fa30

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

core/api/check-updates.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ export async function checkUpdates(
167167
let hasVersion = Boolean(version && version.trim() !== '')
168168
let majorOnly = hasVersion && /^v?\d+$/u.test(version.trim())
169169
let valid = semver.valid(normalized)
170-
considerTags = !hasVersion || majorOnly || !valid
170+
considerTags =
171+
!hasVersion || majorOnly || !valid || !isSemverLike(version)
171172
}
172173

173174
if (considerTags) {

test/api/check-updates.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,4 +1754,53 @@ describe('checkUpdates', () => {
17541754
hasUpdate: false,
17551755
})
17561756
})
1757+
1758+
it('falls back to tags when release tag is not semver-like', async () => {
1759+
let client: GitHubClient = {
1760+
getAllTags: vi.fn().mockResolvedValue([
1761+
{ tag: 'v4.33.0', sha: 'new-sha', message: null, date: null },
1762+
{ tag: 'v4.32.0', sha: 'old-sha', message: null, date: null },
1763+
{
1764+
tag: 'release-bundle-v2.5.0',
1765+
sha: 'bundle-sha',
1766+
message: null,
1767+
date: null,
1768+
},
1769+
]),
1770+
getLatestRelease: vi.fn().mockResolvedValue({
1771+
publishedAt: new Date('2024-06-01'),
1772+
version: 'release-bundle-v2.5.0',
1773+
name: 'Release Bundle v2.5.0',
1774+
isPrerelease: false,
1775+
sha: 'bundle-sha',
1776+
description: null,
1777+
url: 'u',
1778+
}),
1779+
getAllReleases: vi.fn().mockResolvedValue([]),
1780+
getRefType: vi.fn().mockResolvedValue('tag'),
1781+
shouldWaitForRateLimit: vi.fn(),
1782+
getRateLimitStatus: vi.fn(),
1783+
getTagInfo: vi.fn(),
1784+
getTagSha: vi.fn(),
1785+
}
1786+
vi.mocked(createGitHubClient).mockReturnValue(client)
1787+
1788+
let actions: GitHubAction[] = [
1789+
{
1790+
uses: 'owner/repo@v4.32.0',
1791+
ref: 'owner/repo@v4.32.0',
1792+
name: 'owner/repo',
1793+
version: 'v4.32.0',
1794+
type: 'external',
1795+
},
1796+
]
1797+
1798+
let result = await checkUpdates(actions)
1799+
expect(client.getAllTags).toHaveBeenCalledOnce()
1800+
expect(result[0]).toMatchObject({
1801+
latestVersion: 'v4.33.0',
1802+
latestSha: 'new-sha',
1803+
hasUpdate: true,
1804+
})
1805+
})
17571806
})

0 commit comments

Comments
 (0)