當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。