当前位置: 首页>>代码示例>>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;未经允许,请勿转载。