org.guvnor.structure.repositories.Repository.getDefaultBranch()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.guvnor.structure.repositories.Repository.getDefaultBranch方法的一些代码示例,展示了Repository.getDefaultBranch的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.getDefaultBranch方法的具体详情如下:
包路径:org.guvnor.structure.repositories.Repository
类名称:Repository
方法名:getDefaultBranch

Repository.getDefaultBranch介绍

[英]In the case of Git repository this would be master.
[中]在Git存储库的情况下,这将是master。

代码示例

代码示例来源:origin: org.uberfire/uberfire-project-backend

@Override
public WorkspaceProject resolveProject(final Repository repository) {
  if (!repository.getDefaultBranch().isPresent()) {
    throw new IllegalStateException("New repository should always have a branch.");
  }
  return resolveProject(repository.getSpace(),
             repository.getDefaultBranch().get());
}

代码示例来源:origin: org.guvnor/guvnor-structure-client

@Override
public void onNewRepositoryAdded(final Repository repository) {
  addRepositoryItem(repository,
           repository.getDefaultBranch());
}

代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-project-explorer-backend

public Module get(final OrganizationalUnit organizationalUnit,
         final Repository repository) {
  if (organizationalUnit == null || repository == null || !repository.getDefaultBranch().isPresent()) {
    return null;
  }
  final Object obj = content.get(Pair.newPair(organizationalUnit.getName(),
                        repository.getDefaultBranch().get().getPath()).toString());
  if (obj != null && obj instanceof Module) {
    return (Module) obj;
  }
  return null;
}

代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-datasource-mgmt-client

@Override
protected DefExplorerQuery createRefreshQuery() {
  return new DefExplorerQuery(activeOrganizationalUnit,
                activeRepository,
                activeModule,
                activeRepository.getDefaultBranch().get().getName());
}

代码示例来源:origin: org.guvnor/guvnor-structure-client

public void onNewRepository(final @Observes NewRepositoryEvent event) {
  final Repository newRepository = event.getNewRepository();
  aliasBranch.put(newRepository.getAlias(),
          newRepository.getDefaultBranch());
  for (final GuvnorStructureContextChangeHandler handler : handlers.values()) {
    handler.onNewRepositoryAdded(newRepository);
  }
}

代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-project-explorer-client

public void onArchiveActiveRepository() {
  final Optional<Branch> defaultBranch = context.getActiveWorkspaceProject()
                         .map(proj -> proj.getRepository())
                         .orElseThrow(() -> new IllegalStateException("Cannot check for default branch without an active project."))
                         .getDefaultBranch();
  if (defaultBranch.isPresent()) {
    view.archive(defaultBranch.get().getPath());
  }
}

代码示例来源:origin: org.guvnor/guvnor-structure-client

private void updateBranch(final Repository repository) {
  final String branch = aliasBranch.get(repository.getAlias());
  if (branch == null || hasBranchBeenRemoved(repository,
                        branch)) {
    aliasBranch.put(repository.getAlias(),
            repository.getDefaultBranch());
  }
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

private String getNiogitRepoPath(Repository repository) {
  final Branch branch = repository.getDefaultBranch().get();
  final Path path = pathUtil.convert(branch.getPath());
  return pathUtil.getNiogitRepoPath(path);
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

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;
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

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;
}

代码示例来源:origin: org.guvnor/guvnor-rest-backend

private void whenProjectExists() {
  when(repository.getDefaultBranch()).thenReturn("master");
  Path path = mock(Path.class);
  when(path.getFileName()).thenReturn("");
  when(path.toURI()).thenReturn("file://project/");
  when(repository.getBranchRoot("master")).thenReturn(path);
  when(projectService.resolveProject(any(Path.class))).thenReturn(mock(MyProject.class));
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

protected void cleanupOrigin(Repository repository) {
  try {
    // AF-1715: Cleaning origin to prevent errors while importing the new generated repo.
    Git git = ((JGitPathImpl) pathUtil.convert(repository.getDefaultBranch().get().getPath())).getFileSystem().getGit();
    new RemoveRemote(git,"origin",REMOTE_ORIGIN_REF).execute();
  } catch (GitException e) {
    log.warn("Error cleaning up origin for repository '{}': {}", repository.getAlias(), e);
  }
}

代码示例来源:origin: org.uberfire/uberfire-structure-backend

@Test
public void testCreateNewAliasIfNecessary() {
  when(configuredRepositories.getRepositoryByRepositoryAlias(any(),
                                eq("alias"))).thenReturn(repository);
  doReturn(Optional.of(mock(Branch.class))).when(repository).getDefaultBranch();
  doReturn("alias").when(repository).getAlias();
  String newAlias = repositoryService.createFreshRepositoryAlias("alias",
                                  new Space("alias"));
  assertEquals("alias-1",
         newAlias);
}

代码示例来源:origin: org.uberfire/uberfire-structure-backend

@Test
public void testNotCreateNewAliasIfNecessary() {
  when(configuredRepositories.getRepositoryByRepositoryAlias(any(),
                                eq("other-name"))).thenReturn(repository);
  doReturn(Optional.of(mock(Branch.class))).when(repository).getDefaultBranch();
  doReturn("alias").when(repository).getAlias();
  String newAlias = repositoryService.createFreshRepositoryAlias("alias",
                                  new Space("alias"));
  assertEquals("alias",
         newAlias);
}

代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-library-client

@Before
public void setUp() {
  when(libraryPlaces.getActiveWorkspace()).thenReturn(project);
  when(project.getRepository().getDefaultBranch()).thenReturn(Optional.of(branch));
  when(branch.getName()).thenReturn("myBranch");
  presenter = spy(new DeleteBranchPopUpScreen(view,
                        new CallerMock<>(libraryService),
                        libraryPlaces));
}

代码示例来源:origin: org.guvnor/guvnor-structure-client

@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"));
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

@Test
public void spaceHasProjectsWithNameSameProject() throws Exception {
  final boolean hasNoProjects = workspaceProjectService.spaceHasNoProjectsWithName(ou1,
                                           "repository1",
                                           new WorkspaceProject(ou1,
                                                     repository1,
                                                     repository1.getDefaultBranch().get(),
                                                     null));
  assertTrue(hasNoProjects);
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

@Test
public void spaceHasNoProjectsWithName() throws Exception {
  final boolean hasNoProjects = workspaceProjectService.spaceHasNoProjectsWithName(ou1,
                                           "other-project",
                                           new WorkspaceProject(ou1,
                                                     repository1,
                                                     repository1.getDefaultBranch().get(),
                                                     null));
  assertTrue(hasNoProjects);
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

@Test
public void spaceHasProjectsWithName() throws Exception {
  final boolean hasNoProjects = workspaceProjectService.spaceHasNoProjectsWithName(ou1,
                                           "repository1",
                                           new WorkspaceProject(ou1,
                                                     repository2,
                                                     repository2.getDefaultBranch().get(),
                                                     null));
  assertFalse(hasNoProjects);
}

代码示例来源:origin: org.uberfire/uberfire-structure-backend

@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"));
}

相关文章