本文整理汇总了Java中org.eclipse.jgit.errors.MissingObjectException类的典型用法代码示例。如果您正苦于以下问题:Java MissingObjectException类的具体用法?Java MissingObjectException怎么用?Java MissingObjectException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MissingObjectException类属于org.eclipse.jgit.errors包,在下文中一共展示了MissingObjectException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPaths
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
private List<DiffEntry> getPaths(Repository repository, RevCommit rev)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
RevCommit parent = null;
List<DiffEntry> diffs = null;
RevWalk rw = new RevWalk(repository);
DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
df.setRepository(repository);
df.setDiffComparator(RawTextComparator.DEFAULT);
df.setDetectRenames(true);
if (rev.getParentCount() > 0 && rev.getParent(0) != null) {
parent = rw.parseCommit(rev.getParent(0).getId());
diffs = df.scan(parent.getTree(), rev.getTree());
} else {
diffs = df.scan(new EmptyTreeIterator(), new CanonicalTreeParser(
null, rw.getObjectReader(), rev.getTree()));
}
return diffs;
}
示例2: DepthGenerator
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
/**
* @param w
* @param s Parent generator
* @throws MissingObjectException
* @throws IncorrectObjectTypeException
* @throws IOException
*/
DepthGenerator(DepthWalk w, Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
pending = new FIFORevQueue();
walk = (RevWalk)w;
this.depth = w.getDepth();
this.UNSHALLOW = w.getUnshallowFlag();
this.REINTERESTING = w.getReinterestingFlag();
s.shareFreeList(pending);
// Begin by sucking out all of the source's commits, and
// adding them to the pending queue
for (;;) {
RevCommit c = s.next();
if (c == null)
break;
if (((DepthWalk.Commit) c).getDepth() == 0)
pending.add(c);
}
}
示例3: next
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
@Override
public RevCommit next() throws MissingObjectException,
IncorrectObjectTypeException, IOException {
for (;;) {
final RevCommit r = super.next();
if (r == null) {
return null;
}
final RevTree t = r.getTree();
if ((r.flags & UNINTERESTING) != 0) {
if (objectFilter.include(this, t)) {
markTreeUninteresting(t);
}
if (boundary) {
return r;
}
continue;
}
if (objectFilter.include(this, t)) {
pendingObjects.add(t);
}
return r;
}
}
示例4: newTreeVisit
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
private TreeVisit newTreeVisit(RevObject obj) throws LargeObjectException,
MissingObjectException, IncorrectObjectTypeException, IOException {
TreeVisit tv = freeVisit;
if (tv != null) {
freeVisit = tv.parent;
tv.ptr = 0;
tv.namePtr = 0;
tv.nameEnd = 0;
tv.pathLen = 0;
} else {
tv = new TreeVisit();
}
tv.obj = obj;
tv.buf = reader.open(obj, OBJ_TREE).getCachedBytes();
return tv;
}
示例5: next
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
@Override
RevCommit next() throws MissingObjectException,
IncorrectObjectTypeException, IOException {
for (;;) {
final RevCommit c = source.next();
if (c == null)
return null;
boolean rewrote = false;
final RevCommit[] pList = c.parents;
final int nParents = pList.length;
for (int i = 0; i < nParents; i++) {
final RevCommit oldp = pList[i];
final RevCommit newp = rewrite(oldp);
if (oldp != newp) {
pList[i] = newp;
rewrote = true;
}
}
if (rewrote)
c.parents = cleanup(pList);
return c;
}
}
示例6: testRemoteRepositoryHasNoCommitst
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
@Test(expected = MissingObjectException.class)
public void testRemoteRepositoryHasNoCommitst()
throws URISyntaxException, IOException, InvalidRemoteException, TransportException, GitAPIException, NoRepositorySelected {
gitAccess.setRepository(LOCAL_TEST_REPOSITPRY);
final StoredConfig config = gitAccess.getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(db2.getDirectory().toURI().toURL());
remoteConfig.addURI(uri);
remoteConfig.update(config);
config.save();
gitAccess.add(new FileStatus(GitChangeType.ADD, "test.txt"));
gitAccess.commit("file test added");
// throws missingObjectException
db2.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}");
}
示例7: getRevCommit
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
private RevCommit getRevCommit(RevWalk revWalk, ObjectId objectId)
throws MissingObjectException, IOException {
RevCommit revCommit = null;
RevObject revObject = revWalk.parseAny(objectId);
int type = revObject.getType();
// 'git tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]
// <tagname> [<commit> | <object>]
//
// <commit> | <object>
// The object that the new tag will refer to, usually a commit.
// Defaults to HEAD.
//
if (Constants.OBJ_COMMIT == type) {
revCommit = RevCommit.class.cast(revObject);
}
return revCommit;
}
示例8: buildDirCache
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
private void buildDirCache(TreeWalk walk, DirCacheBuilder builder)
throws MissingObjectException, IncorrectObjectTypeException,
CorruptObjectException, IOException {
while (walk.next()) {
AbstractTreeIterator cIter = walk.getTree(0,
AbstractTreeIterator.class);
if (cIter == null) {
// Not in commit, don't add to new index
continue;
}
final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath());
entry.setFileMode(cIter.getEntryFileMode());
entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset());
DirCacheIterator dcIter = walk.getTree(1, DirCacheIterator.class);
if (dcIter != null && dcIter.idEqual(cIter)) {
DirCacheEntry indexEntry = dcIter.getDirCacheEntry();
entry.setLastModified(indexEntry.getLastModified());
entry.setLength(indexEntry.getLength());
}
builder.add(entry);
}
}
示例9: createAllCommitsRevWalk
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
private RevWalk createAllCommitsRevWalk(CommitSelection commitSelection)
throws IOException, MissingObjectException,
IncorrectObjectTypeException {
RevWalk revWalk = new RevWalk(repository);
RefDatabase refDatabase = repository.getRefDatabase();
Map<String, org.eclipse.jgit.lib.Ref> refs = refDatabase.getRefs("");
for (Entry<String, Ref> entryRef : refs.entrySet()) {
ObjectId refObject = entryRef.getValue().getObjectId();
RevObject revObject = revWalk.parseAny(refObject);
if (revObject instanceof RevCommit) {
revWalk.markStart((RevCommit) revObject);
}
}
revWalk.setRevFilter(new CommitSelectionRevFilter(commitSelection));
revWalk.sort(RevSort.REVERSE);
revWalk.sort(RevSort.TOPO, true);
return revWalk;
}
示例10: findLastCommitInComments
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
/**
* Gets the chronologically-last commit from a set of review comments.
*/
private RevCommit findLastCommitInComments(
Collection<ReviewComment> collection, RevCommit defaultCommit)
throws MissingObjectException, IncorrectObjectTypeException, IOException {
RevCommit lastCommit = defaultCommit;
for (ReviewComment comment : collection) {
if (comment.getLocation() == null || comment.getLocation().getCommit() == null
|| comment.getLocation().getCommit().isEmpty()) {
continue;
}
RevCommit currentCommit = resolveRevCommit(comment.getLocation().getCommit());
if (currentCommit != null && currentCommit.getCommitTime() > lastCommit.getCommitTime()) {
lastCommit = currentCommit;
}
}
return lastCommit;
}
示例11: load
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
private Text load(ObjectId tree, String path)
throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException,
IOException {
if (path == null) {
return Text.EMPTY;
}
final TreeWalk tw = TreeWalk.forPath(repo, path, tree);
if (tw == null) {
return Text.EMPTY;
}
if (tw.getFileMode(0).getObjectType() == Constants.OBJ_BLOB) {
return new Text(repo.open(tw.getObjectId(0), Constants.OBJ_BLOB));
} else if (tw.getFileMode(0).getObjectType() == Constants.OBJ_COMMIT) {
String str = "Subproject commit " + ObjectId.toString(tw.getObjectId(0));
return new Text(str.getBytes(UTF_8));
} else {
return Text.EMPTY;
}
}
示例12: loadCommitData
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
private boolean loadCommitData()
throws OrmException, RepositoryNotFoundException, IOException, MissingObjectException,
IncorrectObjectTypeException {
PatchSet ps = currentPatchSet();
if (ps == null) {
return false;
}
String sha1 = ps.getRevision().get();
try (Repository repo = repoManager.openRepository(project());
RevWalk walk = new RevWalk(repo)) {
RevCommit c = walk.parseCommit(ObjectId.fromString(sha1));
commitMessage = c.getFullMessage();
commitFooters = c.getFooterLines();
author = c.getAuthorIdent();
committer = c.getCommitterIdent();
parentCount = c.getParentCount();
}
return true;
}
示例13: includedIn
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
/** Resolves which tip refs include the target commit. */
private Set<String> includedIn(Collection<RevCommit> tips, int limit)
throws IOException, MissingObjectException, IncorrectObjectTypeException {
Set<String> result = new HashSet<>();
for (RevCommit tip : tips) {
boolean commitFound = false;
rw.resetRetain(RevFlag.UNINTERESTING, containsTarget);
rw.markStart(tip);
for (RevCommit commit : rw) {
if (commit.equals(target) || commit.has(containsTarget)) {
commitFound = true;
tip.add(containsTarget);
result.addAll(commitToRef.get(tip));
break;
}
}
if (!commitFound) {
rw.markUninteresting(tip);
} else if (0 < limit && limit < result.size()) {
break;
}
}
return result;
}
示例14: checkIfCommitIsPresentAtBranch
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
/**
* It checks if the commit is present on branch logs. If not it throws a {@link GitException}
* @param git The git repository
* @param branch The branch where it is going to do the search
* @param startCommitString The commit it needs to find
* @throws {@link GitException} when it cannot find the commit in that branch
*/
private RevCommit checkIfCommitIsPresentAtBranch(final GitImpl git,
final String branch,
final String startCommitString) {
try {
final ObjectId id = git.getRef(branch).getObjectId();
final Spliterator<RevCommit> log = git._log().add(id).call().spliterator();
return stream(log,
false)
.filter((elem) -> elem.getName().equals(startCommitString))
.findFirst().orElseThrow(() -> new GitException("Commit is not present at branch " + branch));
} catch (GitAPIException | MissingObjectException | IncorrectObjectTypeException e) {
throw new GitException("A problem occurred when trying to get commit list",
e);
}
}
示例15: getFirstCommits
import org.eclipse.jgit.errors.MissingObjectException; //导入依赖的package包/类
private List<RevCommit> getFirstCommits(Git git, ObjectId objectId, String path, int length)
throws MissingObjectException, IncorrectObjectTypeException, NoHeadException, GitAPIException {
LogCommand command = git.log();
if (objectId != null) {
command.add(objectId);
}
if (StringUtils.isNotBlank(path)) {
command.addPath(path);
}
Iterator<RevCommit> iterator = command.setMaxCount(length).call().iterator();
List<RevCommit> list = new ArrayList<RevCommit>();
for (int i = 0; i < length; i++) {
if (iterator.hasNext()) {
list.add(iterator.next());
} else {
break;
}
}
return list;
}