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:com.google.gerrit.server.notedb.ChangeNotesCache.java

License:Apache License

Value get(Project.NameKey project, Change.Id changeId, ObjectId metaId, ChangeNotesRevWalk rw)
        throws IOException {
    try {/*w w  w .j a  v a2s  .  co m*/
        Key key = new AutoValue_ChangeNotesCache_Key(project, changeId, metaId.copy());
        Loader loader = new Loader(key, rw);
        ChangeNotesState s = cache.get(key, loader);
        return new AutoValue_ChangeNotesCache_Value(s, loader.revisionNoteMap);
    } catch (ExecutionException e) {
        throw new IOException(String.format("Error loading %s in %s at %s", RefNames.changeMetaRef(changeId),
                project, metaId.name()), e);
    }
}

From source file:com.google.gerrit.server.notedb.NoteDbChangeState.java

License:Apache License

public static String toString(ObjectId changeMetaId, Map<Account.Id, ObjectId> draftIds) {
    List<Account.Id> accountIds = Lists.newArrayList(draftIds.keySet());
    Collections.sort(accountIds, ReviewDbUtil.intKeyOrdering());
    StringBuilder sb = new StringBuilder(changeMetaId.name());
    for (Account.Id id : accountIds) {
        sb.append(',').append(id.get()).append('=').append(draftIds.get(id).name());
    }/* w  w  w. j  a  v  a2s .c o m*/
    return sb.toString();
}

From source file:com.google.gerrit.server.notedb.RepoSequenceTest.java

License:Apache License

@Test
public void failOnInvalidValue() throws Exception {
    ObjectId id = writeBlob("id", "not a number");
    exception.expect(OrmException.class);
    exception.expectMessage("invalid value in refs/sequences/id blob at " + id.name());
    newSequence("id", 1, 3).next();
}

From source file:com.google.gerrit.server.PatchSetUtil.java

License:Apache License

public PatchSet insert(ReviewDb db, RevWalk rw, ChangeUpdate update, PatchSet.Id psId, ObjectId commit,
        boolean draft, List<String> groups, String pushCertificate) throws OrmException, IOException {
    checkNotNull(groups, "groups may not be null");
    ensurePatchSetMatches(psId, update);

    PatchSet ps = new PatchSet(psId);
    ps.setRevision(new RevId(commit.name()));
    ps.setUploader(update.getAccountId());
    ps.setCreatedOn(new Timestamp(update.getWhen().getTime()));
    ps.setDraft(draft);//  w w  w  .  j av a  2  s  .  com
    ps.setGroups(groups);
    ps.setPushCertificate(pushCertificate);
    db.patchSets().insert(Collections.singleton(ps));

    update.setCommit(rw, commit, pushCertificate);
    update.setGroups(groups);
    if (draft) {
        update.setPatchSetState(DRAFT);
    }

    return ps;
}

From source file:com.google.gerrit.server.query.change.InternalChangeQuery.java

License:Apache License

public List<ChangeData> byCommit(ObjectId id) throws OrmException {
    return query(commit(schema(indexes), id.name()));
}

From source file:com.google.gerrit.server.schema.Schema_106.java

License:Apache License

@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
    if (!(repoManager instanceof LocalDiskRepositoryManager)) {
        return;//from  w w  w  .  java 2s .c  om
    }

    ui.message("listing all repositories ...");
    SortedSet<Project.NameKey> repoList = repoManager.list();
    ui.message("done");

    ui.message(String.format("creating reflog files for %s branches ...", RefNames.REFS_CONFIG));
    for (Project.NameKey project : repoList) {
        try (Repository repo = repoManager.openRepository(project)) {
            File metaConfigLog = new File(repo.getDirectory(), "logs/" + RefNames.REFS_CONFIG);
            if (metaConfigLog.exists()) {
                continue;
            }

            if (!metaConfigLog.getParentFile().mkdirs() || !metaConfigLog.createNewFile()) {
                throw new IOException(String.format("Failed to create reflog for %s in repository %s",
                        RefNames.REFS_CONFIG, project));
            }

            ObjectId metaConfigId = repo.resolve(RefNames.REFS_CONFIG);
            if (metaConfigId != null) {
                try (PrintWriter writer = new PrintWriter(metaConfigLog, UTF_8.name())) {
                    writer.print(ObjectId.zeroId().name());
                    writer.print(" ");
                    writer.print(metaConfigId.name());
                    writer.print(" ");
                    writer.print(serverUser.toExternalString());
                    writer.print("\t");
                    writer.print("create reflog");
                    writer.println();
                }
            }
        } catch (IOException e) {
            ui.message(
                    String.format("ERROR: Failed to create reflog file for the" + " %s branch in repository %s",
                            RefNames.REFS_CONFIG, project.get()));
        }
    }
    ui.message("done");
}

