host

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package host defines the Host interface and auto-detection logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID     string
	Author string
	Body   string
	// Timestamp is RFC3339 or similar human-readable string.
	Timestamp string
}

Comment represents a PR comment.

type CreatePRInput

type CreatePRInput struct {
	Title        string
	Description  string
	SourceBranch string
	TargetBranch string
	Draft        bool
	Reviewers    []string
}

CreatePRInput carries all fields for a new pull request.

type Host

type Host interface {
	// CreatePR creates a new pull request and returns the created PR.
	CreatePR(ctx context.Context, in CreatePRInput) (*PR, error)
	// GetPR fetches a pull request by ID.
	GetPR(ctx context.Context, id string) (*PR, error)
	// ListPRs lists pull requests. If mine is true, filter to the authed user.
	ListPRs(ctx context.Context, state string, mine bool) ([]*PR, error)
	// MergePR merges a pull request by ID. Returns the merge commit SHA.
	MergePR(ctx context.Context, id string) (string, error)
	// CommentPR posts a comment on a PR. replyTo is a comment ID (empty = top-level).
	CommentPR(ctx context.Context, id, text, replyTo string) error
	// GetBuildStatus returns the CI state for a commit SHA.
	GetBuildStatus(ctx context.Context, sha string) (string, error)
	// GetReviewers returns the list of reviewer usernames for a PR.
	GetReviewers(ctx context.Context, id string) ([]string, error)
	// UpdatePR updates title, description, and adds reviewers to an existing PR.
	UpdatePR(ctx context.Context, id, title, description string, addReviewers []string) error
	// CurrentUser returns the authenticated username.
	CurrentUser(ctx context.Context) (string, error)
}

Host is the interface every git-hosting adapter must implement.

func Detect

func Detect(remoteURL string, cfg *config.Config) (Host, error)

Detect sniffs the remote URL and returns the appropriate Host adapter.

func DetectFromCWD

func DetectFromCWD(remoteName string, cfg *config.Config) (Host, string, error)

DetectFromCWD detects the host from the current working directory's git remote.

type PR

type PR struct {
	ID           string
	URL          string
	Title        string
	Description  string
	State        string // OPEN | MERGED | DECLINED | SUPERSEDED
	Draft        bool
	SourceBranch string
	TargetBranch string
	HeadSHA      string
	Reviewers    []string
	Approvals    []string // users who approved
	Blockers     []string // blocker comment IDs
	CIState      string   // SUCCESSFUL | FAILED | INPROGRESS | UNKNOWN
	LastComment  *Comment
}

PR represents a pull request in a normalised form.

Jump to

Keyboard shortcuts

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