The Hub reads the Cross Events repo's v* tags (each a release, the newest the latest version) and the client notes from WHATS-NEW.md as of the newest tag, every 15 minutes and on Sync now. Urgent/security in a version heading marks it urgent. Repo address, notes path and an optional encrypted token on the Releases page; manual releases only when no repo is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
// Releases from git: reading the repo address and WHATS-NEW.md.
|
|
jest.mock('../src/config/db', () => ({}));
|
|
|
|
const { parseRepoUrl, parseNotes } = require('../src/utils/releaseSync');
|
|
|
|
test('the repository address becomes the Gitea API', () => {
|
|
expect(parseRepoUrl('https://c-git.crosscode.co.za/joshua/hope-events')).toEqual({ api: 'https://c-git.crosscode.co.za/api/v1/repos/joshua/hope-events', owner: 'joshua', repo: 'hope-events' });
|
|
expect(parseRepoUrl('https://c-git.crosscode.co.za/joshua/hope-events.git/').api).toBe('https://c-git.crosscode.co.za/api/v1/repos/joshua/hope-events');
|
|
expect(parseRepoUrl('https://c-git.crosscode.co.za/joshua')).toBeNull();
|
|
expect(parseRepoUrl('ftp://x/y/z')).toBeNull();
|
|
expect(parseRepoUrl('')).toBeNull();
|
|
});
|
|
|
|
describe('WHATS-NEW.md', () => {
|
|
const md = `# What's new in Cross Events
|
|
|
|
Intro text that isn't a release.
|
|
|
|
<!--
|
|
## 9.9.9
|
|
Hidden instructions are not a release.
|
|
-->
|
|
|
|
## 1.46.2 — urgent
|
|
|
|
- **See what's new** before you update, on the
|
|
Licence page.
|
|
- Uses \`code\` and [a link](https://example.com).
|
|
|
|
## [1.46.1] - 2026-10-28
|
|
|
|
Behind-the-scenes maintenance.
|
|
Nothing changes for you.
|
|
|
|
## v1.46.0 (security fix)
|
|
|
|
### Volunteers
|
|
- Rosters
|
|
- Swaps
|
|
`;
|
|
const notes = parseNotes(md);
|
|
|
|
test('one section per version; comments and the title are skipped', () => {
|
|
expect(Object.keys(notes).sort()).toEqual(['1.46.0', '1.46.1', '1.46.2']);
|
|
});
|
|
|
|
test('"urgent" or "security" in the heading marks it urgent', () => {
|
|
expect(notes['1.46.2'].urgent).toBe(true);
|
|
expect(notes['1.46.1'].urgent).toBe(false);
|
|
expect(notes['1.46.0'].urgent).toBe(true);
|
|
});
|
|
|
|
test('markup is removed, wrapped lines joined, list items kept', () => {
|
|
expect(notes['1.46.2'].notes).toBe("- See what's new before you update, on the Licence page.\n- Uses code and a link.");
|
|
expect(notes['1.46.1'].notes).toBe('Behind-the-scenes maintenance. Nothing changes for you.');
|
|
expect(notes['1.46.0'].notes).toBe('Volunteers\n- Rosters\n- Swaps');
|
|
});
|
|
|
|
test('no file means no notes', () => {
|
|
expect(parseNotes('')).toEqual({});
|
|
expect(parseNotes(null)).toEqual({});
|
|
});
|
|
});
|