From source file:com.google.gerrit.testutil.TestChanges.java

License:Apache License

public static PatchSet newPatchSet(PatchSet.Id id, ObjectId revision, Account.Id userId) {
    return newPatchSet(id, revision.name(), userId);
}

From source file:com.google.gitiles.LogServlet.java

License:Open Source License

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
    GitilesView view = ViewFilter.getView(req);
    Repository repo = ServletUtils.getRepository(req);
    RevWalk walk = null;//from w  w  w . j  av  a2  s.  c o m
    try {
        try {
            walk = newWalk(repo, view);
        } catch (IncorrectObjectTypeException e) {
            res.setStatus(SC_NOT_FOUND);
            return;
        }

        Optional<ObjectId> start = getStart(view.getParameters(), walk.getObjectReader());
        if (start == null) {
            res.setStatus(SC_NOT_FOUND);
            return;
        }

        Map<String, Object> data = Maps.newHashMapWithExpectedSize(5);

        if (!view.getRevision().nameIsId()) {
            List<Map<String, Object>> tags = Lists.newArrayListWithExpectedSize(1);
            for (RevObject o : RevisionServlet.listObjects(walk, view.getRevision().getId())) {
                if (o instanceof RevTag) {
                    tags.add(new TagSoyData(linkifier, req).toSoyData((RevTag) o));
                }
            }
            if (!tags.isEmpty()) {
                data.put("tags", tags);
            }
        }

        Paginator paginator = new Paginator(walk, limit, start.orNull());
        Map<AnyObjectId, Set<Ref>> refsById = repo.getAllRefsByPeeledObjectId();
        List<Map<String, Object>> entries = Lists.newArrayListWithCapacity(limit);
        for (RevCommit c : paginator) {
            entries.add(new CommitSoyData(null, req, repo, walk, view, refsById).toSoyData(c, KeySet.SHORTLOG));
        }

        String title = "Log - ";
        if (view.getOldRevision() != Revision.NULL) {
            title += view.getRevisionRange();
        } else {
            title += view.getRevision().getName();
        }

        data.put("title", title);
        data.put("entries", entries);
        ObjectId next = paginator.getNextStart();
        if (next != null) {
            data.put("nextUrl", copyAndCanonicalize(view).replaceParam(START_PARAM, next.name()).toUrl());
        }
        ObjectId prev = paginator.getPreviousStart();
        if (prev != null) {
            GitilesView.Builder prevView = copyAndCanonicalize(view);
            if (!prevView.getRevision().getId().equals(prev)) {
                prevView.replaceParam(START_PARAM, prev.name());
            }
            data.put("previousUrl", prevView.toUrl());
        }

        render(req, res, "gitiles.logDetail", data);
    } catch (RevWalkException e) {
        log.warn("Error in rev walk", e);
        res.setStatus(SC_INTERNAL_SERVER_ERROR);
        return;
    } finally {
        if (walk != null) {
            walk.release();
        }
    }
}

From source file:com.google.gitiles.LogSoyData.java

License:Open Source License

private Map<String, Object> toHeaderSoyData(Paginator paginator, @Nullable String revision) {
    Map<String, Object> data = Maps.newHashMapWithExpectedSize(5);
    data.put("logEntryPretty", pretty);
    ObjectId prev = paginator.getPreviousStart();
    if (prev != null) {
        GitilesView.Builder prevView = copyAndCanonicalizeView(revision);
        if (!prevView.getRevision().getId().equals(prev)) {
            prevView.replaceParam(LogServlet.START_PARAM, prev.name());
        }//from   ww  w. j  av a2  s . c  o m
        data.put("previousUrl", prevView.toUrl());
    }
    return data;
}

From source file:com.google.gitiles.LogSoyData.java

License:Open Source License

private Map<String, Object> toFooterSoyData(Paginator paginator, @Nullable String revision) {
    Map<String, Object> data = Maps.newHashMapWithExpectedSize(1);
    ObjectId next = paginator.getNextStart();
    if (next != null) {
        data.put("nextUrl",
                copyAndCanonicalizeView(revision).replaceParam(LogServlet.START_PARAM, next.name()).toUrl());
    }/*w w w .  jav a 2  s.  com*/
    return data;
}