Example usage for org.eclipse.jgit.lib ObjectId name

List of usage examples for org.eclipse.jgit.lib ObjectId name

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib ObjectId name.

Prototype

public final String name() 

Source Link

Document

name.

Usage

From source file:fr.brouillard.oss.jgitver.strategy.maven.defaults.Scenario8WithDefaultsTest.java

License:Apache License

@Test
public void version_of_D_commit() {
    ObjectId dCommit = scenario.getCommits().get("D");

    // checkout the commit in scenario
    unchecked(() -> git.checkout().setName(dCommit.name()).call());
    assertThat(versionCalculator.getVersion(), is("1.1.0-SNAPSHOT"));
}

From source file:fr.brouillard.oss.jgitver.strategy.maven.defaults.Scenario8WithDefaultsTest.java

License:Apache License

@Test
public void version_of_E_commit() {
    ObjectId eCommit = scenario.getCommits().get("E");

    // checkout the commit in scenario
    unchecked(() -> git.checkout().setName(eCommit.name()).call());
    assertThat(versionCalculator.getVersion(), is("1.1.0-SNAPSHOT"));
}

From source file:fr.brouillard.oss.jgitver.strategy.maven.others.Scenario6WithSpecificFindTagPatternTest.java

License:Apache License

@Test
public void version_of_B_commit() {
    ObjectId bCommit = scenario.getCommits().get("B");

    // checkout the commit in scenario
    unchecked(() -> git.checkout().setName(bCommit.name()).call());
    assertThat(versionCalculator.getVersion(), is("0.0.0-SNAPSHOT"));
}

From source file:fr.brouillard.oss.jgitver.strategy.maven.others.Scenario6WithSpecificFindTagPatternTest.java

License:Apache License

@Test
public void version_of_C_commit() {
    ObjectId cCommit = scenario.getCommits().get("C");

    // checkout the commit in scenario
    unchecked(() -> git.checkout().setName(cCommit.name()).call());
    assertThat(versionCalculator.getVersion(), is("3.0.0"));
}

From source file:fr.brouillard.oss.jgitver.strategy.maven.others.Scenario6WithSpecificFindTagPatternTest.java

License:Apache License

@Test
public void version_of_D_commit() {
    ObjectId dCommit = scenario.getCommits().get("D");

    // checkout the commit in scenario
    unchecked(() -> git.checkout().setName(dCommit.name()).call());
    assertThat(versionCalculator.getVersion(), is("3.0.1-SNAPSHOT"));
}

From source file:fr.brouillard.oss.jgitver.strategy.maven.others.Scenario6WithSpecificFindTagPatternTest.java

License:Apache License

@Test
public void version_of_E_commit() {
    ObjectId eCommit = scenario.getCommits().get("E");

    // checkout the commit in scenario
    unchecked(() -> git.checkout().setName(eCommit.name()).call());
    assertThat(versionCalculator.getVersion(), is("3.0.1-SNAPSHOT"));
}

From source file:hudson.plugins.git.AbstractGitProject.java

License:Open Source License

protected String getHeadRevision(AbstractBuild build, final String branch)
        throws IOException, InterruptedException {
    return build.getWorkspace().act(new FilePath.FileCallable<String>() {
        public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
            try {
                ObjectId oid = Git.with(null, null).in(f).getClient().getRepository()
                        .resolve("refs/heads/" + branch);
                return oid.name();
            } catch (GitException e) {
                throw new RuntimeException(e);
            }/* w w  w .  java 2 s.c  o  m*/
        }
    });
}

From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java

License:Eclipse Distribution License

private void queueWants(final Collection<Ref> want) throws TransportException {
    final HashSet<ObjectId> inWorkQueue = new HashSet<ObjectId>();
    for (final Ref r : want) {
        final ObjectId id = r.getObjectId();
        try {//w w w  . j  a v a 2 s.co m
            final RevObject obj = revWalk.parseAny(id);
            if (obj.has(COMPLETE))
                continue;
            if (inWorkQueue.add(id)) {
                obj.add(IN_WORK_QUEUE);
                workQueue.add(obj);
            }
        } catch (MissingObjectException e) {
            if (inWorkQueue.add(id))
                workQueue.add(id);
        } catch (IOException e) {
            throw new TransportException(MessageFormat.format(JGitText.get().cannotRead, id.name()), e);
        }
    }
}

From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java

License:Eclipse Distribution License

private void process(final ObjectId id) throws TransportException {
    final RevObject obj;
    try {/*from   w  ww.  j  ava2s. com*/
        if (id instanceof RevObject) {
            obj = (RevObject) id;
            if (obj.has(COMPLETE))
                return;
            revWalk.parseHeaders(obj);
        } else {
            obj = revWalk.parseAny(id);
            if (obj.has(COMPLETE))
                return;
        }
    } catch (IOException e) {
        throw new TransportException(MessageFormat.format(JGitText.get().cannotRead, id.name()), e);
    }

    switch (obj.getType()) {
    case Constants.OBJ_BLOB:
        processBlob(obj);
        break;
    case Constants.OBJ_TREE:
        processTree(obj);
        break;
    case Constants.OBJ_COMMIT:
        processCommit(obj);
        break;
    case Constants.OBJ_TAG:
        processTag(obj);
        break;
    default:
        throw new TransportException(MessageFormat.format(JGitText.get().unknownObjectType, id.name()));
    }

    // If we had any prior errors fetching this object they are
    // now resolved, as the object was parsed successfully.
    //
    fetchErrors.remove(id);
}

From source file:it.com.atlassian.labs.speakeasy.util.jgit.WalkFetchConnection.java

License:Eclipse Distribution License

private void verifyAndInsertLooseObject(final AnyObjectId id, final byte[] compressed) throws IOException {
    final ObjectLoader uol;
    try {/*from  w w w . ja va2s.co m*/
        uol = UnpackedObject.parse(compressed, id);
    } catch (CorruptObjectException parsingError) {
        // Some HTTP servers send back a "200 OK" status with an HTML
        // page that explains the requested file could not be found.
        // These servers are most certainly misconfigured, but many
        // of them exist in the world, and many of those are hosting
        // Git repositories.
        //
        // Since an HTML page is unlikely to hash to one of our loose
        // objects we treat this condition as a FileNotFoundException
        // and attempt to recover by getting the object from another
        // source.
        //
        final FileNotFoundException e;
        e = new FileNotFoundException(id.name());
        e.initCause(parsingError);
        throw e;
    }

    final int type = uol.getType();
    final byte[] raw = uol.getCachedBytes();
    if (objCheck != null) {
        try {
            objCheck.check(type, raw);
        } catch (CorruptObjectException e) {
            throw new TransportException(MessageFormat.format(JGitText.get().transportExceptionInvalid,
                    Constants.typeString(type), id.name(), e.getMessage()));
        }
    }

    ObjectId act = inserter.insert(type, raw);
    if (!AnyObjectId.equals(id, act)) {
        throw new TransportException(MessageFormat.format(JGitText.get().incorrectHashFor, id.name(),
                act.name(), Constants.typeString(type), compressed.length));
    }
    inserter.flush();
}