From e3737f216a7b6a36a2ba10146f2d228f32dcbcfb Mon Sep 17 00:00:00 2001 From: vince Date: Thu, 10 Dec 2020 21:12:45 +0800 Subject: expose format version this commit exposes the format version of the operation pack and identity to reduce the changes needed in vendored code when migrating. This also creates error variables that can be propagated and tested against for migrations. --- bug/operation_pack.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bug/operation_pack.go') diff --git a/bug/operation_pack.go b/bug/operation_pack.go index 0bd3fb7d..1a8ef0db 100644 --- a/bug/operation_pack.go +++ b/bug/operation_pack.go @@ -6,6 +6,7 @@ import ( "github.com/pkg/errors" + "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/repository" ) @@ -47,10 +48,10 @@ func (opp *OperationPack) UnmarshalJSON(data []byte) error { } if aux.Version < formatVersion { - return fmt.Errorf("outdated repository format, please use https://github.com/MichaelMure/git-bug-migration to upgrade") + return entity.NewErrOldFormatVersion(aux.Version) } if aux.Version > formatVersion { - return fmt.Errorf("your version of git-bug is too old for this repository (version %v), please upgrade to the latest version", aux.Version) + return entity.NewErrNewFormatVersion(aux.Version) } for _, raw := range aux.Operations { -- cgit