Merge pull request #1564 from github/warn-legacy
lfs: warn on usage of the legacy API
This commit is contained in:
commit
b9d2ad36db
17
api/api.go
17
api/api.go
@ -6,7 +6,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/github/git-lfs/config"
|
"github.com/github/git-lfs/config"
|
||||||
"github.com/github/git-lfs/errors"
|
"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
|
// Legacy calls the legacy API serially and returns ObjectResources
|
||||||
// TODO LEGACY API: remove when legacy API removed
|
// TODO LEGACY API: remove when legacy API removed
|
||||||
func Legacy(cfg *config.Configuration, objects []*ObjectResource, operation string) ([]*ObjectResource, error) {
|
func Legacy(cfg *config.Configuration, objects []*ObjectResource, operation string) ([]*ObjectResource, error) {
|
||||||
|
legacyWarning()
|
||||||
|
|
||||||
retobjs := make([]*ObjectResource, 0, len(objects))
|
retobjs := make([]*ObjectResource, 0, len(objects))
|
||||||
dl := operation == "download"
|
dl := operation == "download"
|
||||||
var globalErr error
|
var globalErr error
|
||||||
@ -136,6 +140,8 @@ func Legacy(cfg *config.Configuration, objects []*ObjectResource, operation stri
|
|||||||
|
|
||||||
// TODO LEGACY API: remove when legacy API removed
|
// TODO LEGACY API: remove when legacy API removed
|
||||||
func DownloadCheck(cfg *config.Configuration, oid string) (*ObjectResource, error) {
|
func DownloadCheck(cfg *config.Configuration, oid string) (*ObjectResource, error) {
|
||||||
|
legacyWarning()
|
||||||
|
|
||||||
req, err := NewRequest(cfg, "GET", oid)
|
req, err := NewRequest(cfg, "GET", oid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "download check")
|
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
|
// TODO LEGACY API: remove when legacy API removed
|
||||||
func UploadCheck(cfg *config.Configuration, oid string, size int64) (*ObjectResource, error) {
|
func UploadCheck(cfg *config.Configuration, oid string, size int64) (*ObjectResource, error) {
|
||||||
|
legacyWarning()
|
||||||
|
|
||||||
reqObj := &ObjectResource{
|
reqObj := &ObjectResource{
|
||||||
Oid: oid,
|
Oid: oid,
|
||||||
Size: size,
|
Size: size,
|
||||||
@ -204,3 +212,12 @@ func UploadCheck(cfg *config.Configuration, oid string, size int64) (*ObjectReso
|
|||||||
|
|
||||||
return obj, nil
|
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`.")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -51,10 +51,11 @@ begin_test "push (legacy): upload to bad dns"
|
|||||||
git config lfs.url "http://git-lfs-bad-dns:$port"
|
git config lfs.url "http://git-lfs-bad-dns:$port"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
GIT_TERMINAL_PROMPT=0 git push origin master
|
GIT_TERMINAL_PROMPT=0 git push origin master 2>&1 | tee push.log
|
||||||
res="$?"
|
res="${PIPESTATUS[0]}"
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
grep "WARNING: Git LFS is using a deprecated API" push.log
|
||||||
refute_server_object "$reponame" "$(calc_oid "hi")"
|
refute_server_object "$reponame" "$(calc_oid "hi")"
|
||||||
if [ "$res" = "0" ]; then
|
if [ "$res" = "0" ]; then
|
||||||
echo "push successful?"
|
echo "push successful?"
|
||||||
|
@ -19,10 +19,11 @@ push_legacy_fail_test() {
|
|||||||
git commit -m "welp"
|
git commit -m "welp"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
git push origin master
|
git push origin master 2>&1 | tee push.log
|
||||||
res="$?"
|
res="${PIPESTATUS[0]}"
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
grep "WARNING: Git LFS is using a deprecated API" push.log
|
||||||
refute_server_object "$reponame" "$(calc_oid "$contents")"
|
refute_server_object "$reponame" "$(calc_oid "$contents")"
|
||||||
if [ "$res" = "0" ]; then
|
if [ "$res" = "0" ]; then
|
||||||
echo "push successful?"
|
echo "push successful?"
|
||||||
|
Loading…
Reference in New Issue
Block a user