Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: source downloading when source and dest have different base name #608

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void act(Outputter out, PropertiesWithFiles properties, ProjectClient cli
String translationPattern = TranslationsUtils.replaceDoubleAsterisk(fileBean.getSource(), fileBean.getTranslation(), filePathKey);
if (exportPattern == null || translationPattern.endsWith(exportPattern)) {
String sourceName = new java.io.File(fileBean.getSource()).getName();
if(sourceName.equals(new java.io.File(filePathKey).getName()) || SourcesUtils.containsPattern(sourceName)) {
if(sourceName.equals(new java.io.File(filePathKey).getName()) || SourcesUtils.containsPattern(sourceName) || searchPattern.contains(filePathKey)) {
filePaths2.add(filePathKey);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void testDifferentPatterns() throws IOException {
.addBuiltFileBean("/folder_2/android_4?.xml", "/%locale%/folder_2/%file_name%.xml")
.addBuiltFileBean("folder1/folder2/**/messages.json", "/folder1/folder2/**/%file_name%_%two_letters_code%.json", new ArrayList<>(), "/folder_on_crowdin/%original_path%/%file_name%.json")
.addBuiltFileBean("folder1/folder2/**/plugins.json", "/folder1/folder2/**/%file_name%_%two_letters_code%.json", new ArrayList<>(), "/folder_on_crowdin/%original_path%/%file_name%.json")
.addBuiltFileBean("foo_string.json", "/workdir/foo/string_%two_letters_code%.json", new ArrayList<>(), "/foo_string.json")
.setBasePath(project.getBasePath())
.setPreserveHierarchy(true)
.build();
Expand All @@ -149,6 +150,7 @@ public void testDifferentPatterns() throws IOException {
.addFile("android_4a.xml", "gettext", 107L, 204L, null, "/%locale%/folder_2/%file_name%.xml")
.addFile("messages.json", "json", 108L, 208L, null, "/folder1/folder2/nested/%file_name%_%two_letters_code%.json")
.addFile("plugins.json", "json", 109L, 208L, null, "/folder1/folder2/nested/%file_name%_%two_letters_code%.json")
.addFile("foo_string.json", "json", 110L, null, null, null)
.build());
URL urlMock = MockitoUtils.getMockUrl(getClass());
when(client.downloadFile(eq(101L)))
Expand All @@ -169,6 +171,8 @@ public void testDifferentPatterns() throws IOException {
.thenReturn(urlMock);
when(client.downloadFile(eq(109L)))
.thenReturn(urlMock);
when(client.downloadFile(eq(110L)))
.thenReturn(urlMock);

FilesInterface files = mock(FilesInterface.class);

Expand All @@ -186,6 +190,7 @@ public void testDifferentPatterns() throws IOException {
verify(client).downloadFile(eq(107L));
verify(client).downloadFile(eq(108L));
verify(client).downloadFile(eq(109L));
verify(client).downloadFile(eq(110L));
verifyNoMoreInteractions(client);

verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/folder_1/android.xml")), any());
Expand All @@ -197,6 +202,7 @@ public void testDifferentPatterns() throws IOException {
verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/folder_2/android_4a.xml")), any());
verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/folder1/folder2/nested/messages.json")), any());
verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/folder1/folder2/nested/plugins.json")), any());
verify(files).writeToFile(eq(Utils.joinPaths(project.getBasePath(), "/foo_string.json")), any());
verifyNoMoreInteractions(files);
}

Expand Down