mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-21 00:11:23 +00:00
273 lines
9.0 KiB
HTML
273 lines
9.0 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>GHCommitSearchBuilder.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub API for Java</a> > <a href="index.source.html" class="el_package">org.kohsuke.github</a> > <span class="el_source">GHCommitSearchBuilder.java</span></div><h1>GHCommitSearchBuilder.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.kohsuke.github.internal.Previews;
|
|
|
|
import java.io.IOException;
|
|
|
|
/**
|
|
* Search commits.
|
|
*
|
|
* @author Marc de Verdelhan
|
|
* @see GitHub#searchCommits() GitHub#searchCommits()
|
|
*/
|
|
@Preview(Previews.CLOAK)
|
|
@Deprecated
|
|
public class GHCommitSearchBuilder extends GHSearchBuilder<GHCommit> {
|
|
GHCommitSearchBuilder(GitHub root) {
|
|
<span class="fc" id="L18"> super(root, CommitSearchResult.class);</span>
|
|
<span class="fc" id="L19"> req.withPreview(Previews.CLOAK);</span>
|
|
<span class="fc" id="L20"> }</span>
|
|
|
|
/**
|
|
* Search terms.
|
|
*/
|
|
public GHCommitSearchBuilder q(String term) {
|
|
<span class="fc" id="L26"> super.q(term);</span>
|
|
<span class="fc" id="L27"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Author gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder author(String v) {
|
|
<span class="fc" id="L38"> return q("author:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Committer gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder committer(String v) {
|
|
<span class="nc" id="L49"> return q("committer:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Author name gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder authorName(String v) {
|
|
<span class="nc" id="L60"> return q("author-name:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Committer name gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder committerName(String v) {
|
|
<span class="nc" id="L71"> return q("committer-name:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Author email gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder authorEmail(String v) {
|
|
<span class="nc" id="L82"> return q("author-email:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Committer email gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder committerEmail(String v) {
|
|
<span class="nc" id="L93"> return q("committer-email:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Author date gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder authorDate(String v) {
|
|
<span class="nc" id="L104"> return q("author-date:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Committer date gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder committerDate(String v) {
|
|
<span class="nc" id="L115"> return q("committer-date:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Merge gh commit search builder.
|
|
*
|
|
* @param merge
|
|
* the merge
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder merge(boolean merge) {
|
|
<span class="nc" id="L126"> return q("merge:" + Boolean.valueOf(merge).toString().toLowerCase());</span>
|
|
}
|
|
|
|
/**
|
|
* Hash gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder hash(String v) {
|
|
<span class="nc" id="L137"> return q("hash:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Parent gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder parent(String v) {
|
|
<span class="nc" id="L148"> return q("parent:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Tree gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder tree(String v) {
|
|
<span class="nc" id="L159"> return q("tree:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Is gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder is(String v) {
|
|
<span class="nc" id="L170"> return q("is:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* User gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder user(String v) {
|
|
<span class="nc" id="L181"> return q("user:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Org gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder org(String v) {
|
|
<span class="fc" id="L192"> return q("org:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Repo gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder repo(String v) {
|
|
<span class="fc" id="L203"> return q("repo:" + v);</span>
|
|
}
|
|
|
|
/**
|
|
* Order gh commit search builder.
|
|
*
|
|
* @param v
|
|
* the v
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder order(GHDirection v) {
|
|
<span class="nc" id="L214"> req.with("order", v);</span>
|
|
<span class="nc" id="L215"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* Sort gh commit search builder.
|
|
*
|
|
* @param sort
|
|
* the sort
|
|
* @return the gh commit search builder
|
|
*/
|
|
public GHCommitSearchBuilder sort(Sort sort) {
|
|
<span class="fc" id="L226"> req.with("sort", sort);</span>
|
|
<span class="fc" id="L227"> return this;</span>
|
|
}
|
|
|
|
/**
|
|
* The enum Sort.
|
|
*/
|
|
<span class="fc" id="L233"> public enum Sort {</span>
|
|
<span class="fc" id="L234"> AUTHOR_DATE, COMMITTER_DATE</span>
|
|
}
|
|
|
|
private static class CommitSearchResult extends SearchResult<GHCommit> {
|
|
private GHCommit[] items;
|
|
|
|
@Override
|
|
GHCommit[] getItems(GitHub root) {
|
|
<span class="fc bfc" id="L242" title="All 2 branches covered."> for (GHCommit commit : items) {</span>
|
|
<span class="fc" id="L243"> String repoName = getRepoName(commit.url);</span>
|
|
try {
|
|
<span class="fc" id="L245"> GHRepository repo = root.getRepository(repoName);</span>
|
|
<span class="fc" id="L246"> commit.wrapUp(repo);</span>
|
|
<span class="nc" id="L247"> } catch (IOException ioe) {</span>
|
|
<span class="fc" id="L248"> }</span>
|
|
}
|
|
<span class="fc" id="L250"> return items;</span>
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param commitUrl
|
|
* a commit URL
|
|
* @return the repo name ("username/reponame")
|
|
*/
|
|
private static String getRepoName(String commitUrl) {
|
|
<span class="pc bpc" id="L260" title="1 of 2 branches missed."> if (StringUtils.isBlank(commitUrl)) {</span>
|
|
<span class="nc" id="L261"> return null;</span>
|
|
}
|
|
<span class="fc" id="L263"> int indexOfUsername = (GitHubClient.GITHUB_URL + "/repos/").length();</span>
|
|
<span class="fc" id="L264"> String[] tokens = commitUrl.substring(indexOfUsername).split("/", 3);</span>
|
|
<span class="fc" id="L265"> return tokens[0] + '/' + tokens[1];</span>
|
|
}
|
|
|
|
@Override
|
|
protected String getApiUrl() {
|
|
<span class="fc" id="L270"> return "/search/commits";</span>
|
|
}
|
|
}
|
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html> |