Skip to content

Commit c9b647c

Browse files
vaindclaude
andcommitted
refactor: simplify dangerfile to focus on testing and flavor improvements
Remove inline suggestions functionality to focus this PR on: - Improved flavor recognition and configuration - Testing infrastructure additions - Consolidating skip-changelog flavors The inline suggestions feature will be implemented in a separate PR. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0b46341 commit c9b647c

File tree

1 file changed

+13
-40
lines changed

1 file changed

+13
-40
lines changed

danger/dangerfile.js

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { getFlavorConfig, findChangelogInsertionPoint, extractPRFlavor } = require('./dangerfile-utils.js');
1+
const { getFlavorConfig, extractPRFlavor } = require('./dangerfile-utils.js');
22

33
const headRepoName = danger.github.pr.head.repo.git_url;
44
const baseRepoName = danger.github.pr.base.repo.git_url;
@@ -77,7 +77,7 @@ async function checkChangelog() {
7777

7878
// check if a changelog entry exists
7979
if (!changelogMatch) {
80-
return await reportMissingChangelog(changelogFile);
80+
return reportMissingChangelog(changelogFile);
8181
}
8282

8383
// Check if the entry is added to an Unreleased section (or rather, check that it's not added to a released one)
@@ -96,42 +96,21 @@ async function checkChangelog() {
9696

9797

9898
/// Report missing changelog entry
99-
async function reportMissingChangelog(changelogFile) {
99+
function reportMissingChangelog(changelogFile) {
100+
fail("Please consider adding a changelog entry for the next release.", changelogFile);
101+
100102
const prTitleFormatted = danger.github.pr.title
101103
.split(": ")
102104
.slice(-1)[0]
103105
.trim()
104106
.replace(/\.+$/, "");
105107

106-
try {
107-
const changelogContents = await danger.github.utils.fileContents(changelogFile);
108-
const lines = changelogContents.split('\n');
109-
110-
// Determine the appropriate section based on PR flavor
111-
const flavorConfig = getFlavorConfig(prFlavor);
112-
const sectionName = flavorConfig.changelog;
113-
const newEntry = `- ${prTitleFormatted} ([#${danger.github.pr.number}](${danger.github.pr.html_url}))`;
114-
115-
// Find where to insert the changelog entry
116-
const insertionResult = findChangelogInsertionPoint(lines, sectionName);
117-
118-
if (insertionResult.success) {
119-
// Create an inline suggestion
120-
const suggestion = insertionResult.isNewSection
121-
? `${insertionResult.sectionHeader}\n\n${newEntry}`
122-
: newEntry;
123-
124-
fail(
125-
`Please consider adding a changelog entry for the next release:\n\n\`\`\`suggestion\n${suggestion}\n\`\`\``,
126-
changelogFile,
127-
insertionResult.lineNumber
128-
);
129-
} else {
130-
// Fallback to the original approach if we can't determine the insertion point
131-
fail("Please consider adding a changelog entry for the next release.", changelogFile);
132-
133-
markdown(
134-
`
108+
// Determine the appropriate section based on PR flavor
109+
const flavorConfig = getFlavorConfig(prFlavor);
110+
const sectionName = flavorConfig.changelog || "Features";
111+
112+
markdown(
113+
`
135114
### Instructions and example for changelog
136115
137116
Please add an entry to \`${changelogFile}\` to the "Unreleased" section. Make sure the entry includes this PR's number.
@@ -147,14 +126,8 @@ Example:
147126
\`\`\`
148127
149128
If none of the above apply, you can opt out of this check by adding \`#skip-changelog\` to the PR description or adding a \`skip-changelog\` label.`.trim(),
150-
changelogFile
151-
);
152-
}
153-
} catch (error) {
154-
console.log(`::debug:: Error reading changelog for suggestion: ${error.message}`);
155-
// Fallback to original approach
156-
fail("Please consider adding a changelog entry for the next release.", changelogFile);
157-
}
129+
changelogFile
130+
);
158131
}
159132

160133
async function checkActionsArePinned() {

0 commit comments

Comments
 (0)