Files
github-api/jacoco/org.kohsuke.github/GHCommitSearchBuilder.java.html
2021-06-02 11:09:28 -07:00

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> &gt; <a href="index.source.html" class="el_package">org.kohsuke.github</a> &gt; <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&lt;GHCommit&gt; {
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(&quot;author:&quot; + 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(&quot;committer:&quot; + 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(&quot;author-name:&quot; + 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(&quot;committer-name:&quot; + 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(&quot;author-email:&quot; + 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(&quot;committer-email:&quot; + 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(&quot;author-date:&quot; + 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(&quot;committer-date:&quot; + 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(&quot;merge:&quot; + 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(&quot;hash:&quot; + 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(&quot;parent:&quot; + 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(&quot;tree:&quot; + 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(&quot;is:&quot; + 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(&quot;user:&quot; + 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(&quot;org:&quot; + 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(&quot;repo:&quot; + 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(&quot;order&quot;, 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(&quot;sort&quot;, 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&lt;GHCommit&gt; {
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 (&quot;username/reponame&quot;)
*/
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 + &quot;/repos/&quot;).length();</span>
<span class="fc" id="L264"> String[] tokens = commitUrl.substring(indexOfUsername).split(&quot;/&quot;, 3);</span>
<span class="fc" id="L265"> return tokens[0] + '/' + tokens[1];</span>
}
@Override
protected String getApiUrl() {
<span class="fc" id="L270"> return &quot;/search/commits&quot;;</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>