diff --git a/api/api.go b/api/api.go index 16a046c2..12d01591 100644 --- a/api/api.go +++ b/api/api.go @@ -6,7 +6,9 @@ import ( "bytes" "encoding/json" "fmt" + "os" "strconv" + "sync" "github.com/github/git-lfs/config" "github.com/github/git-lfs/errors" @@ -114,6 +116,8 @@ func Batch(cfg *config.Configuration, objects []*ObjectResource, operation strin // Legacy calls the legacy API serially and returns ObjectResources // TODO LEGACY API: remove when legacy API removed func Legacy(cfg *config.Configuration, objects []*ObjectResource, operation string) ([]*ObjectResource, error) { + legacyWarning() + retobjs := make([]*ObjectResource, 0, len(objects)) dl := operation == "download" var globalErr error @@ -136,6 +140,8 @@ func Legacy(cfg *config.Configuration, objects []*ObjectResource, operation stri // TODO LEGACY API: remove when legacy API removed func DownloadCheck(cfg *config.Configuration, oid string) (*ObjectResource, error) { + legacyWarning() + req, err := NewRequest(cfg, "GET", oid) if err != nil { return nil, errors.Wrap(err, "download check") @@ -158,6 +164,8 @@ func DownloadCheck(cfg *config.Configuration, oid string) (*ObjectResource, erro // TODO LEGACY API: remove when legacy API removed func UploadCheck(cfg *config.Configuration, oid string, size int64) (*ObjectResource, error) { + legacyWarning() + reqObj := &ObjectResource{ Oid: oid, Size: size, @@ -204,3 +212,12 @@ func UploadCheck(cfg *config.Configuration, oid string, size int64) (*ObjectReso return obj, nil } + +var warningOnce sync.Once + +func legacyWarning() { + warningOnce.Do(func() { + fmt.Println(os.Stderr, "WARNING: Git LFS is using a deprecated API, which will be removed in v1.5.0.") + fmt.Println(os.Stderr, " Consider enabling the latest API by running: `git config lfs.batch true`.") + }) +} diff --git a/test/test-push-bad-dns.sh b/test/test-push-bad-dns.sh index baaac9bf..72523c6d 100755 --- a/test/test-push-bad-dns.sh +++ b/test/test-push-bad-dns.sh @@ -51,10 +51,11 @@ begin_test "push (legacy): upload to bad dns" git config lfs.url "http://git-lfs-bad-dns:$port" set +e - GIT_TERMINAL_PROMPT=0 git push origin master - res="$?" + GIT_TERMINAL_PROMPT=0 git push origin master 2>&1 | tee push.log + res="${PIPESTATUS[0]}" set -e + grep "WARNING: Git LFS is using a deprecated API" push.log refute_server_object "$reponame" "$(calc_oid "hi")" if [ "$res" = "0" ]; then echo "push successful?" diff --git a/test/test-push-legacy-failures.sh b/test/test-push-legacy-failures.sh index 8279e6f4..77662065 100755 --- a/test/test-push-legacy-failures.sh +++ b/test/test-push-legacy-failures.sh @@ -19,10 +19,11 @@ push_legacy_fail_test() { git commit -m "welp" set +e - git push origin master - res="$?" + git push origin master 2>&1 | tee push.log + res="${PIPESTATUS[0]}" set -e + grep "WARNING: Git LFS is using a deprecated API" push.log refute_server_object "$reponame" "$(calc_oid "$contents")" if [ "$res" = "0" ]; then echo "push successful?"