Package de.carne.gradle.plugin.java.util
Class GitHubRepo
- java.lang.Object
-
- de.carne.gradle.plugin.java.util.GitHubRepo
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class GitHubRepo extends java.lang.Object implements java.lang.AutoCloseableGitHub Repository client.
-
-
Constructor Summary
Constructors Constructor Description GitHubRepo(java.io.File dir, java.lang.String token)Constructs a new GitHubRepo instance.GitHubRepo(java.lang.String dir, java.lang.String token)Constructs a new GitHubRepo instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voiddeleteRelease(java.lang.String releaseId)Deletes a repository release.java.io.Filedir()Gets the repository directory.GitHubApi.ReleaseInfodraftRelease(java.lang.String name, java.lang.String body)Drafts a new release.booleanisDirty()Gets the dirty status of the repository.@Nullable GitHubApi.ReleaseInfoqueryRelease(java.lang.String name)Queries a release by name.GitHubApi.ReleaseAssetInfouploadReleaseAsset(java.lang.String uploadUrl, java.io.File assetFile)Uploads a release asset.GitHubApi.ReleaseAssetInfouploadReleaseAsset(java.lang.String uploadUrl, java.io.File assetFile, java.lang.String name)Uploads a release asset.GitHubApi.ReleaseAssetInfouploadReleaseAsset(java.lang.String uploadUrl, java.io.File assetFile, java.lang.String name, @Nullable java.lang.String label)Uploads a release asset.
-
-
-
Constructor Detail
-
GitHubRepo
public GitHubRepo(java.lang.String dir, java.lang.String token) throws java.io.IOExceptionConstructs a new GitHubRepo instance.- Parameters:
dir- the local GitHub repository directory.token- the GitHub access token.- Throws:
java.io.IOException- if an I/O error occurs while accessing the repository.
-
GitHubRepo
public GitHubRepo(java.io.File dir, java.lang.String token) throws java.io.IOExceptionConstructs a new GitHubRepo instance.- Parameters:
dir- the local GitHub repository directory.token- the GitHub access token.- Throws:
java.io.IOException- if an I/O error occurs while accessing the repository.
-
-
Method Detail
-
dir
public java.io.File dir()
Gets the repository directory.- Returns:
- the repository directory.
-
isDirty
public boolean isDirty()
Gets the dirty status of the repository.- Returns:
trueif any uncommitted changes or untracked files exist for this repository.
-
queryRelease
public @Nullable GitHubApi.ReleaseInfo queryRelease(java.lang.String name) throws java.io.IOException
Queries a release by name.- Parameters:
name- the name of the release to query.- Returns:
- the queried release's info or
nullif the release does not exit. - Throws:
java.io.IOException- if an I/O error occurs while performing the request.
-
draftRelease
public GitHubApi.ReleaseInfo draftRelease(java.lang.String name, java.lang.String body) throws java.io.IOException
Drafts a new release.- Parameters:
name- the name of the new release.body- the release description to use.- Returns:
- the newly drafted release's info.
- Throws:
java.io.IOException- if an I/O error occurs while performing the request.
-
uploadReleaseAsset
public GitHubApi.ReleaseAssetInfo uploadReleaseAsset(java.lang.String uploadUrl, java.io.File assetFile) throws java.io.IOException
Uploads a release asset.- Parameters:
uploadUrl- the upload URL of the release.assetFile- the asset file to upload.- Returns:
- the uploaded asset's info.
- Throws:
java.io.IOException- if an I/O error occurs while performing the request.
-
uploadReleaseAsset
public GitHubApi.ReleaseAssetInfo uploadReleaseAsset(java.lang.String uploadUrl, java.io.File assetFile, java.lang.String name) throws java.io.IOException
Uploads a release asset.- Parameters:
uploadUrl- the upload URL of the release.assetFile- the asset file to upload.name- the name of the uploaded asset.- Returns:
- the uploaded asset's info.
- Throws:
java.io.IOException- if an I/O error occurs while performing the request.
-
uploadReleaseAsset
public GitHubApi.ReleaseAssetInfo uploadReleaseAsset(java.lang.String uploadUrl, java.io.File assetFile, java.lang.String name, @Nullable java.lang.String label) throws java.io.IOException
Uploads a release asset.- Parameters:
uploadUrl- the upload URL of the release.assetFile- the asset file to upload.name- the name of the uploaded asset.label- the label of the uploaded asset (may benull).- Returns:
- the uploaded asset's info.
- Throws:
java.io.IOException- if an I/O error occurs while performing the request.
-
deleteRelease
public void deleteRelease(java.lang.String releaseId) throws java.io.IOExceptionDeletes a repository release.- Parameters:
releaseId- the id of the release to delete.- Throws:
java.io.IOException- if an I/O error occurs while performing the request.
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-