Skip to content

Commit 3952845

Browse files
henrymercerCopilot
andcommitted
Remove unused updateChangelog from bundle-changelog.ts
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 9bc74b1 commit 3952845

2 files changed

Lines changed: 0 additions & 106 deletions

File tree

‎pr-checks/bundle-changelog.test.ts‎

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ import {
1515
getPRNumber,
1616
getPRUrl,
1717
PR_URL_ENV_VAR,
18-
updateChangelog,
1918
} from "./bundle-changelog";
20-
import {
21-
EMPTY_CHANGELOG,
22-
NO_CHANGES_STR,
23-
UNRELEASED_PLACEHOLDER,
24-
} from "./changelog";
2519
import { isValidChangenoteContent } from "./changelog/validate";
2620

2721
let testDir: string;
@@ -87,62 +81,6 @@ describe("getPRNumber", async () => {
8781
});
8882
});
8983

90-
const testChangelog = `${EMPTY_CHANGELOG.trimEnd()}
91-
92-
## 4.23.7
93-
94-
- Other change
95-
96-
## 4.23.6
97-
98-
${NO_CHANGES_STR}`;
99-
100-
const expectedChangelog = `# CodeQL Action Changelog
101-
102-
## ${UNRELEASED_PLACEHOLDER}
103-
104-
- Update default CodeQL bundle version to
105-
106-
## 4.23.7
107-
108-
- Other change
109-
110-
## 4.23.6
111-
112-
${NO_CHANGES_STR}`;
113-
114-
describe("updateChangelog", async () => {
115-
await it("removes `NO_CHANGES_STR` if present in [UNRELEASED] section", async () => {
116-
const result = updateChangelog(EMPTY_CHANGELOG, "");
117-
assert.ok(!result.includes(NO_CHANGES_STR));
118-
});
119-
120-
await it("doesn't remove `NO_CHANGES_STR` if present in versioned section", async () => {
121-
const result = updateChangelog(
122-
EMPTY_CHANGELOG.replace(UNRELEASED_PLACEHOLDER, "1.2.3"),
123-
"",
124-
);
125-
assert.ok(result.includes(NO_CHANGES_STR));
126-
});
127-
128-
await it("throws if there are no sections", async () => {
129-
assert.throws(() => {
130-
updateChangelog(
131-
"# CodeQL Action Changelog",
132-
"- Update default CodeQL bundle version to",
133-
);
134-
});
135-
});
136-
137-
await it("adds note at the end of the first section", async () => {
138-
const result = updateChangelog(
139-
testChangelog,
140-
"- Update default CodeQL bundle version to",
141-
);
142-
assert.deepEqual(result, expectedChangelog);
143-
});
144-
});
145-
14684
describe("getChangenote", async () => {
14785
await it("returns a note linking to the bundle release and the PR", async () => {
14886
assert.equal(

‎pr-checks/bundle-changelog.ts‎

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
import * as fs from "node:fs";
88
import * as path from "node:path";
99

10-
import {
11-
parseChangelog,
12-
renderChangelog,
13-
UNRELEASED_PLACEHOLDER,
14-
} from "./changelog";
1510
import { CHANGENOTES_DIR, CLI_BUNDLE_RELEASE_URL_PREFIX } from "./config";
1611
import { getErrorMessage } from "./util";
1712

@@ -58,45 +53,6 @@ export function getPRNumber(prUrl: string) {
5853
return prNumber;
5954
}
6055

61-
/**
62-
* Updates `changelog` by adding `changelogNote` to the first section.
63-
*
64-
* @param contents The existing changelog contents.
65-
* @param changelogNote The note to add to the first section.
66-
*/
67-
export function updateChangelog(contents: string, changelogNote: string) {
68-
// If the "[UNRELEASED]" section starts with "no user facing changes", remove that line.
69-
contents = contents.replace(
70-
`## ${UNRELEASED_PLACEHOLDER}\n\nNo user facing changes.`,
71-
`## ${UNRELEASED_PLACEHOLDER}\n`,
72-
);
73-
74-
const changelog = parseChangelog(contents);
75-
76-
if (changelog.sections.length === 0) {
77-
throw new Error("The changelog contains no existing sections.");
78-
}
79-
80-
// Add the changelog note to the bottom of the first section.
81-
const firstSection = changelog.sections[0];
82-
const lastLine = firstSection.bodyLines.pop();
83-
84-
if (lastLine !== undefined && lastLine.trim() !== "") {
85-
// We expect the last line to be empty. If it isn't for some reason,
86-
// add it back.
87-
firstSection.bodyLines.push(lastLine);
88-
}
89-
90-
firstSection.bodyLines.push(changelogNote);
91-
92-
// If the last line is empty as expected, then add it back in after the new note.
93-
if (lastLine?.trim() === "") {
94-
firstSection.bodyLines.push(lastLine);
95-
}
96-
97-
return renderChangelog(changelog);
98-
}
99-
10056
/**
10157
* Returns the contents of the changenote file for an update to the default
10258
* CodeQL CLI bundle.

0 commit comments

Comments
 (0)