Documentation
¶
Index ¶
- Constants
- func CheckGHAuth() error
- func CheckoutBranch(repoPath, branchName string) error
- func CleanupClone(owner, repo string) error
- func CloneRepository(owner, repo, targetPath string) error
- func ClosePR(owner, repo string, prNumber int) error
- func EnsureCloneDirectory() error
- func FetchBranch(repoPath, branchName string) error
- func FindExistingClone(owner, repo string) (string, bool)
- func GeneratePRPrompt(pr *PRInfo, includeDescription bool) string
- func GetClonePath(owner, repo string) string
- func GetPRDiff(owner, repo string, prNumber int) (string, error)
- func GetRemoteURL(repoPath string) (string, error)
- func IsGitHubRef(input string) bool
- func ListClonedRepos() ([]string, error)
- func MergePR(owner, repo string, prNumber int, method string) error
- func PostPRComment(owner, repo string, prNumber int, body string) error
- type CloneOptions
- type CloneResult
- type PRComment
- type PRInfo
- type ParsedGitHubRef
- type RefType
Constants ¶
const (
// DefaultCloneBase is the default base directory for cloned repositories
DefaultCloneBase = "~/.stapler-squad/repos"
)
Variables ¶
This section is empty.
Functions ¶
func CheckGHAuth ¶
func CheckGHAuth() error
CheckGHAuth checks if GitHub CLI is installed and authenticated
func CheckoutBranch ¶
CheckoutBranch checks out a branch in an existing repository
func CleanupClone ¶
CleanupClone removes a cloned repository Use with caution - this deletes the entire repository directory
func CloneRepository ¶
CloneRepository clones a GitHub repository
func EnsureCloneDirectory ¶
func EnsureCloneDirectory() error
EnsureCloneDirectory ensures the base clone directory exists
func FetchBranch ¶
FetchBranch fetches a specific branch in an existing repository
func FindExistingClone ¶
FindExistingClone checks if a repository is already cloned Returns the path and true if found, empty string and false otherwise
func GeneratePRPrompt ¶
GeneratePRPrompt generates a context prompt from PR information This can be used to initialize a Claude Code session with PR context
func GetClonePath ¶
GetClonePath returns the path where a repository would be cloned Format: ~/.stapler-squad/repos/{owner}/{repo}
func GetRemoteURL ¶
GetRemoteURL returns the remote URL of a repository (used to determine owner/repo)
func IsGitHubRef ¶
IsGitHubRef checks if the input string looks like a GitHub URL or reference This is a quick check that doesn't validate the full format
func ListClonedRepos ¶
ListClonedRepos returns a list of all cloned repositories
Types ¶
type CloneOptions ¶
type CloneOptions struct {
Owner string
Repo string
Branch string // Optional: specific branch to checkout after cloning
Shallow bool // Use shallow clone (--depth=1) for faster cloning
}
CloneOptions specifies options for cloning or accessing a repository
type CloneResult ¶
type CloneResult struct {
Path string // Full path to the repository
WasCloned bool // True if we just cloned it, false if it already existed
Branch string // Current branch name
}
CloneResult contains information about a cloned or existing repository
func GetOrCloneRepository ¶
func GetOrCloneRepository(opts CloneOptions) (*CloneResult, error)
GetOrCloneRepository ensures a repository is available locally It will clone it if not already present, or return the existing clone
type PRComment ¶
type PRComment struct {
ID int `json:"id"`
Author string `json:"author"`
Body string `json:"body"`
CreatedAt time.Time `json:"createdAt"`
Path string `json:"path,omitempty"` // For review comments
Line int `json:"line,omitempty"` // For review comments
IsReview bool `json:"isReview,omitempty"` // True if this is a review comment
}
PRComment represents a comment on a PR (either issue comment or review comment)
type PRInfo ¶
type PRInfo struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
HeadRef string `json:"headRefName"`
BaseRef string `json:"baseRefName"`
State string `json:"state"`
Author string `json:"author"`
Labels []string `json:"labels"`
HTMLURL string `json:"url"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
IsDraft bool `json:"isDraft"`
Mergeable string `json:"mergeable"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
ChangedFiles int `json:"changedFiles"`
}
PRInfo contains metadata about a GitHub pull request
type ParsedGitHubRef ¶
type ParsedGitHubRef struct {
Type RefType
Owner string
Repo string
PRNumber int // Only populated for RefTypePR
IssueNumber int // Only populated for RefTypeIssue
Branch string // Populated for RefTypeBranch, or PR head branch after fetching
CommitSHA string // Only populated for RefTypeCommit
FilePath string // Only populated for RefTypeFile (path within repo)
LineStart int // Only populated for RefTypeFile (optional line number)
LineEnd int // Only populated for RefTypeFile (optional end line for range)
BaseBranch string // Only populated for RefTypeCompare (the base of comparison)
HeadBranch string // Only populated for RefTypeCompare (the head being compared)
Tag string // Only populated for RefTypeRelease
OriginalURL string // The original input string
}
ParsedGitHubRef represents a parsed GitHub URL or reference
func ParseGitHubRef ¶
func ParseGitHubRef(input string) (*ParsedGitHubRef, error)
ParseGitHubRef parses a GitHub URL or shorthand reference into a ParsedGitHubRef Supported formats:
- https://github.com/owner/repo/pull/123
- https://github.com/owner/repo/tree/branch-name
- https://github.com/owner/repo/blob/branch/path/to/file.go
- https://github.com/owner/repo/blob/branch/file.go#L10 (with line number)
- https://github.com/owner/repo/blob/branch/file.go#L10-L20 (with line range)
- https://github.com/owner/repo/commit/abc123
- https://github.com/owner/repo/issues/42
- https://github.com/owner/repo/compare/main...feature
- https://github.com/owner/repo/releases/tag/v1.0.0
- https://github.com/owner/repo
- github.com/owner/repo
- git@github.com:owner/repo.git (SSH)
- ssh://git@github.com/owner/repo (SSH protocol)
- owner/repo:branch-name
- owner/repo
func (*ParsedGitHubRef) CloneURL ¶
func (p *ParsedGitHubRef) CloneURL() string
CloneURL returns the HTTPS clone URL for the repository
func (*ParsedGitHubRef) DisplayName ¶
func (p *ParsedGitHubRef) DisplayName() string
DisplayName returns a human-readable name for the reference
func (*ParsedGitHubRef) HTMLURL ¶
func (p *ParsedGitHubRef) HTMLURL() string
HTMLURL returns the human-readable GitHub URL
func (*ParsedGitHubRef) RepoFullName ¶
func (p *ParsedGitHubRef) RepoFullName() string
RepoFullName returns "owner/repo" format
func (*ParsedGitHubRef) SuggestedSessionName ¶
func (p *ParsedGitHubRef) SuggestedSessionName() string
SuggestedSessionName returns a suggested session name based on the reference