Examples of AbbreviatedObjectId


Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

        RevCommit head = this.createCommit();
        RevCommit head_1 = this.createCommit();
        RevCommit head_2 = this.createCommit();
        head.getParents()[0] = head_1;
        head_1.getParents()[0] = head_2;
        AbbreviatedObjectId abbrevId = head.abbreviate(7);
        this.repository.headObject = mock(ObjectId.class);
        this.repository.commitCache.put(this.repository.headObject, head);

        this.repository.revWalk = mock(RevWalk.class);
        RevFlag seenFlag = RevFlag.UNINTERESTING;
        when(this.repository.revWalk.newFlag("SEEN")).thenReturn(seenFlag);

        when(this.repo.getObjectDatabase().newReader().abbreviate(head)).thenReturn(abbrevId);

        GitTagDescription description = this.repository.describe();
        assertThat(head.has(seenFlag), is(true));
        assertThat(head_1.has(seenFlag), is(true));
        assertThat(head_2.has(seenFlag), is(true));
        assertThat(description.getNextTagName(), is(equalTo("")));
        assertThat(description.toString(), is(equalTo(abbrevId.name())));
    }
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

    }

    @Test
    public void testGetAbbreviatedCommitId() throws Exception {
        RevCommit rawCommit = this.createCommit();
        AbbreviatedObjectId abbrevId = rawCommit.abbreviate(7);
        JGitCommit commit = new JGitCommit(rawCommit);

        when(this.repo.getObjectDatabase().newReader().abbreviate(rawCommit)).thenReturn(abbrevId);

        assertThat(this.repository.getAbbreviatedCommitId(commit), is(equalTo(rawCommit.getName().substring(0, 7))));
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

      return EMPTY;

    if (isBinary())
      return BINARY;

    AbbreviatedObjectId id = entry.getId(side);
    if (!id.isComplete()) {
      Collection<ObjectId> ids = reader.resolve(id);
      if (ids.size() == 1) {
        id = AbbreviatedObjectId.fromObjectId(ids.iterator().next());
        switch (side) {
        case OLD:
          entry.oldId = id;
          break;
        case NEW:
          entry.newId = id;
          break;
        }
      } else if (ids.size() == 0)
        throw new MissingObjectException(id, Constants.OBJ_BLOB);
      else
        throw new AmbiguousObjectException(id, ids);
    }

    try {
      ObjectLoader ldr = source.open(side, entry);
      return ldr.getBytes(binaryFileThreshold);

    } catch (LargeObjectException.ExceedsLimit overLimit) {
      return BINARY;

    } catch (LargeObjectException.ExceedsByteArrayLimit overLimit) {
      return BINARY;

    } catch (LargeObjectException.OutOfMemory tooBig) {
      return BINARY;

    } catch (LargeObjectException tooBig) {
      tooBig.setObjectId(id.toObjectId());
      throw tooBig;
    }
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

      ((ThreeWayMerger) m).setBase(baseId);
    if (!m.merge(oursId, theirsId))
      throw new NotesMergeConflictException(baseList, oursList,
          theirsList);
    ObjectId resultTreeId = m.getResultTreeId();
    AbbreviatedObjectId none = AbbreviatedObjectId.fromString("");
    return NoteParser.parse(none, resultTreeId, reader).nonNotes;
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

    }
    return result;
  }

  private String getAbbreviatedId(GitModelCommit commit) {
    AbbreviatedObjectId shortId = commit.getCachedCommitObj().getId();

    return shortId.name().substring(0, 6);
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

      if (headId != null)
        headCommit = new RevWalk(repo).parseCommit(headId);
      else
        headCommit = null;

      AbbreviatedObjectId commitId;
      if (headCommit != null) {
        tw.addTree(headCommit.getTree());
        commitId = AbbreviatedObjectId.fromObjectId(headCommit);
      } else {
        tw.addTree(new EmptyTreeIterator());
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

      tw.setFilter(ANY_DIFF);
    else
      tw.setFilter(AndTreeFilter.create(ANY_DIFF, pathFilter));

    final Map<String, Change> result = new HashMap<String, GitCommitsModelCache.Change>();
    final AbbreviatedObjectId commitId = getAbbreviatedObjectId(commit);
    final AbbreviatedObjectId parentCommitId = getAbbreviatedObjectId(parentCommit);

    MutableObjectId idBuf = new MutableObjectId();
    while (tw.next()) {
      Change change = new Change();
      change.commitId = commitId;
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

      if (!(modelCommit.getParent() instanceof GitModelRepository))
        return null; // should never happen

      GitModelRepository parent = (GitModelRepository) modelCommit.getParent();
      Repository repo = parent.getRepository();
      AbbreviatedObjectId id = modelCommit.getCachedCommitObj().getId();

      commit = new RevWalk(repo).lookupCommit(id.toObjectId());
    }
    return commit;
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

      // 0 means we don't want to print commit id's at all
      return Optional.absent();
    }

    try {
      AbbreviatedObjectId abbreviatedObjectId = objectReader.abbreviate(commitId, requestedLenght);
      return Optional.of(abbreviatedObjectId);
    } catch (IOException e) {
      return Optional.absent();
    }
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.AbbreviatedObjectId

      return EMPTY;

    if (isBinary())
      return BINARY;

    AbbreviatedObjectId id = entry.getId(side);
    if (!id.isComplete()) {
      Collection<ObjectId> ids = reader.resolve(id);
      if (ids.size() == 1) {
        id = AbbreviatedObjectId.fromObjectId(ids.iterator().next());
        switch (side) {
        case OLD:
          entry.oldId = id;
          break;
        case NEW:
          entry.newId = id;
          break;
        }
      } else if (ids.size() == 0)
        throw new MissingObjectException(id, Constants.OBJ_BLOB);
      else
        throw new AmbiguousObjectException(id, ids);
    }

    try {
      ObjectLoader ldr = source.open(side, entry);
      return ldr.getBytes(binaryFileThreshold);

    } catch (LargeObjectException.ExceedsLimit overLimit) {
      return BINARY;

    } catch (LargeObjectException.ExceedsByteArrayLimit overLimit) {
      return BINARY;

    } catch (LargeObjectException.OutOfMemory tooBig) {
      return BINARY;

    } catch (LargeObjectException tooBig) {
      tooBig.setObjectId(id.toObjectId());
      throw tooBig;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.