java.lang.Object
org.kohsuke.github.GHObject
org.kohsuke.github.GHRepository
A repository on GitHub.
- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Affiliation of a repository collaborator.static class
The type Contributor.static enum
Sort orders for listing forks.static class
AGHRepositoryBuilder
that allows multiple properties to be updated per request.static class
AGHRepositoryBuilder
that allows multiple properties to be updated per request.static enum
Visibility of a repository. -
Field Summary
Fields inherited from class org.kohsuke.github.GHObject
responseHeaderFields
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCollaborators
(Collection<GHUser> users) Add collaborators.void
addCollaborators
(Collection<GHUser> users, GHOrganization.RepositoryRole permission) Add collaborators.void
addCollaborators
(GHOrganization.RepositoryRole permission, GHUser... users) Add collaborators.void
addCollaborators
(GHUser... users) Add collaborators.addDeployKey
(String title, String key) Add deploy key gh deploy key.addDeployKey
(String title, String key, boolean readOnly) Add deploy key gh deploy key.void
allowForking
(boolean value) Allow private fork.void
allowMergeCommit
(boolean value) Allow merge commit.void
allowRebaseMerge
(boolean value) Allow rebase merge.void
allowSquashMerge
(boolean value) Allow squash merge.void
archive()
Will archive and this repository as read-only.Create blob gh blob builder.createCheckRun
(String name, String headSHA) Creates a check run for a commit.Create commit gh commit builder.createCommitStatus
(String sha1, GHCommitState state, String targetUrl, String description) Create commit status gh commit status.createCommitStatus
(String sha1, GHCommitState state, String targetUrl, String description, String context) Creates a commit status.Creates a new content, or update an existing content.createDeployment
(String ref) Create deployment gh deployment builder.createHook
(String name, Map<String, String> config, Collection<GHEvent> events, boolean active) See https://api.github.com/hooks for possible names and their configuration scheme.createIssue
(String title) Create issue gh issue builder.createLabel
(String name, String color) Create label gh label.createLabel
(String name, String color, String description) Description is still in preview.createMilestone
(String title, String description) Create milestone gh milestone.createProject
(String name, String body) Create a project for this repository.createPullRequest
(String title, String head, String base, String body) Creates a new pull request.createPullRequest
(String title, String head, String base, String body, boolean maintainerCanModify) Creates a new pull request.createPullRequest
(String title, String head, String base, String body, boolean maintainerCanModify, boolean draft) Creates a new pull request.Creates a named ref, such as tag, branch, etc.createRelease
(String tag) Create release gh release builder.void
createSecret
(String secretName, String encryptedValue, String publicKeyId) Set/Update a repository secret "https://docs.github.com/rest/reference/actions#create-or-update-a-repository-secret"Create a tag.Create tree gh tree builder.void
createVariable
(String name, String value) Create a repository variable.createWebHook
(URL url) Create web hook gh hook.createWebHook
(URL url, Collection<GHEvent> events) Create web hook gh hook.void
delete()
Deletes this repository.void
deleteBranchOnMerge
(boolean value) After pull requests are merged, you can have head branches deleted automatically.void
deleteHook
(int id) Deletes hook.<T> void
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-eventvoid
enableDownloads
(boolean v) Enable downloads.void
enableIssueTracker
(boolean v) Enables or disables the issue tracker for this repository.void
enableProjects
(boolean v) Enables or disables projects for this repository.void
enableWiki
(boolean v) Enables or disables Wiki for this repository.boolean
Equals.fork()
Forks this repository as your repository.forkTo
(GHOrganization org) Forks this repository into an organization.getArtifact
(long id) Gets an artifact by id.Obtains the metadata & the content of a blob.Gets branch.Gets branches by their names.getCheckRuns
(String ref) Gets check runs for given ref.getCheckRuns
(String ref, Map<String, Object> params) Gets check runs for given ref which validate provided parametersGets the names of the collaborators on this repository.getCollaboratorNames
(GHRepository.CollaboratorAffiliation affiliation) Gets the names of the collaborators on this repository.Gets the collaborators on this repository.Gets a commit object in this repository.getCompare
(String id1, String id2) Gets a comparison between 2 points in the repository.getCompare
(GHBranch id1, GHBranch id2) Gets compare.getCompare
(GHCommit id1, GHCommit id2) Gets compare.Returns the primary branch you'll configure in the "Admin > Options" config page.Gets deploy keys.getDeployment
(long id) Obtains a singleGHDeployment
by its ID.Gets description.getDirectoryContent
(String path) Gets directory content.getDirectoryContent
(String path, String ref) Gets directory content.getFileContent
(String path) Gets file content.getFileContent
(String path, String ref) Gets file content.int
Returns the number of all forks of this repository.Full repository name including the owner or organization.Gets the git:// URL to this repository, such as "git://github.com/kohsuke/jenkins.git" This URL is read-only.Gets homepage.getHook
(int id) Gets hook.getHooks()
Retrieves the currently configured hooks.Gets the html url.Gets the HTTPS URL to this repository, such as "https://github.com/kohsuke/jenkins.git" This URL is read-only.getIssue
(int id) Gets issue.getIssueEvent
(long id) Get a single issue event.getIssues
(GHIssueState state) Gets issues.getIssues
(GHIssueState state, GHMilestone milestone) Gets issues.Gets label.Gets the primary programming language.getLastCommitStatus
(String sha1) Gets the last status of this commit, which is what gets shown in the UI.Gets latest release.Gets the basic license details for the repository.Retrieves the contents of the repository's license file - makes an additional API call.getMilestone
(int number) Gets milestone.Gets the Mirror URL to access this repository: https://github.com/apache/tomee mirrored from git://git.apache.org/tomee.gitgetName()
Short repository name without the owner.Gets node id.int
Gets open issue count.getOwner()
Gets owner.Gets owner name.Forked repositories have a 'parent' attribute that specifies the repository this repository is directly forked from.getPermission
(String user) Obtain permission for a given user in this repository.Obtain permission for a given user in this repository.Gets the public key for the given repo.getPullRequest
(int i) Retrieves a specified pull request.Gets pushed at.https://developer.github.com/v3/repos/contents/#get-the-readmeRetrieve a ref of the given type for the current GitHub repository.GHRef[]
getRefs()
Retrieves all refs for the github repository.GHRef[]
Retrieves all refs of the given type for the current GitHub repository.getRelease
(long id) Gets release.Gets release by tag name.int
getSize()
Gets size.Forked repositories have a 'source' attribute that specifies the ultimate source of the forking chain.Gets the SSH URL to access this repository, such as git@github.com:rails/rails.gitint
Gets stargazers count.Returns the statistics for this repository.int
Gets subscribers count.Returns the current subscription.Gets the Subversion URL to access this repository: https://github.com/rails/railsgetTagObject
(String sha) Returns the annotated tag object.getTeams()
If this repository belongs to an organization, return a set of teams.Get Repository template was the repository created from.Get the top 10 popular contents over the last 14 days as described on https://docs.github.com/en/rest/metrics/traffic?Get the top 10 referrers over the last 14 days as described on https://docs.github.com/en/rest/metrics/traffic?Retrieve a tree of the given type for the current GitHub repository.getTreeRecursive
(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-recursivelygetVariable
(String name) Gets a repository variable.Gets the visibility of the repository.int
Gets the count of watchers.getWorkflow
(long id) Gets a workflow by id.getWorkflow
(String nameOrId) Gets a workflow by name of the file.getWorkflowJob
(long id) Gets a job from a workflow run by id.getWorkflowRun
(long id) Gets a workflow run.boolean
Has admin access boolean.boolean
Checks if the given user is an assignee for this repository.boolean
Has downloads boolean.int
hashCode()
Hash code.boolean
Has issues boolean.boolean
hasPages()
Has pages boolean.boolean
hasPermission
(String user, GHPermissionType permission) Check if a user has at least the given permission in this repository.boolean
hasPermission
(GHUser user, GHPermissionType permission) Check if a user has at least the given permission in this repository.boolean
Has projects boolean.boolean
Has pull access boolean.boolean
Has push access boolean.boolean
hasWiki()
Has wiki boolean.boolean
Is allow private forksboolean
Is allow merge commit boolean.boolean
Is allow rebase merge boolean.boolean
Is allow squash merge boolean.boolean
Is archived boolean.boolean
isCollaborator
(GHUser user) Checks if the given user is a collaborator for this repository.boolean
Automatically deleting head branches when pull requests are merged.boolean
Is disabled boolean.boolean
isFork()
Is fork boolean.boolean
Is private boolean.boolean
Is template boolean.boolean
Check, if vulnerability alerts are enabled for this repository (https://docs.github.com/en/rest/repos/repos?Lists all the artifacts of this repository.Lists all the available assignees to which issues may be assigned.List errors in theCODEOWNERS
file.Lists up the collaborators on this repository.listCollaborators
(GHRepository.CollaboratorAffiliation affiliation) Lists up the collaborators on this repository.Lists up all the commit comments in this repository.listCommitComments
(String commitSha) Lists all comments on a specific commit.Lists all the commits.listCommitStatuses
(String sha1) /** Lists all the commit statuses attached to the given commit, newer ones first.List contributors paged iterable.listDeployments
(String sha, String ref, String task, String environment) List deployments paged iterable.Lists repository events.Lists all the direct forks of this repository, sorted by github api default, currentlyForkSort.NEWEST
*.Lists all the direct forks of this repository, sorted by the given sort order.Lists all the invitations.Get all issue events for this repository.Lists labels in this repository.List languages for the specified repository.listMilestones
(GHIssueState state) Lists up all the milestones in this repository.List all the notifications in a repository for the current user.Returns open projects for this repository.Returns the projects for this repository.listRefs()
Retrieves all refs for the github repository.Retrieves all refs of the given type for the current GitHub repository.List releases paged iterable.listRulesForBranch
(String branch) Get all active rules that apply to the specified branch (https://docs.github.com/en/rest/repos/rules?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.Deprecated.Lists all the subscribers (aka watchers.)listTags()
List tags paged iterable.Return the topics for this repository.Lists all the workflows of this repository.Search commits by specifying filters through a builder pattern.Retrieves issues.Retrieves pull requests.Retrieves workflow runs.Reads the content of a blob as a stream for better efficiency.<T> T
readTar
(InputStreamFunction<T> streamFunction, String ref) Streams a tar archive of the repository, optionally at a givenref
.<T> T
readZip
(InputStreamFunction<T> streamFunction, String ref) Streams a zip archive of the repository, optionally at a givenref
.void
removeCollaborators
(Collection<GHUser> users) Remove collaborators.void
removeCollaborators
(GHUser... users) Remove collaborators.void
Rename this repository.renderMarkdown
(String text, MarkdownMode mode) Render a Markdown document.Retrieves pull requests according to search terms.set()
Creates a builder that can be used to bulk update repository settings.void
setCompareUsePaginatedCommits
(boolean value) SetsgetCompare(String, String)
to return aGHCompare
that uses a paginated commit list instead of limiting to 250 results.void
setDefaultBranch
(String value) Sets default branch.void
setDescription
(String value) Sets description.void
setEmailServiceHook
(String address) Sets email service hook.void
setHomepage
(String value) Sets homepage.void
setPrivate
(boolean value) Sets private.void
Set the topics for this repository.void
Sets visibility.void
star()
Star a repository.subscribe
(boolean subscribed, boolean ignored) Subscribes to this repository to get notifications.Sync this repository fork branchvoid
unstar()
Unstar a repository.update()
Creates a builder that can be used to bulk update repository settings.updateCheckRun
(long checkId) Updates an existing check run.Methods inherited from class org.kohsuke.github.GHObject
getCreatedAt, getId, getResponseHeaderFields, getUpdatedAt, getUrl, setResponseHeaderFields, toString
-
Constructor Details
-
GHRepository
public GHRepository()Create default GHRepository instance
-
-
Method Details
-
createDeployment
Create deployment gh deployment builder.- Parameters:
ref
- the ref- Returns:
- the gh deployment builder
-
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
Obtains a singleGHDeployment
by its ID.- Parameters:
id
- the id- Returns:
- the deployment
- Throws:
IOException
- the io exception
-
getNodeId
Gets node id. -
getDescription
Gets description.- Returns:
- the description
-
getHomepage
Gets homepage.- Returns:
- the homepage
-
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
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
-
getSvnUrl
Gets the Subversion URL to access this repository: https://github.com/rails/rails- Returns:
- the svn url
-
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
Gets the SSH URL to access this repository, such as git@github.com:rails/rails.git- Returns:
- the ssh url
-
getHtmlUrl
Gets the html url.- Returns:
- the html url
-
getName
Short repository name without the owner. For example 'jenkins' in case of http://github.com/jenkinsci/jenkins- Returns:
- the name
-
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
Gets the primary programming language.- Returns:
- the language
-
getOwner
Gets owner.- Returns:
- the owner
- Throws:
IOException
- the io exception
-
getIssue
Gets issue.- Parameters:
id
- the id- Returns:
- the issue
- Throws:
IOException
- the io exception
-
createIssue
Create issue gh issue builder.- Parameters:
title
- the title- Returns:
- the gh issue builder
-
getIssues
Gets issues.- Parameters:
state
- the state- Returns:
- the issues
- Throws:
IOException
- the io exception
-
getIssues
Gets issues.- Parameters:
state
- the statemilestone
- the milestone- Returns:
- the issues
- Throws:
IOException
- the io exception
-
queryIssues
Retrieves issues.- Returns:
- the gh issue query builder
-
createRelease
Create release gh release builder.- Parameters:
tag
- the tag- Returns:
- the gh release builder
-
createRef
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
-
getRelease
Gets release.- Parameters:
id
- the id- Returns:
- the release
- Throws:
IOException
- the io exception
-
getReleaseByTagName
Gets release by tag name.- Parameters:
tag
- the tag- Returns:
- the release by tag name
- Throws:
IOException
- the io exception
-
getLatestRelease
Gets latest release.- Returns:
- the latest release
- Throws:
IOException
- the io exception
-
listReleases
List releases paged iterable.- Returns:
- the paged iterable
- Throws:
IOException
- the io exception
-
listTags
List tags paged iterable.- Returns:
- the paged iterable
- Throws:
IOException
- the io exception
-
listLanguages
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
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
-
isAllowForking
public boolean isAllowForking()Is allow private forks- Returns:
- the boolean
-
isDeleteBranchOnMerge
public boolean isDeleteBranchOnMerge()Automatically deleting head branches when pull requests are merged.- Returns:
- the boolean
-
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
Gets the visibility of the repository.- Returns:
- the visibility
-
isTemplate
public boolean isTemplate()Is template boolean.- Returns:
- the boolean
-
hasDownloads
public boolean hasDownloads()Has downloads boolean.- Returns:
- the boolean
-
hasPages
public boolean hasPages()Has pages boolean.- Returns:
- the boolean
-
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
Gets pushed at.- Returns:
- null if the repository was never pushed at.
-
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.
-
getTemplateRepository
Get Repository template was the repository created from.- Returns:
- the repository template
-
getSize
public int getSize()Gets size.- Returns:
- the size
-
getCollaborators
Gets the collaborators on this repository. This set always appear to include the owner.- Returns:
- the collaborators
- Throws:
IOException
- the io exception
-
listCollaborators
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
Lists all the available assignees to which issues may be assigned.- Returns:
- the paged iterable
- Throws:
IOException
- the io exception
-
hasAssignee
Checks if the given user is an assignee for this repository.- Parameters:
u
- the u- Returns:
- the boolean
- Throws:
IOException
- the io exception
-
getCollaboratorNames
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
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
Obtain permission for a given user in this repository.- Parameters:
user
- aGHPerson.getLogin()
- Returns:
- the permission
- Throws:
IOException
- the io exception
-
getPermission
Obtain permission for a given user in this repository.- Parameters:
u
- the user- Returns:
- the permission
- Throws:
IOException
- the io exception
-
hasPermission
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
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
If this repository belongs to an organization, return a set of teams.- Returns:
- the teams
- 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
Add collaborators.- Parameters:
users
- the users- Throws:
IOException
- the io exception
-
addCollaborators
Add collaborators.- Parameters:
users
- the users- 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
Remove collaborators.- Parameters:
users
- the users- Throws:
IOException
- the io exception
-
removeCollaborators
Remove collaborators.- Parameters:
users
- the users- Throws:
IOException
- the io exception
-
setEmailServiceHook
Sets email service hook.- Parameters:
address
- the address- Throws:
IOException
- the io exception
-
enableIssueTracker
Enables or disables the issue tracker for this repository.- Parameters:
v
- the v- Throws:
IOException
- the io exception
-
enableProjects
Enables or disables projects for this repository.- Parameters:
v
- the v- Throws:
IOException
- the io exception
-
enableWiki
Enables or disables Wiki for this repository.- Parameters:
v
- the v- Throws:
IOException
- the io exception
-
enableDownloads
Enable downloads.- Parameters:
v
- the v- Throws:
IOException
- the io exception
-
renameTo
Rename this repository.- Parameters:
name
- the name- Throws:
IOException
- the io exception
-
setDescription
Sets description.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
setHomepage
Sets homepage.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
setDefaultBranch
Sets default branch.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
setPrivate
Sets private.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
setVisibility
Sets visibility.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
allowSquashMerge
Allow squash merge.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
allowMergeCommit
Allow merge commit.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
allowRebaseMerge
Allow rebase merge.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
allowForking
Allow private fork.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
deleteBranchOnMerge
After pull requests are merged, you can have head branches deleted automatically.- Parameters:
value
- the value- Throws:
IOException
- the io exception
-
delete
Deletes this repository.- Throws:
IOException
- the io exception
-
archive
Will 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
Creates a builder that can be used to bulk update repository settings.- Returns:
- the repository updater
-
set
Creates a builder that can be used to bulk update repository settings.- Returns:
- the repository updater
-
listForks
Lists all the direct forks of this repository, sorted by github api default, currentlyForkSort.NEWEST
*.- Returns:
- the paged iterable
-
listForks
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
Forks this repository as your repository.- Returns:
- Newly forked repository that belong to you.
- Throws:
IOException
- the io exception
-
sync
Sync this repository fork branch- Parameters:
branch
- the branch to sync- Returns:
- The current repository
- Throws:
IOException
- the io exception
-
forkTo
Forks this repository into an organization.- Parameters:
org
- the org- Returns:
- Newly forked repository that belong to you.
- Throws:
IOException
- the io exception
-
getPullRequest
Retrieves a specified pull request.- Parameters:
i
- the- Returns:
- the pull request
- Throws:
IOException
- the io exception
-
queryPullRequests
Retrieves pull requests.- Returns:
- the gh pull request query builder
-
searchPullRequests
Retrieves pull requests according to search terms.- Returns:
- gh pull request search builder for current repository
-
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
Retrieves the currently configured hooks.- Returns:
- the hooks
- Throws:
IOException
- the io exception
-
getHook
Gets hook.- Parameters:
id
- the id- Returns:
- the hook
- Throws:
IOException
- the io exception
-
deleteHook
Deletes hook.- Parameters:
id
- the id- Throws:
IOException
- the io exception
-
setCompareUsePaginatedCommits
public void setCompareUsePaginatedCommits(boolean value) SetsgetCompare(String, String)
to return aGHCompare
that uses a paginated commit list instead of limiting to 250 results. By default,GHCompare
returns 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
Gets a comparison between 2 points in the repository. This would be similar to callinggit log id1...id2
against 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
Gets compare.- Parameters:
id1
- the id 1id2
- the id 2- Returns:
- the compare
- Throws:
IOException
- the io exception
-
getCompare
Gets compare.- Parameters:
id1
- the id 1id2
- the id 2- Returns:
- the compare
- Throws:
IOException
- the io exception
-
getRefs
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
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
Retrieves all refs of the given type for the current GitHub repository.- Parameters:
refType
- the type of reg to search for e.g.tags
orcommits
- 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
Retrieves all refs of the given type for the current GitHub repository.- Parameters:
refType
- the type of reg to search for e.g.tags
orcommits
- 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
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
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
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
Create tree gh tree builder.- Returns:
- the gh tree builder
-
getTreeRecursive
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
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:
-
createBlob
Create blob gh blob builder.- Returns:
- the gh blob builder
-
readBlob
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:
-
getCommit
Gets a commit object in this repository.- Parameters:
sha1
- the sha 1- Returns:
- the commit
- Throws:
IOException
- the io exception
-
createCommit
Create commit gh commit builder.- Returns:
- the gh commit builder
-
listCommits
Lists all the commits.- Returns:
- the paged iterable
-
queryCommits
Search commits by specifying filters through a builder pattern.- Returns:
- the gh commit query builder
-
listCommitComments
Lists up all the commit comments in this repository.- Returns:
- the paged iterable
-
listCommitComments
Lists all comments on a specific commit.- Parameters:
commitSha
- the hash of the commit- Returns:
- the paged iterable
-
getLicense
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
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
/** 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
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
Gets check runs for given ref.- Parameters:
ref
- ref- Returns:
- check runs for given ref
- Throws:
IOException
- the io exception- See Also:
-
getCheckRuns
public PagedIterable<GHCheckRun> getCheckRuns(String ref, Map<String, Object> params) throws IOExceptionGets 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:
-
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:
-
createCheckRun
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
Updates an existing check run.- Parameters:
checkId
- the existing checkId- Returns:
- a builder which you should customize, then call
GHCheckRunBuilder.create()
-
listEvents
Lists repository events.- Returns:
- the paged iterable
- Throws:
IOException
- the io exception
-
listLabels
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
Gets label.- Parameters:
name
- the name- Returns:
- the label
- Throws:
IOException
- the io exception
-
createLabel
Create label gh label.- Parameters:
name
- the namecolor
- the color- Returns:
- the gh label
- Throws:
IOException
- the io exception
-
createLabel
Description is still in preview.- Parameters:
name
- the namecolor
- the colordescription
- the description- Returns:
- gh label
- Throws:
IOException
- the io exception
-
listInvitations
Lists all the invitations.- Returns:
- the paged iterable
-
listSubscribers
Lists all the subscribers (aka watchers.)https://developer.github.com/v3/activity/watching/
- Returns:
- the paged iterable
-
listStargazers2
Deprecated.UselistStargazers()
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.- Returns:
- the paged iterable
-
listStargazers
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.- Returns:
- the paged iterable
-
createHook
public GHHook createHook(String name, Map<String, String> config, Collection<GHEvent> events, boolean active) throws IOExceptionSee 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
Create web hook gh hook.- Parameters:
url
- the urlevents
- the events- Returns:
- the gh hook
- Throws:
IOException
- the io exception
-
createWebHook
Create web hook gh hook.- Parameters:
url
- the url- Returns:
- the gh hook
- Throws:
IOException
- the io exception
-
getBranches
Gets branches by their names.- Returns:
- the branches
- Throws:
IOException
- the io exception
-
getBranch
Gets branch.- Parameters:
name
- the name- Returns:
- the branch
- Throws:
IOException
- the io exception
-
listMilestones
Lists up all the milestones in this repository.- Parameters:
state
- the state- Returns:
- the paged iterable
-
getMilestone
Gets milestone.- Parameters:
number
- the number- Returns:
- the milestone
- Throws:
IOException
- the io exception
-
getFileContent
Gets file content.- Parameters:
path
- the path- Returns:
- the file content
- Throws:
IOException
- the io exception
-
getFileContent
Gets file content.- Parameters:
path
- the pathref
- the ref- Returns:
- the file content
- Throws:
IOException
- the io exception
-
getDirectoryContent
Gets directory content.- Parameters:
path
- the path- Returns:
- the directory content
- Throws:
IOException
- the io exception
-
getDirectoryContent
Gets directory content.- Parameters:
path
- the pathref
- the ref- Returns:
- the directory content
- Throws:
IOException
- the io exception
-
getReadme
https://developer.github.com/v3/repos/contents/#get-the-readme- Returns:
- the readme
- Throws:
IOException
- the io exception
-
createVariable
Create a repository variable.- Parameters:
name
- the variable name (e.g. test-variable)value
- the value- Throws:
IOException
- the io exception
-
getVariable
Gets a repository variable.- Parameters:
name
- the variable name (e.g. test-variable)- Returns:
- the variable
- Throws:
IOException
- the io exception
-
createContent
Creates a new content, or update an existing content.- Returns:
- the gh content builder
-
createMilestone
Create milestone gh milestone.- Parameters:
title
- the titledescription
- the description- Returns:
- the gh milestone
- Throws:
IOException
- the io exception
-
addDeployKey
Add deploy key gh deploy key.- Parameters:
title
- the titlekey
- the key- Returns:
- the gh deploy key
- Throws:
IOException
- the io exception
-
addDeployKey
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
Gets deploy keys.- Returns:
- the deploy keys
- Throws:
IOException
- the io exception
-
getSource
Forked repositories have a 'source' attribute that specifies the ultimate source of the forking chain.- Returns:
GHRepository
that points to the root repository where this repository is forked (indirectly or directly) from. Otherwise null.- Throws:
IOException
- the io exception- See Also:
-
getParent
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:
GHRepository
that points to the repository where this repository is forked directly from. Otherwise null.- Throws:
IOException
- the io exception- See Also:
-
subscribe
Subscribes to this repository to get notifications.- Parameters:
subscribed
- the subscribedignored
- the ignored- Returns:
- the gh subscription
- Throws:
IOException
- the io exception
-
getSubscription
Returns the current subscription.- Returns:
- null if no subscription exists.
- Throws:
IOException
- the io exception
-
listCodeownersErrors
List errors in theCODEOWNERS
file. 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
List contributors paged iterable.- Returns:
- the paged iterable
- Throws:
IOException
- the io exception
-
getStatistics
Returns the statistics for this repository.- Returns:
- the statistics
-
createProject
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
Returns open projects for this repository.- Returns:
- the paged iterable
- Throws:
IOException
- the io exception
-
renderMarkdown
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:
-
listNotifications
List all the notifications in a repository for the current user.- Returns:
- the gh notification stream
-
getViewTraffic
- Returns:
- the view traffic
- Throws:
IOException
- the io exception
-
getCloneTraffic
- Returns:
- the clone traffic
- Throws:
IOException
- the io exception
-
hashCode
public int hashCode()Hash code. -
equals
Equals. -
listIssueEvents
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
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
Lists all the workflows of this repository.- Returns:
- the paged iterable
-
getWorkflow
Gets a workflow by id.- Parameters:
id
- the id of the workflow run- Returns:
- the workflow run
- Throws:
IOException
- the io exception
-
getWorkflow
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
Retrieves workflow runs.- Returns:
- the workflow run query builder
-
getWorkflowRun
Gets a workflow run.- Parameters:
id
- the id of the workflow run- Returns:
- the workflow run
- Throws:
IOException
- the io exception
-
listArtifacts
Lists all the artifacts of this repository.- Returns:
- the paged iterable
-
getArtifact
Gets an artifact by id.- Parameters:
id
- the id of the artifact- Returns:
- the artifact
- Throws:
IOException
- the io exception
-
getWorkflowJob
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
Gets the public key for the given repo.- Returns:
- the public key
- Throws:
IOException
- the io exception
-
listTopics
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
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
Streams a zip archive of the repository, optionally at a givenref
.- Type Parameters:
T
- the type of result- Parameters:
streamFunction
- TheInputStreamFunction
that will process the streamref
- ifnull
the repository's default branch, usuallymain
,- Returns:
- the result of reading the stream.
- Throws:
IOException
- The IO exception.
-
readTar
Streams a tar archive of the repository, optionally at a givenref
.- Type Parameters:
T
- the type of result- Parameters:
streamFunction
- TheInputStreamFunction
that will process the streamref
- ifnull
the repository's default branch, usuallymain
,- Returns:
- the result of reading the stream.
- Throws:
IOException
- The IO exception.
-
dispatch
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
Star a repository.- Throws:
IOException
- the io exception
-
unstar
Unstar a repository.- Throws:
IOException
- the io exception
-
getTopReferralPaths
Get the top 10 popular contents over the last 14 days as described on https://docs.github.com/en/rest/metrics/traffic?apiVersion=2022-11-28#get-top-referral-paths- Returns:
- list of top referral paths
- Throws:
IOException
- the io exception
-
getTopReferralSources
Get the top 10 referrers over the last 14 days as described on https://docs.github.com/en/rest/metrics/traffic?apiVersion=2022-11-28#get-top-referral-sources- Returns:
- list of top referrers
- Throws:
IOException
- the io exception
-
listRulesForBranch
Get all active rules that apply to the specified branch (https://docs.github.com/en/rest/repos/rules?apiVersion=2022-11-28#get-rules-for-a-branch).- Parameters:
branch
- the branch- Returns:
- the rules for branch
- Throws:
IOException
- the io exception
-
isVulnerabilityAlertsEnabled
Check, if vulnerability alerts are enabled for this repository (https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#check-if-vulnerability-alerts-are-enabled-for-a-repository).- Returns:
- true, if vulnerability alerts are enabled
- Throws:
IOException
- the io exception
-
listStargazers()