Skip to content

Commit aacaa41

Browse files
authored
Add some ERC-related naming edge cases (#342)
* Add some ERC-related naming edge cases Signed-off-by: Gavin John <[email protected]> * Add test case Signed-off-by: Gavin John <[email protected]> --------- Signed-off-by: Gavin John <[email protected]>
1 parent f28ba32 commit aacaa41

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/__tests__/namePR.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,20 @@ describe("namePR", () => {
241241
} as PullRequest, files);
242242
expect(prTitle).toEqual(`${localConfig.title.updateEipPrefix.replace("EIP", "ERC").replace("XXXX", "9999")}PR Title Testing 123 (Update ERC-9999)`);
243243
});
244+
245+
it("Correctly Names Simulated PR-18: Modifies ERC-1", async () => {
246+
let files = [{
247+
filename: "ERCS/erc-1.md",
248+
status: "modified",
249+
contents: "---\ntitle: EIP Rules And Guidelines\nstatus: Living\n---\n## Testing1",
250+
previous_contents: "---\ntitle: EIP Rules And Guidelines\nstatus: Living\n---\n## Testing2"
251+
}] as File[];
252+
const prTitle = await generatePRTitle({
253+
title: "PR Title Testing 123 (ERC-1)",
254+
user: {
255+
login: "testUser"
256+
} as User
257+
} as PullRequest, files);
258+
expect(prTitle).toEqual(`${localConfig.title.updateEipPrefix.replace("EIP", "ERC").replace("XXXX", "1")}PR Title Testing 123 (ERC-1)`);
259+
});
244260
});

src/namePr.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function generatePRTitle(pull_request: PullRequest, files: File[])
2121

2222
// If the PR modifies the website, use Website prefix unless the beginning portion is for EIP-1
2323
if (
24-
(files.some(file => file.filename.endsWith(".html") || file.filename.endsWith(".js") || file.filename.endsWith(".css") || (file.filename.startsWith("assets/") && !file.filename.startsWith("assets/eip-")))) &&
24+
(files.some(file => file.filename.endsWith(".html") || file.filename.endsWith(".js") || file.filename.endsWith(".css") || (file.filename.startsWith("assets/") && !file.filename.startsWith("assets/eip-") && !file.filename.startsWith("assets/erc-")))) &&
2525
(!beginnningPortion || !beginnningPortion.toLowerCase().endsWith("eip-1"))
2626
) {
2727
return localConfig.title.websitePrefix + title;
@@ -32,6 +32,11 @@ export async function generatePRTitle(pull_request: PullRequest, files: File[])
3232
return localConfig.title.updateEipPrefix.replace("EIP-XXXX", "EIP-1") + title;
3333
}
3434

35+
// If the PR modifies ERC-1, indicate that
36+
if (files.some(file => file.filename == "ERCS/erc-1.md")) {
37+
return localConfig.title.updateEipPrefix.replace("EIP-XXXX", "ERC-1") + title;
38+
}
39+
3540
// If the PR changes a file in the .github/workflows directory, use CI prefix
3641
if (files.some(file => file.filename.startsWith(".github/workflows"))) {
3742
return localConfig.title.ciPrefix + title;

0 commit comments

Comments
 (0)