Skip to content

Commit

Permalink
support github repo names with dots
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 609745001
Change-Id: I451e744658275cdefd7ca74dac466dbb0189f05e
  • Loading branch information
jeyoungk authored and copybara-github committed Feb 23, 2024
1 parent 2aa4e5c commit 19ed647
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion java/com/google/copybara/git/GitHubPrIntegrateLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GitHubPrIntegrateLabel implements IntegrateLabel {

private static final Pattern LABEL_PATTERN =
Pattern.compile(
"https://github.com/([a-zA-Z0-9_/-]+)/pull/([0-9]+)"
"https://github.com/([.a-zA-Z0-9_/-]+)/pull/([0-9]+)"
+ " from ([^\\s\\r\\n]*)(?: ([0-9a-f]{7,40}))?");

private final GitRepository repository;
Expand Down
28 changes: 28 additions & 0 deletions javatests/com/google/copybara/git/GitHubPrIntegrateLabelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,32 @@ public void testParseLabel() {
+ " from copybarrista:main dbb8386719596088dbf7513fad87559b2ff796cc ", repo, options))
.isNotNull();
}

@Test
public void testParseLabel_containsDot() {
GeneralOptions options =
new GeneralOptions(ImmutableMap.of(), FileSystems.getDefault(), console);

assertThat(
GitHubPrIntegrateLabel.parse(
"https://github.com/foo.cpp/bar/pull/18"
+ " from copybarrista:main dbb8386719596088dbf7513fad87559b2ff796cc ",
repo,
options))
.isNotNull();
}

@Test
public void testParseLabel_hyphenatedUser() {
GeneralOptions options =
new GeneralOptions(ImmutableMap.of(), FileSystems.getDefault(), console);

assertThat(
GitHubPrIntegrateLabel.parse(
"https://github.com/foo/bar/pull/18"
+ " from hyphenated-user:main dbb8386719596088dbf7513fad87559b2ff796cc ",
repo,
options))
.isNotNull();
}
}

0 comments on commit 19ed647

Please # to comment.