Skip to content

Commit

Permalink
[git] Restore double-dot as prohibited combination, and substitute to…
Browse files Browse the repository at this point in the history
… underscore

Fix corresponding test

GitOrigin-RevId: 52c442bc72203f44f37de6db249a44a5666a4688
  • Loading branch information
dmitriysmirnovjb authored and intellij-monorepo-bot committed Oct 20, 2020
1 parent 8377287 commit 469bd22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public final class GitRefNameValidator implements InputValidator {
"(^\\.)|" + // begins with a dot
"(^-)|" + // begins with '-'
"(^/)|" + // begins with '/'
"(\\.\\.)+|" + // two dots in a row
"[ ~:^?*\\[\\\\]+|(@\\{)+|" + // contains invalid character: space, one of ~:^?*[\ or @{ sequence
CONTROL_CHARS // contains a control character
);
Expand Down Expand Up @@ -85,6 +86,6 @@ public String cleanUpBranchNameOnTyping(@NotNull String branchName) {

@NotNull
public String deduplicateChars(@NotNull String branchName) {
return branchName.replaceAll("(/){2,}", "/" ).replaceAll("(\\.){2,}", ".").replaceAll("(_){2,}", "_");
return branchName.replaceAll("(/){2,}", "/" ).replaceAll("(_){2,}", "_");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ private static Object[][] createValidData() {
{ "UNDERSCORED_WORD", "new_branch" },
{ "HIERARCHY", "user/branch" },
{ "HIERARCHY_2", "user/branch/sub_branch" },
{ "BEGINS_WITH_SLASH", "/branch" }, // actual branch name will be with trimmed slash
{ "NON_CONS_DOTS", "complex.branch.name" },
{ "GERRIT_PATTERN", "refs/for/master%topic=my-cool-feature,r=some-reviewer"},
{ "CONTAINS_MINUS", "b-ranch"},
Expand All @@ -53,6 +52,7 @@ private static Object[][] createValidData() {
private static Object[][] createInvalidData() {
return new Object[][] {
{ "BEGIN_WITH_DOT", ".branch" },
{ "BEGINS_WITH_SLASH", "/branch" },
{ "ONLY_DOT", "." },
{ "ENDS_WITH_SLASH", "branch/" },
{ "ENDS_WITH_DOT", "branch." },
Expand Down

0 comments on commit 469bd22

Please sign in to comment.