cmd

package
v0.0.0-...-1eec387 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func ExtractGitHubRepositoryName

func ExtractGitHubRepositoryName(repo string) (string, string, error)

ExtractGitHubRepositoryName extracts repository owner and name from a string. This function treats following syntax. 1. GitHub URL

2. SCP-like address

  • git@github.com:<owner>/<name>.git -> (owner, name)

3. Other

  • <owner>/<name> -> (owner, name)

Types

type GitHubClient

type GitHubClient struct {
	// contains filtered or unexported fields
}

GitHubClient implements a partial GitHub GraphQL API v4.

func NewGitHubClient

func NewGitHubClient(ctx context.Context, token string) GitHubClient

NewGitHubClient creates GitHubClient.

func (GitHubClient) AddAssigneeToPullRequest

func (gh GitHubClient) AddAssigneeToPullRequest(ctx context.Context, userID, prID string) error

AddAssigneeToPullRequest add a assignee to a pull request.

func (GitHubClient) CreatePullRequest

func (gh GitHubClient) CreatePullRequest(ctx context.Context, repo, base, head, title, body string, draft bool) (*PullRequest, error)

CreatePullRequest creates a new pull request to merge head into base. title must not be empty. When succeeds, it returns this:

  • a global node ID of the new PR
  • a number of the new PR
  • a permalink to the new PR

func (GitHubClient) GetDraftPR

func (gh GitHubClient) GetDraftPR(ctx context.Context, repo *GitHubRepository, branch string) (string, error)

GetDraftPR returns a draft pull request in a repository for a branch. If no pull request is found, this returns ("", nil).

func (GitHubClient) GetIssueTitle

func (gh GitHubClient) GetIssueTitle(ctx context.Context, repo *GitHubRepository, issue int) (string, error)

GetIssueTitle returns issue title.

func (GitHubClient) GetRepository

func (gh GitHubClient) GetRepository(ctx context.Context, owner, name string) (*GitHubRepository, error)

GetRepository acquires global node ID and database ID and returns GitHubRepository with them.

func (GitHubClient) GetViewer

func (gh GitHubClient) GetViewer(ctx context.Context) (*GitHubUser, error)

GetViewer returns global node ID and Login ID of the login user.

func (GitHubClient) MarkDraftReadyForReview

func (gh GitHubClient) MarkDraftReadyForReview(ctx context.Context, id string) error

MarkDraftReadyForReview marks a draft pull request ready for review.

type GitHubRepository

type GitHubRepository struct {
	Owner      string // repository owner (e.g. cybozu-go)
	Name       string // repository name (e.g. neco)
	ID         string // global node ID used for GitHub GraphQL API
	DatabaseID int    // database ID used for GitHub REST API
}

GitHubRepository represents a repository hosted on GitHub.

type GitHubUser

type GitHubUser struct {
	ID    string
	Login string
}

GitHubUser represents a GitHub user.

type PullRequest

type PullRequest struct {
	ID        string
	Number    int
	Permalink string
}

PullRequest represents a pull request on GitHub.

type ZenHubClient

type ZenHubClient struct {
	// contains filtered or unexported fields
}

ZenHubClient implements a partial ZenHub API.

func NewZenHubClient

func NewZenHubClient(token string) *ZenHubClient

NewZenHubClient creates ZenHubClient.

func (*ZenHubClient) Connect

func (zh *ZenHubClient) Connect(ctx context.Context, issueID, pullRequestID string) error

Connect connect a pull request with an issue.

func (*ZenHubClient) GetIssueID

func (zh *ZenHubClient) GetIssueID(ctx context.Context, repositoryGhID, issueGhNumber int) (string, error)

GetIssueID gets a zenhub internal ID for either PR or issue.

Jump to

Keyboard shortcuts

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