aboutsummaryrefslogtreecommitdiff
path: root/ref/store/files
diff options
context:
space:
mode:
Diffstat (limited to 'ref/store/files')
-rw-r--r--ref/store/files/batch_rejection.go25
-rw-r--r--ref/store/files/batch_test.go5
-rw-r--r--ref/store/files/update_cleanup_parents.go5
3 files changed, 19 insertions, 16 deletions
diff --git a/ref/store/files/batch_rejection.go b/ref/store/files/batch_rejection.go
index 6ec4bbda..7f31536c 100644
--- a/ref/store/files/batch_rejection.go
+++ b/ref/store/files/batch_rejection.go
@@ -7,13 +7,22 @@ import (
)
func isBatchRejected(err error) bool {
+ _, invalidName := errors.AsType[*refstore.InvalidNameError](err)
+ _, invalidValue := errors.AsType[*refstore.InvalidValueError](err)
+ _, duplicateUpdate := errors.AsType[*refstore.DuplicateUpdateError](err)
+ _, createExists := errors.AsType[*refstore.CreateExistsError](err)
+ _, incorrectOldValue := errors.AsType[*refstore.IncorrectOldValueError](err)
+ _, expectedDetached := errors.AsType[*refstore.ExpectedDetachedError](err)
+ _, expectedSymbolic := errors.AsType[*refstore.ExpectedSymbolicError](err)
+ _, nameConflict := errors.AsType[*refstore.NameConflictError](err)
+
return errors.Is(err, refstore.ErrReferenceNotFound) ||
- errors.As(err, new(*refstore.InvalidNameError)) ||
- errors.As(err, new(*refstore.InvalidValueError)) ||
- errors.As(err, new(*refstore.DuplicateUpdateError)) ||
- errors.As(err, new(*refstore.CreateExistsError)) ||
- errors.As(err, new(*refstore.IncorrectOldValueError)) ||
- errors.As(err, new(*refstore.ExpectedDetachedError)) ||
- errors.As(err, new(*refstore.ExpectedSymbolicError)) ||
- errors.As(err, new(*refstore.NameConflictError))
+ invalidName ||
+ invalidValue ||
+ duplicateUpdate ||
+ createExists ||
+ incorrectOldValue ||
+ expectedDetached ||
+ expectedSymbolic ||
+ nameConflict
}
diff --git a/ref/store/files/batch_test.go b/ref/store/files/batch_test.go
index 5580a2ce..55ea4d0a 100644
--- a/ref/store/files/batch_test.go
+++ b/ref/store/files/batch_test.go
@@ -45,8 +45,7 @@ func TestBatchApplyRejectsStaleDeleteAndAppliesIndependentDelete(t *testing.T) {
t.Fatalf("results[0].Status = %v, want rejected", results[0].Status)
}
- if !errors.Is(results[0].Error, refstore.ErrReferenceNotFound) &&
- errors.As(results[0].Error, new(*refstore.IncorrectOldValueError)) == false {
+ if _, ok := errors.AsType[*refstore.IncorrectOldValueError](results[0].Error); !errors.Is(results[0].Error, refstore.ErrReferenceNotFound) && !ok {
t.Fatalf("results[0].Error = %v, want stale-value rejection", results[0].Error)
}
@@ -104,7 +103,7 @@ func TestBatchApplyRejectsDuplicateQueuedRef(t *testing.T) {
t.Fatalf("results[1].Status = %v, want rejected", results[1].Status)
}
- if !errors.As(results[1].Error, new(*refstore.DuplicateUpdateError)) {
+ if _, ok := errors.AsType[*refstore.DuplicateUpdateError](results[1].Error); !ok {
t.Fatalf("results[1].Error = %v, want duplicate update error", results[1].Error)
}
diff --git a/ref/store/files/update_cleanup_parents.go b/ref/store/files/update_cleanup_parents.go
index c62681fa..5a994dcd 100644
--- a/ref/store/files/update_cleanup_parents.go
+++ b/ref/store/files/update_cleanup_parents.go
@@ -22,11 +22,6 @@ func (executor *refUpdateExecutor) tryRemoveEmptyParentPaths(kind rootKind, name
return
}
- var pathErr *os.PathError
- if errors.As(err, &pathErr) {
- return
- }
-
return
}