diff --git a/service.go b/service.go index 8ac5b06..a5a0709 100644 --- a/service.go +++ b/service.go @@ -180,6 +180,13 @@ func (s *service) RenderManifests( if err != nil { return res, errors.Wrap(err, "error loading branch metadata") } + if oldTargetBranchMetadata == nil { + return res, errors.Errorf( + "target branch %q already exists, but does not appear to be managed by "+ + "Bookkeeper; refusing to overwrite branch contents", + rc.request.TargetBranch, + ) + } rc.target.oldBranchMetadata = *oldTargetBranchMetadata if rc.target.commit.branch, err = switchToCommitBranch(rc); err != nil {