Skip to content
Merged
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
31 changes: 16 additions & 15 deletions scripts/changelog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { config } = require('dotenv');
const { getInfo } = require('@changesets/get-github-info');
const { getCommitInfo } = require('@changesets/get-github-info');

config();

Expand All @@ -8,6 +8,15 @@ const SEE_LINE = /^See:\s*(.*)/i;
const TRAILING_CHAR = /[.;:]$/g;
const listFormatter = new Intl.ListFormat('en-US');

const getCommitLinks = async commit => {
const info = await getCommitInfo({ repo: REPO, commit });
return {
commit: info?.commit.markdownLink,
pull: info?.pull?.markdownLink,
user: info?.author?.markdownLink,
};
};

const getSummaryLines = cs => {
let lines = cs.summary.trim().split(/\r?\n/);
if (!lines.some(line => /```/.test(line))) {
Expand Down Expand Up @@ -49,12 +58,7 @@ const changelogFunctions = {
return (match && match[1].trim()) || undefined;
}

const { links } = await getInfo({
repo: REPO,
commit: cs.commit,
});

return links;
return getCommitLinks(cs.commit);
})
);

Expand Down Expand Up @@ -83,14 +87,11 @@ const changelogFunctions = {
const [firstLine, ...futureLines] = lines;

if (changeset.commit && !pull) {
const { links } = await getInfo({
repo: REPO,
commit: changeset.commit,
});

pull = links.pull || undefined;
commit = links.commit || undefined;
user = links.user || undefined;
const links = await getCommitLinks(changeset.commit);

pull = links.pull;
commit = links.commit;
user = links.user;
}

let annotation = '';
Expand Down