Package org.kohsuke.github
Class GHRepository
- java.lang.Object
-
- org.kohsuke.github.GHObject
-
- org.kohsuke.github.GHRepository
-
public class GHRepository extends GHObject
A repository on GitHub.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGHRepository.CollaboratorAffiliationAffiliation of a repository collaborator.static classGHRepository.ContributorThe type Contributor.static classGHRepository.ForkSortSort orders for listing forks.static classGHRepository.SetterAGHRepositoryBuilderthat allows multiple properties to be updated per request.static classGHRepository.UpdaterAGHRepositoryBuilderthat allows multiple properties to be updated per request.static classGHRepository.VisibilityVisibility of a repository.
-
Field Summary
-
Fields inherited from class org.kohsuke.github.GHObject
responseHeaderFields
-
-
Constructor Summary
Constructors Constructor Description GHRepository()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCollaborators(Collection<GHUser> users)Add collaborators.voidaddCollaborators(Collection<GHUser> users, GHOrganization.Permission permission)Deprecated.#addCollaborators(Collection, GHOrganization.RolePermission)voidaddCollaborators(Collection<GHUser> users, GHOrganization.RepositoryRole permission)Add collaborators.voidaddCollaborators(GHOrganization.Permission permission, GHUser... users)Deprecated.#addCollaborators(GHOrganization.RolePermission, GHUser)voidaddCollaborators(GHOrganization.RepositoryRole permission, GHUser... users)Add collaborators.voidaddCollaborators(GHUser... users)Add collaborators.GHDeployKeyaddDeployKey(String title, String key)Add deploy key gh deploy key.GHDeployKeyaddDeployKey(String title, String key, boolean readOnly)Add deploy key gh deploy key.voidallowMergeCommit(boolean value)Allow merge commit.voidallowRebaseMerge(boolean value)Allow rebase merge.voidallowSquashMerge(boolean value)Allow squash merge.voidarchive()Will archive and this repository as read-only.GHBlobBuildercreateBlob()Create blob gh blob builder.GHCheckRunBuildercreateCheckRun(String name, String headSHA)Creates a check run for a commit.GHCommitBuildercreateCommit()Create commit gh commit builder.GHCommitStatuscreateCommitStatus(String sha1, GHCommitState state, String targetUrl, String description)Create commit status gh commit status.GHCommitStatuscreateCommitStatus(String sha1, GHCommitState state, String targetUrl, String description, String context)Creates a commit status.GHContentBuildercreateContent()Creates a new content, or update an existing content.GHContentUpdateResponsecreateContent(byte[] contentBytes, String commitMessage, String path)Deprecated.GHContentUpdateResponsecreateContent(byte[] contentBytes, String commitMessage, String path, String branch)Deprecated.GHContentUpdateResponsecreateContent(String content, String commitMessage, String path)Deprecated.GHContentUpdateResponsecreateContent(String content, String commitMessage, String path, String branch)Deprecated.GHDeploymentBuildercreateDeployment(String ref)Create deployment gh deployment builder.GHDeploymentStatusBuildercreateDeployStatus(int deploymentId, GHDeploymentState ghDeploymentState)Deprecated.UsegetDeployment(deploymentId).createStatus(ghDeploymentState)GHHookcreateHook(String name, Map<String,String> config, Collection<GHEvent> events, boolean active)See https://api.github.com/hooks for possible names and their configuration scheme.GHIssueBuildercreateIssue(String title)Create issue gh issue builder.GHLabelcreateLabel(String name, String color)Create label gh label.GHLabelcreateLabel(String name, String color, String description)Description is still in preview.GHMilestonecreateMilestone(String title, String description)Create milestone gh milestone.GHProjectcreateProject(String name, String body)Create a project for this repository.GHPullRequestcreatePullRequest(String title, String head, String base, String body)Creates a new pull request.GHPullRequestcreatePullRequest(String title, String head, String base, String body, boolean maintainerCanModify)Creates a new pull request.GHPullRequestcreatePullRequest(String title, String head, String base, String body, boolean maintainerCanModify, boolean draft)Creates a new pull request.GHRefcreateRef(String name, String sha)Creates a named ref, such as tag, branch, etc.GHReleaseBuildercreateRelease(String tag)Create release gh release builder.voidcreateSecret(String secretName, String encryptedValue, String publicKeyId)Set/Update a repository secret "https://docs.github.com/rest/reference/actions#create-or-update-a-repository-secret"GHTagObjectcreateTag(String tag, String message, String object, String type)Create a tag.GHTreeBuildercreateTree()Create tree gh tree builder.GHHookcreateWebHook(URL url)Create web hook gh hook.GHHookcreateWebHook(URL url, Collection<GHEvent> events)Create web hook gh hook.voiddelete()Deletes this repository.voiddeleteBranchOnMerge(boolean value)After pull requests are merged, you can have head branches deleted automatically.voiddeleteHook(int id)Deletes hook.<T> voiddispatch(String eventType, T clientPayload)Create a repository dispatch event, which can be used to start a workflow/action from outside github, as described on https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-eventvoidenableDownloads(boolean v)Enable downloads.voidenableIssueTracker(boolean v)Enables or disables the issue tracker for this repository.voidenableProjects(boolean v)Enables or disables projects for this repository.voidenableWiki(boolean v)Enables or disables Wiki for this repository.booleanequals(Object obj)Equals.GHRepositoryfork()Forks this repository as your repository.GHRepositoryforkTo(GHOrganization org)Forks this repository into an organization.GHArtifactgetArtifact(long id)Gets an artifact by id.GHBlobgetBlob(String blobSha)Obtains the metadata & the content of a blob.GHBranchgetBranch(String name)Gets branch.Map<String,GHBranch>getBranches()Gets branches by their names.PagedIterable<GHCheckRun>getCheckRuns(String ref)Gets check runs for given ref.PagedIterable<GHCheckRun>getCheckRuns(String ref, Map<String,Object> params)Gets check runs for given ref which validate provided parametersGHRepositoryCloneTrafficgetCloneTraffic()Set<String>getCollaboratorNames()Gets the names of the collaborators on this repository.Set<String>getCollaboratorNames(GHRepository.CollaboratorAffiliation affiliation)Gets the names of the collaborators on this repository.GHPersonSet<GHUser>getCollaborators()Gets the collaborators on this repository.GHCommitgetCommit(String sha1)Gets a commit object in this repository.GHComparegetCompare(String id1, String id2)Gets a comparison between 2 points in the repository.GHComparegetCompare(GHBranch id1, GHBranch id2)Gets compare.GHComparegetCompare(GHCommit id1, GHCommit id2)Gets compare.StringgetDefaultBranch()Returns the primary branch you'll configure in the "Admin > Options" config page.List<GHDeployKey>getDeployKeys()Gets deploy keys.GHDeploymentgetDeployment(long id)Obtains a singleGHDeploymentby its ID.PagedIterable<GHDeploymentStatus>getDeploymentStatuses(int id)Deprecated.UsegetDeployment(id).listStatuses()StringgetDescription()Gets description.List<GHContent>getDirectoryContent(String path)Gets directory content.List<GHContent>getDirectoryContent(String path, String ref)Gets directory content.GHContentgetFileContent(String path)Gets file content.GHContentgetFileContent(String path, String ref)Gets file content.intgetForks()Deprecated.usegetForksCount()insteadintgetForksCount()Returns the number of all forks of this repository.StringgetFullName()Full repository name including the owner or organization.StringgetGitTransportUrl()Gets the git:// URL to this repository, such as "git://github.com/kohsuke/jenkins.git" This URL is read-only.StringgetHomepage()Gets homepage.GHHookgetHook(int id)Gets hook.List<GHHook>getHooks()Retrieves the currently configured hooks.URLgetHtmlUrl()Gets the html url.StringgetHttpTransportUrl()Gets the HTTPS URL to this repository, such as "https://github.com/kohsuke/jenkins.git" This URL is read-only.GHIssuegetIssue(int id)Gets issue.GHIssueEventgetIssueEvent(long id)Get a single issue event.List<GHIssue>getIssues(GHIssueState state)Gets issues.List<GHIssue>getIssues(GHIssueState state, GHMilestone milestone)Gets issues.GHLabelgetLabel(String name)Gets label.StringgetLanguage()Gets the primary programming language.GHCommitStatusgetLastCommitStatus(String sha1)Gets the last status of this commit, which is what gets shown in the UI.GHReleasegetLatestRelease()Gets latest release.GHLicensegetLicense()Gets the basic license details for the repository.GHContentgetLicenseContent()Retrieves the contents of the repository's license file - makes an additional API call.StringgetMasterBranch()Deprecated.Renamed togetDefaultBranch()GHMilestonegetMilestone(int number)Gets milestone.Map<Integer,GHMilestone>getMilestones()Deprecated.StringgetMirrorUrl()Gets the Mirror URL to access this repository: https://github.com/apache/tomee mirrored from git://git.apache.org/tomee.gitStringgetName()Short repository name without the owner.StringgetNodeId()Gets node id.intgetOpenIssueCount()Gets open issue count.GHUsergetOwner()Gets owner.StringgetOwnerName()Gets owner name.GHRepositorygetParent()Forked repositories have a 'parent' attribute that specifies the repository this repository is directly forked from.GHPermissionTypegetPermission(String user)Obtain permission for a given user in this repository.GHPermissionTypegetPermission(GHUser u)Obtain permission for a given user in this repository.Set<URL>getPostCommitHooks()Deprecated.GHRepositoryPublicKeygetPublicKey()Gets the public key for the given repo.GHPullRequestgetPullRequest(int i)Retrieves a specified pull request.List<GHPullRequest>getPullRequests(GHIssueState state)Retrieves all the pull requests of a particular state.DategetPushedAt()Gets pushed at.GHContentgetReadme()https://developer.github.com/v3/repos/contents/#get-the-readmeGHRefgetRef(String refName)Retrieve a ref of the given type for the current GitHub repository.GHRef[]getRefs()Retrieves all refs for the github repository.GHRef[]getRefs(String refType)Retrieves all refs of the given type for the current GitHub repository.GHReleasegetRelease(long id)Gets release.GHReleasegetReleaseByTagName(String tag)Gets release by tag name.List<GHRelease>getReleases()Deprecated.uselistReleases()GHRepositoryVariablegetRepoVariable(String name)Gets a variable by nameGitHubgetRoot()Deprecated.For access to theGitHubinstance, use a local copy instead of pulling it out of objects.intgetSize()Gets size.GHRepositorygetSource()Forked repositories have a 'source' attribute that specifies the ultimate source of the forking chain.StringgetSshUrl()Gets the SSH URL to access this repository, such as git@github.com:rails/rails.gitintgetStargazersCount()Gets stargazers count.GHRepositoryStatisticsgetStatistics()Returns the statistics for this repository.intgetSubscribersCount()Gets subscribers count.GHSubscriptiongetSubscription()Returns the current subscription.StringgetSvnUrl()Gets the Subversion URL to access this repository: https://github.com/rails/railsGHTagObjectgetTagObject(String sha)Returns the annotated tag object.Set<GHTeam>getTeams()If this repository belongs to an organization, return a set of teams.GHTreegetTree(String sha)Retrieve a tree of the given type for the current GitHub repository.GHTreegetTreeRecursive(String sha, int recursive)Retrieves the tree for the current GitHub repository, recursively as described in here: https://developer.github.com/v3/git/trees/#get-a-tree-recursivelyGHRepositoryViewTrafficgetViewTraffic()GHRepository.VisibilitygetVisibility()Gets the visibility of the repository.intgetWatchers()Deprecated.usegetWatchersCount()insteadintgetWatchersCount()Gets the count of watchers.GHWorkflowgetWorkflow(long id)Gets a workflow by id.GHWorkflowgetWorkflow(String nameOrId)Gets a workflow by name of the file.GHWorkflowJobgetWorkflowJob(long id)Gets a job from a workflow run by id.GHWorkflowRungetWorkflowRun(long id)Gets a workflow run.StringgitHttpTransportUrl()Deprecated.Typo ofgetHttpTransportUrl()booleanhasAdminAccess()Has admin access boolean.booleanhasAssignee(GHUser u)Checks if the given user is an assignee for this repository.booleanhasDownloads()Has downloads boolean.inthashCode()Hash code.booleanhasIssues()Has issues boolean.booleanhasPages()Has pages boolean.booleanhasPermission(String user, GHPermissionType permission)Check if a user has at least the given permission in this repository.booleanhasPermission(GHUser user, GHPermissionType permission)Check if a user has at least the given permission in this repository.booleanhasProjects()Has projects boolean.booleanhasPullAccess()Has pull access boolean.booleanhasPushAccess()Has push access boolean.booleanhasWiki()Has wiki boolean.booleanisAllowMergeCommit()Is allow merge commit boolean.booleanisAllowRebaseMerge()Is allow rebase merge boolean.booleanisAllowSquashMerge()Is allow squash merge boolean.booleanisArchived()Is archived boolean.booleanisCollaborator(GHUser user)Checks if the given user is a collaborator for this repository.booleanisDeleteBranchOnMerge()Automatically deleting head branches when pull requests are merged.booleanisDisabled()Is disabled boolean.booleanisFork()Is fork boolean.booleanisPrivate()Is private boolean.booleanisTemplate()Is template boolean.PagedIterable<GHArtifact>listArtifacts()Lists all the artifacts of this repository.PagedIterable<GHUser>listAssignees()Lists all the available assignees to which issues may be assigned.List<GHCodeownersError>listCodeownersErrors()List errors in theCODEOWNERSfile.PagedIterable<GHUser>listCollaborators()Lists up the collaborators on this repository.PagedIterable<GHUser>listCollaborators(GHRepository.CollaboratorAffiliation affiliation)Lists up the collaborators on this repository.PagedIterable<GHCommitComment>listCommitComments()Lists up all the commit comments in this repository.PagedIterable<GHCommitComment>listCommitComments(String commitSha)Lists all comments on a specific commit.PagedIterable<GHCommit>listCommits()Lists all the commits.PagedIterable<GHCommitStatus>listCommitStatuses(String sha1)/** Lists all the commit statuses attached to the given commit, newer ones first.PagedIterable<GHRepository.Contributor>listContributors()List contributors paged iterable.PagedIterable<GHDeployment>listDeployments(String sha, String ref, String task, String environment)List deployments paged iterable.PagedIterable<GHEventInfo>listEvents()Lists repository events.PagedIterable<GHRepository>listForks()Lists all the direct forks of this repository, sorted by github api default, currentlyForkSort.NEWEST*.PagedIterable<GHRepository>listForks(GHRepository.ForkSort sort)Lists all the direct forks of this repository, sorted by the given sort order.PagedIterable<GHInvitation>listInvitations()Lists all the invitations.PagedIterable<GHIssueEvent>listIssueEvents()Get all issue events for this repository.PagedIterable<GHIssue>listIssues(GHIssueState state)Deprecated.UsequeryIssues()PagedIterable<GHLabel>listLabels()Lists labels in this repository.Map<String,Long>listLanguages()List languages for the specified repository.PagedIterable<GHMilestone>listMilestones(GHIssueState state)Lists up all the milestones in this repository.GHNotificationStreamlistNotifications()List all the notifications in a repository for the current user.PagedIterable<GHProject>listProjects()Returns open projects for this repository.PagedIterable<GHProject>listProjects(GHProject.ProjectStateFilter status)Returns the projects for this repository.PagedIterable<GHPullRequest>listPullRequests(GHIssueState state)Deprecated.PagedIterable<GHRef>listRefs()Retrieves all refs for the github repository.PagedIterable<GHRef>listRefs(String refType)Retrieves all refs of the given type for the current GitHub repository.PagedIterable<GHRelease>listReleases()List releases paged iterable.PagedIterable<GHUser>listStargazers()Lists all the users who have starred this repo based on the old version of the API.PagedIterable<GHStargazer>listStargazers2()Lists all the users who have starred this repo based on new version of the API, having extended information like the time when the repository was starred.PagedIterable<GHUser>listSubscribers()Lists all the subscribers (aka watchers.)PagedIterable<GHTag>listTags()List tags paged iterable.List<String>listTopics()Return the topics for this repository.PagedIterable<GHWorkflow>listWorkflows()Lists all the workflows of this repository.GHCommitQueryBuilderqueryCommits()Search commits by specifying filters through a builder pattern.GHIssueQueryBuilder.ForRepositoryqueryIssues()Retrieves issues.GHPullRequestQueryBuilderqueryPullRequests()Retrieves pull requests.GHWorkflowRunQueryBuilderqueryWorkflowRuns()Retrieves workflow runs.InputStreamreadBlob(String blobSha)Reads the content of a blob as a stream for better efficiency.<T> TreadTar(InputStreamFunction<T> streamFunction, String ref)Streams a tar archive of the repository, optionally at a givenref.<T> TreadZip(InputStreamFunction<T> streamFunction, String ref)Streams a zip archive of the repository, optionally at a givenref.voidremoveCollaborators(Collection<GHUser> users)Remove collaborators.voidremoveCollaborators(GHUser... users)Remove collaborators.voidrenameTo(String name)Rename this repository.ReaderrenderMarkdown(String text, MarkdownMode mode)Render a Markdown document.GHRepository.Setterset()Creates a builder that can be used to bulk update repository settings.voidsetCompareUsePaginatedCommits(boolean value)SetsgetCompare(String, String)to return aGHComparethat uses a paginated commit list instead of limiting to 250 results.voidsetDefaultBranch(String value)Sets default branch.voidsetDescription(String value)Sets description.voidsetEmailServiceHook(String address)Sets email service hook.voidsetHomepage(String value)Sets homepage.voidsetPrivate(boolean value)Sets private.voidsetTopics(List<String> topics)Set the topics for this repository.voidsetVisibility(GHRepository.Visibility value)Sets visibility.voidstar()Star a repository.GHSubscriptionsubscribe(boolean subscribed, boolean ignored)Subscribes to this repository to get notifications.voidunstar()Unstar a repository.GHRepository.Updaterupdate()Creates a builder that can be used to bulk update repository settings.GHCheckRunBuilderupdateCheckRun(long checkId)Updates an existing check run.-
Methods inherited from class org.kohsuke.github.GHObject
getCreatedAt, getId, getResponseHeaderFields, getUpdatedAt, getUrl, setResponseHeaderFields, toString
-
-
-
-
Method Detail
-
createDeployment
public GHDeploymentBuilder createDeployment(String ref)
Create deployment gh deployment builder.- Parameters:
ref- the ref- Returns:
- the gh deployment builder
-
getDeploymentStatuses
@Deprecated public PagedIterable<GHDeploymentStatus> getDeploymentStatuses(int id) throws IOException
Deprecated.UsegetDeployment(id).listStatuses()Gets deployment statuses.- Parameters:
id- the id- Returns:
- the deployment statuses
- Throws:
IOException- the io exception
-
listDeployments
public PagedIterable<GHDeployment> listDeployments(String sha, String ref, String task, String environment)
List deployments paged iterable.- Parameters:
sha- the sharef- the reftask- the taskenvironment- the environment- Returns:
- the paged iterable
-
getDeployment
public GHDeployment getDeployment(long id) throws IOException
Obtains a singleGHDeploymentby its ID.- Parameters:
id- the id- Returns:
- the deployment
- Throws:
IOException- the io exception
-
createDeployStatus
@Deprecated public GHDeploymentStatusBuilder createDeployStatus(int deploymentId, GHDeploymentState ghDeploymentState) throws IOException
Deprecated.UsegetDeployment(deploymentId).createStatus(ghDeploymentState)Gets deploy status.- Parameters:
deploymentId- the deployment idghDeploymentState- the gh deployment state- Returns:
- the deploy status
- Throws:
IOException- the io exception
-
getNodeId
public String getNodeId()
Gets node id.- Overrides:
getNodeIdin classGHObject- Returns:
- the node id
- See Also:
- Using Global Node IDs
-
getDescription
public String getDescription()
Gets description.- Returns:
- the description
-
getHomepage
public String getHomepage()
Gets homepage.- Returns:
- the homepage
-
getGitTransportUrl
public String getGitTransportUrl()
Gets the git:// URL to this repository, such as "git://github.com/kohsuke/jenkins.git" This URL is read-only.- Returns:
- the git transport url
-
getHttpTransportUrl
public String getHttpTransportUrl()
Gets the HTTPS URL to this repository, such as "https://github.com/kohsuke/jenkins.git" This URL is read-only.- Returns:
- the http transport url
-
gitHttpTransportUrl
@Deprecated public String gitHttpTransportUrl()
Deprecated.Typo ofgetHttpTransportUrl()Git http transport url string.- Returns:
- the string
-
getSvnUrl
public String getSvnUrl()
Gets the Subversion URL to access this repository: https://github.com/rails/rails- Returns:
- the svn url
-
getMirrorUrl
public String getMirrorUrl()
Gets the Mirror URL to access this repository: https://github.com/apache/tomee mirrored from git://git.apache.org/tomee.git- Returns:
- the mirror url
-
getSshUrl
public String getSshUrl()
Gets the SSH URL to access this repository, such as git@github.com:rails/rails.git- Returns:
- the ssh url
-
getHtmlUrl
public URL getHtmlUrl()
Gets the html url.- Specified by:
getHtmlUrlin classGHObject- Returns:
- the html url
-
getName
public String getName()
Short repository name without the owner. For example 'jenkins' in case of http://github.com/jenkinsci/jenkins- Returns:
- the name
-
getFullName
public String getFullName()
Full repository name including the owner or organization. For example 'jenkinsci/jenkins' in case of http://github.com/jenkinsci/jenkins- Returns:
- the full name
-
hasPullAccess
public boolean hasPullAccess()
Has pull access boolean.- Returns:
- the boolean
-
hasPushAccess
public boolean hasPushAccess()
Has push access boolean.- Returns:
- the boolean
-
hasAdminAccess
public boolean hasAdminAccess()
Has admin access boolean.- Returns:
- the boolean
-
getLanguage
public String getLanguage()
Gets the primary programming language.- Returns:
- the language
-
getOwner
public GHUser getOwner() throws IOException
Gets owner.- Returns:
- the owner
- Throws:
IOException- the io exception
-
getIssue
public GHIssue getIssue(int id) throws IOException
Gets issue.- Parameters:
id- the id- Returns:
- the issue
- Throws:
IOException- the io exception
-
createIssue
public GHIssueBuilder createIssue(String title)
Create issue gh issue builder.- Parameters:
title- the title- Returns:
- the gh issue builder
-
getIssues
public List<GHIssue> getIssues(GHIssueState state) throws IOException
Gets issues.- Parameters:
state- the state- Returns:
- the issues
- Throws:
IOException- the io exception
-
getIssues
public List<GHIssue> getIssues(GHIssueState state, GHMilestone milestone) throws IOException
Gets issues.- Parameters:
state- the statemilestone- the milestone- Returns:
- the issues
- Throws:
IOException- the io exception
-
listIssues
@Deprecated public PagedIterable<GHIssue> listIssues(GHIssueState state)
Deprecated.UsequeryIssues()Lists up all the issues in this repository.- Parameters:
state- the state- Returns:
- the paged iterable
-
queryIssues
public GHIssueQueryBuilder.ForRepository queryIssues()
Retrieves issues.- Returns:
- the gh issue query builder
-
createRelease
public GHReleaseBuilder createRelease(String tag)
Create release gh release builder.- Parameters:
tag- the tag- Returns:
- the gh release builder
-
createRef
public GHRef createRef(String name, String sha) throws IOException
Creates a named ref, such as tag, branch, etc.- Parameters:
name- The name of the fully qualified reference (ie: refs/heads/main). If it doesn't start with 'refs' and have at least two slashes, it will be rejected.sha- The SHA1 value to set this reference to- Returns:
- the gh ref
- Throws:
IOException- the io exception
-
getReleases
public List<GHRelease> getReleases() throws IOException
Deprecated.uselistReleases()Gets releases.- Returns:
- the releases
- Throws:
IOException- the io exception
-
getRelease
public GHRelease getRelease(long id) throws IOException
Gets release.- Parameters:
id- the id- Returns:
- the release
- Throws:
IOException- the io exception
-
getReleaseByTagName
public GHRelease getReleaseByTagName(String tag) throws IOException
Gets release by tag name.- Parameters:
tag- the tag- Returns:
- the release by tag name
- Throws:
IOException- the io exception
-
getLatestRelease
public GHRelease getLatestRelease() throws IOException
Gets latest release.- Returns:
- the latest release
- Throws:
IOException- the io exception
-
listReleases
public PagedIterable<GHRelease> listReleases() throws IOException
List releases paged iterable.- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
listTags
public PagedIterable<GHTag> listTags() throws IOException
List tags paged iterable.- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
listLanguages
public Map<String,Long> listLanguages() throws IOException
List languages for the specified repository. The value on the right of a language is the number of bytes of code written in that language. { "C": 78769, "Python": 7769 }- Returns:
- the map
- Throws:
IOException- the io exception
-
getOwnerName
public String getOwnerName()
Gets owner name.- Returns:
- the owner name
-
hasIssues
public boolean hasIssues()
Has issues boolean.- Returns:
- the boolean
-
hasProjects
public boolean hasProjects()
Has projects boolean.- Returns:
- the boolean
-
hasWiki
public boolean hasWiki()
Has wiki boolean.- Returns:
- the boolean
-
isFork
public boolean isFork()
Is fork boolean.- Returns:
- the boolean
-
isArchived
public boolean isArchived()
Is archived boolean.- Returns:
- the boolean
-
isDisabled
public boolean isDisabled()
Is disabled boolean.- Returns:
- the boolean
-
isAllowSquashMerge
public boolean isAllowSquashMerge()
Is allow squash merge boolean.- Returns:
- the boolean
-
isAllowMergeCommit
public boolean isAllowMergeCommit()
Is allow merge commit boolean.- Returns:
- the boolean
-
isAllowRebaseMerge
public boolean isAllowRebaseMerge()
Is allow rebase merge boolean.- Returns:
- the boolean
-
isDeleteBranchOnMerge
public boolean isDeleteBranchOnMerge()
Automatically deleting head branches when pull requests are merged.- Returns:
- the boolean
-
getForks
@Deprecated public int getForks()
Deprecated.usegetForksCount()insteadReturns the number of all forks of this repository. This not only counts direct forks, but also forks of forks, and so on.- Returns:
- the forks
-
getForksCount
public int getForksCount()
Returns the number of all forks of this repository. This not only counts direct forks, but also forks of forks, and so on.- Returns:
- the forks
-
getStargazersCount
public int getStargazersCount()
Gets stargazers count.- Returns:
- the stargazers count
-
isPrivate
public boolean isPrivate()
Is private boolean.- Returns:
- the boolean
-
getVisibility
@Preview(NEBULA) public GHRepository.Visibility getVisibility()
Gets the visibility of the repository.- Returns:
- the visibility
-
hasDownloads
public boolean hasDownloads()
Has downloads boolean.- Returns:
- the boolean
-
hasPages
public boolean hasPages()
Has pages boolean.- Returns:
- the boolean
-
getWatchers
@Deprecated public int getWatchers()
Deprecated.usegetWatchersCount()insteadGets watchers.- Returns:
- the watchers
-
getWatchersCount
public int getWatchersCount()
Gets the count of watchers.- Returns:
- the watchers
-
getOpenIssueCount
public int getOpenIssueCount()
Gets open issue count.- Returns:
- the open issue count
-
getSubscribersCount
public int getSubscribersCount()
Gets subscribers count.- Returns:
- the subscribers count
-
getPushedAt
public Date getPushedAt()
Gets pushed at.- Returns:
- null if the repository was never pushed at.
-
getDefaultBranch
public String getDefaultBranch()
Returns the primary branch you'll configure in the "Admin > Options" config page.- Returns:
- This field is null until the user explicitly configures the default branch.
-
getMasterBranch
@Deprecated public String getMasterBranch()
Deprecated.Renamed togetDefaultBranch()Gets default branch. Name is an artifact of when "master" was the most common default.- Returns:
- the default branch
-
getSize
public int getSize()
Gets size.- Returns:
- the size
-
getCollaborators
@WithBridgeMethods(java.util.Set.class) public GHPersonSet<GHUser> getCollaborators() throws IOException
Gets the collaborators on this repository. This set always appear to include the owner.- Returns:
- the collaborators
- Throws:
IOException- the io exception
-
listCollaborators
public PagedIterable<GHUser> listCollaborators() throws IOException
Lists up the collaborators on this repository.- Returns:
- Users paged iterable
- Throws:
IOException- the io exception
-
listCollaborators
public PagedIterable<GHUser> listCollaborators(GHRepository.CollaboratorAffiliation affiliation) throws IOException
Lists up the collaborators on this repository.- Parameters:
affiliation- Filter users by affiliation- Returns:
- Users paged iterable
- Throws:
IOException- the io exception
-
listAssignees
public PagedIterable<GHUser> listAssignees() throws IOException
Lists all the available assignees to which issues may be assigned.- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
hasAssignee
public boolean hasAssignee(GHUser u) throws IOException
Checks if the given user is an assignee for this repository.- Parameters:
u- the u- Returns:
- the boolean
- Throws:
IOException- the io exception
-
getCollaboratorNames
public Set<String> getCollaboratorNames() throws IOException
Gets the names of the collaborators on this repository. This method deviates from the principle of this library but it works a lot faster thangetCollaborators().- Returns:
- the collaborator names
- Throws:
IOException- the io exception
-
getCollaboratorNames
public Set<String> getCollaboratorNames(GHRepository.CollaboratorAffiliation affiliation) throws IOException
Gets the names of the collaborators on this repository. This method deviates from the principle of this library but it works a lot faster thangetCollaborators().- Parameters:
affiliation- Filter users by affiliation- Returns:
- the collaborator names
- Throws:
IOException- the io exception
-
isCollaborator
public boolean isCollaborator(GHUser user) throws IOException
Checks if the given user is a collaborator for this repository.- Parameters:
user- aGHUser- Returns:
- true if the user is a collaborator for this repository
- Throws:
IOException- the io exception
-
getPermission
public GHPermissionType getPermission(String user) throws IOException
Obtain permission for a given user in this repository.- Parameters:
user- aGHPerson.getLogin()- Returns:
- the permission
- Throws:
IOException- the io exception
-
getPermission
public GHPermissionType getPermission(GHUser u) throws IOException
Obtain permission for a given user in this repository.- Parameters:
u- the user- Returns:
- the permission
- Throws:
IOException- the io exception
-
hasPermission
public boolean hasPermission(String user, GHPermissionType permission) throws IOException
Check if a user has at least the given permission in this repository.- Parameters:
user- aGHPerson.getLogin()permission- the permission to check- Returns:
- true if the user has at least this permission level
- Throws:
IOException- the io exception
-
hasPermission
public boolean hasPermission(GHUser user, GHPermissionType permission) throws IOException
Check if a user has at least the given permission in this repository.- Parameters:
user- the userpermission- the permission to check- Returns:
- true if the user has at least this permission level
- Throws:
IOException- the io exception
-
getTeams
public Set<GHTeam> getTeams() throws IOException
If this repository belongs to an organization, return a set of teams.- Returns:
- the teams
- Throws:
IOException- the io exception
-
addCollaborators
@Deprecated public void addCollaborators(GHOrganization.Permission permission, GHUser... users) throws IOException
Deprecated.#addCollaborators(GHOrganization.RolePermission, GHUser)Add collaborators.- Parameters:
permission- the permission levelusers- the users- Throws:
IOException- the io exception
-
addCollaborators
public void addCollaborators(GHOrganization.RepositoryRole permission, GHUser... users) throws IOException
Add collaborators.- Parameters:
permission- the permission levelusers- the users- Throws:
IOException- the io exception
-
addCollaborators
public void addCollaborators(GHUser... users) throws IOException
Add collaborators.- Parameters:
users- the users- Throws:
IOException- the io exception
-
addCollaborators
public void addCollaborators(Collection<GHUser> users) throws IOException
Add collaborators.- Parameters:
users- the users- Throws:
IOException- the io exception
-
addCollaborators
@Deprecated public void addCollaborators(Collection<GHUser> users, GHOrganization.Permission permission) throws IOException
Deprecated.#addCollaborators(Collection, GHOrganization.RolePermission)Add collaborators.- Parameters:
users- the userspermission- the permission level- Throws:
IOException- the io exception
-
addCollaborators
public void addCollaborators(Collection<GHUser> users, GHOrganization.RepositoryRole permission) throws IOException
Add collaborators.- Parameters:
users- the userspermission- the permission level- Throws:
IOException- the io exception
-
removeCollaborators
public void removeCollaborators(GHUser... users) throws IOException
Remove collaborators.- Parameters:
users- the users- Throws:
IOException- the io exception
-
removeCollaborators
public void removeCollaborators(Collection<GHUser> users) throws IOException
Remove collaborators.- Parameters:
users- the users- Throws:
IOException- the io exception
-
setEmailServiceHook
public void setEmailServiceHook(String address) throws IOException
Sets email service hook.- Parameters:
address- the address- Throws:
IOException- the io exception
-
enableIssueTracker
public void enableIssueTracker(boolean v) throws IOExceptionEnables or disables the issue tracker for this repository.- Parameters:
v- the v- Throws:
IOException- the io exception
-
enableProjects
public void enableProjects(boolean v) throws IOExceptionEnables or disables projects for this repository.- Parameters:
v- the v- Throws:
IOException- the io exception
-
enableWiki
public void enableWiki(boolean v) throws IOExceptionEnables or disables Wiki for this repository.- Parameters:
v- the v- Throws:
IOException- the io exception
-
enableDownloads
public void enableDownloads(boolean v) throws IOExceptionEnable downloads.- Parameters:
v- the v- Throws:
IOException- the io exception
-
renameTo
public void renameTo(String name) throws IOException
Rename this repository.- Parameters:
name- the name- Throws:
IOException- the io exception
-
setDescription
public void setDescription(String value) throws IOException
Sets description.- Parameters:
value- the value- Throws:
IOException- the io exception
-
setHomepage
public void setHomepage(String value) throws IOException
Sets homepage.- Parameters:
value- the value- Throws:
IOException- the io exception
-
setDefaultBranch
public void setDefaultBranch(String value) throws IOException
Sets default branch.- Parameters:
value- the value- Throws:
IOException- the io exception
-
setPrivate
public void setPrivate(boolean value) throws IOExceptionSets private.- Parameters:
value- the value- Throws:
IOException- the io exception
-
setVisibility
@Preview(NEBULA) public void setVisibility(GHRepository.Visibility value) throws IOException
Sets visibility.- Parameters:
value- the value- Throws:
IOException- the io exception
-
allowSquashMerge
public void allowSquashMerge(boolean value) throws IOExceptionAllow squash merge.- Parameters:
value- the value- Throws:
IOException- the io exception
-
allowMergeCommit
public void allowMergeCommit(boolean value) throws IOExceptionAllow merge commit.- Parameters:
value- the value- Throws:
IOException- the io exception
-
allowRebaseMerge
public void allowRebaseMerge(boolean value) throws IOExceptionAllow rebase merge.- Parameters:
value- the value- Throws:
IOException- the io exception
-
deleteBranchOnMerge
public void deleteBranchOnMerge(boolean value) throws IOExceptionAfter pull requests are merged, you can have head branches deleted automatically.- Parameters:
value- the value- Throws:
IOException- the io exception
-
delete
public void delete() throws IOExceptionDeletes this repository.- Throws:
IOException- the io exception
-
archive
public void archive() throws IOExceptionWill archive and this repository as read-only. When a repository is archived, any operation that can change its state is forbidden. This applies symmetrically if trying to unarchive it.When you try to do any operation that modifies a read-only repository, it returns the response:
org.kohsuke.github.HttpException: { "message":"Repository was archived so is read-only.", "documentation_url":"https://developer.github.com/v3/repos/#edit" }- Throws:
IOException- In case of any networking error or error from the server.
-
update
public GHRepository.Updater update()
Creates a builder that can be used to bulk update repository settings.- Returns:
- the repository updater
-
set
public GHRepository.Setter set()
Creates a builder that can be used to bulk update repository settings.- Returns:
- the repository updater
-
listForks
public PagedIterable<GHRepository> listForks()
Lists all the direct forks of this repository, sorted by github api default, currentlyForkSort.NEWEST*.- Returns:
- the paged iterable
-
listForks
public PagedIterable<GHRepository> listForks(GHRepository.ForkSort sort)
Lists all the direct forks of this repository, sorted by the given sort order.- Parameters:
sort- the sort order. If null, defaults to github api default, currentlyForkSort.NEWEST.- Returns:
- the paged iterable
-
fork
public GHRepository fork() throws IOException
Forks this repository as your repository.- Returns:
- Newly forked repository that belong to you.
- Throws:
IOException- the io exception
-
forkTo
public GHRepository forkTo(GHOrganization org) throws IOException
Forks this repository into an organization.- Parameters:
org- the org- Returns:
- Newly forked repository that belong to you.
- Throws:
IOException- the io exception
-
getPullRequest
public GHPullRequest getPullRequest(int i) throws IOException
Retrieves a specified pull request.- Parameters:
i- the- Returns:
- the pull request
- Throws:
IOException- the io exception
-
getPullRequests
public List<GHPullRequest> getPullRequests(GHIssueState state) throws IOException
Retrieves all the pull requests of a particular state.- Parameters:
state- the state- Returns:
- the pull requests
- Throws:
IOException- the io exception- See Also:
#listPullRequests(GHIssueState)
-
listPullRequests
@Deprecated public PagedIterable<GHPullRequest> listPullRequests(GHIssueState state)
Deprecated.Retrieves all the pull requests of a particular state.- Parameters:
state- the state- Returns:
- the paged iterable
-
queryPullRequests
public GHPullRequestQueryBuilder queryPullRequests()
Retrieves pull requests.- Returns:
- the gh pull request query builder
-
createPullRequest
public GHPullRequest createPullRequest(String title, String head, String base, String body) throws IOException
Creates a new pull request.- Parameters:
title- Required. The title of the pull request.head- Required. The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch.base- Required. The name of the branch you want your changes pulled into. This should be an existing branch on the current repository.body- The contents of the pull request. This is the markdown description of a pull request.- Returns:
- the gh pull request
- Throws:
IOException- the io exception
-
createPullRequest
public GHPullRequest createPullRequest(String title, String head, String base, String body, boolean maintainerCanModify) throws IOException
Creates a new pull request. Maintainer's permissions aware.- Parameters:
title- Required. The title of the pull request.head- Required. The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch.base- Required. The name of the branch you want your changes pulled into. This should be an existing branch on the current repository.body- The contents of the pull request. This is the markdown description of a pull request.maintainerCanModify- Indicates whether maintainers can modify the pull request.- Returns:
- the gh pull request
- Throws:
IOException- the io exception
-
createPullRequest
public GHPullRequest createPullRequest(String title, String head, String base, String body, boolean maintainerCanModify, boolean draft) throws IOException
Creates a new pull request. Maintainer's permissions and draft aware.- Parameters:
title- Required. The title of the pull request.head- Required. The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch.base- Required. The name of the branch you want your changes pulled into. This should be an existing branch on the current repository.body- The contents of the pull request. This is the markdown description of a pull request.maintainerCanModify- Indicates whether maintainers can modify the pull request.draft- Indicates whether to create a draft pull request or not.- Returns:
- the gh pull request
- Throws:
IOException- the io exception
-
getHooks
public List<GHHook> getHooks() throws IOException
Retrieves the currently configured hooks.- Returns:
- the hooks
- Throws:
IOException- the io exception
-
getHook
public GHHook getHook(int id) throws IOException
Gets hook.- Parameters:
id- the id- Returns:
- the hook
- Throws:
IOException- the io exception
-
deleteHook
public void deleteHook(int id) throws IOExceptionDeletes hook.- Parameters:
id- the id- Throws:
IOException- the io exception
-
setCompareUsePaginatedCommits
public void setCompareUsePaginatedCommits(boolean value)
SetsgetCompare(String, String)to return aGHComparethat uses a paginated commit list instead of limiting to 250 results. By default,GHComparereturns all commits in the comparison as part of the request, limited to 250 results. More recently GitHub added the ability to return the commits as a paginated query allowing for more than 250 results.- Parameters:
value- true if you want commits returned in paginated form.
-
getCompare
public GHCompare getCompare(String id1, String id2) throws IOException
Gets a comparison between 2 points in the repository. This would be similar to callinggit log id1...id2against a local repository.- Parameters:
id1- an identifier for the first point to compare from, this can be a sha1 ID (for a commit, tag etc) or a direct tag nameid2- an identifier for the second point to compare to. Can be the same as the first point.- Returns:
- the comparison output
- Throws:
IOException- on failure communicating with GitHub
-
getCompare
public GHCompare getCompare(GHCommit id1, GHCommit id2) throws IOException
Gets compare.- Parameters:
id1- the id 1id2- the id 2- Returns:
- the compare
- Throws:
IOException- the io exception
-
getCompare
public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException
Gets compare.- Parameters:
id1- the id 1id2- the id 2- Returns:
- the compare
- Throws:
IOException- the io exception
-
getRefs
public GHRef[] getRefs() throws IOException
Retrieves all refs for the github repository.- Returns:
- an array of GHRef elements corresponding with the refs in the remote repository.
- Throws:
IOException- on failure communicating with GitHub
-
listRefs
public PagedIterable<GHRef> listRefs() throws IOException
Retrieves all refs for the github repository.- Returns:
- paged iterable of all refs
- Throws:
IOException- on failure communicating with GitHub, potentially due to an invalid ref type being requested
-
getRefs
public GHRef[] getRefs(String refType) throws IOException
Retrieves all refs of the given type for the current GitHub repository.- Parameters:
refType- the type of reg to search for e.g.tagsorcommits- Returns:
- an array of all refs matching the request type
- Throws:
IOException- on failure communicating with GitHub, potentially due to an invalid ref type being requested
-
listRefs
public PagedIterable<GHRef> listRefs(String refType) throws IOException
Retrieves all refs of the given type for the current GitHub repository.- Parameters:
refType- the type of reg to search for e.g.tagsorcommits- Returns:
- paged iterable of all refs of the specified type
- Throws:
IOException- on failure communicating with GitHub, potentially due to an invalid ref type being requested
-
getRef
public GHRef getRef(String refName) throws IOException
Retrieve a ref of the given type for the current GitHub repository.- Parameters:
refName- eg: heads/branch- Returns:
- refs matching the request type
- Throws:
IOException- on failure communicating with GitHub, potentially due to an invalid ref type being requested
-
getTagObject
public GHTagObject getTagObject(String sha) throws IOException
Returns the annotated tag object. Only valid if theGHRef.getObject()has aGHRef.GHObject.getType()oftag.- Parameters:
sha- the sha of the tag object- Returns:
- the annotated tag object
- Throws:
IOException- the io exception
-
getTree
public GHTree getTree(String sha) throws IOException
Retrieve a tree of the given type for the current GitHub repository.- Parameters:
sha- sha number or branch name ex: "main"- Returns:
- refs matching the request type
- Throws:
IOException- on failure communicating with GitHub, potentially due to an invalid tree type being requested
-
createTree
public GHTreeBuilder createTree()
Create tree gh tree builder.- Returns:
- the gh tree builder
-
getTreeRecursive
public GHTree getTreeRecursive(String sha, int recursive) throws IOException
Retrieves the tree for the current GitHub repository, recursively as described in here: https://developer.github.com/v3/git/trees/#get-a-tree-recursively- Parameters:
sha- sha number or branch name ex: "main"recursive- use 1- Returns:
- the tree recursive
- Throws:
IOException- on failure communicating with GitHub, potentially due to an invalid tree type being requested
-
getBlob
public GHBlob getBlob(String blobSha) throws IOException
Obtains the metadata & the content of a blob.This method retrieves the whole content in memory, so beware when you are dealing with large BLOB.
- Parameters:
blobSha- the blob sha- Returns:
- the blob
- Throws:
IOException- the io exception- See Also:
- Get a blob,
#readBlob(String)
-
createBlob
public GHBlobBuilder createBlob()
Create blob gh blob builder.- Returns:
- the gh blob builder
-
readBlob
public InputStream readBlob(String blobSha) throws IOException
Reads the content of a blob as a stream for better efficiency.- Parameters:
blobSha- the blob sha- Returns:
- the input stream
- Throws:
IOException- the io exception- See Also:
- Get a blob,
#getBlob(String)
-
getCommit
public GHCommit getCommit(String sha1) throws IOException
Gets a commit object in this repository.- Parameters:
sha1- the sha 1- Returns:
- the commit
- Throws:
IOException- the io exception
-
createCommit
public GHCommitBuilder createCommit()
Create commit gh commit builder.- Returns:
- the gh commit builder
-
listCommits
public PagedIterable<GHCommit> listCommits()
Lists all the commits.- Returns:
- the paged iterable
-
queryCommits
public GHCommitQueryBuilder queryCommits()
Search commits by specifying filters through a builder pattern.- Returns:
- the gh commit query builder
-
listCommitComments
public PagedIterable<GHCommitComment> listCommitComments()
Lists up all the commit comments in this repository.- Returns:
- the paged iterable
-
listCommitComments
public PagedIterable<GHCommitComment> listCommitComments(String commitSha)
Lists all comments on a specific commit.- Parameters:
commitSha- the hash of the commit- Returns:
- the paged iterable
-
getLicense
public GHLicense getLicense() throws IOException
Gets the basic license details for the repository.- Returns:
- null if there's no license.
- Throws:
IOException- as usual but also if you don't use the preview connector
-
getLicenseContent
public GHContent getLicenseContent() throws IOException
Retrieves the contents of the repository's license file - makes an additional API call.- Returns:
- details regarding the license contents, or null if there's no license.
- Throws:
IOException- as usual but also if you don't use the preview connector
-
listCommitStatuses
public PagedIterable<GHCommitStatus> listCommitStatuses(String sha1) throws IOException
/** Lists all the commit statuses attached to the given commit, newer ones first.- Parameters:
sha1- the sha 1- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
getLastCommitStatus
public GHCommitStatus getLastCommitStatus(String sha1) throws IOException
Gets the last status of this commit, which is what gets shown in the UI.- Parameters:
sha1- the sha 1- Returns:
- the last commit status
- Throws:
IOException- the io exception
-
getCheckRuns
@Preview(ANTIOPE) public PagedIterable<GHCheckRun> getCheckRuns(String ref) throws IOException
Gets check runs for given ref.- Parameters:
ref- ref- Returns:
- check runs for given ref
- Throws:
IOException- the io exception- See Also:
- List check runs for a specific ref
-
getCheckRuns
@Preview(ANTIOPE) public PagedIterable<GHCheckRun> getCheckRuns(String ref, Map<String,Object> params) throws IOException
Gets check runs for given ref which validate provided parameters- Parameters:
ref- the Git referenceparams- a map of parameters to filter check runs- Returns:
- check runs for the given ref
- Throws:
IOException- the io exception- See Also:
- List check runs for a specific ref
-
createCommitStatus
public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description, String context) throws IOException
Creates a commit status.- Parameters:
sha1- the sha 1state- the statetargetUrl- Optional parameter that points to the URL that has more details.description- Optional short description.context- Optional commit status context.- Returns:
- the gh commit status
- Throws:
IOException- the io exception
-
createCommitStatus
public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description) throws IOException
Create commit status gh commit status.- Parameters:
sha1- the sha 1state- the statetargetUrl- the target urldescription- the description- Returns:
- the gh commit status
- Throws:
IOException- the io exception- See Also:
#createCommitStatus(String, GHCommitState,String,String,String)
-
createCheckRun
@Preview(ANTIOPE) @NonNull public GHCheckRunBuilder createCheckRun(@NonNull String name, @NonNull String headSHA)
Creates a check run for a commit.- Parameters:
name- an identifier for the runheadSHA- the commit hash- Returns:
- a builder which you should customize, then call
GHCheckRunBuilder.create()
-
updateCheckRun
@Preview(BAPTISTE) @NonNull public GHCheckRunBuilder updateCheckRun(long checkId)
Updates an existing check run.- Parameters:
checkId- the existing checkId- Returns:
- a builder which you should customize, then call
GHCheckRunBuilder.create()
-
listEvents
public PagedIterable<GHEventInfo> listEvents() throws IOException
Lists repository events.- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
listLabels
public PagedIterable<GHLabel> listLabels() throws IOException
Lists labels in this repository.https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
getLabel
public GHLabel getLabel(String name) throws IOException
Gets label.- Parameters:
name- the name- Returns:
- the label
- Throws:
IOException- the io exception
-
createLabel
public GHLabel createLabel(String name, String color) throws IOException
Create label gh label.- Parameters:
name- the namecolor- the color- Returns:
- the gh label
- Throws:
IOException- the io exception
-
createLabel
public GHLabel createLabel(String name, String color, String description) throws IOException
Description is still in preview.- Parameters:
name- the namecolor- the colordescription- the description- Returns:
- gh label
- Throws:
IOException- the io exception
-
listInvitations
public PagedIterable<GHInvitation> listInvitations()
Lists all the invitations.- Returns:
- the paged iterable
-
listSubscribers
public PagedIterable<GHUser> listSubscribers()
Lists all the subscribers (aka watchers.)https://developer.github.com/v3/activity/watching/
- Returns:
- the paged iterable
-
listStargazers
public PagedIterable<GHUser> listStargazers()
Lists all the users who have starred this repo based on the old version of the API. For additional information, like date when the repository was starred, seelistStargazers2()- Returns:
- the paged iterable
-
listStargazers2
public PagedIterable<GHStargazer> listStargazers2()
Lists all the users who have starred this repo based on new version of the API, having extended information like the time when the repository was starred. For compatibility with the old API seelistStargazers()- Returns:
- the paged iterable
-
createHook
public GHHook createHook(String name, Map<String,String> config, Collection<GHEvent> events, boolean active) throws IOException
See https://api.github.com/hooks for possible names and their configuration scheme. TODO: produce type-safe binding- Parameters:
name- Type of the hook to be created. See https://api.github.com/hooks for possible names.config- The configuration hash.events- Can be null. Types of events to hook into.active- the active- Returns:
- the gh hook
- Throws:
IOException- the io exception
-
createWebHook
public GHHook createWebHook(URL url, Collection<GHEvent> events) throws IOException
Create web hook gh hook.- Parameters:
url- the urlevents- the events- Returns:
- the gh hook
- Throws:
IOException- the io exception
-
createWebHook
public GHHook createWebHook(URL url) throws IOException
Create web hook gh hook.- Parameters:
url- the url- Returns:
- the gh hook
- Throws:
IOException- the io exception
-
getPostCommitHooks
@Deprecated public Set<URL> getPostCommitHooks()
Deprecated.Returns a set that represents the post-commit hook URLs. The returned set is live, and changes made to them are reflected to GitHub.- Returns:
- the post commit hooks
-
getBranches
public Map<String,GHBranch> getBranches() throws IOException
Gets branches by their names.- Returns:
- the branches
- Throws:
IOException- the io exception
-
getBranch
public GHBranch getBranch(String name) throws IOException
Gets branch.- Parameters:
name- the name- Returns:
- the branch
- Throws:
IOException- the io exception
-
getMilestones
public Map<Integer,GHMilestone> getMilestones() throws IOException
Deprecated.Gets milestones.- Returns:
- the milestones
- Throws:
IOException- the io exception
-
listMilestones
public PagedIterable<GHMilestone> listMilestones(GHIssueState state)
Lists up all the milestones in this repository.- Parameters:
state- the state- Returns:
- the paged iterable
-
getMilestone
public GHMilestone getMilestone(int number) throws IOException
Gets milestone.- Parameters:
number- the number- Returns:
- the milestone
- Throws:
IOException- the io exception
-
getFileContent
public GHContent getFileContent(String path) throws IOException
Gets file content.- Parameters:
path- the path- Returns:
- the file content
- Throws:
IOException- the io exception
-
getFileContent
public GHContent getFileContent(String path, String ref) throws IOException
Gets file content.- Parameters:
path- the pathref- the ref- Returns:
- the file content
- Throws:
IOException- the io exception
-
getDirectoryContent
public List<GHContent> getDirectoryContent(String path) throws IOException
Gets directory content.- Parameters:
path- the path- Returns:
- the directory content
- Throws:
IOException- the io exception
-
getDirectoryContent
public List<GHContent> getDirectoryContent(String path, String ref) throws IOException
Gets directory content.- Parameters:
path- the pathref- the ref- Returns:
- the directory content
- Throws:
IOException- the io exception
-
getReadme
public GHContent getReadme() throws IOException
https://developer.github.com/v3/repos/contents/#get-the-readme- Returns:
- the readme
- Throws:
IOException- the io exception
-
getRepoVariable
public GHRepositoryVariable getRepoVariable(String name) throws IOException
Gets a variable by name- Parameters:
name- the variable name (e.g. test-variable)- Returns:
- the variable
- Throws:
IOException- the io exception
-
createContent
public GHContentBuilder createContent()
Creates a new content, or update an existing content.- Returns:
- the gh content builder
-
createContent
@Deprecated public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException
Deprecated.UsecreateContent().- Parameters:
content- the contentcommitMessage- the commit messagepath- the path- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
createContent
@Deprecated public GHContentUpdateResponse createContent(String content, String commitMessage, String path, String branch) throws IOException
Deprecated.UsecreateContent().- Parameters:
content- the contentcommitMessage- the commit messagepath- the pathbranch- the branch- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
createContent
@Deprecated public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path) throws IOException
Deprecated.UsecreateContent().- Parameters:
contentBytes- the content bytescommitMessage- the commit messagepath- the path- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
createContent
@Deprecated public GHContentUpdateResponse createContent(byte[] contentBytes, String commitMessage, String path, String branch) throws IOException
Deprecated.UsecreateContent().- Parameters:
contentBytes- the content bytescommitMessage- the commit messagepath- the pathbranch- the branch- Returns:
- the gh content update response
- Throws:
IOException- the io exception
-
createMilestone
public GHMilestone createMilestone(String title, String description) throws IOException
Create milestone gh milestone.- Parameters:
title- the titledescription- the description- Returns:
- the gh milestone
- Throws:
IOException- the io exception
-
addDeployKey
public GHDeployKey addDeployKey(String title, String key) throws IOException
Add deploy key gh deploy key.- Parameters:
title- the titlekey- the key- Returns:
- the gh deploy key
- Throws:
IOException- the io exception
-
addDeployKey
public GHDeployKey addDeployKey(String title, String key, boolean readOnly) throws IOException
Add deploy key gh deploy key.- Parameters:
title- the titlekey- the keyreadOnly- read-only ability of the key- Returns:
- the gh deploy key
- Throws:
IOException- the io exception
-
getDeployKeys
public List<GHDeployKey> getDeployKeys() throws IOException
Gets deploy keys.- Returns:
- the deploy keys
- Throws:
IOException- the io exception
-
getSource
public GHRepository getSource() throws IOException
Forked repositories have a 'source' attribute that specifies the ultimate source of the forking chain.- Returns:
GHRepositorythat points to the root repository where this repository is forked (indirectly or directly) from. Otherwise null.- Throws:
IOException- the io exception- See Also:
#getParent()
-
getParent
public GHRepository getParent() throws IOException
Forked repositories have a 'parent' attribute that specifies the repository this repository is directly forked from. If we keep traversinggetParent()until it returns null, that isgetSource().- Returns:
GHRepositorythat points to the repository where this repository is forked directly from. Otherwise null.- Throws:
IOException- the io exception- See Also:
#getSource()
-
subscribe
public GHSubscription subscribe(boolean subscribed, boolean ignored) throws IOException
Subscribes to this repository to get notifications.- Parameters:
subscribed- the subscribedignored- the ignored- Returns:
- the gh subscription
- Throws:
IOException- the io exception
-
getSubscription
public GHSubscription getSubscription() throws IOException
Returns the current subscription.- Returns:
- null if no subscription exists.
- Throws:
IOException- the io exception
-
listCodeownersErrors
public List<GHCodeownersError> listCodeownersErrors() throws IOException
List errors in theCODEOWNERSfile. Note that GitHub skips lines with incorrect syntax; these are reported in the web interface, but not in the API call which this library uses.- Returns:
- the list of errors
- Throws:
IOException- the io exception
-
listContributors
public PagedIterable<GHRepository.Contributor> listContributors() throws IOException
List contributors paged iterable.- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
getStatistics
public GHRepositoryStatistics getStatistics()
Returns the statistics for this repository.- Returns:
- the statistics
-
createProject
public GHProject createProject(String name, String body) throws IOException
Create a project for this repository.- Parameters:
name- the namebody- the body- Returns:
- the gh project
- Throws:
IOException- the io exception
-
listProjects
public PagedIterable<GHProject> listProjects(GHProject.ProjectStateFilter status) throws IOException
Returns the projects for this repository.- Parameters:
status- The status filter (all, open or closed).- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
listProjects
public PagedIterable<GHProject> listProjects() throws IOException
Returns open projects for this repository.- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
renderMarkdown
public Reader renderMarkdown(String text, MarkdownMode mode) throws IOException
Render a Markdown document.In GFM mode, issue numbers and user mentions are linked accordingly.
- Parameters:
text- the textmode- the mode- Returns:
- the reader
- Throws:
IOException- the io exception- See Also:
GitHub#renderMarkdown(String)
-
listNotifications
public GHNotificationStream listNotifications()
List all the notifications in a repository for the current user.- Returns:
- the gh notification stream
-
getViewTraffic
public GHRepositoryViewTraffic getViewTraffic() throws IOException
- Returns:
- the view traffic
- Throws:
IOException- the io exception
-
getCloneTraffic
public GHRepositoryCloneTraffic getCloneTraffic() throws IOException
- Returns:
- the clone traffic
- Throws:
IOException- the io exception
-
equals
public boolean equals(Object obj)
Equals.
-
listIssueEvents
public PagedIterable<GHIssueEvent> listIssueEvents() throws IOException
Get all issue events for this repository. See https://developer.github.com/v3/issues/events/#list-events-for-a-repository- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
getIssueEvent
public GHIssueEvent getIssueEvent(long id) throws IOException
Get a single issue event. See https://developer.github.com/v3/issues/events/#get-a-single-event- Parameters:
id- the id- Returns:
- the issue event
- Throws:
IOException- the io exception
-
listWorkflows
public PagedIterable<GHWorkflow> listWorkflows()
Lists all the workflows of this repository.- Returns:
- the paged iterable
-
getWorkflow
public GHWorkflow getWorkflow(long id) throws IOException
Gets a workflow by id.- Parameters:
id- the id of the workflow run- Returns:
- the workflow run
- Throws:
IOException- the io exception
-
getWorkflow
public GHWorkflow getWorkflow(String nameOrId) throws IOException
Gets a workflow by name of the file.- Parameters:
nameOrId- either the name of the file (e.g. my-workflow.yml) or the id as a string- Returns:
- the workflow run
- Throws:
IOException- the io exception
-
queryWorkflowRuns
public GHWorkflowRunQueryBuilder queryWorkflowRuns()
Retrieves workflow runs.- Returns:
- the workflow run query builder
-
getWorkflowRun
public GHWorkflowRun getWorkflowRun(long id) throws IOException
Gets a workflow run.- Parameters:
id- the id of the workflow run- Returns:
- the workflow run
- Throws:
IOException- the io exception
-
listArtifacts
public PagedIterable<GHArtifact> listArtifacts()
Lists all the artifacts of this repository.- Returns:
- the paged iterable
-
getArtifact
public GHArtifact getArtifact(long id) throws IOException
Gets an artifact by id.- Parameters:
id- the id of the artifact- Returns:
- the artifact
- Throws:
IOException- the io exception
-
getWorkflowJob
public GHWorkflowJob getWorkflowJob(long id) throws IOException
Gets a job from a workflow run by id.- Parameters:
id- the id of the job- Returns:
- the job
- Throws:
IOException- the io exception
-
getPublicKey
public GHRepositoryPublicKey getPublicKey() throws IOException
Gets the public key for the given repo.- Returns:
- the public key
- Throws:
IOException- the io exception
-
listTopics
public List<String> listTopics() throws IOException
Return the topics for this repository. See https://developer.github.com/v3/repos/#list-all-topics-for-a-repository- Returns:
- the list
- Throws:
IOException- the io exception
-
setTopics
public void setTopics(List<String> topics) throws IOException
Set the topics for this repository. See https://developer.github.com/v3/repos/#replace-all-topics-for-a-repository- Parameters:
topics- the topics- Throws:
IOException- the io exception
-
createSecret
public void createSecret(String secretName, String encryptedValue, String publicKeyId) throws IOException
Set/Update a repository secret "https://docs.github.com/rest/reference/actions#create-or-update-a-repository-secret"- Parameters:
secretName- the name of the secretencryptedValue- The encrypted value for this secretpublicKeyId- The id of the Public Key used to encrypt this secret- Throws:
IOException- the io exception
-
createTag
public GHTagObject createTag(String tag, String message, String object, String type) throws IOException
Create a tag. See https://developer.github.com/v3/git/tags/#create-a-tag-object- Parameters:
tag- The tag's name.message- The tag message.object- The SHA of the git object this is tagging.type- The type of the object we're tagging: "commit", "tree" or "blob".- Returns:
- The newly created tag.
- Throws:
IOException- Signals that an I/O exception has occurred.
-
readZip
public <T> T readZip(InputStreamFunction<T> streamFunction, String ref) throws IOException
Streams a zip archive of the repository, optionally at a givenref.- Type Parameters:
T- the type of result- Parameters:
streamFunction- TheInputStreamFunctionthat will process the streamref- ifnullthe repository's default branch, usuallymain,- Returns:
- the result of reading the stream.
- Throws:
IOException- The IO exception.
-
readTar
public <T> T readTar(InputStreamFunction<T> streamFunction, String ref) throws IOException
Streams a tar archive of the repository, optionally at a givenref.- Type Parameters:
T- the type of result- Parameters:
streamFunction- TheInputStreamFunctionthat will process the streamref- ifnullthe repository's default branch, usuallymain,- Returns:
- the result of reading the stream.
- Throws:
IOException- The IO exception.
-
dispatch
public <T> void dispatch(String eventType, @Nullable T clientPayload) throws IOException
Create a repository dispatch event, which can be used to start a workflow/action from outside github, as described on https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event- Type Parameters:
T- type of client payload- Parameters:
eventType- the eventTypeclientPayload- a custom payload , can be nullable- Throws:
IOException- the io exception
-
star
public void star() throws IOExceptionStar a repository.- Throws:
IOException- the io exception
-
unstar
public void unstar() throws IOExceptionUnstar a repository.- Throws:
IOException- the io exception
-
getRoot
@Deprecated public GitHub getRoot()
Deprecated.For access to theGitHubinstance, use a local copy instead of pulling it out of objects.Get the rootGitHubinstance for this object.- Returns:
- the root
GitHubinstance
-
-