commands/uploader: ignore known supporters of the locking API

This commit is contained in:
Taylor Blau 2017-04-17 15:29:23 -06:00
parent b244dd4157
commit 23fb84ef13

@ -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()