@GET @Path("branch") @Produces(MediaType.APPLICATION_JSON) public List<Branch> branchList(@QueryParam("listMode") String listMode) throws ApiException { try (GitConnection gitConnection = getGitConnection()) { return gitConnection.branchList(listMode == null ? null : BranchListMode.valueOf(listMode)); } catch (IllegalArgumentException exception) { throw new BadRequestException(exception.getMessage()); } }
/** * Update the list of branches. * * @param remoteMode is a remote mode */ private void updateBranches(@NotNull final BranchListMode remoteMode) { service .branchList(project.getLocation(), remoteMode) .then( branches -> { if (LIST_REMOTE.equals(remoteMode)) { view.setRemoteBranches( branchSearcher.getRemoteBranchesToDisplay(view.getRepositoryName(), branches)); updateBranches(LIST_LOCAL); } else { view.setLocalBranches(branchSearcher.getLocalBranchesToDisplay(branches)); for (Branch branch : branches) { if (branch.isActive()) { view.selectRemoteBranch(branch.getDisplayName()); break; } } } }) .catchError( error -> { handleError(error.getCause(), BRANCH_LIST_COMMAND_NAME); view.setEnablePullButton(false); }); }
/** Get the list of branches. */ private void getBranches() { service .branchList(project.getLocation(), BranchListMode.from(view.getFilterValue())) .then( branches -> { if (branches.isEmpty()) { dialogFactory .createMessageDialog( constant.branchTitle(), constant.initCommitWasNotPerformed(), null) .show(); } else { view.setBranches(branches); view.showDialogIfClosed(); } }) .catchError( error -> { handleError(error.getCause(), BRANCH_LIST_COMMAND_NAME); }); }
.then( branches -> { if (LIST_REMOTE.equals(remoteMode)) { view.setRemoteBranches( branchSearcher.getRemoteBranchesToDisplay(view.getRepositoryName(), branches));