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


Java RevisionSyntaxException类代码示例

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


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

示例1: getConfiguration

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
/**
 * Export the git tag identified by the entry id
 * 
 * @param config
 * @param e
 * @param exportDirectory
 * @throws Exception
 */
public void getConfiguration(Configuration config, Entry e, File exportDirectory) throws Exception {
	Preconditions.checkNotNull(config, "Configuration must be supplied.");
	Preconditions.checkNotNull(e, "Entry must be supplied.");
	Preconditions.checkNotNull(exportDirectory, "Directory must be supplied.");
	File zip = new File(exportDirectory, e.getUUID().toString()+".zip");
	ArchiveCommand.registerFormat("zip", new ZipFormat());
	try (FileOutputStream out = new FileOutputStream(zip);){
		LOG.debug("Exporting tag {} to {}", e.getUUID(), zip);
		git.archive().setTree(git.getRepository().resolve(e.getUUID().toString()))
			.setFormat("zip")
			.setOutputStream(out)
			.call();
	    unzip(zip);
	} catch (IOException | RevisionSyntaxException | GitAPIException ioe) {
		zip.delete();
		LOG.error("Error creating archive from tag: " + e.getUUID().toString(), ioe);
		throw ioe;
	} finally {
		ArchiveCommand.unregisterFormat("zip");
	}
}
 
开发者ID:dlmarion,项目名称:raccovery,代码行数:30,代码来源:AccumuloConfigurations.java

示例2: diff

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
/**
 * wrapper of git diff ref1..ref2
 */
