mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-14 08:21:22 +00:00
105 lines
4.6 KiB
HTML
105 lines
4.6 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>GHCommitPointer.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">GHCommitPointer.java</span></div><h1>GHCommitPointer.java</h1><pre class="source lang-java linenums">/*
|
|
* The MIT License
|
|
*
|
|
* Copyright (c) 2010, Kohsuke Kawaguchi
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
package org.kohsuke.github;
|
|
|
|
import java.io.IOException;
|
|
|
|
/**
|
|
* Identifies a commit in {@link GHPullRequest}.
|
|
*
|
|
* @author Kohsuke Kawaguchi
|
|
*/
|
|
<span class="fc" id="L33">public class GHCommitPointer {</span>
|
|
private String ref, sha, label;
|
|
private GHUser user;
|
|
private GHRepository repo;
|
|
|
|
/**
|
|
* This points to the user who owns the {@link #getRepository()}.
|
|
*
|
|
* @return the user
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHUser getUser() throws IOException {
|
|
<span class="pc bpc" id="L46" title="1 of 2 branches missed."> if (user != null)</span>
|
|
<span class="fc" id="L47"> return user.root.intern(user);</span>
|
|
<span class="nc" id="L48"> return user;</span>
|
|
}
|
|
|
|
/**
|
|
* The repository that contains the commit.
|
|
*
|
|
* @return the repository
|
|
*/
|
|
public GHRepository getRepository() {
|
|
<span class="nc" id="L57"> return repo;</span>
|
|
}
|
|
|
|
/**
|
|
* Named ref to the commit. This appears to be a "short ref" that doesn't include "refs/heads/" portion.
|
|
*
|
|
* @return the ref
|
|
*/
|
|
public String getRef() {
|
|
<span class="fc" id="L66"> return ref;</span>
|
|
}
|
|
|
|
/**
|
|
* SHA1 of the commit.
|
|
*
|
|
* @return the sha
|
|
*/
|
|
public String getSha() {
|
|
<span class="fc" id="L75"> return sha;</span>
|
|
}
|
|
|
|
/**
|
|
* String that looks like "USERNAME:REF".
|
|
*
|
|
* @return the label
|
|
*/
|
|
public String getLabel() {
|
|
<span class="fc" id="L84"> return label;</span>
|
|
}
|
|
|
|
/**
|
|
* Obtains the commit that this pointer is referring to.
|
|
*
|
|
* @return the commit
|
|
* @throws IOException
|
|
* the io exception
|
|
*/
|
|
public GHCommit getCommit() throws IOException {
|
|
<span class="nc" id="L95"> return getRepository().getCommit(getSha());</span>
|
|
}
|
|
|
|
void wrapUp(GitHub root) {
|
|
<span class="pc bpc" id="L99" title="1 of 2 branches missed."> if (user != null)</span>
|
|
<span class="fc" id="L100"> user.root = root;</span>
|
|
<span class="pc bpc" id="L101" title="1 of 2 branches missed."> if (repo != null)</span>
|
|
<span class="fc" id="L102"> repo.wrap(root);</span>
|
|
<span class="fc" id="L103"> }</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> |