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. --- entity/err.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'entity') diff --git a/entity/err.go b/entity/err.go index 7d6c662e..90304d03 100644 --- a/entity/err.go +++ b/entity/err.go @@ -30,3 +30,29 @@ func IsErrMultipleMatch(err error) bool { _, ok := err.(*ErrMultipleMatch) return ok } + +// ErrOldFormatVersion indicate that the read data has a too old format. +type ErrOldFormatVersion struct { + formatVersion uint +} + +func NewErrOldFormatVersion(formatVersion uint) *ErrOldFormatVersion { + return &ErrOldFormatVersion{formatVersion: formatVersion} +} + +func (e ErrOldFormatVersion) Error() string { + return fmt.Sprintf("outdated repository format %v, please use https://github.com/MichaelMure/git-bug-migration to upgrade", e.formatVersion) +} + +// ErrNewFormatVersion indicate that the read data is too new for this software. +type ErrNewFormatVersion struct { + formatVersion uint +} + +func NewErrNewFormatVersion(formatVersion uint) *ErrNewFormatVersion { + return &ErrNewFormatVersion{formatVersion: formatVersion} +} + +func (e ErrNewFormatVersion) Error() string { + return fmt.Sprintf("your version of git-bug is too old for this repository (version %v), please upgrade to the latest version", e.formatVersion) +} -- cgit