api

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

SPDX-License-Identifier: BSD-3-Clause

Authors: Alexander Jung <alex@nderjung.net>

Copyright (c) 2020, Alexander Jung. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCommentHTMLURL

func ParseCommentHTMLURL(prUrl string) (int, error)

ParseCommentHTMLURL takes in a standard issue URL and returns the issue number, e.g.: https://github.com/octocat/Hello-World/issues/1347#issuecomment-1

Types

type Git added in v0.1.4

type Git interface {
	Init(string) error
	Pull(string, string, int, bool, bool) error
	RevParse(string) (string, error)
	Fetch(string, int, int, bool) error
	Checkout(string, string, bool) error
	Merge(string, bool) error
	Rebase(string, string, bool) error
	GitCryptUnlock(string) error
}

Git interface for testing purposes.

type GitClient added in v0.1.4

type GitClient struct {
	AccessToken string
	Directory   string
	Output      io.Writer
}

GitClient ...

func NewGitClient added in v0.1.4

func NewGitClient(accessToken string, skipSsl, disableGitLfs bool, dir string, output io.Writer) (*GitClient, error)

NewGitClient ...

func (*GitClient) Checkout added in v0.1.4

func (g *GitClient) Checkout(branch, sha string, submodules bool) error

CheckOut

func (*GitClient) Endpoint added in v0.1.4

func (g *GitClient) Endpoint(uri string) (string, error)

Endpoint takes an uri and produces an endpoint with the login information baked in.

func (*GitClient) Fetch added in v0.1.4

func (g *GitClient) Fetch(uri string, prNumber int, depth int, submodules bool) error

Fetch ...

func (*GitClient) GitCryptUnlock added in v0.1.4

func (g *GitClient) GitCryptUnlock(base64key string) error

GitCryptUnlock unlocks the repository using git-crypt

func (*GitClient) Init added in v0.1.4

func (g *GitClient) Init(branch string) error

Init ...

func (*GitClient) Merge added in v0.1.4

func (g *GitClient) Merge(sha string, submodules bool) error

Merge ...

func (*GitClient) Pull added in v0.1.4

func (g *GitClient) Pull(uri, branch string, depth int, submodules bool, fetchTags bool) error

Pull ...

func (*GitClient) Rebase added in v0.1.4

func (g *GitClient) Rebase(baseRef string, headSha string, submodules bool) error

Rebase ...

func (*GitClient) RevParse added in v0.1.4

func (g *GitClient) RevParse(branch string) (string, error)

RevParse retrieves the SHA of the given branch.

type Github

type Github interface {
	ListPullRequests() ([]*github.PullRequest, error)
	GetPullRequest(prID int) (*github.PullRequest, error)
	ListPullRequestComments(prID int) ([]*github.PullRequestComment, error)
	ListPullRequestReviews(prID int) ([]*github.PullRequestReview, error)
	GetPullRequestComment(commentID int64) (*github.IssueComment, error)
	GetPullRequestReview(prID int, reviewID int64) (*github.PullRequestReview, error)
	SetPullRequestState(prID int, state string) error
	DeleteLastPullRequestComment(prID int) error
	AddPullRequestLabels(prID int, labels []string) error
	RemovePullRequestLabels(prID int, labels []string) error
	ReplacePullRequestLabels(prID int, labels []string) error
	CreatePullRequestComment(prID int, comment string) error
}

Github interface representing the desired functions for this resource.

type GithubClient

type GithubClient struct {
	Owner      string
	Repository string
	Client     *github.Client
}

GithubClient containing the necessary information to authenticate and perform actions against the REST API.

func NewGithubClient

func NewGithubClient(repo string, accessToken string, skipSSL bool, githubEndpoint string) (*GithubClient, error)

NewGitHubClient for creating a new instance of the client.

func (*GithubClient) AddPullRequestLabels

func (c *GithubClient) AddPullRequestLabels(prID int, labels []string) error

AddPullRequestLabels adds the list of labels to the existing set of labels given the relative pull request ID to the configure repo

func (*GithubClient) CreatePullRequestComment

func (c *GithubClient) CreatePullRequestComment(prID int, comment string) error

CreatePullRequestComment adds a new comment to the pull request given its ID relative to the configured repo

func (*GithubClient) DeleteLastPullRequestComment

func (c *GithubClient) DeleteLastPullRequestComment(prID int) error

func (*GithubClient) GetPullRequest

func (c *GithubClient) GetPullRequest(prID int) (*github.PullRequest, error)

GetPullRequest returns the specific pull request given its ID relative to the configured repo

func (*GithubClient) GetPullRequestComment

func (c *GithubClient) GetPullRequestComment(commentID int64) (*github.IssueComment, error)

GetPulLRequestComment returns the specific comment given its unique Github ID

func (*GithubClient) GetPullRequestReview added in v0.1.4

func (c *GithubClient) GetPullRequestReview(prID int, reviewID int64) (*github.PullRequestReview, error)

GetPulLRequestReview returns the specific review given its unique Github ID

func (*GithubClient) ListPullRequestComments

func (c *GithubClient) ListPullRequestComments(prID int) ([]*github.IssueComment, error)

ListPullRequestComments returns the list of comments for the specific pull request given its ID relative to the configured repo

func (*GithubClient) ListPullRequestReviews added in v0.1.4

func (c *GithubClient) ListPullRequestReviews(prID int) ([]*github.PullRequestReview, error)

ListPullRequestReviews returns the list of reviews for the specific pull request given its ID relative to the configured repo

func (*GithubClient) ListPullRequests

func (c *GithubClient) ListPullRequests() ([]*github.PullRequest, error)

ListPullRequests returns the list of pull requests for the configured repo

func (*GithubClient) RemovePullRequestLabels

func (c *GithubClient) RemovePullRequestLabels(prID int, labels []string) error

RemovePullRequestLabels remove the list of labels from the set of existing labels given the relative pull request ID to the configured repo

func (*GithubClient) ReplacePullRequestLabels

func (c *GithubClient) ReplacePullRequestLabels(prID int, labels []string) error

ReplacePullRequestLabels overrides all existing labels with the given set of labels for the pull request ID relative to the configured repo

func (*GithubClient) SetPullRequestState

func (c *GithubClient) SetPullRequestState(prID int, state string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL