Example usage for org.eclipse.jgit.lib Constants OBJ_COMMIT

List of usage examples for org.eclipse.jgit.lib Constants OBJ_COMMIT

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants OBJ_COMMIT.

Prototype

int OBJ_COMMIT

To view the source code for org.eclipse.jgit.lib Constants OBJ_COMMIT.

Click Source Link

Document

In-pack object type: commit.

Usage

From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java

License:Apache License

public static String asObjectType(int objectType) {
    switch (objectType) {
    case Constants.OBJ_BAD:
        return "BAD";
    case Constants.OBJ_BLOB:
        return "BLOB";
    case Constants.OBJ_COMMIT:
        return "COMMIT";
    case Constants.OBJ_EXT:
        return "EXT(future)";
    case Constants.OBJ_OFS_DELTA:
        return "OFS_DELTA(offset_delta)";
    case Constants.OBJ_REF_DELTA:
        return "REF_DELTA(reference_delta)";
    case Constants.OBJ_TAG:
        return "TAG";
    case Constants.OBJ_TREE:
        return "TREE";
    case Constants.OBJ_TYPE_5:
        return "TYPE_S(future)";
    default:/*  ww  w.  ja va 2 s  . com*/
        return "[" + objectType + "]";
    }
}

From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java

License:Apache License

public static String getObjectName(Repository repo, ObjectId objectId) {
    try {// w  ww.  j  a  v a2s.co m
        ObjectLoader loader = repo.open(objectId);
        StringBuilder ret = new StringBuilder();

        if (loader.isLarge()) {
            ret.append("LARGE! ");
        }

        switch (loader.getType()) {
        case Constants.OBJ_BAD:
            ret.append("BAD ");
            break;
        case Constants.OBJ_BLOB:
            ret.append("BLOB ");
            break;
        case Constants.OBJ_COMMIT:
            ret.append("COMMIT ");
            break;
        case Constants.OBJ_EXT:
            ret.append("EXT ");
            break;
        case Constants.OBJ_OFS_DELTA:
            ret.append("OFS_DELTA ");
            break;
        case Constants.OBJ_REF_DELTA:
            ret.append("REF_DELTA ");
            break;
        case Constants.OBJ_TAG:
            ret.append("TAG ");
            break;
        case Constants.OBJ_TREE:
            ret.append("TREE ");
            break;
        case Constants.OBJ_TYPE_5:
            ret.append("TYPE_5 ");
            break;
        default:
            ret.append("UNKNOWN[").append(loader.getType()).append("] ");
            break;
        }

        ret.append(String.format("Size=%,d", loader.getSize()));
        return ret.toString();
    } catch (MissingObjectException e) {
        LOG.log(Level.WARNING, "Unable to open objectId: " + objectId, e);
        return "<missing object>";
    } catch (IOException e) {
        LOG.log(Level.WARNING, "Unable to open objectId: " + objectId, e);
        return "<unable to open object>";
    }
}

From source file:org.eclipse.egit.core.test.op.TagOperationTest.java

License:Open Source License

@Test
public void addTag() throws Exception {
    assertTrue("Tags should be empty", repository1.getRepository().getTags().isEmpty());
    TagBuilder newTag = new TagBuilder();
    newTag.setTag("TheNewTag");
    newTag.setMessage("Well, I'm the tag");
    newTag.setTagger(RawParseUtils.parsePersonIdent(TestUtils.AUTHOR));
    newTag.setObjectId(repository1.getRepository().resolve("refs/heads/master"), Constants.OBJ_COMMIT);
    TagOperation top = new TagOperation(repository1.getRepository(), newTag, false);
    top.execute(new NullProgressMonitor());
    assertFalse("Tags should not be empty", repository1.getRepository().getTags().isEmpty());

    try {/* ww w . j  a va  2s.c o m*/
        top.execute(null);
        fail("Expected Exception not thrown");
    } catch (CoreException e) {
        // expected
    }

    top = new TagOperation(repository1.getRepository(), newTag, true);
    try {
        top.execute(null);
        fail("Expected Exception not thrown");
    } catch (CoreException e) {
        // expected
    }
    Ref tagRef = repository1.getRepository().getTags().get("TheNewTag");
    RevWalk walk = new RevWalk(repository1.getRepository());
    RevTag tag = walk.parseTag(repository1.getRepository().resolve(tagRef.getName()));

    newTag.setMessage("Another message");
    assertFalse("Messages should differ", tag.getFullMessage().equals(newTag.getMessage()));
    top.execute(null);
    tag = walk.parseTag(repository1.getRepository().resolve(tagRef.getName()));
    assertTrue("Messages be same", tag.getFullMessage().equals(newTag.getMessage()));
}

From source file:org.eclipse.egit.ui.internal.components.RefContentProposal.java

License:Open Source License

