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

133 lines
5.2 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>GHCommitQueryBuilder.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">GHCommitQueryBuilder.java</span></div><h1>GHCommitQueryBuilder.java</h1><pre class="source lang-java linenums">package org.kohsuke.github;
import java.util.Date;
/**
* Builds up query for listing commits.
*
* &lt;p&gt;
* Call various methods that set the filter criteria, then {@link #list()} method to actually list up the commit.
*
* &lt;pre&gt;
* GHRepository r = ...;
* for (GHCommit c : r.queryCommits().since(x).until(y).author(&quot;kohsuke&quot;)) {
* ...
* }
* &lt;/pre&gt;
*
* @author Kohsuke Kawaguchi
* @see GHRepository#queryCommits() GHRepository#queryCommits()
*/
public class GHCommitQueryBuilder {
private final Requester req;
private final GHRepository repo;
<span class="fc" id="L25"> GHCommitQueryBuilder(GHRepository repo) {</span>
<span class="fc" id="L26"> this.repo = repo;</span>
<span class="fc" id="L27"> this.req = repo.root.createRequest(); // requester to build up</span>
<span class="fc" id="L28"> }</span>
/**
* GItHub login or email address by which to filter by commit author.
*
* @param author
* the author
* @return the gh commit query builder
*/
public GHCommitQueryBuilder author(String author) {
<span class="fc" id="L38"> req.with(&quot;author&quot;, author);</span>
<span class="fc" id="L39"> return this;</span>
}
/**
* Only commits containing this file path will be returned.
*
* @param path
* the path
* @return the gh commit query builder
*/
public GHCommitQueryBuilder path(String path) {
<span class="fc" id="L50"> req.with(&quot;path&quot;, path);</span>
<span class="fc" id="L51"> return this;</span>
}
/**
* Specifies the SHA1 commit / tag / branch / etc to start listing commits from.
*
* @param ref
* the ref
* @return the gh commit query builder
*/
public GHCommitQueryBuilder from(String ref) {
<span class="fc" id="L62"> req.with(&quot;sha&quot;, ref);</span>
<span class="fc" id="L63"> return this;</span>
}
/**
* Page size gh commit query builder.
*
* @param pageSize
* the page size
* @return the gh commit query builder
*/
public GHCommitQueryBuilder pageSize(int pageSize) {
<span class="fc" id="L74"> req.with(&quot;per_page&quot;, pageSize);</span>
<span class="fc" id="L75"> return this;</span>
}
/**
* Only commits after this date will be returned
*
* @param dt
* the dt
* @return the gh commit query builder
*/
public GHCommitQueryBuilder since(Date dt) {
<span class="fc" id="L86"> req.with(&quot;since&quot;, GitHubClient.printDate(dt));</span>
<span class="fc" id="L87"> return this;</span>
}
/**
* Only commits after this date will be returned
*
* @param timestamp
* the timestamp
* @return the gh commit query builder
*/
public GHCommitQueryBuilder since(long timestamp) {
<span class="fc" id="L98"> return since(new Date(timestamp));</span>
}
/**
* Only commits before this date will be returned
*
* @param dt
* the dt
* @return the gh commit query builder
*/
public GHCommitQueryBuilder until(Date dt) {
<span class="fc" id="L109"> req.with(&quot;until&quot;, GitHubClient.printDate(dt));</span>
<span class="fc" id="L110"> return this;</span>
}
/**
* Only commits before this date will be returned
*
* @param timestamp
* the timestamp
* @return the gh commit query builder
*/
public GHCommitQueryBuilder until(long timestamp) {
<span class="fc" id="L121"> return until(new Date(timestamp));</span>
}
/**
* Lists up the commits with the criteria built so far.
*
* @return the paged iterable
*/
public PagedIterable&lt;GHCommit&gt; list() {
<span class="fc" id="L130"> return req.withUrlPath(repo.getApiTailUrl(&quot;commits&quot;)).toIterable(GHCommit[].class, item -&gt; item.wrapUp(repo));</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>