api

package
v0.0.0-...-ddc1c62 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitHub

type GitHub struct {
	GraphQLClient *api.GraphQLClient
	*github.Client
	Host       string
	Owner      string
	Repository string
}

GitHub implements the PullRequester interface allowing to create pull requests for a given repository

func NewGitHubUpserter

func NewGitHubUpserter(ctx context.Context, endpoint *transport.Endpoint) (*GitHub, error)

NewGitHubUpserter instanciates an upserter that uses the github API to create and update pull requests

func (*GitHub) DefaultBranch

func (g *GitHub) DefaultBranch(ctx context.Context) string

DefaultBranch returns the default branch of the remote repository

func (*GitHub) Ensure

func (g *GitHub) Ensure(ctx context.Context, options PullRequestOptions) (*PullRequest, bool, error)

Ensure ensures a PR is opened for the head branch

func (*GitHub) LinkedTopicIssues

func (g *GitHub) LinkedTopicIssues(topicSearchString string) string

LinkedTopicIssues returns the search URL for linked issues

func (*GitHub) RepoHost

func (g *GitHub) RepoHost() string

RepoHost implements the ghrepo.Interface interface required to call the github graphql API from https://github.com/cli/cli See https://github.com/cli/cli/blob/dc804d928714120a3f4b53f78847aec7ba282c63/internal/ghrepo/repo.go#L14

func (*GitHub) RepoName

func (g *GitHub) RepoName() string

RepoName implements the ghrepo.Interface interface required to call the github graphql API from https://github.com/cli/cli See https://github.com/cli/cli/blob/dc804d928714120a3f4b53f78847aec7ba282c63/internal/ghrepo/repo.go#L14

func (*GitHub) RepoOwner

func (g *GitHub) RepoOwner() string

RepoHost implements the ghrepo.Interface interface required to call the github graphql API from https://github.com/cli/cli See https://github.com/cli/cli/blob/dc804d928714120a3f4b53f78847aec7ba282c63/internal/ghrepo/repo.go#L14

func (*GitHub) Update

func (g *GitHub) Update(ctx context.Context, pr *PullRequest, options PullRequestOptions) (*PullRequest, error)

Update implements the Update interface to update an existing pull request

type PullRequest

type PullRequest struct {
	ID  string
	URL string
}

PullRequest defines the object

type PullRequestOptions

type PullRequestOptions struct {
	Base  string
	Head  string
	Title string
	Body  string
	WIP   bool
	Ready bool
}

PullRequestOptions are the options available to create or update a pull request

type PullRequester

type PullRequester interface {
	// Update defines the interface to create or update a pull request to match options
	Update(context.Context, *PullRequest, PullRequestOptions) (*PullRequest, error)
	// Ensure ensures one and only one pull request exists for the given head
	Ensure(context.Context, PullRequestOptions) (*PullRequest, bool, error)
	LinkedTopicIssues(topicSearchString string) string
	DefaultBranch(context.Context) string
}

PullRequester defines the interface to implement to handle pull requests

func NewPullRequester

func NewPullRequester(ctx context.Context, remote *git.Remote) (PullRequester, error)

type Repo

type Repo struct {
	// Domain is the domain the API is exposed on
	Domain string
	// Repository is the name of the repository exposed on the API
	// (owner/repository for github repositories)
	Repository string
	// Username contains the name of the authenticated user
	// accessing the repository API
	Username string
	// Password contains the password of the authenticated user
	// accessing the repository API
	Password string
}

Repo describes how to reach a repository using an API

func NewRepoFromGitRemote

func NewRepoFromGitRemote(remoteName string) (*Repo, error)

NewRepoFromGitRemote parses the a git remote URL to determine the API configuration

Jump to

Keyboard shortcuts

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