public String getDescription() {
    if (objectId == null)
        return null;
    ObjectReader reader = db.newObjectReader();
    try {//from w w w. j  a  va  2s  .  c  om
        final ObjectLoader loader = reader.open(objectId);
        final StringBuilder sb = new StringBuilder();
        sb.append(refName);
        sb.append('\n');
        sb.append(reader.abbreviate(objectId).name());
        sb.append(" - "); //$NON-NLS-1$

        switch (loader.getType()) {
        case Constants.OBJ_COMMIT:
            RevCommit c = new RevWalk(db).parseCommit(objectId);
            appendObjectSummary(sb, UIText.RefContentProposal_commit, c.getAuthorIdent(), c.getFullMessage());
            break;
        case Constants.OBJ_TAG:
            RevWalk walk = new RevWalk(db);
            RevTag t = walk.parseTag(objectId);
            appendObjectSummary(sb, UIText.RefContentProposal_tag, t.getTaggerIdent(), t.getFullMessage());
            break;
        case Constants.OBJ_TREE:
            sb.append(UIText.RefContentProposal_tree);
            break;
        case Constants.OBJ_BLOB:
            sb.append(UIText.RefContentProposal_blob);
            break;
        default:
            sb.append(UIText.RefContentProposal_unknownObject);
        }
        return sb.toString();
    } catch (IOException e) {
        Activator.logError(NLS.bind(UIText.RefContentProposal_errorReadingObject, objectId), e);
        return null;
    } finally {
        reader.release();
    }
}

From source file:org.eclipse.egit.ui.test.team.actions.BranchAndResetActionTest.java

License:Open Source License

@BeforeClass
public static void setup() throws Exception {
    repositoryFile = createProjectAndCommitToRepository();
    Repository repo = lookupRepository(repositoryFile);
    perspective = bot.activePerspective();
    bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate();

    TagBuilder tag = new TagBuilder();
    tag.setTag("SomeTag");
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm just a little tag");
    tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);/*from  w  w  w.  j  a  v a 2 s  . com*/
    touchAndSubmit(null);

    RepositoriesViewLabelProvider provider = new RepositoriesViewLabelProvider();
    LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(null, repo), repo));
    TAGS = provider.getText(new TagsNode(new RepositoryNode(null, repo), repo));
    waitInUI();
}

From source file:org.eclipse.egit.ui.test.team.actions.CommitActionTest.java

License:Open Source License

@BeforeClass
public static void setup() throws Exception {
    repositoryFile = createProjectAndCommitToRepository();
    Repository repo = lookupRepository(repositoryFile);
    // TODO delete the second project for the time being (.gitignore is
    // currently not hiding the .project file from commit)
    ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ2).delete(false, null);

    TagBuilder tag = new TagBuilder();
    tag.setTag("SomeTag");
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm just a little tag");
    tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);/* w w w.  ja  va2s . co  m*/
    touchAndSubmit(null);

    perspective = bot.activePerspective();
    bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate();
    waitInUI();
}

From source file:org.eclipse.egit.ui.test.team.actions.CompareActionsTest.java

License:Open Source License

@BeforeClass
public static void setup() throws Exception {
    repositoryFile = createProjectAndCommitToRepository();
    Repository repo = lookupRepository(repositoryFile);
    perspective = bot.activePerspective();
    bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate();

    TagBuilder tag = new TagBuilder();
    tag.setTag("SomeTag");
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm just a little tag");
    tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
    commitOfTag = tag.getObjectId();//www.  j a  v a  2  s.com
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);
    touchAndSubmit(null);

    RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils.createLabelProvider();
    // LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(
    // null, repo), repo));
    TAGS = provider.getText(new TagsNode(new RepositoryNode(null, repo), repo));
    waitInUI();
}

From source file:org.eclipse.egit.ui.test.team.actions.CreatePatchActionTest.java

License:Open Source License

@BeforeClass
public static void setup() throws Exception {
    perspective = bot.activePerspective();
    bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate();
    File gitDir = createProjectAndCommitToRepository();
    repo = new FileRepository(gitDir);

    IFile[] commitables = getAllFiles();
    ArrayList<IFile> untracked = new ArrayList<IFile>();
    untracked.addAll(Arrays.asList(commitables));
    CommitOperation cop = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR,
            TestUtil.TESTCOMMITTER, "Initial commit");
    cop.setAmending(true);//from  w  ww. j  a v a2  s.c  o m
    cop.execute(null);

    TagBuilder tag = new TagBuilder();
    tag.setTag(TAG_NAME);
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm a savepoint");
    tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);

    waitInUI();
}

From source file:org.eclipse.egit.ui.test.team.actions.ReplaceActionsTest.java

License:Open Source License

@BeforeClass
public static void setup() throws Exception {
    repositoryFile = createProjectAndCommitToRepository();
    Repository repo = lookupRepository(repositoryFile);
    perspective = bot.activePerspective();
    bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate();

    TagBuilder tag = new TagBuilder();
    tag.setTag("SomeTag");
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm just a little tag");
    tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
    commitOfTag = tag.getObjectId();/*from w w  w  .  j  a  v  a2s. c om*/
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);
    touchAndSubmit(null);
    waitInUI();
}

From source file:org.eclipse.egit.ui.test.team.actions.TagActionTest.java

License:Open Source License

@BeforeClass
public static void setup() throws Exception {
    perspective = bot.activePerspective();
    bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate();

    repositoryFile = createProjectAndCommitToRepository();
    Repository repo = lookupRepository(repositoryFile);

    TagBuilder tag = new TagBuilder();
    tag.setTag("SomeTag");
    tag.setTagger(RawParseUtils.parsePersonIdent(TestUtil.TESTAUTHOR));
    tag.setMessage("I'm just a little tag");
    tag.setObjectId(repo.resolve(repo.getFullBranch()), Constants.OBJ_COMMIT);
    TagOperation top = new TagOperation(repo, tag, false);
    top.execute(null);//  w ww .  j  av  a2s  .c  om
    touchAndSubmit(null);
    waitInUI();
}