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

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

Introduction

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

Prototype

String R_NOTES

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

Click Source Link

Document

Prefix for notes refs

Usage

From source file:com.gitblit.utils.JGitUtils.java

License:Apache License

/**
 * Returns the list of note branches. If repository does not exist or is
 * empty, an empty list is returned.//  ww w.  java2s . c  o  m
 *
 * @param repository
 * @param fullName
 *            if true, /refs/notes/yadayadayada is returned. If false,
 *            yadayadayada is returned.
 * @param maxCount
 *            if < 0, all note branches are returned
 * @return list of note branches
 */
public static List<RefModel> getNoteBranches(Repository repository, boolean fullName, int maxCount) {
    return getRefs(repository, Constants.R_NOTES, fullName, maxCount);
}

From source file:com.rimerosolutions.ant.git.tasks.FetchTask.java

License:Apache License

@Override
public void doExecute() {
    try {//from  w  w w. j  a v  a  2 s  . c  o  m
        StoredConfig config = git.getRepository().getConfig();
        List<RemoteConfig> remoteConfigs = RemoteConfig.getAllRemoteConfigs(config);

        if (remoteConfigs.isEmpty()) {
            URIish uri = new URIish(getUri());

            RemoteConfig remoteConfig = new RemoteConfig(config, Constants.DEFAULT_REMOTE_NAME);
            remoteConfig.addURI(uri);
            remoteConfig.addFetchRefSpec(new RefSpec("+" + Constants.R_HEADS + "*:" + Constants.R_REMOTES
                    + Constants.DEFAULT_REMOTE_NAME + "/*"));

            config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
                    ConfigConstants.CONFIG_KEY_REMOTE, Constants.DEFAULT_REMOTE_NAME);
            config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER,
                    ConfigConstants.CONFIG_KEY_MERGE, Constants.R_HEADS + Constants.MASTER);

            remoteConfig.update(config);
            config.save();
        }

        List<RefSpec> specs = new ArrayList<RefSpec>(3);

        specs.add(new RefSpec(
                "+" + Constants.R_HEADS + "*:" + Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/*"));
        specs.add(new RefSpec("+" + Constants.R_NOTES + "*:" + Constants.R_NOTES + "*"));
        specs.add(new RefSpec("+" + Constants.R_TAGS + "*:" + Constants.R_TAGS + "*"));

        FetchCommand fetchCommand = git.fetch().setDryRun(dryRun).setThin(thinPack).setRemote(getUri())
                .setRefSpecs(specs).setRemoveDeletedRefs(removeDeletedRefs);

        setupCredentials(fetchCommand);

        if (getProgressMonitor() != null) {
            fetchCommand.setProgressMonitor(getProgressMonitor());
        }

        FetchResult fetchResult = fetchCommand.call();

        GitTaskUtils.validateTrackingRefUpdates(FETCH_FAILED_MESSAGE, fetchResult.getTrackingRefUpdates());

        log(fetchResult.getMessages());

    } catch (URISyntaxException e) {
        throw new GitBuildException("Invalid URI syntax: " + e.getMessage(), e);
    } catch (IOException e) {
        throw new GitBuildException("Could not save or get repository configuration: " + e.getMessage(), e);
    } catch (InvalidRemoteException e) {
        throw new GitBuildException("Invalid remote URI: " + e.getMessage(), e);
    } catch (TransportException e) {
        throw new GitBuildException("Communication error: " + e.getMessage(), e);
    } catch (GitAPIException e) {
        throw new GitBuildException("Unexpected exception: " + e.getMessage(), e);
    }
}

From source file:org.eclipse.egit.core.internal.gerrit.GerritUtil.java

License:Open Source License

/**
 * Configure fetching review summary notes
 *
 * @param remoteConfig/*from   w w w  .  j  a va 2 s .  c o  m*/
 *            the remote configuration to configure this in
 * @return {@code true} if the {@code remoteConfig} was changed,
 *         {@code false} otherwise.
 */
public static boolean configureFetchNotes(RemoteConfig remoteConfig) {
    String notesRef = Constants.R_NOTES + "*"; //$NON-NLS-1$
    List<RefSpec> fetchRefSpecs = remoteConfig.getFetchRefSpecs();
    for (RefSpec refSpec : fetchRefSpecs) {
        if (refSpec.matchSource(notesRef)) {
            return false;
        }
    }
    remoteConfig.addFetchRefSpec(new RefSpec(notesRef + ':' + notesRef));
    return true;
}

From source file:org.eclipse.egit.core.internal.gerrit.GerritUtil.java

License:Open Source License

/**
 * @param rc//from  ww w .  ja v a  2s  .  co m
 *            the remote configuration
 * @return {@code true} if the remote configuration is configured for
 *         fetching from Gerrit
 */
public static boolean isGerritFetch(RemoteConfig rc) {
    for (RefSpec fetchSpec : rc.getFetchRefSpecs()) {
        String source = fetchSpec.getSource();
        String destination = fetchSpec.getDestination();
        if (source == null || destination == null) {
            continue;
        }
        if (source.startsWith(Constants.R_NOTES) && destination.startsWith(Constants.R_NOTES)) {
            return true;
        }
    }
    return false;
}

From source file:org.eclipse.egit.ui.internal.commit.RepositoryCommit.java

License:Open Source License

/**
 * Get notes for this commit./*from   w  ww  .j av a 2s .  co m*/
 *
 * @return non-null but possibly empty array of {@link RepositoryCommitNote}
 *         instances.
 */
public RepositoryCommitNote[] getNotes() {
    if (notes == null) {
        List<RepositoryCommitNote> noteList = new ArrayList<RepositoryCommitNote>();
        try {
            Repository repo = getRepository();
            Git git = Git.wrap(repo);
            RevCommit revCommit = getRevCommit();
            for (Ref ref : repo.getRefDatabase().getRefs(Constants.R_NOTES).values()) {
                Note note = git.notesShow().setNotesRef(ref.getName()).setObjectId(revCommit).call();
                if (note != null)
                    noteList.add(new RepositoryCommitNote(this, ref, note));
            }
            notes = noteList.toArray(new RepositoryCommitNote[noteList.size()]);
        } catch (Exception e) {
            Activator.logError("Error showing notes", e); //$NON-NLS-1$
            notes = new RepositoryCommitNote[0];
        }
    }
    return notes;
}

From source file:org.eclipse.egit.ui.internal.gerrit.ConfigureGerritWizard.java

License:Open Source License

private void configureFetchNotes() {
    String notesRef = Constants.R_NOTES + "*"; //$NON-NLS-1$
    List<RefSpec> fetchRefSpecs = remoteConfig.getFetchRefSpecs();
    for (RefSpec refSpec : fetchRefSpecs) {
        if (refSpec.matchSource(notesRef))
            return;
    }/* w w w .java  2 s . c  o m*/
    remoteConfig.addFetchRefSpec(new RefSpec(notesRef + ":" + notesRef)); //$NON-NLS-1$
}

From source file:org.eclipse.mylyn.internal.gerrit.ui.egit.GerritRepositorySearchPage.java

License:Open Source License

private void addFetchReviewNotesRefSpec(GitRepositoryInfo gitRepositoryInfo) {
    String notesRef = Constants.R_NOTES + "*"; //$NON-NLS-1$
    gitRepositoryInfo.addFetchRefSpec("+" + notesRef + ":" + notesRef);
}

From source file:org.flowerplatform.web.git.history.remote.GitHistoryStatefulService.java

License:Open Source License

private void setupWalk(WebWalk walk, Repository repo, String path) throws IOException {
    walk.addAdditionalRefs(repo.getRefDatabase().getAdditionalRefs());
    walk.addAdditionalRefs(repo.getRefDatabase().getRefs(Constants.R_NOTES).values());

    walk.sort(RevSort.COMMIT_TIME_DESC, true);
    walk.sort(RevSort.BOUNDARY, true);/*  w  w  w  . j a  va 2 s  . c om*/
    walk.setRetainBody(false);

    setWalkStartPoints(walk, repo, walk.parseCommit(repo.resolve(Constants.HEAD)));

    createFileWalker(walk, repo, path);

}

From source file:org.flowerplatform.web.git.history.remote.GitHistoryStatefulService.java

License:Open Source License

private void setWalkStartPoints(RevWalk walk, Repository repo, AnyObjectId headId) throws IOException {
    markStartAllRefs(repo, walk, Constants.R_HEADS);
    markStartAllRefs(repo, walk, Constants.R_REMOTES);
    markStartAllRefs(repo, walk, Constants.R_TAGS);

    markStartAdditionalRefs(repo, walk);
    markUninteresting(repo, walk, Constants.R_NOTES);

    walk.markStart(walk.parseCommit(headId));
}

From source file:org.gitective.tests.GitTestCase.java

License:Open Source License

/**
 * Add note to latest commit with given content
 *
 * @param content/* w  ww .j  a  va 2 s . com*/
 * @param ref
 * @return note
 * @throws Exception
 */
protected Note note(String content, String ref) throws Exception {
    Git git = Git.open(testRepo);
    Note note = git.notesAdd().setMessage(content).setNotesRef(Constants.R_NOTES + ref)
            .setObjectId(CommitUtils.getHead(git.getRepository())).call();
    assertNotNull(note);
    return note;
}