Java Code Examples for org.eclipse.jgit.storage.file.FileRepositoryBuilder#findGitDir()
The following examples show how to use
org.eclipse.jgit.storage.file.FileRepositoryBuilder#findGitDir() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DifferentFiles.java From gitflow-incremental-builder with MIT License | 6 votes |
private Git setupGit(Configuration configuration) throws IOException { final FileRepositoryBuilder builder = new FileRepositoryBuilder(); File pomDir = mavenSession.getCurrentProject().getBasedir().toPath().toFile(); builder.findGitDir(pomDir); if (builder.getGitDir() == null) { String gitDirNotFoundMessage = "Git repository root directory not found ascending from current working directory:'" + pomDir + "'."; logger.warn(gitDirNotFoundMessage + " Next step is determined by failOnMissingGitDir property."); if (configuration.failOnMissingGitDir) { throw new IllegalArgumentException(gitDirNotFoundMessage); } else { throw new SkipExecutionException(gitDirNotFoundMessage); } } if (isWorktree(builder)) { throw new SkipExecutionException(UNSUPPORTED_WORKTREE + builder.getGitDir()); } return Git.wrap(builder.build()); }
Example 2
Source File: SimpleCommitSearcher.java From SZZUnleashed with MIT License | 5 votes |
/** * Constructor using a path to a local repository. */ public SimpleCommitSearcher(String repoPath) throws IOException, GitAPIException { Configuration conf = Configuration.getInstance(); FileRepositoryBuilder builder = new FileRepositoryBuilder(); builder.setMustExist(true); builder.addCeilingDirectory(new File(repoPath)); builder.findGitDir(new File(repoPath)); this.repo = builder.build(); this.git = new Git(repo); bugpatterns = Arrays.asList(compile("JENKINS\\-[0-9]")); }
Example 3
Source File: GitParser.java From SZZUnleashed with MIT License | 5 votes |
/** * The constructor for the GitParser class. It requires the repository to exist and will fail if * its not. The resultPath is also created if it's not existing. * * @param path the path to where the local repository can be found. * @param resultPath the path to where the JSON files will be written. */ public GitParser(String path, String resultPath, int depth, int customContext) throws IOException, GitAPIException { FileRepositoryBuilder builder = new FileRepositoryBuilder(); builder.setMustExist(true); builder.addCeilingDirectory(new File(path)); builder.findGitDir(new File(path)); this.repo = builder.build(); this.resultPath = resultPath; /* * Check if the resultpath exists otherwise create it. */ if (this.resultPath != null) { File resDirectory = new File(resultPath); if (!resDirectory.exists()) resDirectory.mkdirs(); } else { System.err.println("Resultpath not set! Using deafult directory instead."); this.resultPath = this.DEFAULT_RES_PATH; } this.util = new CommitUtil(this.repo, customContext); this.depth = depth; }
Example 4
Source File: Git.java From docker-maven-plugin with Apache License 2.0 | 5 votes |
public Git() throws IOException { final FileRepositoryBuilder builder = new FileRepositoryBuilder(); // scan environment GIT_* variables builder.readEnvironment(); // scan up the file system tree builder.findGitDir(); // if getGitDir is null, then we are not in a git repository repo = builder.getGitDir() == null ? null : builder.build(); }