nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: seachicken/gh-poi
Pull request #110 (2023-09-09 10:52:29)

Fix parsing of ssh userinfo
Fix an issue where `git remote -v` did not work if the URL was `origin	hoge-1@github.com:org/repo (fetch)`


Patch:
diff --git a/shared/remote.go b/shared/remote.go
index 81b81fa..3579da8 100644
--- a/shared/remote.go
+++ b/shared/remote.go
@@ -13,7 +13,8 @@ type (
 	}
 )
 
-var regex = regexp.MustCompile(`^(?:\w+://|\w+@)?([a-zA-Z0-9\.-]+)[:/](.+?/.+?)(?:\.git|)$`)
+// https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
+var regex = regexp.MustCompile(`^(?:(?:[a-zA-Z0-9-._~]+)(?:://|@))?([a-zA-Z0-9-._~]+)[:/](.+?/.+?)(?:\.git|)$`)
 
 func NewRemote(remoteConfig string) Remote {
 	splitConfig := strings.Fields(remoteConfig)


Test patch:
diff --git a/shared/remote_test.go b/shared/remote_test.go
index 635f667..4de0c40 100644
--- a/shared/remote_test.go
+++ b/shared/remote_test.go
@@ -17,6 +17,17 @@ func Test_CreateRemoteWithScpLikeUrl(t *testing.T) {
 	)
 }
 
+func Test_CreateRemoteWithScpLikeUrlAndCustomUserinfo(t *testing.T) {
+	assert.Equal(t,
+		Remote{
+			Name:     "origin",
+			Hostname: "github.com",
+			RepoName: "org/repo",
+		},
+		NewRemote("origin	git0-._~@github.com:org/repo (fetch)"),
+	)
+}
+
 func Test_CreateRemoteWithScpLikeUrlWithoutUserinfo(t *testing.T) {
 	assert.Equal(t,
 		Remote{