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

#308 - fix download sources command #537

Merged
merged 2 commits into from
Mar 2, 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
8 changes: 6 additions & 2 deletions src/main/java/com/crowdin/cli/utils/PlaceholderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ public List<String> formatForRegex(List<String> toFormat, boolean onProjectLangs
}

public static String formatSourcePatternForRegex(String toFormat) {
if(Utils.isWindows()){
toFormat = toFormat
.replace("\\", "\\\\");
}
toFormat = toFormat
.replace(ESCAPE_DOT, ESCAPE_DOT_PLACEHOLDER)
.replace(DOT, ESCAPE_DOT)
Expand All @@ -237,8 +241,8 @@ public static String formatSourcePatternForRegex(String toFormat) {
if (Utils.isWindows()) {
toFormat = toFormat
.replace("**", ".+")
.replace("\\", "\\\\")
.replace(ASTERISK, "[^/]+");
.replace("\\" + ASTERISK + "\\", "[^/]+")
;
} else {
toFormat = toFormat
.replace(ESCAPE_ASTERISK, ESCAPE_ASTERISK_PLACEHOLDER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.crowdin.cli.properties.helper.TempProject;
import com.crowdin.cli.utils.PlaceholderUtilBuilder;
import com.crowdin.cli.utils.Utils;
import org.apache.commons.io.FilenameUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -14,6 +15,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -160,6 +162,7 @@ public void testFilterProjectFiles_wPreserveHierarchy_wIgnores(
List<String> actual = SourcesUtils.filterProjectFiles(
filePaths, sourcePattern, ignorePatterns, true, PlaceholderUtilBuilder.STANDART.build(""));
// assertEquals(expected.size(), actual.size());
expected = expected.stream().map(FilenameUtils::separatorsToSystem).collect(Collectors.toList());
assertThat(actual, containsInAnyOrder(expected.toArray()));
}

Expand Down