Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return error instead of panicking upon branch hijacking #168

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@
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,
)
}

Check warning on line 189 in service.go

View check run for this annotation

Codecov / codecov/patch

service.go#L183-L189

Added lines #L183 - L189 were not covered by tests
rc.target.oldBranchMetadata = *oldTargetBranchMetadata

if rc.target.commit.branch, err = switchToCommitBranch(rc); err != nil {
Expand Down