Skip to content

Commit

Permalink
Merge pull request #248 from Open-MBEE/feature/244
Browse files Browse the repository at this point in the history
Feature/244
  • Loading branch information
HuiJun authored May 25, 2023
2 parents 99cd478 + 0e850d4 commit 9ba2192
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 9ba2192

Please sign in to comment.