diff options
author | Jeremy Stribling <strib@alum.mit.edu> | 2017-11-29 14:15:32 -0800 |
---|---|---|
committer | Jeremy Stribling <strib@alum.mit.edu> | 2017-11-29 14:29:19 -0800 |
commit | 4c1569511db5e1d26e42e9cd8dadb9e65ccafb20 (patch) | |
tree | 38e12de7c82d8c36d215775c13d17d3e566b2069 /repository.go | |
parent | b18457df6a1f75283d95999fde5c162ba1a19651 (diff) | |
download | go-git-4c1569511db5e1d26e42e9cd8dadb9e65ccafb20.tar.gz |
storer: separate loose and packed object mgmt into optional ifaces
Suggested by mcuadros.
Diffstat (limited to 'repository.go')
-rw-r--r-- | repository.go | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/repository.go b/repository.go index d96399b..d7cca89 100644 --- a/repository.go +++ b/repository.go @@ -25,14 +25,15 @@ import ( ) var ( - ErrInvalidReference = errors.New("invalid reference, should be a tag or a branch") - ErrRepositoryNotExists = errors.New("repository does not exist") - ErrRepositoryAlreadyExists = errors.New("repository already exists") - ErrRemoteNotFound = errors.New("remote not found") - ErrRemoteExists = errors.New("remote already exists ") - ErrWorktreeNotProvided = errors.New("worktree should be provided") - ErrIsBareRepository = errors.New("worktree not available in a bare repository") - ErrUnableToResolveCommit = errors.New("unable to resolve commit") + ErrInvalidReference = errors.New("invalid reference, should be a tag or a branch") + ErrRepositoryNotExists = errors.New("repository does not exist") + ErrRepositoryAlreadyExists = errors.New("repository already exists") + ErrRemoteNotFound = errors.New("remote not found") + ErrRemoteExists = errors.New("remote already exists ") + ErrWorktreeNotProvided = errors.New("worktree should be provided") + ErrIsBareRepository = errors.New("worktree not available in a bare repository") + ErrUnableToResolveCommit = errors.New("unable to resolve commit") + ErrPackedObjectsNotSupported = errors.New("Packed objects not supported") ) // Repository represents a git repository @@ -1024,8 +1025,13 @@ type RepackConfig struct { } func (r *Repository) RepackObjects(cfg *RepackConfig) (err error) { + pos, ok := r.Storer.(storer.PackedObjectStorer) + if !ok { + return ErrPackedObjectsNotSupported + } + // Get the existing object packs. - hs, err := r.Storer.ObjectPacks() + hs, err := pos.ObjectPacks() if err != nil { return err } @@ -1042,7 +1048,7 @@ func (r *Repository) RepackObjects(cfg *RepackConfig) (err error) { if h == nh { continue } - err = r.Storer.DeleteOldObjectPackAndIndex(h, cfg.OnlyDeletePacksOlderThan) + err = pos.DeleteOldObjectPackAndIndex(h, cfg.OnlyDeletePacksOlderThan) if err != nil { return err } |