aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/common.go
diff options
context:
space:
mode:
authorJeremy Stribling <strib@users.noreply.github.com>2019-02-13 07:28:28 -0800
committerGitHub <noreply@github.com>2019-02-13 07:28:28 -0800
commit2ab6d5cd72b59cfd36b08078ddeebd1efb0d2254 (patch)
treea398b9df6d0d1afd13b6923393766a96b2a7af2d /plumbing/transport/common.go
parentdcc9f375f4daedfef61e7ff2fbbfd851d42a72d8 (diff)
parent3889c6446da5f9d658b9bfe317429196e25aa4b7 (diff)
downloadgo-git-2ab6d5cd72b59cfd36b08078ddeebd1efb0d2254.tar.gz
Merge pull request #1066 from keybase/strib/909-git-push-speedup-when-local
remote: speed up pushes when the "remote" repo is local
Diffstat (limited to 'plumbing/transport/common.go')
-rw-r--r--plumbing/transport/common.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/plumbing/transport/common.go b/plumbing/transport/common.go
index f7b882b..dcf9391 100644
--- a/plumbing/transport/common.go
+++ b/plumbing/transport/common.go
@@ -19,10 +19,10 @@ import (
"fmt"
"io"
"net/url"
- "regexp"
"strconv"
"strings"
+ giturl "gopkg.in/src-d/go-git.v4/internal/url"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp"
"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/capability"
@@ -224,34 +224,28 @@ func getPath(u *url.URL) string {
return res
}
-var (
- isSchemeRegExp = regexp.MustCompile(`^[^:]+://`)
- scpLikeUrlRegExp = regexp.MustCompile(`^(?:(?P<user>[^@]+)@)?(?P<host>[^:\s]+):(?:(?P<port>[0-9]{1,5})/)?(?P<path>[^\\].*)$`)
-)
-
func parseSCPLike(endpoint string) (*Endpoint, bool) {
- if isSchemeRegExp.MatchString(endpoint) || !scpLikeUrlRegExp.MatchString(endpoint) {
+ if giturl.MatchesScheme(endpoint) || !giturl.MatchesScpLike(endpoint) {
return nil, false
}
- m := scpLikeUrlRegExp.FindStringSubmatch(endpoint)
-
- port, err := strconv.Atoi(m[3])
+ user, host, portStr, path := giturl.FindScpLikeComponents(endpoint)
+ port, err := strconv.Atoi(portStr)
if err != nil {
port = 22
}
return &Endpoint{
Protocol: "ssh",
- User: m[1],
- Host: m[2],
+ User: user,
+ Host: host,
Port: port,
- Path: m[4],
+ Path: path,
}, true
}
func parseFile(endpoint string) (*Endpoint, bool) {
- if isSchemeRegExp.MatchString(endpoint) {
+ if giturl.MatchesScheme(endpoint) {
return nil, false
}