當前位置: 首頁>>代碼示例>>Java>>正文


Java FileRepositoryBuilder.getGitDir方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.storage.file.FileRepositoryBuilder.getGitDir方法的典型用法代碼示例。如果您正苦於以下問題:Java FileRepositoryBuilder.getGitDir方法的具體用法?Java FileRepositoryBuilder.getGitDir怎麽用?Java FileRepositoryBuilder.getGitDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.storage.file.FileRepositoryBuilder的用法示例。


在下文中一共展示了FileRepositoryBuilder.getGitDir方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createId

import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //導入方法依賴的package包/類
static String createId(File repositoryDirectory) {
	FileRepositoryBuilder builder = new FileRepositoryBuilder();
	builder.readEnvironment();
	builder.findGitDir(repositoryDirectory);
	File gitDir = builder.getGitDir();
	if (gitDir == null) {
		String message = MessageFormat.format(
				"No git repository found at {0}", repositoryDirectory);
		throw new GitRepositoryException(message);
	}
	try {
		return gitDir.getCanonicalPath();
	} catch (IOException e) {
		throw new IllegalStateException(e);
	}
}
 
開發者ID:link-intersystems,項目名稱:GitDirStat,代碼行數:17,代碼來源:GitRepository.java

示例2: GitRepo

import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //導入方法依賴的package包/類
public GitRepo(final File repo) throws GitChangelogRepositoryException {
  try {
    File repoFile = new File(repo.getAbsolutePath());
    final File gitRepoFile = new File(repo.getAbsolutePath() + "/.git");
    if (gitRepoFile.exists()) {
      repoFile = gitRepoFile;
    }
    final FileRepositoryBuilder builder =
        new FileRepositoryBuilder() //
            .findGitDir(repoFile) //
            .readEnvironment();
    if (builder.getGitDir() == null) {
      throw new GitChangelogRepositoryException(
          "Did not find a GIT repo in " + repo.getAbsolutePath());
    }
    this.repository = builder.build();
    this.revWalk = new RevWalk(this.repository);
    this.git = new Git(this.repository);
  } catch (final IOException e) {
    throw new GitChangelogRepositoryException(
        "Could not use GIT repo in " + repo.getAbsolutePath(), e);
  }
}
 
開發者ID:tomasbjerre,項目名稱:git-changelog-lib,代碼行數:24,代碼來源:GitRepo.java

示例3: pullGitUpdate

import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //導入方法依賴的package包/類
public void pullGitUpdate (	String scmUserid, String encodedPass, File sourceLocation,
							Writer outputWriter )
		throws Exception {

	String message = "\n\n *** Updating existing branch on git repository: "
			+ sourceLocation.getAbsolutePath()
			+ "\n Optional: use service clean to delete build location to force a new clone on new branch to be created.";

	logger.info( "{}", message );
	outputWriter.append( "\n" + message );
	outputWriter.flush();

	FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder();
	repositoryBuilder.findGitDir( sourceLocation );
	File gitLocation = repositoryBuilder.getGitDir();
	ObjectId oldHead = null;
	try (Repository repository = repositoryBuilder.setWorkTree( gitLocation ).build()) {
		oldHead = repository.resolve( "HEAD^{tree}" );
	}
	try (Git git = Git.open( gitLocation )) {

		// FetchCommand fetchCommand = git.fetch();
		PullCommand pullCommand = git.pull();

		if ( scmUserid.length() > 0 ) {
			pullCommand.setCredentialsProvider(
				new UsernamePasswordCredentialsProvider(
					scmUserid,
					encryptor.decrypt( encodedPass ) ) );
		}
		pullCommand.setProgressMonitor( gitMonitor( outputWriter ) );

		PullResult result = pullCommand.call();
		logger.info( "merge results: {}", result.getMergeResult() );
		outputWriter.append( "\n" + result.getMergeResult() + "\n\n Updated files:" );
		outputWriter.flush();

		printGitModifications( gitLocation, outputWriter, repositoryBuilder, oldHead, git );
		// ResetCommand command = git.reset() ;
		// command.setP
		// command.setMode( ResetType.HARD ).call() ;
	}

	// catch (Exception e) {
	// logger.error( "Failed to complete pull and diff of repository: {}",
	// csapApp.getCsapFilteredStackTrace( e ) );
	// isSuccessful = false;
	// }

	logger.info( "git sync complete" );
	outputWriter.append( "\n\n ================= git sync complete =============\n\n" );
	outputWriter.flush();
	return;
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:55,代碼來源:SourceControlManager.java


注:本文中的org.eclipse.jgit.storage.file.FileRepositoryBuilder.getGitDir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。