mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-17 15:50:20 +00:00
133 lines
5.2 KiB
HTML
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> > <a href="index.source.html" class="el_package">org.kohsuke.github</a> > <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.
|
|
*
|
|
* <p>
|
|
* Call various methods that set the filter criteria, then {@link #list()} method to actually list up the commit.
|
|
*
|
|
* <pre>
|
|
* GHRepository r = ...;
|
|
* for (GHCommit c : r.queryCommits().since(x).until(y).author("kohsuke")) {
|
|
* ...
|
|
* }
|
|
* </pre>
|
|
*
|
|
* @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("author", 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("path", 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("sha", 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("per_page", 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("since", 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("until", 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<GHCommit> list() {
|
|
<span class="fc" id="L130"> return req.withUrlPath(repo.getApiTailUrl("commits")).toIterable(GHCommit[].class, item -> 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> |