Package org.kohsuke.github
Class GHCommit
- java.lang.Object
-
- org.kohsuke.github.GHCommit
-
- Direct Known Subclasses:
GHCompare.Commit
public class GHCommit extends Object
A commit in a repository.- Author:
- Kohsuke Kawaguchi
- See Also:
GHRepository#getCommit(String)
,GHCommitComment#getCommit()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GHCommit.File
A file that was modified.static class
GHCommit.GHAuthor
Deprecated.UseGitUser
instead.static class
GHCommit.Parent
The type Parent.static class
GHCommit.ShortInfo
Short summary of this commit.static class
GHCommit.Stats
The type Stats.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GHCommitComment
createComment(String body)
Create comment gh commit comment.GHCommitComment
createComment(String body, String path, Integer line, Integer position)
Creates a commit comment.GHUser
getAuthor()
Gets author.Date
getAuthoredDate()
Gets the date the change was authored on.PagedIterable<GHCheckRun>
getCheckRuns()
Gets check-runs for given sha.Date
getCommitDate()
Gets the date the change was committed on.GHCommit.ShortInfo
getCommitShortInfo()
Gets commit short info.GHUser
getCommitter()
Gets committer.List<GHCommit.File>
getFiles()
List of files changed/added/removed in this commit.URL
getHtmlUrl()
Gets html url.GHCommitStatus
getLastStatus()
Gets last status.int
getLinesAdded()
Gets lines added.int
getLinesChanged()
Gets lines changed.int
getLinesDeleted()
Gets lines deleted.GHRepository
getOwner()
Gets owner.List<GHCommit>
getParents()
Resolves the parent commit objects and return them.List<String>
getParentSHA1s()
Gets parent sha 1 s.String
getSHA1()
Gets sha 1.GHTree
getTree()
Use this method to walk the tree.URL
getUrl()
Gets url.PagedIterable<GHBranch>
listBranchesWhereHead()
Retrieves a list of branches where this commit is the head commit.PagedIterable<GHCommitComment>
listComments()
List comments paged iterable.PagedIterable<GHPullRequest>
listPullRequests()
Retrieves a list of pull requests which contain this commit.PagedIterable<GHCommitStatus>
listStatuses()
List statuses paged iterable.
-
-
-
Constructor Detail
-
GHCommit
public GHCommit()
Creates an instance ofGHCommit
.
-
-
Method Detail
-
getCommitShortInfo
public GHCommit.ShortInfo getCommitShortInfo() throws IOException
Gets commit short info.- Returns:
- the commit short info
- Throws:
IOException
- the io exception
-
getOwner
public GHRepository getOwner()
Gets owner.- Returns:
- the repository that contains the commit.
-
getLinesChanged
public int getLinesChanged() throws IOException
Gets lines changed.- Returns:
- the number of lines added + removed.
- Throws:
IOException
- if the field was not populated and refresh fails
-
getLinesAdded
public int getLinesAdded() throws IOException
Gets lines added.- Returns:
- Number of lines added.
- Throws:
IOException
- if the field was not populated and refresh fails
-
getLinesDeleted
public int getLinesDeleted() throws IOException
Gets lines deleted.- Returns:
- Number of lines removed.
- Throws:
IOException
- if the field was not populated and refresh fails
-
getTree
public GHTree getTree() throws IOException
Use this method to walk the tree.- Returns:
- a GHTree to walk
- Throws:
IOException
- on error
-
getHtmlUrl
public URL getHtmlUrl()
Gets html url.- Returns:
- URL of this commit like "https://github.com/kohsuke/sandbox-ant/commit/8ae38db0ea5837313ab5f39d43a6f73de3bd9000"
-
getSHA1
public String getSHA1()
Gets sha 1.- Returns:
- [0 -9a-f]{40} SHA1 checksum.
-
getUrl
public URL getUrl()
Gets url.- Returns:
- API URL of this object.
-
getFiles
public List<GHCommit.File> getFiles() throws IOException
List of files changed/added/removed in this commit.- Returns:
- Can be empty but never null.
- Throws:
IOException
- on error
-
getParentSHA1s
public List<String> getParentSHA1s()
Gets parent sha 1 s.- Returns:
- SHA1 of parent commit objects.
-
getParents
public List<GHCommit> getParents() throws IOException
Resolves the parent commit objects and return them.- Returns:
- parent commit objects
- Throws:
IOException
- on error
-
getAuthor
public GHUser getAuthor() throws IOException
Gets author.- Returns:
- the author
- Throws:
IOException
- the io exception
-
getAuthoredDate
public Date getAuthoredDate() throws IOException
Gets the date the change was authored on.- Returns:
- the date the change was authored on.
- Throws:
IOException
- if the information was not already fetched and an attempt at fetching the information failed.
-
getCommitter
public GHUser getCommitter() throws IOException
Gets committer.- Returns:
- the committer
- Throws:
IOException
- the io exception
-
getCommitDate
public Date getCommitDate() throws IOException
Gets the date the change was committed on.- Returns:
- the date the change was committed on.
- Throws:
IOException
- if the information was not already fetched and an attempt at fetching the information failed.
-
listPullRequests
@Preview(GROOT) public PagedIterable<GHPullRequest> listPullRequests()
Retrieves a list of pull requests which contain this commit.- Returns:
PagedIterable
with the pull requests which contain this commit
-
listBranchesWhereHead
@Preview(GROOT) public PagedIterable<GHBranch> listBranchesWhereHead() throws IOException
Retrieves a list of branches where this commit is the head commit.- Returns:
PagedIterable
with the branches where the commit is the head commit- Throws:
IOException
- the io exception
-
listComments
public PagedIterable<GHCommitComment> listComments()
List comments paged iterable.- Returns:
PagedIterable
with all the commit comments in this repository.
-
createComment
public GHCommitComment createComment(String body, String path, Integer line, Integer position) throws IOException
Creates a commit comment.I'm not sure how path/line/position parameters interact with each other.
- Parameters:
body
- body of the commentpath
- path of file being commented online
- target line for commentposition
- position on line- Returns:
- created GHCommitComment
- Throws:
IOException
- if comment is not created
-
createComment
public GHCommitComment createComment(String body) throws IOException
Create comment gh commit comment.- Parameters:
body
- the body- Returns:
- the gh commit comment
- Throws:
IOException
- the io exception
-
listStatuses
public PagedIterable<GHCommitStatus> listStatuses() throws IOException
List statuses paged iterable.- Returns:
- status of this commit, newer ones first.
- Throws:
IOException
- if statuses cannot be read
-
getLastStatus
public GHCommitStatus getLastStatus() throws IOException
Gets last status.- Returns:
- the last status of this commit, which is what gets shown in the UI.
- Throws:
IOException
- on error
-
getCheckRuns
@Preview(ANTIOPE) public PagedIterable<GHCheckRun> getCheckRuns() throws IOException
Gets check-runs for given sha.- Returns:
- check runs for given sha.
- Throws:
IOException
- on error
-
-