protected List<DiffInfo> diff(RepositoryPK repositoryPK, String ref1, String ref2) {
  try (RepositoryReader reader = new RepositoryReader(repositoryPK)) {
    Git git = reader.getGit();
    Repository repository = reader.getRepository();

    List<DiffEntry> entries = diff(git, ref1, ref2);

    List<DiffInfo> diffInfos = new ArrayList<>();
    for (DiffEntry entry : entries) {
      Optional<FileContent> oldContent = getFileContent(git, entry.getOldPath(), entry.getOldId());
      Optional<FileContent> newContent = getFileContent(git, entry.getNewPath(), entry.getNewId());

      CustomDiffFormatter diffFormatter = new CustomDiffFormatter(repository);
      List<DiffBlock> diffLineList = diffFormatter.diffFormat(entry);
      DiffInfo diffInfo = DiffInfo.ofDiff(entry, oldContent.orElse(null), newContent.orElse(null), diffLineList);
      diffInfos.add(diffInfo);
    }
    return diffInfos;
  } catch (RevisionSyntaxException | IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:kamegu,项目名称:git-webapp,代码行数:26,代码来源:GitOperation.java

示例3: populateHEADGeneralData

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
private void populateHEADGeneralData(RepositoryRevision head,Git git) {
	try {
		
		ObjectId headObject = git.getRepository().resolve(Constants.HEAD);

		head.setLastCommit(git.log().add(headObject).call().iterator()
				.next().getId().getName());
		head.setLastCommitMessage(git.log().add(headObject).call()
				.iterator().next().getShortMessage());
		head.setLastCommitAuthor(git.log().add(headObject).call()
				.iterator().next().getAuthorIdent().getName());

	} catch (RevisionSyntaxException | IOException | GitAPIException
			| NullPointerException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:XMLVersioningFramework,项目名称:XMLVersioningFramework,代码行数:19,代码来源:GitHandler.java

示例4: resolve

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
@Override
public Commit resolve(String reference) {
	RevWalk revWalk = null;

	try {
		ObjectId ref = git.getRepository().resolve(reference);
		revWalk = new RevWalk(git.getRepository());
		RevCommit revCommit = revWalk.parseCommit(ref);

		return new Commit(revCommit.getName(), revCommit.getCommitterIdent().getWhen());
	} catch (RevisionSyntaxException | IOException e) {
		throw new RepositoryMinerException("Error getting the commit from " + reference + ".", e);
	} finally {
		if (revWalk != null) {
			revWalk.close();
		}
	}
}
 
开发者ID:visminer,项目名称:repositoryminer,代码行数:19,代码来源:GitSCM.java

示例5: getFileContentOfLastCommit

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
public static File getFileContentOfLastCommit(String filePath,Repository repository) throws RevisionSyntaxException, AmbiguousObjectException, IncorrectObjectTypeException, IOException {
	// find the HEAD
	ObjectId lastCommitId = repository.resolve(Constants.HEAD);

	// a RevWalk allows to walk over commits based on some filtering that is
	// defined
	RevWalk revWalk = new RevWalk(repository);
	RevCommit commit = revWalk.parseCommit(lastCommitId);
	// and using commit's tree find the path
	RevTree tree = commit.getTree();
	System.out.println("Having tree: " + tree);

	// now try to find a specific file
	TreeWalk treeWalk = new TreeWalk(repository);
	treeWalk.addTree(tree);
	treeWalk.setRecursive(true);
	treeWalk.setPostOrderTraversal(true);
	treeWalk.setFilter(PathFilter.create(filePath));
	if (!treeWalk.next()) {
		//TODO the file is added to project
		throw new IllegalStateException(
				"CHANGECOMMIT -- Did not find expected file '" + filePath + "'");
	}

	ObjectId objectId = treeWalk.getObjectId(0);
	ObjectLoader loader = repository.open(objectId);

	return Utils.inputStreamToFile(loader.openStream());
}
 
开发者ID:SEMERU-WM,项目名称:ChangeScribe,代码行数:30,代码来源:Utils.java

示例6: getStringContentOfLastCommit

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
public static String getStringContentOfLastCommit(String filePath,Repository repository) throws RevisionSyntaxException, AmbiguousObjectException, IncorrectObjectTypeException, IOException {
	// find the HEAD
	ObjectId lastCommitId = repository.resolve(Constants.HEAD);
	// a RevWalk allows to walk over commits based on some filtering that is
	// defined
	RevWalk revWalk = new RevWalk(repository);
	RevCommit commit = revWalk.parseCommit(lastCommitId);
	// and using commit's tree find the path
	RevTree tree = commit.getTree();
	System.out.println("Having tree: " + tree);
	// now try to find a specific file
	TreeWalk treeWalk = new TreeWalk(repository);
	treeWalk.addTree(tree);
	treeWalk.setRecursive(true);
	treeWalk.setPostOrderTraversal(true);
	treeWalk.setFilter(PathFilter.create(filePath));
	if (!treeWalk.next()) {
		//TODO the file is added to project
		throw new IllegalStateException(
				"CHANGECOMMIT -- Did not find expected file '" + filePath + "'");
	}

	ObjectId objectId = treeWalk.getObjectId(0);
	ObjectLoader loader = repository.open(objectId);
	
	return IOUtils.stringFromFile(Utils.inputStreamToFile(loader.openStream()).getAbsolutePath(), "utf-8");
}
 
开发者ID:SEMERU-WM,项目名称:ChangeScribe,代码行数:28,代码来源:Utils.java

示例7: getStringContentOfCommitID

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
public static String getStringContentOfCommitID(String filePath,Repository repository, String commitID) throws RevisionSyntaxException, AmbiguousObjectException, IncorrectObjectTypeException, IOException {
	// find the HEAD
	ObjectId lastCommitId = repository.resolve(commitID);

	// a RevWalk allows to walk over commits based on some filtering that is
	// defined
	RevWalk revWalk = new RevWalk(repository);
	RevCommit commit = revWalk.parseCommit(lastCommitId);
	// and using commit's tree find the path
	RevTree tree = commit.getTree();
	System.out.println("Having tree: " + tree);

	// now try to find a specific file
	TreeWalk treeWalk = new TreeWalk(repository);
	treeWalk.addTree(tree);
	treeWalk.setRecursive(true);
	treeWalk.setPostOrderTraversal(true);
	treeWalk.setFilter(PathFilter.create(filePath.substring(filePath.indexOf("/") + 1)));
	if (!treeWalk.next()) {
		
		//TODO the file is added to project
		throw new IllegalStateException(
				"CHANGECOMMIT -- Did not find expected file '" + filePath + "'");
	}
	ObjectId objectId = treeWalk.getObjectId(0);
	ObjectLoader loader = repository.open(objectId);
	return IOUtils.stringFromFile(Utils.inputStreamToFile(loader.openStream()).getAbsolutePath(), "utf-8");
}
 
开发者ID:SEMERU-WM,项目名称:ChangeScribe,代码行数:29,代码来源:Utils.java

示例8: getCommitsFromBranch

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
private Iterable<RevCommit> getCommitsFromBranch(String refName) {
	try {
		return git.log().add(git.getRepository().resolve(refName)).call();
	} catch (RevisionSyntaxException | GitAPIException | IOException e) {
		close();
		throw new RepositoryMinerException(e);
	}
}
 
开发者ID:visminer,项目名称:repositoryminer,代码行数:9,代码来源:GitSCM.java

示例9: merge

import org.eclipse.jgit.errors.RevisionSyntaxException; //导入依赖的package包/类
public boolean merge(String baseBranchName, IssuePK issuePK, String message, LoginContext loginContext) {
  String mergeMessage = PullRequest.getMergeMessage(issuePK, new PullRequestEndpoint(issuePK.getRepositoryPK(), baseBranchName))
      + "\n\n" + message;
  try (RepositoryReader reader = new RepositoryReader(issuePK.getRepositoryPK())) {
    Repository repository = reader.getRepository();

    String pullBranch = Constants.R_REFS + "pull/" + issuePK.getIssueId() + "/head";
    String baseBranchRefName = Constants.R_HEADS + baseBranchName;

    ThreeWayMerger merger = MergeStrategy.RECURSIVE.newMerger(repository, true);
    ObjectInserter inserter = repository.newObjectInserter();

    try {
      ObjectId baseObjectId = repository.resolve(baseBranchRefName);
      ObjectId pullBranchObjectId = repository.resolve(pullBranch);

      boolean noError = merger.merge(baseObjectId, pullBranchObjectId);
      if (!noError) {
        throw new RuntimeException("cannot merge!!");
      }

      ObjectId resultTreeId = merger.getResultTreeId();

      PersonIdent personIdent = new PersonIdent(loginContext.getName(), loginContext.getEmail());
      CommitBuilder commit = new CommitBuilder();
      commit.setCommitter(personIdent);
      commit.setAuthor(personIdent);
      commit.setMessage(mergeMessage);
      commit.setParentIds(baseObjectId, pullBranchObjectId);
      commit.setTreeId(resultTreeId);
      ObjectId mergedCommitId = inserter.insert(commit);
      inserter.flush();

      RefUpdate refUpdate = repository.updateRef(baseBranchRefName);
      refUpdate.setNewObjectId(mergedCommitId);
      refUpdate.setForceUpdate(false);
      refUpdate.setRefLogIdent(personIdent);
      refUpdate.setRefLogMessage("merged", false);
      refUpdate.update();

      return true;
    } catch (RevisionSyntaxException | IOException e) {
      return false;
    } finally {
      inserter.release();
    }
  }
}
 
开发者ID:kamegu,项目名称:git-webapp,代码行数:49,代码来源:GitOperation.java


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