Skip to content

Commit 478a494

Browse files
authored
Danger repo name check fixes (#16)
* Fix color checks. * Fix localization warning string.
1 parent e54ba54 commit 478a494

3 files changed

Lines changed: 13 additions & 19 deletions

File tree

org/allPRs.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,7 @@ export const localizedStrings = async () => {
8686
// * NSLocalizedString(
8787
// This way it will match `NSLocalizedString(` but not `NSLocalizedString` (without the opening parenthesis, which could be used in a comment).
8888
if (addedLines?.find(value => /\bNSLocalizedString\(/.test(value))) {
89-
let instructions = "";
90-
if (danger.github.thisPR.repo == "iOS") {
91-
instructions = " See [Localization Guidelines](https://app.asana.com/0/0/1185863667140706/f) for more information.";
92-
} else if (danger.github.thisPR.repo == "macos-browser") {
93-
instructions = " See [Localization Guidelines](https://app.asana.com/0/0/1206727265537758/f) for more information.";
94-
}
89+
let instructions = " See [iOS](https://app.asana.com/0/0/1185863667140706/f) and [macOS](https://app.asana.com/0/0/1206727265537758/f) localization guidelines for more information.";
9590
message("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change." + instructions);
9691
break;
9792
}
@@ -108,9 +103,9 @@ export const licensedFonts = async () => {
108103

109104
export const newColors = async () => {
110105
// Fail if new colors are added to the app (DesignResourcesKit)
111-
if (danger.github.thisPR.repo == "iOS") {
106+
if (danger.github.thisPR.repo == "apple-browsers") {
112107
const createdFiles = danger.git.created_files;
113-
if (createdFiles.some(path => path.match(/Assets.xcassets\/.*\.colorset/))) {
108+
if (createdFiles.some(path => path.match(/iOS\/DuckDuckGo\/Assets.xcassets\/.*\.colorset/))) {
114109
fail("DesignResourcesKit: No new colors should be added to this app.")
115110
}
116111
}

tests/localizedStrings.allPRs.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe("Localized Strings checks", () => {
8484

8585
await localizedStrings()
8686

87-
expect(dm.message).toHaveBeenCalledWith("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See [Localization Guidelines](https://app.asana.com/0/0/1185863667140706/f) for more information.")
87+
expect(dm.message).toHaveBeenCalledWith("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See [iOS](https://app.asana.com/0/0/1185863667140706/f) and [macOS](https://app.asana.com/0/0/1206727265537758/f) localization guidelines for more information.")
8888
})
8989

9090
it("messages with added code that contains NSLocalizedString call, including macOS Localization guidelines URL when run for macos-browser repo", async () => {
@@ -95,7 +95,7 @@ describe("Localized Strings checks", () => {
9595

9696
await localizedStrings()
9797

98-
expect(dm.message).toHaveBeenCalledWith("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See [Localization Guidelines](https://app.asana.com/0/0/1206727265537758/f) for more information.")
98+
expect(dm.message).toHaveBeenCalledWith("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See [iOS](https://app.asana.com/0/0/1185863667140706/f) and [macOS](https://app.asana.com/0/0/1206727265537758/f) localization guidelines for more information.")
9999
})
100100

101101
it("messages with UserText.swift-style added code, including iOS Localization guidelines URL when run for iOS repo", async () => {
@@ -106,7 +106,7 @@ describe("Localized Strings checks", () => {
106106

107107
await localizedStrings()
108108

109-
expect(dm.message).toHaveBeenCalledWith("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See [Localization Guidelines](https://app.asana.com/0/0/1185863667140706/f) for more information.")
109+
expect(dm.message).toHaveBeenCalledWith("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See [iOS](https://app.asana.com/0/0/1185863667140706/f) and [macOS](https://app.asana.com/0/0/1206727265537758/f) localization guidelines for more information.")
110110
})
111111

112112
it("messages with UserText.swift-style added code, including macOS Localization guidelines URL when run for macos-browser repo", async () => {
@@ -117,6 +117,6 @@ describe("Localized Strings checks", () => {
117117

118118
await localizedStrings()
119119

120-
expect(dm.message).toHaveBeenCalledWith("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See [Localization Guidelines](https://app.asana.com/0/0/1206727265537758/f) for more information.")
120+
expect(dm.message).toHaveBeenCalledWith("You seem to be updating localized strings. Make sure that you request translations and include translated strings before you ship your change. See [iOS](https://app.asana.com/0/0/1185863667140706/f) and [macOS](https://app.asana.com/0/0/1206727265537758/f) localization guidelines for more information.")
121121
})
122122
})

tests/newColors.allPRs.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ beforeEach(() => {
1010

1111
dm.danger = {
1212
git: {
13-
modified_files: ["Core/AppConfigurationURLProvider.swift"],
13+
modified_files: ["iOS/Core/AppConfigurationURLProvider.swift"],
1414
created_files: [],
1515
deleted_files: [],
1616
},
1717
github: {
1818
thisPR: {
19-
repo: "iOS"
19+
repo: "apple-browsers"
2020
}
2121
},
2222
};
@@ -32,24 +32,23 @@ describe("New colors checks", () => {
3232
})
3333

3434
it("does not fail with changes to colorset files", async () => {
35-
dm.danger.git.modified_files = ["DuckDuckGo/Assets.xcassets/SomeColor.colorset/Contents.json", "Core/AppConfigurationURLProvider.swift"]
35+
dm.danger.git.modified_files = ["iOS/DuckDuckGo/Assets.xcassets/SomeColor.colorset/Contents.json", "iOS/Core/AppConfigurationURLProvider.swift"]
3636

3737
await newColors()
3838

3939
expect(dm.fail).not.toHaveBeenCalled()
4040
})
4141

4242
it("fails with new colorset file", async () => {
43-
dm.danger.git.created_files = ["DuckDuckGo/Assets.xcassets/SomeColor.colorset/Contents.json", "Core/AppConfigurationURLProvider.swift"]
43+
dm.danger.git.created_files = ["iOS/DuckDuckGo/Assets.xcassets/SomeColor.colorset/Contents.json", "iOS/Core/AppConfigurationURLProvider.swift"]
4444

4545
await newColors()
4646

4747
expect(dm.fail).toHaveBeenCalledWith("DesignResourcesKit: No new colors should be added to this app.")
4848
})
4949

50-
it("does not fail in others repos than iOS", async () => {
51-
dm.danger.github.thisPR.repo = "macos-browser"
52-
dm.danger.git.created_files = ["DuckDuckGo/Assets.xcassets/SomeColor.colorset/Contents.json"]
50+
it("does not fail in the macOS client", async () => {
51+
dm.danger.git.created_files = ["macOS/DuckDuckGo/Assets.xcassets/SomeColor.colorset/Contents.json"]
5352

5453
await newColors()
5554

0 commit comments

Comments
 (0)