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


Java AnyObjectId类代码示例

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


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

示例1: lookupAny

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
/**
 * Locate a reference to any object without loading it.
 * <p>
 * The object may or may not exist in the repository. It is impossible to
 * tell from this method's return value.
 *
 * @param id
 *            name of the object.
 * @param type
 *            type of the object. Must be a valid Git object type.
 * @return reference to the object. Never null.
 */
public RevObject lookupAny(final AnyObjectId id, final int type) {
	RevObject r = objects.get(id);
	if (r == null) {
		switch (type) {
		case Constants.OBJ_COMMIT:
			r = createCommit(id);
			break;
		case Constants.OBJ_TREE:
			r = new RevTree(id);
			break;
		case Constants.OBJ_BLOB:
			r = new RevBlob(id);
			break;
		case Constants.OBJ_TAG:
			r = new RevTag(id);
			break;
		default:
			throw new IllegalArgumentException(MessageFormat.format(
					JGitText.get().invalidGitType, Integer.valueOf(type)));
		}
		objects.add(r);
	}
	return r;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:37,代码来源:RevWalk.java

示例2: putColumnMetaAsObject

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
/**
 * 
 * @param columns
 * @param objectInserter
 * @param tblTree
 * @param walkTbl
 * @return
 * @throws SQLException
 * @throws IOException 
 */
public static ObjectId putColumnMetaAsObject(ResultSet columns, 
        ObjectInserter objectInserter, TreeFormatter tblTree, RevWalk walkTbl) throws SQLException, IOException {

    // Build object for column attributs
    ObjectId objectId = buildMetaObject(columns, Consts.COLUMN_META_ATTRIBUTES, objectInserter);

    tblTree.append(Consts.COLUMN_META, FileMode.REGULAR_FILE, (AnyObjectId) objectId);

    // Add empty tree for the column content
    TreeFormatter clmnDataTree = new TreeFormatter();
    ObjectId clmnDataTreeId = objectInserter.insert(clmnDataTree);
    objectInserter.flush();

    tblTree.append(Consts.COLUMN_DATA, walkTbl.parseTree(clmnDataTreeId));

    return objectId;
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:28,代码来源:Utils.java

示例3: updateFileSystemStatus

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
@Nonnull
private Result updateFileSystemStatus(GfsStatusProvider.Update update, Merger merger) throws IOException {
  AnyObjectId treeId = merger.getResultTreeId();
  checkout(gfs, treeId);
  RevCommit newCommit = null;
  if(commit && !squash) {
    prepareCommitter();
    newCommit = createCommit(message, treeId, committer, committer, Arrays.asList(headCommit, sourceHeadCommit), repo);
    BranchUtils.merge(branch, newCommit, sourceRef, "Merge made by " + strategy.getName() + ".", repo);
    update.commit(newCommit);
  }
  if(!commit) {
    update.mergeNote(MergeNote.mergeNoCommit(sourceHeadCommit, message));
    return Result.mergedNotCommitted();
  }
  if(squash) {
    update.mergeNote(MergeNote.mergeSquash(message));
    return Result.mergedSquashed();
  }
  return Result.merged(newCommit);
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:22,代码来源:GfsMerge.java

示例4: doExecute

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
@Nonnull
@Override
protected GfsCreateStash.Result doExecute(GfsStatusProvider.Update update) throws IOException {
  prepareBranch();
  prepareCommitter();
  prepareParent();
  prepareIndexMessage();
  prepareDirectoryMessage();
  AnyObjectId resultTree = gfs.flush();
  GfsCreateStash.Result result;
  if(parent != null && parent.getTree().equals(resultTree)) {
    result = noChange();
  } else {
    RevCommit indexCommit = makeIndexCommit(resultTree);
    RevCommit stashCommit = makeWorkingDirectoryCommit(indexCommit);
    addToStash(stashCommit, repo);
    result = success(stashCommit);
  }
  return result;
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:21,代码来源:GfsCreateStash.java

示例5: getGitRepositoryMetaData

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
public static GitRepoMetaData getGitRepositoryMetaData(String repoPath) {
        try {
            if(!repoPath.endsWith(".git"))
                repoPath = repoPath+File.separator+".git";
            System.out.println("repopath:  "+repoPath);
            GitRepoMetaData gitMetaData = new GitRepoMetaData();
            FileRepositoryBuilder builder = new FileRepositoryBuilder();
            Repository repository = builder.setGitDir(new File(repoPath))
                    .readEnvironment()
                    .setMustExist(true)
                    .findGitDir()
                    .build();
            RevWalk walk = new RevWalk(repository);
            AnyObjectId id = repository.resolve("HEAD");
            if(id == null)
                return null;//Empty repository
            RevCommit rCommit =walk.parseCommit(id);
            walk.markStart(rCommit);
            gitMetaData.setRepository(repository);
            gitMetaData.setRevWalk(walk);
            return gitMetaData;
        } catch (IOException exception) {
//[LOG]            logger.debug("IOException getGitRepositoryMetaData", exception);
        };
        return null;
    }
 
开发者ID:jughyd,项目名称:GitFx,代码行数:27,代码来源:GitFXGsonUtil.java

示例6: getSrcCommit

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
public RevCommit getSrcCommit() {
    try {
        RevWalk revWalk = new RevWalk(git.getRepository());
        AnyObjectId headId = git.getRepository().resolve(Constants.HEAD);
        RevCommit root = revWalk.parseCommit(headId);
        revWalk.sort(RevSort.REVERSE);
        revWalk.markStart(root);
        return revWalk.next();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:PizzaCrust,项目名称:IodineToolkit,代码行数:13,代码来源:PatchService.java

示例7: getChangedFiles

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
public List<Path> getChangedFiles() throws IOException {
    List<Path> changedFiles = new ArrayList<>();
    RevWalk revWalk = new RevWalk(git.getRepository());
    AnyObjectId headId = git.getRepository().resolve(Constants.HEAD);
    RevCommit head = revWalk.parseCommit(headId);
    DiffFormatter formatter = new DiffFormatter(null);
    formatter.setRepository(git.getRepository());
    formatter.setDiffComparator(RawTextComparator.DEFAULT);
    formatter.setDetectRenames(true);
    List<DiffEntry> entries = formatter.scan(getSrcCommit().getTree(), head);
    entries.forEach((diffEntry -> changedFiles.add(Paths.get(diffEntry.getPath(DiffEntry.Side.NEW)))));
    return changedFiles;
}
 
开发者ID:PizzaCrust,项目名称:IodineToolkit,代码行数:14,代码来源:PatchService.java

示例8: getCommitIndexVersion

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
private String getCommitIndexVersion(final IndexSearcher searcher, AnyObjectId commitId) throws IOException {
	final AtomicReference<String> indexVersion = new AtomicReference<>(null);
	
	searcher.search(COMMIT_HASH.query(commitId.getName()), new Collector() {

		private int docBase;
		
		@Override
		public void setScorer(Scorer scorer) throws IOException {
		}

		@Override
		public void collect(int doc) throws IOException {
			indexVersion.set(searcher.doc(docBase+doc).get(COMMIT_INDEX_VERSION.name()));
		}

		@Override
		public void setNextReader(AtomicReaderContext context) throws IOException {
			docBase = context.docBase;
		}

		@Override
		public boolean acceptsDocsOutOfOrder() {
			return true;
		}
		
	});
	return indexVersion.get();
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:30,代码来源:DefaultIndexManager.java

示例9: parseNew

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
private RevObject parseNew(AnyObjectId id, ObjectLoader ldr)
		throws LargeObjectException, CorruptObjectException,
		MissingObjectException, IOException {
	RevObject r;
	int type = ldr.getType();
	switch (type) {
	case Constants.OBJ_COMMIT: {
		final RevCommit c = createCommit(id);
		c.parseCanonical(this, getCachedBytes(c, ldr));
		r = c;
		break;
	}
	case Constants.OBJ_TREE: {
		r = new RevTree(id);
		r.flags |= PARSED;
		break;
	}
	case Constants.OBJ_BLOB: {
		r = new RevBlob(id);
		r.flags |= PARSED;
		break;
	}
	case Constants.OBJ_TAG: {
		final RevTag t = new RevTag(id);
		t.parseCanonical(this, getCachedBytes(t, ldr));
		r = t;
		break;
	}
	default:
		throw new IllegalArgumentException(MessageFormat.format(
				JGitText.get().badObjectType, Integer.valueOf(type)));
	}
	objects.add(r);
	return r;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:36,代码来源:RevWalk.java

示例10: diff

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
public static List<DiffEntry> diff(Repository repository, AnyObjectId oldRevId, AnyObjectId newRevId) {
	List<DiffEntry> diffs = new ArrayList<>();
	try (	DiffFormatter diffFormatter = new DiffFormatter(NullOutputStream.INSTANCE);
			RevWalk revWalk = new RevWalk(repository);
			ObjectReader reader = repository.newObjectReader();) {
    	diffFormatter.setRepository(repository);
    	diffFormatter.setDetectRenames(true);
    	diffFormatter.setDiffComparator(RawTextComparator.DEFAULT);
    	
    	CanonicalTreeParser oldTreeParser = new CanonicalTreeParser();
    	if (!oldRevId.equals(ObjectId.zeroId()))
    		oldTreeParser.reset(reader, revWalk.parseCommit(oldRevId).getTree());
    	
    	CanonicalTreeParser newTreeParser = new CanonicalTreeParser();
    	if (!newRevId.equals(ObjectId.zeroId()))
    		newTreeParser.reset(reader, revWalk.parseCommit(newRevId).getTree());
    	
    	for (DiffEntry entry: diffFormatter.scan(oldTreeParser, newTreeParser)) {
    		if (!Objects.equal(entry.getOldPath(), entry.getNewPath())
    				|| !Objects.equal(entry.getOldMode(), entry.getNewMode())
    				|| entry.getOldId()==null || !entry.getOldId().isComplete()
    				|| entry.getNewId()== null || !entry.getNewId().isComplete()
    				|| !entry.getOldId().equals(entry.getNewId())) {
    			diffs.add(entry);
    		}
    	}
	} catch (IOException e) {
		throw new RuntimeException(e);
	}			
	return diffs;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:32,代码来源:GitUtils.java

示例11: restartMerge

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
/**
 * Restore to the initial state of the repository. Only applicable if the
 * repository has conflicts
 */
public void restartMerge() {
	try {
		AnyObjectId commitToMerge = git.getRepository().resolve("MERGE_HEAD");
		git.clean().call();
		git.reset().setMode(ResetType.HARD).call();
		git.merge().include(commitToMerge).setStrategy(MergeStrategy.RECURSIVE).call();
		
		fireFileStateChanged(new ChangeEvent(GitCommand.MERGE_RESTART, Collections.<String> emptyList()));
	} catch (GitAPIException | IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(END_FETCH_DEBUG_MESSAGE);
		}
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:19,代码来源:GitAccess.java

示例12: setupMergeCommand

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
private static void setupMergeCommand(MergeCommand merge, List<Ref> commitsByRef, List<AnyObjectId> commitsById,
                                      List<NamedCommit> commitsByNameAndId, ProgressMonitor monitor,
                                      MergeStrategy strategy, MergeCommand.FastForwardMode fastForwardMode) {
    commitsByRef.forEach(merge::include);
    commitsById.forEach(merge::include);
    commitsByNameAndId.forEach(nc -> merge.include(nc.getName(), nc.getObjectId()));

    if (monitor != null) { merge.setProgressMonitor(monitor); }

    merge
            .setFastForward(fastForwardMode)
            .setStrategy(strategy);
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:14,代码来源:GitHelper.java

示例13: mergeWithSquash

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
public static MergeResult mergeWithSquash(Git git, MergeStrategy strategy,  List<Ref> commitsByRef,
                                   List<AnyObjectId> commitsById, List<NamedCommit> commitsByNameAndId,
                                   MergeCommand.FastForwardMode fastForwardMode,
                                   ProgressMonitor monitor) throws GitAPIException {
    MergeCommand merge = git.merge();

    setupMergeCommand(merge, commitsByRef, commitsById, commitsByNameAndId, monitor, strategy, fastForwardMode);

    return merge
            .setStrategy(strategy)
            .setFastForward(fastForwardMode)
            .setSquash(true)
            .call();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:15,代码来源:GitHelper.java

示例14: mergeWithoutCommit

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
public static MergeResult mergeWithoutCommit(Git git, MergeStrategy strategy, List<Ref> commitsByRef,
                                      List<AnyObjectId> commitsById, List<NamedCommit> commitsByNameAndId,
                                      MergeCommand.FastForwardMode fastForwardMode,
                                      ProgressMonitor monitor) throws GitAPIException {
    MergeCommand merge = git.merge();

    setupMergeCommand(merge, commitsByRef, commitsById, commitsByNameAndId, monitor, strategy, fastForwardMode);

    return merge
            .setStrategy(strategy)
            .setFastForward(fastForwardMode)
            .setCommit(false)
            .call();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:15,代码来源:GitHelper.java

示例15: mergeWithCommit

import org.eclipse.jgit.lib.AnyObjectId; //导入依赖的package包/类
public static MergeResult mergeWithCommit(Git git, MergeStrategy strategy, List<Ref> commitsByRef, List<AnyObjectId> commitsById,
                                          List<NamedCommit> commitsByNameAndId, String commitMessage,
                                          MergeCommand.FastForwardMode fastForwardMode,
                                          ProgressMonitor monitor) throws GitAPIException {
    MergeCommand merge = git.merge();

    setupMergeCommand(merge, commitsByRef, commitsById, commitsByNameAndId, monitor, strategy, fastForwardMode);

    return git.merge()
            .setMessage(commitMessage)           // message to be used for merge commit
            .call();
}
 
开发者ID:JordanMartinez,项目名称:JGitFX,代码行数:13,代码来源:GitHelper.java


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