Documentation
¶
Index ¶
- func CloneRepository(session GithubSessionInterface, options CloneOptions) (*git.Repository, error)
- func CloneRepositoryNoCheckout(session GithubSessionInterface, repositoryURL, workDir, branch string) (*git.Repository, error)
- func CloneRepositorySimple(session GithubSessionInterface, repositoryURL, workDir, branch string) (*git.Repository, error)
- func CloneRepositoryWithAuth(session GithubSessionInterface, repositoryURL, workDir, branch string, ...) (*git.Repository, error)
- func CommitAllChangesWithToken(repo *git.Repository, branch, message string, githubAccessToken string) (string, error)
- func CommitChanges(repo *git.Repository, options CommitOptions) (string, error)
- func CommitChangesWithToken(repo *git.Repository, branch, message string, files []string, ...) (string, error)
- func CreateCheckRun(ctx context.Context, session GithubSessionInterface, options CheckRunOptions) error
- func CreateCheckRunSimple(ctx context.Context, session GithubSessionInterface, ...) error
- type AuthorInfo
- type CheckRunOptions
- type CloneOptions
- type CommitOptions
- type GithubConfig
- type GithubSession
- func (s *GithubSession) AuthToken() *oauth2.Token
- func (s *GithubSession) Client() *github.Client
- func (s *GithubSession) CreatePullRequest(ctx context.Context, owner, repo string, opts *PullRequestOptions) (*github.PullRequest, error)
- func (s *GithubSession) CreatePullRequestSimple(ctx context.Context, owner, repo, title, head, base string) (*github.PullRequest, error)
- type GithubSessionInterface
- type PullRequestOptions
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneRepository ¶
func CloneRepository(session GithubSessionInterface, options CloneOptions) (*git.Repository, error)
CloneRepository clones the specified GitHub repository with the provided options
func CloneRepositoryNoCheckout ¶ added in v1.3.12
func CloneRepositoryNoCheckout(session GithubSessionInterface, repositoryURL, workDir, branch string) (*git.Repository, error)
CloneRepositoryNoCheckout is a convenience function that clones a repository without checking out files
func CloneRepositorySimple ¶ added in v1.3.11
func CloneRepositorySimple(session GithubSessionInterface, repositoryURL, workDir, branch string) (*git.Repository, error)
CloneRepositorySimple is a convenience function that clones a repository with basic options
func CloneRepositoryWithAuth ¶ added in v1.3.11
func CloneRepositoryWithAuth( session GithubSessionInterface, repositoryURL, workDir, branch string, auth *ghhttp.BasicAuth, gitOptions *git.CloneOptions, ) (*git.Repository, error)
CloneRepositoryWithAuth is a convenience function that clones a repository with custom authentication
func CommitAllChangesWithToken ¶ added in v1.3.11
func CommitAllChangesWithToken( repo *git.Repository, branch, message string, githubAccessToken string, ) (string, error)
CommitAllChangesWithToken is a convenience function that commits all changes with token authentication
func CommitChanges ¶ added in v1.3.11
func CommitChanges(repo *git.Repository, options CommitOptions) (string, error)
CommitChanges commits changes to the repository with the provided options
func CommitChangesWithToken ¶ added in v1.3.11
func CommitChangesWithToken( repo *git.Repository, branch, message string, files []string, githubAccessToken string, ) (string, error)
CommitChangesWithToken is a convenience function that creates CommitOptions with token authentication
func CreateCheckRun ¶
func CreateCheckRun(ctx context.Context, session GithubSessionInterface, options CheckRunOptions) error
CreateCheckRun creates a check run in the specified GitHub repository with the provided options
func CreateCheckRunSimple ¶ added in v1.3.11
func CreateCheckRunSimple( ctx context.Context, session GithubSessionInterface, headSHA, repo, org, name, title, conclusion, status, summary string, ) error
CreateCheckRunSimple is a convenience function that creates a basic check run
Types ¶
type AuthorInfo ¶ added in v1.3.11
AuthorInfo defines the author information for commits
func GetDefaultAuthor ¶ added in v1.3.11
func GetDefaultAuthor() AuthorInfo
GetDefaultAuthor provides a default author configuration
type CheckRunOptions ¶ added in v1.3.11
type CheckRunOptions struct {
// Required fields
HeadSHA string
Repository string
Org string
Name string
// Optional fields with defaults
Title string
Conclusion string
Status string
Summary string
Text string
// Advanced options
DetailsURL string
ExternalID string
StartedAt *time.Time
CompletedAt *time.Time
Actions []*github.CheckRunAction
Images []*github.CheckRunImage
Annotations []*github.CheckRunAnnotation
}
CheckRunOptions defines the configuration for creating check runs
type CloneOptions ¶ added in v1.3.11
type CloneOptions struct {
// Repository URL to clone
RepositoryURL string
// Local directory to clone into
WorkDir string
// Branch to clone (optional, defaults to default branch)
Branch string
// Authentication credentials (optional, will use session token if not provided)
Auth *ghhttp.BasicAuth
// Git clone options (optional, will use defaults if not provided)
GitCloneOptions *git.CloneOptions
// Progress output (optional, defaults to os.Stdout)
Progress *os.File
// Single branch clone (defaults to true)
SingleBranch bool
// Clone depth (defaults to 1 for shallow clone)
Depth int
// No checkout - clone without checking out files (defaults to false)
NoCheckout bool
}
CloneOptions defines the configuration for cloning repositories
func DefaultCloneOptions ¶ added in v1.3.11
func DefaultCloneOptions() CloneOptions
DefaultCloneOptions provides sensible defaults for cloning
type CommitOptions ¶ added in v1.3.11
type CommitOptions struct {
// Branch to commit to
Branch string
// Commit message
Message string
// Files to add to the commit (if empty, will add all changes)
Files []string
// Add all changes if true, otherwise only add specified files
AddAll bool
// Author information
Author AuthorInfo
// Authentication for pushing
Auth *ghhttp.BasicAuth
// Remote URL (optional, will use existing remote if not specified)
RemoteURL string
// Remote name (defaults to "origin")
RemoteName string
}
CommitOptions defines the configuration for committing changes
type GithubConfig ¶
type GithubConfig struct {
Pem string `mapstructure:"pem"`
AppId string `mapstructure:"app_id"`
InstallId string `mapstructure:"install_id"`
}
func GithubLoadConfig ¶
func GithubLoadConfig() (*GithubConfig, error)
type GithubSession ¶
type GithubSession struct {
// contains filtered or unexported fields
}
func NewGithubSession ¶
func NewGithubSession(pem, appID, installID string) (*GithubSession, error)
NewGithubSession creates a new Github session using the provided PEM file, App ID, and Install ID
func (*GithubSession) AuthToken ¶
func (s *GithubSession) AuthToken() *oauth2.Token
Get AuthToken returns the authentication token
func (*GithubSession) Client ¶
func (s *GithubSession) Client() *github.Client
Get Client returns the authenticated Github client
func (*GithubSession) CreatePullRequest ¶ added in v1.3.13
func (s *GithubSession) CreatePullRequest( ctx context.Context, owner, repo string, opts *PullRequestOptions, ) (*github.PullRequest, error)
CreatePullRequest creates a new pull request in the specified repository using the provided options
Example ¶
Example test demonstrating usage
// This example shows how to use the new extensible CreatePullRequest function
session := &GithubSession{} // Assume properly initialized
opts := &PullRequestOptions{
Title: "Add new feature",
Head: "feature-branch",
Base: "main",
Body: github.Ptr("This PR adds a new feature with comprehensive tests"),
Draft: github.Ptr(false),
MaintainerCanModify: github.Ptr(true),
Assignees: []string{"developer1"},
Reviewers: []string{"reviewer1", "reviewer2"},
Labels: []string{"enhancement", "needs-review"},
Milestone: github.Ptr(1),
}
ctx := context.Background()
pr, err := session.CreatePullRequest(ctx, "owner", "repo", opts)
if err != nil {
fmt.Printf("Error creating PR: %v\n", err)
return
}
fmt.Printf("Created PR #%d: %s\n", pr.GetNumber(), pr.GetTitle())
func (*GithubSession) CreatePullRequestSimple ¶ added in v1.3.13
func (s *GithubSession) CreatePullRequestSimple( ctx context.Context, owner, repo, title, head, base string, ) (*github.PullRequest, error)
CreatePullRequestSimple creates a pull request with basic options (backward compatibility)
type GithubSessionInterface ¶
GithubSessionInterface defines the interface for Github sessions
type PullRequestOptions ¶ added in v1.3.13
type PullRequestOptions struct {
Title string `json:"title"`
Head string `json:"head"`
Base string `json:"base"`
Body *string `json:"body,omitempty"`
Draft *bool `json:"draft,omitempty"`
MaintainerCanModify *bool `json:"maintainer_can_modify,omitempty"`
Assignees []string `json:"assignees,omitempty"`
Reviewers []string `json:"reviewers,omitempty"`
TeamReviewers []string `json:"team_reviewers,omitempty"`
Labels []string `json:"labels,omitempty"`
Milestone *int `json:"milestone,omitempty"`
}
PullRequestOptions contains options for creating a pull request
func (*PullRequestOptions) Validate ¶ added in v1.3.13
func (opts *PullRequestOptions) Validate() error
Validate validates the pull request options