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

Feature/244 #248

Merged
merged 10 commits into from
May 25, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ public RefsResponse getBranch(String projectId, String id) {
public RefJson createBranch(String projectId, RefJson branch) {
Instant now = Instant.now();
ContextHolder.setContext(projectId);
Branch b = new Branch();

Optional<Branch> branchesOption = this.branchRepository.findByBranchId(branch.getId());
Branch b = branchesOption.orElseGet(Branch::new);
if (b.isDeleted()) {
throw new BadRequestException("Bad Request Error: Branch was previously deleted.");
}

b.setBranchId(branch.getId());
b.setBranchName(branch.getName());
Expand Down