Example usage for org.eclipse.jgit.api Git notesList

List of usage examples for org.eclipse.jgit.api Git notesList

Introduction

In this page you can find the example usage for org.eclipse.jgit.api Git notesList.

Prototype

public ListNotesCommand notesList() 

Source Link

Document

Return a command to list all notes

Usage

From source file:com.chungkwong.jgitgui.NoteListTreeItem.java

License:Open Source License

public NoteListTreeItem(Git git) throws GitAPIException {
    super(java.util.ResourceBundle.getBundle("com/chungkwong/jgitgui/text").getString("NOTE"));
    for (Note note : git.notesList().call())
        getChildren().add(new NoteTreeItem(note));
}

From source file:com.google.appraise.eclipse.core.client.git.AppraiseGitReviewClient.java

License:Open Source License

/**
 * Retrieves all the reviews in the current project's repository by commit hash.
 *///from  w  w w  . j  ava2  s .c o m
public Map<String, Review> listReviews() throws GitClientException {
    // Get the most up-to-date list of reviews.
    syncCommentsAndReviews();

    Map<String, Review> reviews = new LinkedHashMap<>();

    Git git = new Git(repo);
    try {
        ListNotesCommand cmd = git.notesList();
        cmd.setNotesRef(REVIEWS_REF);
        List<Note> notes = cmd.call();
        for (Note note : notes) {
            String rawNoteDataStr = noteToString(repo, note);
            Review latest = extractLatestReviewFromNotes(rawNoteDataStr);
            if (latest != null) {
                reviews.put(note.getName(), latest);
            }
        }
    } catch (Exception e) {
        throw new GitClientException(e);
    } finally {
        git.close();
    }
    return reviews;
}

From source file:com.maiereni.sling.sources.git.GitProjectDownloader.java

License:Apache License

private void update(final Git git) throws Exception {
    logger.debug("Fetch from remote");
    FetchResult fr = git.fetch().call(); // .setRemote(url)
    Collection<Ref> refs = fr.getAdvertisedRefs();
    Iterable<RevCommit> logs = git.log().call();
    for (RevCommit rev : logs) {
        PersonIdent authorIdent = rev.getAuthorIdent();
        Date date = authorIdent.getWhen();
        String authName = authorIdent.getName();
        logger.debug("Commit at " + SDF.format(date) + " by " + authName + ": " + rev.getId().name() + " text: "
                + rev.getShortMessage());
    }//w  ww  . j a v  a  2  s.co m
    List<Note> notes = git.notesList().call();
    for (Ref ref : refs) {
        if (ref.getName().equals("HEAD")) {
            git.rebase().setUpstream(ref.getObjectId()).call();
            logger.debug("Rebase on HEAD");
            for (Note note : notes) {
                if (note.getName().equals(ref.getObjectId().getName())) {
                    logger.debug("Found note: " + note + " for commit " + ref.getName());
                    // displaying the contents of the note is done via a simple blob-read
                    ObjectLoader loader = git.getRepository().open(note.getData());
                    loader.copyTo(System.out);
                }
            }
        }
    }
}

From source file:gov.va.isaac.sync.git.SyncServiceGIT.java

License:Apache License

/**
 * @throws MergeFailure //from w  w w .  j  ava  2  s .  c o m
 * @throws NoWorkTreeException 
 * @see gov.va.isaac.interfaces.sync.ProfileSyncI#resolveMergeFailures(java.io.File, java.util.Map)
 */
@Override
public Set<String> resolveMergeFailures(Map<String, MergeFailOption> resolutions)
        throws IllegalArgumentException, IOException, NoWorkTreeException, MergeFailure {
    log.info("resolve merge failures called - resolutions: {}", resolutions);
    try {
        Git git = getGit();

        List<Note> notes = git.notesList().call();

        Set<String> conflicting = git.status().call().getConflicting();
        if (conflicting.size() == 0) {
            throw new IllegalArgumentException("You do not appear to have any conflicting files");
        }
        if (conflicting.size() != resolutions.size()) {
            throw new IllegalArgumentException(
                    "You must provide a resolution for each conflicting file.  Files in conflict: "
                            + conflicting);
        }
        for (String s : conflicting) {
            if (!resolutions.containsKey(s)) {
                throw new IllegalArgumentException("No conflit resolution specified for file " + s
                        + ".  Resolutions must be specified for all files");
            }
        }

        if (notes == null || notes.size() == 0) {
            throw new IllegalArgumentException(
                    "The 'note' that is required for tracking state is missing.  This merge failure must be resolved on the command line");
        }

        String noteValue = new String(git.getRepository().open(notes.get(0).getData()).getBytes());

        MergeFailType mergeFailType;
        if (noteValue.startsWith(NOTE_FAILED_MERGE_HAPPENED_ON_REMOTE)) {
            mergeFailType = MergeFailType.REMOTE_TO_LOCAL;
        } else if (noteValue.startsWith(NOTE_FAILED_MERGE_HAPPENED_ON_STASH)) {
            mergeFailType = MergeFailType.STASH_TO_LOCAL;
        } else {
            throw new IllegalArgumentException(
                    "The 'note' that is required for tracking state contains an unexpected value of '"
                            + noteValue + "'");
        }
        String stashIdToApply = null;
        if (noteValue.contains(STASH_MARKER)) {
            stashIdToApply = noteValue.substring(noteValue.indexOf(STASH_MARKER) + STASH_MARKER.length());
        }

        return resolveMergeFailures(mergeFailType, stashIdToApply, resolutions);
    } catch (GitAPIException | LargeObjectException e) {
        log.error("Unexpected", e);
        throw new IOException("Internal error", e);
    }
}

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

License:Open Source License

@Test
public void testConfigureFetchAfterCloneTask() throws Exception {
    createNoteInOrigin();/*w ww  . j ava  2 s.  c  o  m*/

    URIish uri = new URIish("file:///" + repository1.getRepository().getDirectory().toString());
    CloneOperation clop = new CloneOperation(uri, true, null, workdir2, "refs/heads/master", "origin", 0);

    clop.addPostCloneTask(new ConfigureFetchAfterCloneTask("origin", "refs/notes/review:refs/notes/review"));
    clop.run(null);
    Repository clonedRepo = new FileRepository(new File(workdir2, Constants.DOT_GIT));
    assertTrue(clonedRepo.getConfig().getStringList(ConfigConstants.CONFIG_REMOTE_SECTION, "origin", "fetch")[1]
            .equals("refs/notes/review:refs/notes/review"));
    Git clonedGit = new Git(clonedRepo);
    assertEquals(1, clonedGit.notesList().setNotesRef("refs/notes/review").call().size());
}