From c601a09fcf3e6fc389bf47d7381a9239f520c69d Mon Sep 17 00:00:00 2001 From: Bryce Tompkins Date: Wed, 6 Nov 2024 12:55:56 -0500 Subject: [PATCH 1/2] Update GitRemote#normalize to support organizations prefixed with a number --- rewrite-core/src/main/java/org/openrewrite/GitRemote.java | 2 +- rewrite-core/src/test/java/org/openrewrite/GitRemoteTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rewrite-core/src/main/java/org/openrewrite/GitRemote.java b/rewrite-core/src/main/java/org/openrewrite/GitRemote.java index b56b0997ed2..bdcfc429389 100644 --- a/rewrite-core/src/main/java/org/openrewrite/GitRemote.java +++ b/rewrite-core/src/main/java/org/openrewrite/GitRemote.java @@ -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 { diff --git a/rewrite-core/src/test/java/org/openrewrite/GitRemoteTest.java b/rewrite-core/src/test/java/org/openrewrite/GitRemoteTest.java index d765cd8aa1d..63759dedb7c 100644 --- a/rewrite-core/src/test/java/org/openrewrite/GitRemoteTest.java +++ b/rewrite-core/src/test/java/org/openrewrite/GitRemoteTest.java @@ -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 git@github.com:org/repo.git, github.com, org/repo, org, repo + git@github.com: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 @@ -41,6 +43,7 @@ public class GitRemoteTest { https://bitbucket.org/PRJ/repo, bitbucket.org, PRJ/repo, PRJ, repo git@bitbucket.org:PRJ/repo.git, bitbucket.org, PRJ/repo, PRJ, repo + git@bitbucket.org:1PRJ/repo.git, bitbucket.org, 1PRJ/repo, 1PRJ, repo ssh://bitbucket.org/PRJ/repo.git, bitbucket.org, PRJ/repo, PRJ, repo https://org@dev.azure.com/org/project/_git/repo, dev.azure.com, org/project/repo, org/project, repo From 3f139ae8b3d235924d18478795cb9a6f6d9652ca Mon Sep 17 00:00:00 2001 From: Bryce Tompkins Date: Tue, 12 Nov 2024 10:27:15 -0500 Subject: [PATCH 2/2] Update regex to match number only orgs --- rewrite-core/src/main/java/org/openrewrite/GitRemote.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rewrite-core/src/main/java/org/openrewrite/GitRemote.java b/rewrite-core/src/main/java/org/openrewrite/GitRemote.java index bdcfc429389..6816c8e9c8b 100644 --- a/rewrite-core/src/main/java/org/openrewrite/GitRemote.java +++ b/rewrite-core/src/main/java/org/openrewrite/GitRemote.java @@ -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 {