本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}