Documentation ¶
Overview ¶
Package repository contains everything related to working with git repositories hosted on GitHub: cloning, commits, creating branches, pushing, creating/updating/merging pull requests, and so on.
Index ¶
- Constants
- type BranchProtectionKind
- type CommitMessage
- type GitHubOptions
- type GitOptions
- type PullRequestMergeOptions
- type PullRequestOptions
- type PullRequestResult
- type RepoUpdateResult
- type Repository
- type ResultFile
- type SearchType
- type Strategy
- func NewAppendStrategy(repository Repository, repoPath string, updaters []update.Updater, ...) *Strategy
- func NewRecreateStrategy(repository Repository, repoPath string, updaters []update.Updater, ...) *Strategy
- func NewResetStrategy(repository Repository, repoPath string, updaters []update.Updater, ...) *Strategy
- type UpdateOptions
Constants ¶
const ( IgnoreUpdateOperation = "ignore" ReplaceUpdateOperation = "replace" PrependUpdateOperation = "prepend" AppendUpdateOperation = "append" PublicGithubURL = "https://github.com" )
definition of the different kind of Pull Request update operations
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchProtectionKind ¶ added in v1.9.0
type BranchProtectionKind string
BranchProtectionKind enumerates possible branch protections to wait for before attempting a PR merge.
const ( // BranchProtectionKindStatusChecks waits for all required statues & checksuite runs to be passing ("success", "neutral", "skipped") BranchProtectionKindStatusChecks BranchProtectionKind = "statusChecks" // BranchProtectionKindAll wait for all protection rules BranchProtectionKindAll BranchProtectionKind = "all" // BranchProtectionKindBypass waits until the user can bypass branch protection rules BranchProtectionKindBypass BranchProtectionKind = "bypass" )
func (*BranchProtectionKind) Set ¶ added in v1.9.0
func (b *BranchProtectionKind) Set(s string) error
func (*BranchProtectionKind) String ¶ added in v1.9.0
func (b *BranchProtectionKind) String() string
func (*BranchProtectionKind) Type ¶ added in v1.9.0
func (b *BranchProtectionKind) Type() string
type CommitMessage ¶ added in v1.11.1
func NewCommitMessage ¶ added in v1.11.1
func NewCommitMessage(title, body, footer string) CommitMessage
func (CommitMessage) String ¶ added in v1.11.1
func (c CommitMessage) String() string
type GitHubOptions ¶
type GitHubOptions struct { URL string AuthMethod string Token string AppID int64 InstallationID int64 PrivateKey string PrivateKeyPath string PullRequest PullRequestOptions }
GitHubOptions holds all the options required to perform github operations: auth, PRs, ...
type GitOptions ¶
type GitOptions struct { CloneDir string StagePatterns []string StageAllChanged bool AuthorName string AuthorEmail string CommitterName string CommitterEmail string CommitTitle string CommitBody string BranchPrefix string SigningKeyPath string SigningKeyPassphrase string }
GitOptions holds all the options required to perform git operations: clone, commit, ...
type PullRequestMergeOptions ¶
type PullRequestMergeOptions struct { Enabled bool Auto bool AutoWait bool Method string CommitTitle string CommitMessage string SHA string PollInterval time.Duration PollTimeout time.Duration RetryCount int BranchProtection BranchProtectionKind }
PullRequestMergeOptions holds all the options required to merge github PRs
type PullRequestOptions ¶
type PullRequestOptions struct { Labels []string BaseBranch string Title string TitleUpdateOperation string Body string BodyUpdateOperation string Comments []string Assignees []string Draft bool Merge PullRequestMergeOptions }
PullRequestOptions holds all the options required to perform github PR operations: title/body, merge, ...
type PullRequestResult ¶ added in v1.8.0
type RepoUpdateResult ¶ added in v1.8.0
type RepoUpdateResult struct { Owner string `json:"owner"` Repo string `json:"repo"` Error *string `json:"error"` PullRequest *PullRequestResult `json:"pr"` IsUpdated bool }
type Repository ¶
Repository is a representation of a GitHub repository.
func Parse ¶
func Parse(ctx context.Context, repos []string, githubOpts GitHubOptions) ([]Repository, error)
Parse parses a set of repositories defined as string - from the CLI for example - and returns properly formatted Repositories expected syntax is documented in the user documentation: docs/current-version/content/repos/{static,dynamic}.md
func (Repository) FullName ¶
func (r Repository) FullName() string
FullName returns the repository full name.
func (Repository) GitFullName ¶ added in v1.1.32
func (r Repository) GitFullName() string
FullName returns the repository full name with the git extension
func (Repository) Update ¶
func (r Repository) Update(ctx context.Context, updaters []update.Updater, options UpdateOptions) (bool, *github.PullRequest, error)
Update is the entrypoint to update a repository with a set of updaters. It returns a boolean indicating whether the repository was updated or not.
type ResultFile ¶ added in v1.8.0
type ResultFile struct {
Repos []RepoUpdateResult `json:"repos"`
}
type SearchType ¶ added in v1.5.0
type SearchType int
SearchType represents the type of search to be performed.
const ( // Repositories is a search type for repositories. Repositories SearchType = iota // Code is a search type for code. Code )
type Strategy ¶
type Strategy struct { Repository Repository RepoPath string Updaters []update.Updater Options UpdateOptions FindMatchingPullRequest bool DefaultUpdateOperation string ResetFromBase bool }
Strategy defines how the pull request will be created or updated if one already exists.
func NewAppendStrategy ¶ added in v1.11.1
func NewAppendStrategy(repository Repository, repoPath string, updaters []update.Updater, options UpdateOptions) *Strategy
AppendStrategy is a strategy that appends new commits to any existing Pull Request. So it will try to find a matching PR first, and use it (its branch). Then it will commit on this branch, and update the existing PR - or create a new one if there is no matching PR.
func NewRecreateStrategy ¶ added in v1.11.1
func NewRecreateStrategy(repository Repository, repoPath string, updaters []update.Updater, options UpdateOptions) *Strategy
RecreateStrategy is a strategy implementation that always creates a new Pull Request - even if an existing one for the same labels already exists.
func NewResetStrategy ¶ added in v1.11.1
func NewResetStrategy(repository Repository, repoPath string, updaters []update.Updater, options UpdateOptions) *Strategy
ResetStrategy is a strategy implementation that resets any existing Pull Request from the base branch. So it will try to find a matching PR first, and use it (its branch) - but it will "reset" the branch from the base branch. And it will update the existing PR - or create a new one.
type UpdateOptions ¶
type UpdateOptions struct { DryRun bool KeepFiles bool Git GitOptions GitHub GitHubOptions Strategy string }
UpdateOptions is the options entrypoint for a git repo update