зеркало из https://github.com/golang/dep.git
gps: Fix error name in accordance with lint rules
This commit is contained in:
Родитель
be7b31d631
Коммит
2ade7e7139
|
@ -249,7 +249,7 @@ func getDirectDependencies(sm gps.SourceManager, p *dep.Project) (pkgtree.Packag
|
|||
// in handling them and informing the user appropriately
|
||||
func handleAllTheFailuresOfTheWorld(err error) error {
|
||||
switch errors.Cause(err) {
|
||||
case context.Canceled, context.DeadlineExceeded, gps.SourceManagerIsReleased:
|
||||
case context.Canceled, context.DeadlineExceeded, gps.ErrSourceManagerIsReleased:
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -810,56 +810,56 @@ func TestErrAfterRelease(t *testing.T) {
|
|||
_, err := sm.SourceExists(id)
|
||||
if err == nil {
|
||||
t.Errorf("SourceExists did not error after calling Release()")
|
||||
} else if err != SourceManagerIsReleased {
|
||||
} else if err != ErrSourceManagerIsReleased {
|
||||
t.Errorf("SourceExists errored after Release(), but with unexpected error: %T %s", err, err.Error())
|
||||
}
|
||||
|
||||
err = sm.SyncSourceFor(id)
|
||||
if err == nil {
|
||||
t.Errorf("SyncSourceFor did not error after calling Release()")
|
||||
} else if err != SourceManagerIsReleased {
|
||||
} else if err != ErrSourceManagerIsReleased {
|
||||
t.Errorf("SyncSourceFor errored after Release(), but with unexpected error: %T %s", err, err.Error())
|
||||
}
|
||||
|
||||
_, err = sm.ListVersions(id)
|
||||
if err == nil {
|
||||
t.Errorf("ListVersions did not error after calling Release()")
|
||||
} else if err != SourceManagerIsReleased {
|
||||
} else if err != ErrSourceManagerIsReleased {
|
||||
t.Errorf("ListVersions errored after Release(), but with unexpected error: %T %s", err, err.Error())
|
||||
}
|
||||
|
||||
_, err = sm.RevisionPresentIn(id, "")
|
||||
if err == nil {
|
||||
t.Errorf("RevisionPresentIn did not error after calling Release()")
|
||||
} else if err != SourceManagerIsReleased {
|
||||
} else if err != ErrSourceManagerIsReleased {
|
||||
t.Errorf("RevisionPresentIn errored after Release(), but with unexpected error: %T %s", err, err.Error())
|
||||
}
|
||||
|
||||
_, err = sm.ListPackages(id, nil)
|
||||
if err == nil {
|
||||
t.Errorf("ListPackages did not error after calling Release()")
|
||||
} else if err != SourceManagerIsReleased {
|
||||
} else if err != ErrSourceManagerIsReleased {
|
||||
t.Errorf("ListPackages errored after Release(), but with unexpected error: %T %s", err, err.Error())
|
||||
}
|
||||
|
||||
_, _, err = sm.GetManifestAndLock(id, nil, naiveAnalyzer{})
|
||||
if err == nil {
|
||||
t.Errorf("GetManifestAndLock did not error after calling Release()")
|
||||
} else if err != SourceManagerIsReleased {
|
||||
} else if err != ErrSourceManagerIsReleased {
|
||||
t.Errorf("GetManifestAndLock errored after Release(), but with unexpected error: %T %s", err, err.Error())
|
||||
}
|
||||
|
||||
err = sm.ExportProject(context.Background(), id, nil, "")
|
||||
if err == nil {
|
||||
t.Errorf("ExportProject did not error after calling Release()")
|
||||
} else if err != SourceManagerIsReleased {
|
||||
} else if err != ErrSourceManagerIsReleased {
|
||||
t.Errorf("ExportProject errored after Release(), but with unexpected error: %T %s", err, err.Error())
|
||||
}
|
||||
|
||||
_, err = sm.DeduceProjectRoot("")
|
||||
if err == nil {
|
||||
t.Errorf("DeduceProjectRoot did not error after calling Release()")
|
||||
} else if err != SourceManagerIsReleased {
|
||||
} else if err != ErrSourceManagerIsReleased {
|
||||
t.Errorf("DeduceProjectRoot errored after Release(), but with unexpected error: %T %s", err, err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1417,5 +1417,5 @@ func pa2lp(pa atom, pkgs map[string]struct{}) LockedProject {
|
|||
}
|
||||
|
||||
func contextCanceledOrSMReleased(err error) bool {
|
||||
return err == context.Canceled || err == context.DeadlineExceeded || err == SourceManagerIsReleased
|
||||
return err == context.Canceled || err == context.DeadlineExceeded || err == ErrSourceManagerIsReleased
|
||||
}
|
||||
|
|
|
@ -169,10 +169,10 @@ type SourceMgr struct {
|
|||
|
||||
var _ SourceManager = &SourceMgr{}
|
||||
|
||||
// SourceManagerIsReleased is the error returned by any SourceManager method
|
||||
// ErrSourceManagerIsReleased is the error returned by any SourceManager method
|
||||
// called after the SourceManager has been released, rendering its methods no
|
||||
// longer safe to call.
|
||||
var SourceManagerIsReleased error = fmt.Errorf("this SourceManager has been released, its methods can no longer be called")
|
||||
var ErrSourceManagerIsReleased error = fmt.Errorf("this SourceManager has been released, its methods can no longer be called")
|
||||
|
||||
// SourceManagerConfig holds configuration information for creating SourceMgrs.
|
||||
type SourceManagerConfig struct {
|
||||
|
@ -405,7 +405,7 @@ func (sm *SourceMgr) Release() {
|
|||
// DeriveManifestAndLock() method.
|
||||
func (sm *SourceMgr) GetManifestAndLock(id ProjectIdentifier, v Version, an ProjectAnalyzer) (Manifest, Lock, error) {
|
||||
if atomic.LoadInt32(&sm.releasing) == 1 {
|
||||
return nil, nil, SourceManagerIsReleased
|
||||
return nil, nil, ErrSourceManagerIsReleased
|
||||
}
|
||||
|
||||
srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id)
|
||||
|
@ -420,7 +420,7 @@ func (sm *SourceMgr) GetManifestAndLock(id ProjectIdentifier, v Version, an Proj
|
|||
// of the given ProjectIdentifier, at the given version.
|
||||
func (sm *SourceMgr) ListPackages(id ProjectIdentifier, v Version) (pkgtree.PackageTree, error) {
|
||||
if atomic.LoadInt32(&sm.releasing) == 1 {
|
||||
return pkgtree.PackageTree{}, SourceManagerIsReleased
|
||||
return pkgtree.PackageTree{}, ErrSourceManagerIsReleased
|
||||
}
|
||||
|
||||
srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id)
|
||||
|
@ -445,7 +445,7 @@ func (sm *SourceMgr) ListPackages(id ProjectIdentifier, v Version) (pkgtree.Pack
|
|||
// went away), an error will be returned.
|
||||
func (sm *SourceMgr) ListVersions(id ProjectIdentifier) ([]PairedVersion, error) {
|
||||
if atomic.LoadInt32(&sm.releasing) == 1 {
|
||||
return nil, SourceManagerIsReleased
|
||||
return nil, ErrSourceManagerIsReleased
|
||||
}
|
||||
|
||||
srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id)
|
||||
|
@ -461,7 +461,7 @@ func (sm *SourceMgr) ListVersions(id ProjectIdentifier) ([]PairedVersion, error)
|
|||
// repository.
|
||||
func (sm *SourceMgr) RevisionPresentIn(id ProjectIdentifier, r Revision) (bool, error) {
|
||||
if atomic.LoadInt32(&sm.releasing) == 1 {
|
||||
return false, SourceManagerIsReleased
|
||||
return false, ErrSourceManagerIsReleased
|
||||
}
|
||||
|
||||
srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id)
|
||||
|
@ -477,7 +477,7 @@ func (sm *SourceMgr) RevisionPresentIn(id ProjectIdentifier, r Revision) (bool,
|
|||
// for the provided ProjectIdentifier.
|
||||
func (sm *SourceMgr) SourceExists(id ProjectIdentifier) (bool, error) {
|
||||
if atomic.LoadInt32(&sm.releasing) == 1 {
|
||||
return false, SourceManagerIsReleased
|
||||
return false, ErrSourceManagerIsReleased
|
||||
}
|
||||
|
||||
srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id)
|
||||
|
@ -495,7 +495,7 @@ func (sm *SourceMgr) SourceExists(id ProjectIdentifier) (bool, error) {
|
|||
// The primary use case for this is prefetching.
|
||||
func (sm *SourceMgr) SyncSourceFor(id ProjectIdentifier) error {
|
||||
if atomic.LoadInt32(&sm.releasing) == 1 {
|
||||
return SourceManagerIsReleased
|
||||
return ErrSourceManagerIsReleased
|
||||
}
|
||||
|
||||
srcg, err := sm.srcCoord.getSourceGatewayFor(context.TODO(), id)
|
||||
|
@ -510,7 +510,7 @@ func (sm *SourceMgr) SyncSourceFor(id ProjectIdentifier) error {
|
|||
// ProjectRoot, at the provided version, to the provided directory.
|
||||
func (sm *SourceMgr) ExportProject(ctx context.Context, id ProjectIdentifier, v Version, to string) error {
|
||||
if atomic.LoadInt32(&sm.releasing) == 1 {
|
||||
return SourceManagerIsReleased
|
||||
return ErrSourceManagerIsReleased
|
||||
}
|
||||
|
||||
srcg, err := sm.srcCoord.getSourceGatewayFor(ctx, id)
|
||||
|
@ -530,7 +530,7 @@ func (sm *SourceMgr) ExportProject(ctx context.Context, id ProjectIdentifier, v
|
|||
// activity, as its behavior is well-structured)
|
||||
func (sm *SourceMgr) DeduceProjectRoot(ip string) (ProjectRoot, error) {
|
||||
if atomic.LoadInt32(&sm.releasing) == 1 {
|
||||
return "", SourceManagerIsReleased
|
||||
return "", ErrSourceManagerIsReleased
|
||||
}
|
||||
|
||||
pd, err := sm.deduceCoord.deduceRootPath(context.TODO(), ip)
|
||||
|
|
Загрузка…
Ссылка в новой задаче