Skip to content

Commit

Permalink
#308 fix download sources
Browse files Browse the repository at this point in the history
  • Loading branch information
yzerk committed Mar 1, 2023
1 parent d6db0a2 commit 8589484
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/com/crowdin/cli/utils/PlaceholderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,26 @@ 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)
.replace(ESCAPE_DOT_PLACEHOLDER, ESCAPE_DOT)

.replace(ESCAPE_QUESTION, ESCAPE_QUESTION_PLACEHOLDER)
.replace(QUESTION_MARK, "[^/]")
.replace(ESCAPE_QUESTION_PLACEHOLDER, ESCAPE_QUESTION);

if (Utils.isWindows()) {
toFormat = toFormat
.replace("**", ".+")
.replace("\\", "\\\\")
.replace(ASTERISK, "[^/]+");
.replace("\\" + ASTERISK + "\\", "[^/]+")
;
} else {
toFormat = toFormat
.replace(ESCAPE_DOT, ESCAPE_DOT_PLACEHOLDER)
.replace(DOT, ESCAPE_DOT)
.replace(ESCAPE_DOT_PLACEHOLDER, ESCAPE_DOT)
.replace(ESCAPE_ASTERISK, ESCAPE_ASTERISK_PLACEHOLDER)
.replace("**", ".+")
.replace(ESCAPE_ASTERISK_PLACEHOLDER, ESCAPE_ASTERISK)
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

0 comments on commit 8589484

Please sign in to comment.