githubpr

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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

	// LegacyTokenEnv is the legacy environment variable for GitHub token.
	LegacyTokenEnv = "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"
)

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
}

GitClient handles Git operations for PR creation.

func NewGitClient

func NewGitClient(workspaceDir, token 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(message string) (string, error)

CommitChanges commits all changes with the given message.

func (*GitClient) CreateBranch

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

CreateBranch creates a new branch or checks out existing one.

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

	// 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