Skip to content

Commit 62bfe52

Browse files
committed
chore: new attempt
1 parent 09e139e commit 62bfe52

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/index.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ interface ChangesetWithPR extends NewChangesetWithCommit {
1212

1313
// Keep track of all authors across changesets
1414
let allAuthors = new Set<string>();
15-
let patchChanges = new Set<string>();
15+
let hasAddedCredits = false; // Track if we've added credits in this changelog
1616

1717
// Reset function to be called at the start of each changelog generation
1818
function resetChangelogState() {
1919
allAuthors.clear();
20-
patchChanges.clear();
20+
hasAddedCredits = false;
2121
}
2222

2323
async function getReleaseLine(
@@ -63,7 +63,6 @@ async function getReleaseLine(
6363
repo,
6464
pull: prFromSummary,
6565
});
66-
console.log(`[Debug] Pull request info: ${user}`);
6766
if (user) {
6867
allAuthors.add(user);
6968
}
@@ -77,7 +76,6 @@ async function getReleaseLine(
7776
repo,
7877
commit: commitToFetchFrom,
7978
});
80-
console.log(`[Debug] Commit info: ${info.user}`);
8179
if (info.user) {
8280
allAuthors.add(info.user);
8381
}
@@ -140,7 +138,6 @@ async function getDependencyReleaseLine(
140138
repo,
141139
commit: cs.commit,
142140
});
143-
console.log(`[Debug] Commit info: ${user}`);
144141
if (user) {
145142
allAuthors.add(user);
146143
}
@@ -174,8 +171,15 @@ async function getDependencyReleaseLine(
174171

175172
// Function to get the credits section
176173
function getCreditsSection(): string {
174+
if (allAuthors.size === 0) {
175+
return "";
176+
}
177+
178+
if (hasAddedCredits) {
179+
return "";
180+
}
181+
177182
const authors = Array.from(allAuthors).sort();
178-
console.log(`[Debug] Authors: ${authors}`);
179183
const authorLinks = authors.map((author) => `@${author}`);
180184

181185
if (authorLinks.length === 0) {
@@ -194,6 +198,7 @@ function getCreditsSection(): string {
194198
)}, and ${lastAuthor} for helping!`;
195199
}
196200

201+
hasAddedCredits = true;
197202
return credits;
198203
}
199204

@@ -205,11 +210,13 @@ const wrappedGetReleaseLine: ChangelogFunctions["getReleaseLine"] = async (
205210
) => {
206211
const result = await getReleaseLine(changeset as ChangesetWithPR, type, opts);
207212

208-
// Track patch changes
209-
if (type === "patch") {
210-
patchChanges.add(changeset.summary);
213+
// Add credits section if this is the last entry and we have authors
214+
if (allAuthors.size > 0 && !hasAddedCredits) {
215+
const credits = getCreditsSection();
216+
// Reset state after adding credits
217+
resetChangelogState();
218+
return result + credits;
211219
}
212-
213220
return result;
214221
};
215222

@@ -221,9 +228,8 @@ const wrappedGetDependencyReleaseLine: ChangelogFunctions["getDependencyReleaseL
221228
opts
222229
);
223230

224-
console.log(`[Debug] Authors: ${allAuthors.size}`);
225-
// Add credits section if we have authors
226-
if (allAuthors.size > 0) {
231+
// Add credits section if this is the last entry and we have authors
232+
if (allAuthors.size > 0 && !hasAddedCredits) {
227233
const credits = getCreditsSection();
228234
// Reset state after adding credits
229235
resetChangelogState();

0 commit comments

Comments
 (0)