当前位置: 首页>>代码示例>>Java>>正文


Java Repository.close方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.Repository.close方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.close方法的具体用法?Java Repository.close怎么用?Java Repository.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.Repository的用法示例。


在下文中一共展示了Repository.close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isUserSetup

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
public static boolean isUserSetup (File root) {
    Repository repository = getRepository(root);
    boolean userExists = true;
    if (repository != null) {
        try {
            StoredConfig config = repository.getConfig();
            String name = config.getString("user", null, "name"); //NOI18N
            String email = config.getString("user", null, "email"); //NOI18N
            if (name == null || name.isEmpty() || email == null || email.isEmpty()) {
                userExists = false;
            }
        } finally {
            repository.close();
        }
    }
    return userExists;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JGitUtils.java

示例2: persistUser

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
public static void persistUser (File root, GitUser author) throws GitException {
    Repository repository = getRepository(root);
    if (repository != null) {
        try {
            StoredConfig config = repository.getConfig();
            config.setString("user", null, "name", author.getName()); //NOI18N
            config.setString("user", null, "email", author.getEmailAddress()); //NOI18N
            try {
                config.save();
                FileUtil.refreshFor(new File(GitUtils.getGitFolderForRoot(root), "config"));
            } catch (IOException ex) {
                throw new GitException(ex);
            }
        } finally {
            repository.close();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JGitUtils.java

示例3: load

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
@Override
public void load() {
    final List<Repository> gitRepos = gitService.repos();
    repos = new HashSet<>(gitRepos.size());

    for (Repository repo : gitRepos) {
        try {
            List<String> tags = JGitUtil.tags(repo);
            String gitRepoName = repo.getDirectory().getName();

            // git repo needs tags
            if (tags.isEmpty()) {
                LOGGER.warn("Git repo '%s' cannot be synced since missing tag", gitRepoName);
                continue;
            }

            gitRepoName = StringUtil.trimEnd(gitRepoName, ".git");
            repos.add(new SyncRepo(gitRepoName, tags.get(0)));
        } catch (GitException e) {
            LOGGER.warn(e.getMessage());
        } finally {
            repo.close();
        }
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:26,代码来源:SyncServiceImpl.java

示例4: should_list_existing_repo_from_git_workspace

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
@Test
public void should_list_existing_repo_from_git_workspace() throws Throwable {
    // given: copy exit git to workspace
    ClassLoader classLoader = TestBase.class.getClassLoader();
    URL resource = classLoader.getResource("hello.git");
    File path = new File(resource.getFile());
    FileUtils.copyDirectoryToDirectory(path, gitWorkspace.toFile());

    // when: load repos from git workspace
    List<Repository> repos = gitService.repos();
    Assert.assertEquals(1, repos.size());

    // then:
    Repository helloRepo = repos.get(0);
    Map<String, Ref> tags = helloRepo.getTags();
    Assert.assertEquals(1, tags.size());
    Assert.assertTrue(tags.keySet().contains("v1.0"));
    Assert.assertEquals("hello.git", helloRepo.getDirectory().getName());

    for (Repository repo : repos) {
        repo.close();
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:24,代码来源:GitServiceTest.java

示例5: getPushMode

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
public static RepositoryInfo.PushMode getPushMode (File root) {
    Repository repository = getRepository(root);
    if (repository != null) {
        try {
            String val = repository.getConfig().getString("push", null, "default"); //NOI18N
            if ("upstream".equals(val)) { //NOI18N
                return PushMode.UPSTREAM;
            }
        } finally {
            repository.close();
        }
    }
    return PushMode.ASK;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JGitUtils.java

示例6: cloneRepo

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
public void cloneRepo(final String gitUri, final Path repoDir) throws InvalidRemoteException, GitAPIException, IOException {
    if (Files.exists(repoDir)) {
        LOGGER.debug("Deleting left-over repo dir" + repoDir.toAbsolutePath().toString());
        com.sap.cloud.lm.sl.cf.core.util.FileUtils.deleteDirectory(repoDir);
    }

    configureGitSslValidation();
    if (shoudlUseToken(gitServiceUrlString, gitUri)) {
        cloneCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(userName, token));
    }
    if (refName != null && !refName.isEmpty()) {
        String fullRefName = refName.startsWith("refs/") ? refName : "refs/heads/" + refName;
        cloneCommand.setBranchesToClone(Arrays.asList(new String[] { fullRefName }));
        cloneCommand.setBranch(fullRefName);
    }
    cloneCommand.setTimeout(290);
    cloneCommand.setDirectory(repoDir.toAbsolutePath().toFile());
    cloneCommand.setURI(gitUri);
    LOGGER.debug(
        MessageFormat.format("cloning repo with url {0} in repo dir {1} ref '{2}'", gitUri, repoDir.toAbsolutePath().toString()));
    try (Git callInstance = cloneCommand.call()) {
        Repository repo = callInstance.getRepository();
        repo.close();
    } catch (TransportException e) {
        Throwable cause1 = e.getCause();
        if (cause1 != null && cause1.getCause() instanceof SSLHandshakeException) {
            throw new SLException(cause1.getCause(), "Failed to establish ssl connection"); // NOSONAR
        }
        throw e;
    }
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:32,代码来源:GitRepoCloner.java

示例7: on

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
@Listen
public void on(SystemStopping event) {
	synchronized(repositoryCache) {
		for (Repository repository: repositoryCache.values()) {
			repository.close();
		}
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:9,代码来源:DefaultProjectManager.java

示例8: testCompareSubmodule

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
/**
 * <p><b>Description:</b> diff on submodule.</p>
 * <p><b>Bug ID:</b> EXM-40621</p>
 *
 * @author sorin_carbunaru
 *
 * @throws Exception
 */
@Test
public void testCompareSubmodule() throws Exception {
  GitAccess gitAccess = GitAccess.getInstance();
  
  // PARENT repos
  String localTestRepositoryP = "target/test-resources/localCS";
  String remoteTestRepositoryP = "target/test-resources/remoteCS";
  Repository remoteRepoP = createRepository(remoteTestRepositoryP);
  Repository localRepoP = createRepository(localTestRepositoryP);
  bindLocalToRemote(localRepoP, remoteRepoP);
  
  // SUBMODULE repos
  String remoteTestRepositorySubModule = "target/test-resources/remoteCS-SubModule/";
  Repository remoteRepoSubModule = createRepository(remoteTestRepositorySubModule);
  // Commit (very important)
  gitAccess.commit("Commit");
  
  // Set the PARENT repo as the current one, to which we'll add the submodule
  gitAccess.setRepository(localTestRepositoryP);
  
  // Add SUBMODULE
  SubmoduleAddCommand addCommand = gitAccess.submoduleAdd();
  addCommand.setURI(remoteRepoSubModule.getDirectory().toURI().toString());
  addCommand.setPath("modules/submodule");
  Repository subRepo = addCommand.call();
  subRepo.close();
  
  File parentWorkDir = gitAccess.getRepository().getWorkTree();
  assertTrue( new File( parentWorkDir, "modules/submodule" ).isDirectory() );
  assertTrue( new File( parentWorkDir, ".gitmodules" ).isFile() );

  // Check the SUBMODULE
  Map<String,SubmoduleStatus> submodules = gitAccess.submoduleStatus().call();
  assertEquals(1, submodules.size());
  SubmoduleStatus status = submodules.get("modules/submodule");
  assertNotNull(status);
  assertEquals(SubmoduleStatusType.INITIALIZED, status.getType());
  
  // SHOW DIFF
  DiffPresenter diffPresenter = new DiffPresenter(
      // The submodule
      gitAccess.getStagedFiles().get(1),
      Mockito.mock(StageController.class));
  diffPresenter.showDiff();
  
  assertNotNull(leftDiff);
  assertNotNull(rightDiff);
  
  String left = "git://CurrentSubmodule/modules/submodule.txt";
  assertEquals(left, leftDiff.toString());
  assertTrue(read(new URL(left)).startsWith("Subproject commit "));
  
  String right = "git://PreviousSubmodule/modules/submodule.txt";
  assertEquals(right, rightDiff.toString());
  assertTrue(read(new URL(right)).startsWith("Subproject commit "));
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:65,代码来源:DiffPresenterTest.java


注:本文中的org.eclipse.jgit.lib.Repository.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。