github

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAuth added in v1.0.0

func CheckAuth() error

CheckAuth verifies that the gh CLI is authenticated and returns an error if not.

Types

type CheckStatus

type CheckStatus struct {
	State   string // "success", "failure", "pending", "error"
	Summary string // e.g., "3/3 checks passed"
}

CheckStatus represents CI check status

type Client

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

Client wraps GitHub operations using gh CLI

func NewClient

func NewClient(remoteURL string) (*Client, error)

NewClient creates a new GitHub client by parsing the remote URL

func (*Client) CreatePR

func (c *Client) CreatePR(title, body, head, base string, draft bool) (*PR, error)

CreatePR creates a new pull request

func (*Client) EnsureCorrectBaseBranches added in v0.1.2

func (c *Client) EnsureCorrectBaseBranches(stack *config.Stack) error

EnsureCorrectBaseBranches ensures each PR's base branch matches the expected parent branch.

func (*Client) GetPR

func (c *Client) GetPR(number int) (*PR, error)

GetPR gets a PR by number

func (*Client) GetPRByBranch

func (c *Client) GetPRByBranch(branch string) (*PR, error)

GetPRByBranch gets a PR by its head branch name

func (*Client) GetPRChecks

func (c *Client) GetPRChecks(number int) (*CheckStatus, error)

GetPRChecks gets the CI check status for a PR

func (*Client) ListOpenPRs

func (c *Client) ListOpenPRs() ([]OpenPR, error)

ListOpenPRs returns all open PRs in the repository

func (*Client) MergePR added in v1.1.1

func (c *Client) MergePR(number int, method string, deleteRemoteBranch bool) error

MergePR merges a pull request using the specified method (merge, squash, rebase)

func (*Client) SetPRDraft added in v1.1.1

func (c *Client) SetPRDraft(number int) error

SetPRDraft marks a PR as draft

func (*Client) SetPRReady added in v1.1.1

func (c *Client) SetPRReady(number int) error

SetPRReady marks a draft PR as ready for review

func (*Client) UpdatePR

func (c *Client) UpdatePR(number int, body string) error

UpdatePR updates a PR's body

func (*Client) UpdatePRBase

func (c *Client) UpdatePRBase(number int, base string) error

UpdatePRBase updates a PR's base branch

func (*Client) UpdateStackDescription

func (c *Client) UpdateStackDescription(stack *config.Stack, currentBranch string) error

UpdateStackDescription updates PR descriptions with stack info.

type ClientInterface

type ClientInterface interface {
	// CreatePR creates a new pull request
	CreatePR(title, body, head, base string, draft bool) (*PR, error)

	// GetPR gets a PR by number
	GetPR(number int) (*PR, error)

	// GetPRByBranch gets a PR by its head branch name
	GetPRByBranch(branch string) (*PR, error)

	// GetPRChecks gets the CI check status for a PR
	GetPRChecks(number int) (*CheckStatus, error)

	// UpdatePR updates a PR's body
	UpdatePR(number int, body string) error

	// UpdatePRBase updates a PR's base branch
	UpdatePRBase(number int, base string) error

	// ListOpenPRs returns all open PRs in the repository
	ListOpenPRs() ([]OpenPR, error)

	// MergePR merges a pull request using the specified method
	MergePR(number int, method string, deleteRemoteBranch bool) error

	// SetPRDraft marks a PR as draft
	SetPRDraft(number int) error

	// SetPRReady marks a draft PR as ready for review
	SetPRReady(number int) error

	// UpdateStackDescription updates PR descriptions with stack info
	UpdateStackDescription(stack *config.Stack, currentBranch string) error
}

ClientInterface defines the interface for GitHub operations This allows for mocking in tests

type OpenPR

type OpenPR struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	Branch string `json:"headRefName"`
	Author string `json:"author"`
	URL    string `json:"url"`
}

OpenPR represents a minimal PR for listing

type PR

type PR struct {
	Number      int    `json:"number"`
	URL         string `json:"url"`
	Title       string `json:"title"`
	Body        string `json:"body"`
	State       string `json:"state"`
	Base        string `json:"baseRefName"`
	Head        string `json:"headRefName"`
	MergedAt    string `json:"mergedAt"` // non-empty if merged
	Merged      bool   // computed from MergedAt
	Mergeable   string `json:"mergeable"`
	IsDraft     bool   `json:"isDraft"`
	ReviewState string `json:"reviewDecision"`
}

PR represents a pull request

Jump to

Keyboard shortcuts

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