private boolean hasBranchBeenRemoved(final Repository repository, final String branchName) { return !repository .getBranches() .stream() .anyMatch(branch -> branch.getName().equals(branchName)); }
private Branch getBranch(final Repository repository, final Path convertedPath) { for (final Branch branch : repository.getBranches()) { if (branch.getPath().equals(convertedPath)) { return branch; } } return null; }
private void populateBranches(final String currentBranch) { final ArrayList<String> branches = new ArrayList<String>(repository.getBranches()); Collections.reverse(branches); view.clearBranches(); for (String branch : branches) { view.addBranch(branch); } view.setSelectedBranch(currentBranch); }
public void repositoryUpdatedEvent(@Observes final RepositoryUpdatedEvent event) { final Repository repository = event.getRepository(); if (libraryPlaces.isThisRepositoryBeingAccessed(repository)) { updateBranches(repository.getBranches()); } }
@PostConstruct public void setup() { view.init(AddBranchPopUpPresenter.this); project = libraryPlaces.getActiveWorkspace(); view.setBranches(project.getRepository().getBranches().stream().map(Branch::getName).sorted(SortHelper.ALPHABETICAL_ORDER_COMPARATOR).collect(Collectors.toList())); view.setBranchFrom(project.getBranch().getName()); }
@Override public Collection<String> getBranches(final Space space, final String repositoryName) { checkNotNull("repositoryName", repositoryName); final Repository repository = repositoryService.getRepositoryFromSpace(space, repositoryName); return repository != null ? toBranchNames(repository.getBranches()) : new ArrayList<>(); }
private Branch resolveBranch(final org.uberfire.java.nio.file.Path repositoryRoot, final Repository repository) { final Branch defaultBranch = repository.getDefaultBranch().get(); if (!Paths.convert(defaultBranch.getPath()).equals(repositoryRoot)) { for (final Branch branch : repository.getBranches()) { if (Paths.convert(branch.getPath()).equals(repositoryRoot)) { return branch; } } } return defaultBranch; }
private Repository mockLegacyRepository() { final Repository legacyRepository = mock(Repository.class); final ArrayList<Branch> branches = new ArrayList<>(); branches.add(legacyMasterBranch); branches.add(legacyDevBranch); doReturn(branches).when(legacyRepository).getBranches(); final ArrayList<OrganizationalUnit> ous = new ArrayList<>(); ous.add(organizationalUnit); doReturn(ous).when(organizationalUnitService).getOrganizationalUnits(legacyRepository); when(legacyRepository.getDefaultBranch()).thenReturn(Optional.of(legacyMasterBranch)); return legacyRepository; }
public static Repository makeRepository(final String alias, final String... branches) { final Repository repository = mock(Repository.class); when(repository.getAlias()).thenReturn(alias); when(repository.getBranches()).thenReturn(Arrays.asList(branches)); when(repository.getDefaultBranch()).thenReturn("master"); return repository; } }
@Test public void testReLoadPicksUpRemovedBranch() throws Exception { // This deletes master branch when(repositories.get(0).getBranches()).thenReturn(Arrays.asList("dev")); when(repositories.get(0).getDefaultBranch()).thenReturn("dev"); context.getRepositories(callback); assertEquals("dev", context.getCurrentBranch("my-repo")); assertEquals("master", context.getCurrentBranch("your-repo")); }
@Test public void testLoadSingle() throws Exception { final Repository single = configuredRepositories.getRepositoryByRepositoryAlias(SPACE1, REPO1S1); assertEquals(1, single.getBranches().size()); assertNotNull(single.getBranch("master")); }
@Test public void testLoadSingle() throws Exception { final Repository single = configuredRepositories.getRepositoryByRepositoryAlias(SPACE1, REPO1S1); assertEquals(1, single.getBranches().size()); assertNotNull(single.getBranch("master")); }
@Test public void testLoadSingle() throws Exception { final Repository single = configuredRepositories.getRepositoryByRepositoryAlias("single"); assertEquals(1, single.getBranches().size()); assertNotNull(single.getBranchRoot("master")); }
@Test public void testBranches() throws Exception { rootDirectories.add(createPath("default://origin@uf-playground")); rootDirectories.add(createPath("default://master@uf-playground")); rootDirectories.add(createPath("default://branch1@uf-playground")); ConfigGroup configGroup = getConfigGroup(); configGroup.setName("test"); Repository repository = helper.newRepository(configGroup); assertEquals(3, repository.getBranches().size()); assertTrue(repository.getDefaultBranch().get().getPath().toURI().contains("master")); }
@Test public void testBranches() throws Exception { rootDirectories.add(createPath("default://origin@uf-playground")); rootDirectories.add(createPath("default://master@uf-playground")); rootDirectories.add(createPath("default://branch1@uf-playground")); ConfigGroup configGroup = getConfigGroup(); configGroup.setName("test"); Repository repository = helper.newRepository(configGroup); assertEquals(3, repository.getBranches().size()); assertTrue(repository.getRoot().toURI().contains("master")); }
public void setupForProject(final WorkspaceProject project) { setupForSpace(project.getOrganizationalUnit()); breadcrumbs.addBreadCrumb(LIBRARY_PERSPECTIVE, project.getName(), () -> libraryPlaces.goToProject(libraryPlaces.getActiveWorkspace())); breadcrumbs.addBreadCrumb(LIBRARY_PERSPECTIVE, projectBranchBreadcrumb.setup(project.getRepository().getBranches())); }
@Test public void setupTest() { presenter.setup(repository.getBranches()); verify(view).init(presenter); final List<Branch> orderedBranches = presenter.getBranches(); assertEquals("branch1", (orderedBranches).get(0).getName()); assertEquals("branch2", (orderedBranches).get(1).getName()); assertEquals("branch3", (orderedBranches).get(2).getName()); assertEquals("branch4", (orderedBranches).get(3).getName()); }
@Test public void testLoadMultiBranch() throws Exception { final Repository single = configuredRepositories.getRepositoryByRepositoryAlias(SPACE1, REPO2S1); assertEquals(3, single.getBranches().size()); assertNotNull(single.getBranch("master")); assertNotNull(single.getBranch("dev")); assertNotNull(single.getBranch("release")); }
@Test public void testLoadMultiBranch() throws Exception { final Repository single = configuredRepositories.getRepositoryByRepositoryAlias(SPACE1, REPO2S1); assertEquals(3, single.getBranches().size()); assertNotNull(single.getBranch("master")); assertNotNull(single.getBranch("dev")); assertNotNull(single.getBranch("release")); }
@Test public void testLoadMultiBranch() throws Exception { final Repository single = configuredRepositories.getRepositoryByRepositoryAlias("multibranch"); assertEquals(3, single.getBranches().size()); assertNotNull(single.getBranchRoot("master")); assertNotNull(single.getBranchRoot("dev")); assertNotNull(single.getBranchRoot("release")); }