From 23fb84ef13aacdc2efc3b9de079813c14f6838e9 Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Mon, 17 Apr 2017 15:29:23 -0600 Subject: [PATCH] commands/uploader: ignore known supporters of the locking API --- commands/uploader.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/commands/uploader.go b/commands/uploader.go index 65e54b97..10ba253b 100644 --- a/commands/uploader.go +++ b/commands/uploader.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "net/url" "os" "strconv" "strings" @@ -135,7 +136,7 @@ func verifyLocks(remote string) (ours, theirs []locking.Lock) { } else { ExitWithError(err) } - } else if state == verifyStateUnknown { + } else if state == verifyStateUnknown && !supportsLockingAPI(endpoint) { Print("Locking support detected on remote %q. Consider enabling it with:", remote) Print(" $ git config 'lfs.%s.locksverify' true", endpoint.Url) } @@ -143,6 +144,35 @@ func verifyLocks(remote string) (ours, theirs []locking.Lock) { return ours, theirs } +var ( + // hostsWithKnownLockingSupport is a list of scheme-less hostnames + // (without port numbers) that are known to implement the LFS locking + // API. + // + // Additions are welcome. + hostsWithKnownLockingSupport = []string{ + "github.com", + } +) + +// supportsLockingAPI returns whether or not a given lfsapi.Endpoint "e" +// is known to support the LFS locking API by whether or not its hostname is +// included in the list above. +func supportsLockingAPI(e lfsapi.Endpoint) bool { + u, err := url.Parse(e.Url) + if err != nil { + tracerx.Printf("commands: unable to parse %q to determine locking support: %v", e.Url, err) + return false + } + + for _, host := range hostsWithKnownLockingSupport { + if u.Hostname() == host { + return true + } + } + return false +} + func (c *uploadContext) scannerError() error { c.errMu.Lock() defer c.errMu.Unlock()