githubpr

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TokenEnv is the environment variable for GitHub token.
	TokenEnv = "GITHUB_TOKEN"

	// HolonTokenEnv is the environment variable for Holon-specific GitHub token.
	// This has higher priority than GITHUB_TOKEN.
	HolonTokenEnv = "HOLON_GITHUB_TOKEN"

	// BranchFlag is the flag name for branch configuration.
	BranchFlag = "branch"

	// TitleFlag is the flag name for PR title configuration.
	TitleFlag = "title"

	// IssueFlag is the flag name for issue ID reference.
	IssueFlag = "issue_id"

	// AuthorNameFlag is the flag name for git author name configuration.
	AuthorNameFlag = "git_author_name"

	// AuthorEmailFlag is the flag name for git author email configuration.
	AuthorEmailFlag = "git_author_email"
)

Variables

This section is empty.

Functions

func ExtractBranchFromSummary

func ExtractBranchFromSummary(summary string, issueID string) string

ExtractBranchFromSummary extracts a branch name from summary.md content. Looks for patterns like "Branch: holon/fix-123" or returns a default.

func ExtractTitleFromSummary

func ExtractTitleFromSummary(summary string) string

ExtractTitleFromSummary extracts a PR title from summary.md content. Uses the first non-empty line (excluding markdown headers) as the title.

func FormatPRBody

func FormatPRBody(summary string, issueID string) string

FormatPRBody formats the PR body from summary content. Adds issue reference if provided.

Types

type GitClient

type GitClient struct {
	// WorkspaceDir is the path to the Git workspace
	WorkspaceDir string

	// Token is the GitHub authentication token
	Token string

	// AuthorName is the git author name for commits
	AuthorName string

	// AuthorEmail is the git author email for commits
	AuthorEmail string
}

GitClient handles Git operations for PR creation.

func NewGitClient

func NewGitClient(workspaceDir, token, authorName, authorEmail string) *GitClient

NewGitClient creates a new Git client.

func (*GitClient) ApplyPatch

func (g *GitClient) ApplyPatch(ctx context.Context, patchPath string) error

ApplyPatch applies a patch file to the workspace and stages all changes.

func (*GitClient) CommitChanges

func (g *GitClient) CommitChanges(ctx context.Context, message string) (string, error)

CommitChanges commits all changes with the given message.

func (*GitClient) CreateBranch

func (g *GitClient) CreateBranch(ctx context.Context, branchName string) error

CreateBranch creates a new branch or checks out existing one.

NOTE: This function performs destructive git operations (reset --hard, clean -fd) to ensure the worktree is clean before branch creation. This is safe for publish workflows where the workspace should be in a clean state, but could discard uncommitted changes if called in other contexts.

func (*GitClient) EnsureCleanWorkspace

func (g *GitClient) EnsureCleanWorkspace() error

EnsureCleanWorkspace ensures the workspace is a Git repository.

func (*GitClient) Push

func (g *GitClient) Push(branchName string) error

Push pushes the current branch to remote.

type PRPublisher

type PRPublisher struct{}

PRPublisher publishes Holon outputs as GitHub PRs.

func NewPRPublisher

func NewPRPublisher() *PRPublisher

NewPRPublisher creates a new PR publisher instance.

func (*PRPublisher) Name

func (p *PRPublisher) Name() string

Name returns the provider name.

func (*PRPublisher) Publish

Publish sends Holon outputs to GitHub as a PR.

func (*PRPublisher) Validate

func (p *PRPublisher) Validate(req publisher.PublishRequest) error

Validate checks if the request is valid for this publisher.

type PRPublisherConfig

type PRPublisherConfig struct {
	// BranchName is the name of the branch to create/use for the PR
	BranchName string

	// Title is the PR title (if empty, derived from summary.md)
	Title string

	// CommitMessage is the commit message (if empty, derived from summary.md)
	CommitMessage string

	// IssueID is the optional issue number to reference in the PR
	IssueID string

	// AuthorName is the git author name for commits (if empty, uses "holonbot[bot]")
	AuthorName string

	// AuthorEmail is the git author email for commits (if empty, uses holonbot noreply address)
	AuthorEmail string

	// DryRun if true, validates without making changes
	DryRun bool
}

PRPublisherConfig contains configuration for PR publishing.

type PRRef

type PRRef struct {
	Owner      string
	Repo       string
	BaseBranch string // Optional: defaults to "main"
}

PRRef represents a parsed GitHub repository reference. Supports formats: "owner/repo", "owner/repo:base_branch"

func ParsePRRef

func ParsePRRef(target string) (*PRRef, error)

ParsePRRef parses a PR reference string into a PRRef struct.

func (PRRef) CloneURL

func (r PRRef) CloneURL() string

CloneURL returns the HTTPS clone URL for the repository.

func (PRRef) FullName

func (r PRRef) FullName() string

FullName returns the full repository name (owner/repo).

func (PRRef) GitCloneURLWithToken

func (r PRRef) GitCloneURLWithToken(token string) string

GitCloneURLWithToken returns the HTTPS clone URL with an embedded token.

func (PRRef) String

func (r PRRef) String() string

String returns the string representation of the PR reference.

Jump to

Keyboard shortcuts

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