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

Update GitRemote#normalize to support organizations prefixed with a number #4651

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion rewrite-core/src/main/java/org/openrewrite/GitRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private String repositoryPath(RemoteServerMatch match, URI normalizedUri) {
.replaceFirst("^/", "");
}

private static final Pattern PORT_PATTERN = Pattern.compile(":\\d+");
private static final Pattern PORT_PATTERN = Pattern.compile(":\\d+(/.+)(/.+)+");

static URI normalize(String url) {
try {
Expand Down
3 changes: 3 additions & 0 deletions rewrite-core/src/test/java/org/openrewrite/GitRemoteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class GitRemoteTest {
@ParameterizedTest
@CsvSource(textBlock = """
https://github.com/org/repo, github.com, org/repo, org, repo
https://github.com/1org/repo, github.com, 1org/repo, 1org, repo
[email protected]:org/repo.git, github.com, org/repo, org, repo
[email protected]:1org/1repo.git, github.com, 1org/1repo, 1org, 1repo
ssh://github.com/org/repo.git, github.com, org/repo, org, repo

https://gitlab.com/group/repo.git, gitlab.com, group/repo, group, repo
Expand All @@ -41,6 +43,7 @@ public class GitRemoteTest {

https://bitbucket.org/PRJ/repo, bitbucket.org, PRJ/repo, PRJ, repo
[email protected]:PRJ/repo.git, bitbucket.org, PRJ/repo, PRJ, repo
[email protected]:1PRJ/repo.git, bitbucket.org, 1PRJ/repo, 1PRJ, repo
ssh://bitbucket.org/PRJ/repo.git, bitbucket.org, PRJ/repo, PRJ, repo

https://[email protected]/org/project/_git/repo, dev.azure.com, org/project/repo, org/project, repo
Expand Down