Skip to content
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
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

## 0.25.0

## Automated Changelog Generation
### Automated Changelog Generation

We now automatically generate changelog entries for the `auto` changelog policy where none provided, instead of saying "No documented changes". The commits/PRs are grouped by their associated GitHub milestones and the milestone title and description are used in the changelog along with a list of related commits/PRs. Any unaccounted changes are grouped under the "Various improvements and fixes" section.

PRs: #291, #290, #289, #287, #285

## Added Maven Target (ongoing)
### Added Maven Target (ongoing)

Added the long-awaited Maven target, full with Android support.

PRs: #271, #275, #276, #270, #258

## Added symbol-collector Target
### Added symbol-collector Target

Added target for our very own [symbol-collector](https://github.com/getsentry/symbol-collector/) to collect and upload all native system symbols with Craft.

PRs: #284, #277, #269, #268, #267, #266

## Fixed Cocoapods Support
### Fixed Cocoapods Support

Turns out our Cocoapods target was a bit outdated and broken. We have fixed it in this release! 🥳
Turns out our Cocoapods target was a bit outdated and broken. We have fixed it in this release! 🥳

PRs: #281, #282

## Various fixes & improvements
### Various fixes & improvements

- build: Drop Node 12 support, target Node 14 (#293)
- build(deps): Bump tmpl from 1.0.4 to 1.0.5 (#292)
Expand All @@ -37,7 +37,7 @@ PRs: #281, #282
- build(deps): Bump path-parse from 1.0.6 to 1.0.7 (#274)
- build(deps-dev): Bump tar from 4.4.8 to 4.4.15 (#273)
- docs: Consistent code samples for shell (e84f693f)
- docs: Mention release/** branches on README (#263)
- docs: Mention release/\*\* branches on README (#263)

## 0.24.4

Expand Down
16 changes: 8 additions & 8 deletions src/utils/__tests__/changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('generateChangesetFromGit', () => {
makeCommitResponse([]);
const changes = await generateChangesetFromGit(dummyGit, '1.0.0');
expect(changes).toMatchInlineSnapshot(`
"## Various fixes & improvements
"### Various fixes & improvements

- Upgraded the kernel (abcdef12)"
`);
Expand All @@ -336,7 +336,7 @@ describe('generateChangesetFromGit', () => {
makeCommitResponse([{ hash: 'abcdef1234567890' }]);
const changes = await generateChangesetFromGit(dummyGit, '1.0.0');
expect(changes).toMatchInlineSnapshot(`
"## Various fixes & improvements
"### Various fixes & improvements

- Upgraded the kernel (abcdef12)"
`);
Expand All @@ -357,7 +357,7 @@ describe('generateChangesetFromGit', () => {
]);
const changes = await generateChangesetFromGit(dummyGit, '1.0.0');
expect(changes).toMatchInlineSnapshot(`
"## Various fixes & improvements
"### Various fixes & improvements

- Upgraded the kernel (#123)"
`);
Expand All @@ -374,7 +374,7 @@ describe('generateChangesetFromGit', () => {
makeCommitResponse([{ hash: 'abcdef1234567890', pr: '123' }]);
const changes = await generateChangesetFromGit(dummyGit, '1.0.0');
expect(changes).toMatchInlineSnapshot(`
"## Various fixes & improvements
"### Various fixes & improvements

- Upgraded the kernel (#123)"
`);
Expand Down Expand Up @@ -410,7 +410,7 @@ describe('generateChangesetFromGit', () => {
]);
const changes = await generateChangesetFromGit(dummyGit, '1.0.0');
expect(changes).toMatchInlineSnapshot(`
"## Various fixes & improvements
"### Various fixes & improvements

- Upgraded the kernel (abcdef12)
- Upgraded the manifold (#123)
Expand Down Expand Up @@ -495,19 +495,19 @@ describe('generateChangesetFromGit', () => {
});
const changes = await generateChangesetFromGit(dummyGit, '1.0.0');
expect(changes).toMatchInlineSnapshot(`
"## Better drivetrain
"### Better drivetrain

We have upgraded the drivetrain for a smoother and more performant driving experience. Enjoy!

PRs: #123, #456

## Better driver experience (ongoing)
### Better driver experience (ongoing)

We are working on making your driving experience more pleasant and safer.

PRs: #789, #900

## Various fixes & improvements
### Various fixes & improvements

- Upgraded the kernel (abcdef12)
- Fix the clacking sound on gear changes (#950)"
Expand Down
28 changes: 24 additions & 4 deletions src/utils/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ import { getVersion } from './version';
export const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
export const DEFAULT_UNRELEASED_TITLE = 'Unreleased';
const DEFAULT_CHANGESET_BODY = '- No documented changes.';
const VERSION_HEADER_LEVEL = 2;
const SUBSECTION_HEADER_LEVEL = VERSION_HEADER_LEVEL + 1;

// Ensure subsections are nested under version headers otherwise we won't be
// able to find them and put on GitHub releases.
if (SUBSECTION_HEADER_LEVEL <= VERSION_HEADER_LEVEL) {
throw new Error('Subsection headers should nest under version headers!');
}
/**
* A single changeset with name and description
*/
Expand All @@ -32,6 +39,11 @@ export interface ChangesetLoc {
padding: string;
}

function markdownHeader(level: number, text: string): string {
const prefix = new Array(level + 1).join('#');
return `${prefix} ${text}`;
}

/**
* Extracts a specific changeset from a markdown document
*
Expand Down Expand Up @@ -70,7 +82,10 @@ function locateChangeset(
markdown: string,
predicate: (match: string) => boolean
): ChangesetLoc | null {
const HEADER_REGEX = /^( *)(?:## +([^\n]+?) *(?:##)?|([^\n]+)\n *(?:-){2,}) *(?:\n+|$)/gm;
const HEADER_REGEX = new RegExp(
`^( *)(?:#{${VERSION_HEADER_LEVEL}} +([^\\n]+?) *(?:#{${VERSION_HEADER_LEVEL}})?|([^\\n]+)\\n *(?:-){2,}) *(?:\\n+|$)`,
'gm'
);

for (
let match = HEADER_REGEX.exec(markdown);
Expand Down Expand Up @@ -171,7 +186,7 @@ export function prependChangeset(
const underline = new Array(changeset.name.length + 1).join('-');
header = `${changeset.name}\n${underline}`;
} else {
header = `## ${changeset.name}`;
header = markdownHeader(VERSION_HEADER_LEVEL, changeset.name);
}
const newSection = `${padding}${header}\n\n${body.replace(
/^/gm,
Expand Down Expand Up @@ -269,7 +284,10 @@ export async function generateChangesetFromGit(
}

changelogSections.push(
`## ${milestone.title}${milestone.state === 'OPEN' ? ' (ongoing)' : ''}`
markdownHeader(
SUBSECTION_HEADER_LEVEL,
`${milestone.title}${milestone.state === 'OPEN' ? ' (ongoing)' : ''}`
)
);
changelogSections.push(milestone.description);
changelogSections.push(
Expand All @@ -278,7 +296,9 @@ export async function generateChangesetFromGit(
}

if (leftovers.length > 0) {
changelogSections.push(`## Various fixes & improvements`);
changelogSections.push(
markdownHeader(SUBSECTION_HEADER_LEVEL, 'Various fixes & improvements')
);
changelogSections.push(leftovers.map(formatCommit).join('\n'));
}

Expand Down