本文整理了Java中org.eclipse.jgit.lib.Repository.getDirectory
方法的一些代码示例,展示了Repository.getDirectory
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.getDirectory
方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Repository
类名称:Repository
方法名:getDirectory
[英]Get local metadata directory
[中]获取本地元数据目录
代码示例来源:origin: gocd/gocd
public void initialize() throws IOException {
if (!gitRepo.getDirectory().exists()) {
gitRepo.create();
} else {
cleanAndResetToMaster();
}
}
代码示例来源:origin: jphp-group/jphp
@Signature
public File getDirectory() {
return getWrappedObject().getRepository().getDirectory();
}
代码示例来源:origin: apache/incubator-gobblin
this.remoteRepo.create(true);
this.gitForPush = Git.cloneRepository().setURI(this.remoteRepo.getDirectory().getAbsolutePath()).setDirectory(cloneDir).call();
+ ConfigurationKeys.GIT_MONITOR_REPO_URI, this.remoteRepo.getDirectory().getAbsolutePath())
.addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TEST_DIR + "/git-flowgraph")
.addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5)
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* @param db
* @param refname
*/
ReflogReaderImpl(Repository db, String refname) {
logName = new File(db.getDirectory(), Constants.LOGS + '/' + refname);
}
代码示例来源:origin: apache/incubator-gobblin
remoteRepo.create(true);
Git gitForPush = Git.cloneRepository().setURI(remoteRepo.getDirectory().getAbsolutePath()).setDirectory(cloneDir).call();
+ ConfigurationKeys.GIT_MONITOR_REPO_URI, remoteRepo.getDirectory().getAbsolutePath())
.addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TESTDIR + "/git-flowgraph")
.addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5)
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private ProcessBuilder createProcess(List<String> args) {
ProcessBuilder pb = new ProcessBuilder();
pb.command(args);
File directory = local != null ? local.getDirectory() : null;
if (directory != null) {
pb.environment().put(Constants.GIT_DIR_KEY,
directory.getPath());
}
return pb;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private static String computeKey(Repository repo) {
if (repo instanceof DfsRepository) {
DfsRepository dfs = (DfsRepository) repo;
return dfs.getDescription().getRepositoryName();
}
if (repo.getDirectory() != null) {
return repo.getDirectory().toURI().toString();
}
throw new IllegalArgumentException();
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
public File findHook(Repository repository, String hookName) {
final File gitdir = repository.getDirectory();
if (gitdir == null) {
return null;
}
final Path hookPath = gitdir.toPath().resolve(Constants.HOOKS)
.resolve(hookName);
if (Files.isExecutable(hookPath))
return hookPath.toFile();
return null;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
@NonNull
public String toString() {
String desc;
File directory = getDirectory();
if (directory != null)
desc = directory.getPath();
else
desc = getClass().getSimpleName() + "-" //$NON-NLS-1$
+ System.identityHashCode(this);
return "Repository[" + desc + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
代码示例来源:origin: apache/incubator-gobblin
@BeforeClass
public void setup() throws Exception {
cleanUpDir(TEST_DIR);
// Create a bare repository
RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(remoteDir, FS.DETECTED);
this.remoteRepo = fileKey.open(false);
this.remoteRepo.create(true);
this.gitForPush = Git.cloneRepository().setURI(this.remoteRepo.getDirectory().getAbsolutePath()).setDirectory(cloneDir).call();
// push an empty commit as a base for detecting changes
this.gitForPush.commit().setMessage("First commit").call();
this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call();
this.config = ConfigBuilder.create()
.addPrimitive(GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_URI,
this.remoteRepo.getDirectory().getAbsolutePath())
.addPrimitive(GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TEST_DIR + "/jobConfig")
.addPrimitive(ConfigurationKeys.FLOWSPEC_STORE_DIR_KEY, TEST_DIR + "flowCatalog")
.addPrimitive(ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5)
.build();
this.flowCatalog = new FlowCatalog(config);
this.flowCatalog.startAsync().awaitRunning();
this.gitConfigMonitor = new GitConfigMonitor(this.config, this.flowCatalog);
this.gitConfigMonitor.setActive(true);
}
代码示例来源:origin: centic9/jgit-cookbook
private static File createRepository() throws IOException, GitAPIException {
File dir = File.createTempFile("gitinit", ".test");
if(!dir.delete()) {
throw new IOException("Could not delete temporary file " + dir);
}
Git.init()
.setDirectory(dir)
.call();
try (Repository repository = FileRepositoryBuilder.create(new File(dir.getAbsolutePath(), ".git"))) {
System.out.println("Created a new repository at " + repository.getDirectory());
}
return dir;
}
}
代码示例来源:origin: centic9/jgit-cookbook
public static void main(String[] args) throws IOException, IllegalStateException, GitAPIException {
// prepare a new folder
File localPath = File.createTempFile("TestGitRepository", "");
if(!localPath.delete()) {
throw new IOException("Could not delete temporary file " + localPath);
}
// create the directory
try (Git git = Git.init().setDirectory(localPath).call()) {
System.out.println("Having repository: " + git.getRepository().getDirectory());
}
// clean up here to not keep using more and more disk-space for these samples
FileUtils.deleteDirectory(localPath);
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* <p>
* Constructor for RebaseCommand.
* </p>
*
* @param repo
* the {@link org.eclipse.jgit.lib.Repository}
*/
protected RebaseCommand(Repository repo) {
super(repo);
walk = new RevWalk(repo);
rebaseState = new RebaseState(repo.getDirectory());
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
static boolean isCached(@NonNull Repository repo) {
File gitDir = repo.getDirectory();
if (gitDir == null) {
return false;
}
FileKey key = new FileKey(gitDir, repo.getFS());
return cache.cacheMap.get(key) == repo;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* @return The path to the commit edit message file relative to the
* repository's work tree, or null if the repository is bare.
*/
private String getCommitEditMessageFilePath() {
File gitDir = getRepository().getDirectory();
if (gitDir == null) {
return null;
}
return Repository.stripWorkDir(getRepository().getWorkTree(), new File(
gitDir, Constants.COMMIT_EDITMSG));
}
代码示例来源:origin: centic9/jgit-cookbook
private static void addSubmodule(Repository mainRepo) throws GitAPIException {
System.out.println("Adding submodule");
try (Git git = new Git(mainRepo)) {
try (Repository subRepoInit = git.submoduleAdd().
setURI("https://github.com/github/testrepo.git").
setPath("testrepo").
call()) {
if(subRepoInit.isBare()) {
throw new IllegalStateException("Repository at " + subRepoInit.getDirectory() + " should not be bare");
}
}
}
}
代码示例来源:origin: centic9/jgit-cookbook
private static void addSubmodule(Repository mainRepo) throws GitAPIException {
System.out.println("Adding submodule");
try (Git git = new Git(mainRepo)) {
try (Repository subRepoInit = git.submoduleAdd().
setURI("https://github.com/github/testrepo.git").
setPath("testrepo").
call()) {
if(subRepoInit.isBare()) {
throw new IllegalStateException("Repository at " + subRepoInit.getDirectory() + " should not be bare");
}
}
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Load the attributes node
*
* @return the attributes node
* @throws java.io.IOException
*/
public AttributesNode load() throws IOException {
AttributesNode r = new AttributesNode();
FS fs = repository.getFS();
File attributes = fs.resolve(repository.getDirectory(),
Constants.INFO_ATTRIBUTES);
FileRepository.AttributesNodeProviderImpl.loadRulesFromFile(r, attributes);
return r.getRules().isEmpty() ? null : r;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private TemporaryBuffer doMerge(MergeResult<RawText> result)
throws IOException {
TemporaryBuffer.LocalFile buf = new TemporaryBuffer.LocalFile(
db != null ? nonNullRepo().getDirectory() : null, inCoreLimit);
try {
new MergeFormatter().formatMerge(buf, result,
Arrays.asList(commitNames), UTF_8);
buf.close();
} catch (IOException e) {
buf.destroy();
throw e;
}
return buf;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
public Transport open(URIish uri, Repository local, String remoteName)
throws NoRemoteRepositoryException {
File localPath = local.isBare() ? local.getDirectory() : local.getWorkTree();
File path = local.getFS().resolve(localPath, uri.getPath());
// If the reference is to a local file, C Git behavior says
// assume this is a bundle, since repositories are directories.
if (path.isFile())
return new TransportBundleFile(local, uri, path);
File gitDir = RepositoryCache.FileKey.resolve(path, local.getFS());
if (gitDir == null)
throw new NoRemoteRepositoryException(uri, JGitText.get().notFound);
return new TransportLocal(local, uri, gitDir);
}
内容来源于网络,如有侵权,请联系作者删除!