Class GitHubRepo

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class GitHubRepo
    extends java.lang.Object
    implements java.lang.AutoCloseable
    GitHub Repository client.
    • Constructor Detail

      • GitHubRepo

        public GitHubRepo​(java.lang.String dir,
                          java.lang.String token)
                   throws java.io.IOException
        Constructs 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.IOException
        Constructs 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:
        true if 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 null if 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 be null).
        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.IOException
        Deletes 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:
        close in interface java.lang.AutoCloseable