当前位置: 首页>>代码示例>>Java>>正文


Java FileRepository类代码示例

本文整理汇总了Java中org.eclipse.jgit.internal.storage.file.FileRepository的典型用法代码示例。如果您正苦于以下问题:Java FileRepository类的具体用法?Java FileRepository怎么用?Java FileRepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileRepository类属于org.eclipse.jgit.internal.storage.file包,在下文中一共展示了FileRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasAnyAccount

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
public boolean hasAnyAccount() throws IOException {
  File path = getPath();
  if (path == null) {
    return false;
  }

  try (Repository repo = new FileRepository(path)) {
    return Accounts.hasAnyAccount(repo);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:AccountsOnInit.java

示例2: LambdaConfig

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
private LambdaConfig() {
    try (InputStream is = getClass().getClassLoader().getResourceAsStream("env.properties")) {
        this.props.load(is);
        this.repository = new FileRepository(new File(System.getProperty("java.io.tmpdir"), "s3"));
    }
    catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
    overwriteWithSystemProperty(ENV_BRANCH);
    overwriteWithSystemProperty(ENV_BUCKET);
    overwriteWithSystemProperty(ENV_GITHUB);

    this.remote = new Remote(Constants.DEFAULT_REMOTE_NAME);
    this.branch = new Branch(props.getProperty(ENV_BRANCH, Constants.MASTER));
    this.authentication = new SecureShellAuthentication(new Bucket(props.getProperty(ENV_BUCKET)), client);
}
 
开发者ID:berlam,项目名称:github-bucket,代码行数:17,代码来源:LambdaConfig.java

示例3: pullRepo

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
@Override
public PullResult pullRepo(File repoDir) throws SysException {
    try {
        Repository repository = new FileRepository(repoDir.getAbsolutePath() + "/.git");
        Git git = new Git(repository);

        PullCommand pull = git.pull();

        String user = config.getRepo("username");
        String passwd = config.getRepo("password");

        if (StringUtils.isNotBlank(user) && StringUtils.isNotBlank(passwd)) {
            UsernamePasswordCredentialsProvider upcp = new UsernamePasswordCredentialsProvider(user, passwd);
            pull.setCredentialsProvider(upcp);
        }

        PullResult result = pull.call();

        return result;
    } catch (Exception e) {
        throw new SysException(e);
    }
}
 
开发者ID:speedyproject,项目名称:dcmp,代码行数:24,代码来源:RepertoryServiceImpl.java

示例4: main

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
    
    Repository repo = new FileRepository(Consts.META_REPO_PATH + ".git");
    
    // get a list of all known heads, tags, remotes, ...
    Collection<Ref> allRefs = repo.getAllRefs().values();

    // a RevWalk allows to walk over commits based on some filtering that is defined
    try (RevWalk revWalk = new RevWalk(repo)) {
        for (Ref ref : allRefs) {
            revWalk.markStart(revWalk.parseCommit(ref.getObjectId()));
        }
        System.out.println("Walking all commits starting with " + allRefs.size() + " refs: " + allRefs);
        int count = 0;
        for (RevCommit commit : revWalk) {
            System.out.println("Commit: " + commit);
            count++;
        }
        System.out.println("Had " + count + " commits");
    }
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:22,代码来源:RefList.java

示例5: containsGitRepo

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
/**
 * Tells if the given filesystem directory contains a valid git repository.
 *
 * @param dir
 *            a {@link Path} to check
 * @return {@code true} if the given {@code dir} contains a valid git repository; {@code false} otherwise.
 */
private static boolean containsGitRepo(Path dir) {
    Path gitDir = dir.resolve(".git");
    if (!Files.exists(gitDir)) {
        return false;
    } else {
        try (FileRepository repo = new FileRepository(gitDir.toFile())) {
            return repo.getObjectDatabase().exists();
        } catch (IOException e) {
            log.warn(String.format("Could not check if [%s] contains a git repository", dir), e);
            /*
             * We could perhaps throw e out of this method rather than return false. Returning false sounds as a
             * better idea in case the repo is somehow damaged.
             */
            return false;
        }
    }
}
 
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:25,代码来源:JGitScm.java

示例6: returnsCurrentCommitForNonEmptyRepos

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
@Test
public void returnsCurrentCommitForNonEmptyRepos() throws Exception {
    Git git = emptyRepo();
    FileRepository repository = (FileRepository) git.getRepository();
    File dir = repository.getDirectory();
    FileUtils.writeStringToFile(new File(dir, "file1"), "Hello", "UTF-8");
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Initial commit")
        .setAuthor(new PersonIdent("Author Test", "[email protected]"))
        .call();

    FileUtils.writeStringToFile(new File(dir, "file2"), "Hello too", "UTF-8");
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Second commit")
        .setAuthor(new PersonIdent("Second contributor", "[email protected]"))
        .call();

    JSONObject actual = GitCommit.fromHEAD(git).toJSON();
    JSONAssert.assertEquals("{" +
        "author: 'Second contributor', message: 'Second commit'" +
        "}", actual, JSONCompareMode.LENIENT);

    assertThat(actual.getLong("date"), Matchers.greaterThanOrEqualTo(System.currentTimeMillis() - 1000));
    assertThat(actual.getString("id"), actual.getString("id").length(), is("3688d7063d2d647e3989d62d9770d0dfd0ce3c25".length()));

}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:27,代码来源:GitCommitTest.java

示例7: getObjectFiles

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
private SortedSet<String> getObjectFiles(Project.NameKey project) throws Exception {
  SortedSet<String> files = new TreeSet<>();
  try (Repository repo = repoManager.openRepository(project)) {
    Files.walkFileTree(
        ((FileRepository) repo).getObjectDatabase().getDirectory().toPath(),
        new SimpleFileVisitor<Path>() {
          @Override
          public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
            String name = file.getFileName().toString();
            if (!attrs.isDirectory() && !name.endsWith(".pack") && !name.endsWith(".idx")) {
              files.add(name);
            }
            return FileVisitResult.CONTINUE;
          }
        });
  }
  return files;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:OnlineNoteDbMigrationIT.java

示例8: JGitOperator

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
public JGitOperator(String repositoryPath) {

try {
          // need to verify repo was created successfully - this is not enough
	/*if(!repositoryPath.contains("\\.git") && !repositoryPath.equals("."))
	{
		repositoryPath=repositoryPath.concat("\\.git");
	}*/
          _repo = new FileRepository(repositoryPath);
          _git = new Git(_repo);
 
          } catch (IOException e) {
          throw new RuntimeException(String.format(
                  "Failed creating git repository for path [%s]",
                  repositoryPath), e);
          }
      }
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:18,代码来源:JGitOperator.java

示例9: gitPull

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
/**
 * Execute git pull command on the given repository.
 * It populates an ArrayList with all the updated files.
 * @param localPath The path where the project is.
 * @return Returns true if you should update plugins, false otherwise.
 */
private boolean gitPull(File localPath) {
    try {
        Repository localRepo = new FileRepository(localPath.getAbsolutePath() + "/.git");
        git = new Git(localRepo);
        
        populateDiff();
        
        if(!pluginsToUpdate.isEmpty()){
            PullCommand pullCmd = git.pull();
            pullCmd.call();
            return true;
        }
        else{
            return false;
        }
        
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    return true;
}
 
开发者ID:Neembuu-Uploader,项目名称:neembuu-uploader,代码行数:29,代码来源:UpdaterGenerator.java

示例10: gitPull

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
/**
 * Execute git pull command on the given repository.
 * It populates an ArrayList with all the updated files.
 * @param localPath The path where the project is.
 * @return Returns true if you should update plugins, false otherwise.
 */
private boolean gitPull(File localPath) {
    try {
        Repository localRepo = new FileRepository(localPath.getAbsolutePath() + "/.git");
        git = new Git(localRepo);
        
        
        
        if(populateDiff()){
            PullCommand pullCmd = git.pull();
            pullCmd.call();
            return true;
        }
        else{
            return false;
        }
        
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    return true;
}
 
开发者ID:Neembuu-Uploader,项目名称:neembuu-uploader,代码行数:29,代码来源:UpdaterGenerator.java

示例11: cloneBranch

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
public String cloneBranch(String projectName, String branchName) throws IOException, GitAPIException {
String repoPath = LOCAL_PATH + "\\" + projectName; // + "/" + branchName;
System.out.println("Initializing git object for project: " + projectName + " at path: " + repoPath);
try {
	Repository localRepo = new FileRepository(repoPath + "/.git");
	GitInstance newGitObject = new GitInstance(projectName + "_" + branchName, new Git(localRepo));
	storedRepos.add(newGitObject);
} catch (IOException e) {
	e.printStackTrace();
}

String remotePath = REPO_URL + projectName + ".git";
System.out.println("branchName - " + branchName);
String branchPath = LOCAL_PATH + "\\" + projectName;
System.out.println("Cloning branch [" + branchName + "] to path [" + branchPath + "]");
// createOrCleanDir(branchPath);

File branchFolder = new File(branchPath);
if(!branchFolder.exists()) {
    Git.cloneRepository().setURI(remotePath)
    	.setDirectory(branchFolder)
    	.setBranch(branchName).call();
}
      return branchPath;
  }
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:26,代码来源:MondoGitHandler.java

示例12: cloneBranch

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
public String cloneBranch(String projectName, String branchName) throws IOException, GitAPIException {
String repoPath = localPath + "/" + projectName + "/" + branchName;
System.out.println("Initializing git object for project: " + projectName + " at path: " + repoPath);
try {
	Repository localRepo = new FileRepository(repoPath + "/.git");
	GitInstance newGitObject = new GitInstance(projectName + "_" + branchName, new Git(localRepo));
	storedRepos.add(newGitObject);
} catch (IOException e) {
	e.printStackTrace();
}

String remotePath = "https://github.com/1forintos/" + projectName + ".git";
System.out.println("branchName - " + branchName);
String branchPath = localPath + "/" + projectName + "/" + branchName;
System.out.println("Cloning branch [" + branchName + "] to path [" + branchPath + "]");
// createOrCleanDir(branchPath);

File branchFolder = new File(branchPath);
if(!branchFolder.exists()) {
    Git.cloneRepository().setURI(remotePath)
    	.setDirectory(branchFolder)
    	.setBranch(branchName).call();
}
      return branchPath;
  }
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:26,代码来源:MondoGitHandler.java

示例13: getGit

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
private Git getGit() throws IOException, IllegalArgumentException
{
	if (localFolder == null)
	{
		throw new IllegalArgumentException("localFolder has not yet been set - please call setRootLocation(...)");
	}
	if (!localFolder.isDirectory())
	{
		log.error("The passed in local folder '{}' didn't exist", localFolder);
		throw new IllegalArgumentException("The localFolder must be a folder, and must exist");
	}

	File gitFolder = new File(localFolder, ".git");

	if (!gitFolder.isDirectory())
	{
		log.error("The passed in local folder '{}' does not appear to be a git repository", localFolder);
		throw new IllegalArgumentException("The localFolder does not appear to be a git repository");
	}
	return new Git(new FileRepository(gitFolder));
}
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:22,代码来源:SyncServiceGIT.java

示例14: isCloned

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
   public boolean isCloned(final GitRepository repository) throws RepositoryException {
	try {
		final FileRepository fileRepository = getFileRepository(repository);
		for (final RemoteConfig remoteConfig : RemoteConfig.getAllRemoteConfigs(fileRepository.getConfig())) {
			for (final URIish uri : remoteConfig.getURIs()) {
				if (uri.equals(new URIish(repository.getUri()))) {
					return true;
				}
			}
		}
	} catch (final URISyntaxException urise) {
		throw new RepositoryException("URI syntax exception, please check that the syntax is correct", urise);
	}
	logger.debug("Remote repository is not yet cloned: " + repository.getUri());
	return false;
   }
 
开发者ID:astralbat,项目名称:gitcommitviewer,代码行数:21,代码来源:DefaultGitRepositoryService.java

示例15: getBranchHeads

import org.eclipse.jgit.internal.storage.file.FileRepository; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Map<String, GitCommitKey> getBranchHeads(final GitRepository repository) throws RepositoryException {
	Validate.notNull(repository, "repository must not be null");
	
	final FileRepository fileRepository = getFileRepository(repository);
	try {
		final List<Ref> branchRefs = Git.wrap(fileRepository)
			.branchList()
			.call();
		
		final Map<String, GitCommitKey> branches = new HashMap<String, GitCommitKey>();
		final RevWalk walk = new RevWalk(fileRepository);
		for (final Ref branch : branchRefs) {
			final RevCommit revCommit = walk.parseCommit(branch.getObjectId());
			branches.put(branch.getName().substring("refs/heads/".length()), 
					new GitCommitKey(branch.getObjectId().getName(), revCommit.getCommitTime()));
		}
		return branches;
	} catch (final IOException ioe) {
		throw new RepositoryException("IO error while scanning branch tips", ioe);
	} catch (final GitAPIException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:astralbat,项目名称:gitcommitviewer,代码行数:28,代码来源:DefaultGitRepositoryService.java


注:本文中的org.eclipse.jgit.internal.storage.file.FileRepository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。