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

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

Introduction

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

Prototype

public static ObjectId fromString(String str) 

Source Link

Document

Convert an ObjectId from hex characters.

Usage

From source file:com.google.gerrit.acceptance.git.GitUtil.java

License:Apache License

public static Commit amendCommit(Git git, PersonIdent i, String msg, String changeId)
        throws GitAPIException, IOException {
    msg = ChangeIdUtil.insertId(msg, ObjectId.fromString(changeId.substring(1)));
    return createCommit(git, i, msg, changeId);
}

From source file:com.google.gerrit.acceptance.git.GitUtil.java

License:Apache License

private static Commit createCommit(Git git, PersonIdent i, String msg, String changeId)
        throws GitAPIException, IOException {

    final CommitCommand commitCmd = git.commit();
    commitCmd.setAmend(changeId != null);
    commitCmd.setAuthor(i);/*from   www  .  j av a2  s .c  om*/
    commitCmd.setCommitter(i);

    if (changeId == null) {
        ObjectId id = computeChangeId(git, i, msg);
        changeId = "I" + id.getName();
    }
    msg = ChangeIdUtil.insertId(msg, ObjectId.fromString(changeId.substring(1)));
    commitCmd.setMessage(msg);

    RevCommit c = commitCmd.call();
    return new Commit(c, changeId);
}

From source file:com.google.gerrit.acceptance.git.RefAdvertisementIT.java

License:Apache License

private static ObjectId obj(ChangeData cd, int psNum) throws Exception {
    PatchSet.Id psId = new PatchSet.Id(cd.getId(), psNum);
    PatchSet ps = cd.patchSet(psId);/*  w  w  w . j a  v a2s  . c  om*/
    assertWithMessage("%s not found in %s", psId, cd.patchSets()).that(ps).isNotNull();
    return ObjectId.fromString(ps.getRevision().get());
}

From source file:com.google.gerrit.acceptance.rest.change.SubmitByRebaseAlwaysIT.java

License:Apache License

private RevCommit getCurrentCommit(PushOneCommit.Result change) throws Exception {
    testRepo.git().fetch().setRemote("origin").call();
    ChangeInfo info = get(change.getChangeId());
    RevCommit c = testRepo.getRevWalk().parseCommit(ObjectId.fromString(info.currentRevision));
    testRepo.getRevWalk().parseBody(c);/*  w  w w  .  j  av a 2s  . c  o  m*/
    return c;
}

From source file:com.google.gerrit.acceptance.rest.project.GetCommitIT.java

License:Apache License

@Test
public void getNonExistingCommit_NotFound() throws Exception {
    assertNotFound(ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
}

From source file:com.google.gerrit.acceptance.server.change.ConsistencyCheckerIT.java

License:Apache License

@Test
public void patchSetObjectAndRefMissing() throws Exception {
    Change c = insertChange();/*from   ww w  . jav  a2 s .c  om*/
    PatchSet ps = newPatchSet(c.currentPatchSetId(),
            ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), adminId);
    db.patchSets().insert(singleton(ps));

    assertProblems(c, "Ref missing: " + ps.getId().toRefName(),
            "Object missing: patch set 1: deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
}

From source file:com.google.gerrit.acceptance.server.change.ConsistencyCheckerIT.java

License:Apache License

@Test
public void patchSetObjectAndRefMissingWithFix() throws Exception {
    Change c = insertChange();/*from w  w  w  . j a  v a  2  s.co  m*/
    PatchSet ps = newPatchSet(c.currentPatchSetId(),
            ObjectId.fromString("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), adminId);
    db.patchSets().insert(singleton(ps));

    String refName = ps.getId().toRefName();
    List<ProblemInfo> problems = checker.check(c, new FixInput()).problems();
    ProblemInfo p = problems.get(0);
    assertThat(p.message).isEqualTo("Ref missing: " + refName);
    assertThat(p.status).isNull();
}

From source file:com.google.gerrit.acceptance.server.change.ConsistencyCheckerIT.java

License:Apache License

@Test
public void patchSetRefMissing() throws Exception {
    Change c = insertChange();/*  ww w. j  ava  2 s  . c  o m*/
    PatchSet ps = insertPatchSet(c);
    String refName = ps.getId().toRefName();
    testRepo.update("refs/other/foo", ObjectId.fromString(ps.getRevision().get()));
    deleteRef(refName);

    assertProblems(c, "Ref missing: " + refName);
}

From source file:com.google.gerrit.acceptance.server.change.ConsistencyCheckerIT.java

License:Apache License

@Test
public void patchSetRefMissingWithFix() throws Exception {
    Change c = insertChange();/*from   w w  w .  j  av a 2  s.c  o  m*/
    PatchSet ps = insertPatchSet(c);
    String refName = ps.getId().toRefName();
    testRepo.update("refs/other/foo", ObjectId.fromString(ps.getRevision().get()));
    deleteRef(refName);

    List<ProblemInfo> problems = checker.check(c, new FixInput()).problems();
    ProblemInfo p = problems.get(0);
    assertThat(p.message).isEqualTo("Ref missing: " + refName);
    assertThat(p.status).isEqualTo(ProblemInfo.Status.FIXED);
    assertThat(p.outcome).isEqualTo("Repaired patch set ref");

    assertThat(testRepo.getRepository().getRef(refName).getObjectId().name()).isEqualTo(ps.getRevision().get());
}

From source file:com.google.gerrit.acceptance.server.change.ConsistencyCheckerIT.java

License:Apache License

private PatchSet insertMissingPatchSet(Change c, String id) throws Exception {
    PatchSet ps = newPatchSet(c.currentPatchSetId(), ObjectId.fromString(id), adminId);
    db.patchSets().insert(singleton(ps));
    return ps;//from  w w  w . j  av a2 s .  co m
}