Documentation
¶
Overview ¶
Package ado is the Azure DevOps provider. It works through the az CLI and its azure-devops extension, except for the two pull request changes az cannot make (changing the target branch, and completing with a rebase), which go to the REST API directly.
Index ¶
- Variables
- func ExecRunner(args ...string) ([]byte, error)
- func Plugin(run Runner, rest *REST) protocol.Plugin
- type Client
- func (c *Client) CreatePR(n protocol.NewCR) (*PR, error)
- func (c *Client) GetPR(id int) (*PR, error)
- func (c *Client) GetRepo() (*RepoInfo, error)
- func (c *Client) ListPRs(criteria map[string]string) ([]*PR, error)
- func (c *Client) Policies() ([]*Policy, error)
- func (c *Client) UpdatePR(id int, u PRUpdate) (*PR, error)
- type Identity
- type PR
- type PRUpdate
- type Policy
- type Provider
- func (p *Provider) CancelAutoMerge(n int) error
- func (p *Provider) CreateCR(n protocol.NewCR) (*protocol.CR, error)
- func (p *Provider) FindCRForBranch(branch string) (*protocol.CR, error)
- func (p *Provider) GetBranch(name string) (*protocol.Branch, error)
- func (p *Provider) GetCR(n int) (*protocol.CR, error)
- func (p *Provider) GetRepo() (*protocol.RepoSettings, error)
- func (p *Provider) ListCRsTargeting(branch string) ([]*protocol.CR, error)
- func (p *Provider) MarkReady(n int) (*protocol.CR, error)
- func (p *Provider) Merge(n int, method, sha string) (*protocol.CR, error)
- func (p *Provider) SearchCRs(text string) ([]*protocol.CR, error)
- func (p *Provider) SyncStack([]int) error
- func (p *Provider) ToCR(pr *PR) *protocol.CR
- func (p *Provider) Unstack([]int) error
- func (p *Provider) UpdateCR(n int, u protocol.Update) (*protocol.CR, error)
- type REST
- type Ref
- type RepoInfo
- type Repository
- type Runner
Constants ¶
This section is empty.
Variables ¶
var Info = protocol.Info{ Name: "ado", Terms: protocol.Terms{Short: "PR", Long: "pull request", Ref: "!%d"}, MaxBody: 4000, MergeMethods: []string{protocol.MethodMerge, protocol.MethodSquash, protocol.MethodRebase}, }
Info describes the Azure DevOps provider. Descriptions are limited to 4000 characters.
Functions ¶
func ExecRunner ¶
ExecRunner runs the az binary. It never installs extensions: without the azure-devops extension az fails at once, and classify says how to add it.
Types ¶
type Client ¶
type Client struct {
Run Runner
Repo Repository
// REST makes the calls az cannot.
REST *REST
}
Client makes Azure DevOps calls for one repository.
func (*Client) ListPRs ¶
ListPRs returns this repository's pull requests matching the search criteria (e.g. "status", "sourceRefName"), newest first. The list is project-wide (see invoke), so other repositories' PRs are dropped here.
type PR ¶
type PR struct {
ID int `json:"pullRequestId"`
Title string `json:"title"`
Description string `json:"description"`
Status string `json:"status"` // active, completed, abandoned
IsDraft bool `json:"isDraft"`
SourceRefName string `json:"sourceRefName"`
TargetRefName string `json:"targetRefName"`
LastMergeSourceCommit *Ref `json:"lastMergeSourceCommit"`
AutoCompleteSetBy *Identity `json:"autoCompleteSetBy"`
CompletionOptions *struct {
DeleteSourceBranch bool `json:"deleteSourceBranch"`
} `json:"completionOptions"`
// MergeStatus is notSet, queued, conflicts, succeeded, rejectedByPolicy or failure.
MergeStatus string `json:"mergeStatus"`
MergeFailureMessage string `json:"mergeFailureMessage"`
// CompletionQueueTime is set once someone asked to complete the PR.
CompletionQueueTime string `json:"completionQueueTime"`
ForkSource json.RawMessage `json:"forkSource"`
Repository struct {
Name string `json:"name"`
} `json:"repository"`
}
PR is the subset of an Azure DevOps pull request that git-stack uses.
type PRUpdate ¶
type PRUpdate struct {
Title, Description *string
Draft, AutoComplete *bool
// Status "completed" completes the PR at its current head; Squash then
// chooses squashing.
Status string
Squash *bool
}
PRUpdate lists the changes `az repos pr update` can make; nil fields are left alone.
type Policy ¶
type Policy struct {
IsEnabled bool `json:"isEnabled"`
IsBlocking bool `json:"isBlocking"`
IsDeleted bool `json:"isDeleted"`
Type struct {
ID string `json:"id"`
} `json:"type"`
Settings struct {
Scope []struct {
RepositoryID string `json:"repositoryId"`
RefName string `json:"refName"`
MatchKind string `json:"matchKind"` // exact, prefix, defaultBranch
} `json:"scope"`
AllowNoFastForward bool `json:"allowNoFastForward"`
AllowSquash bool `json:"allowSquash"`
AllowRebase bool `json:"allowRebase"`
AllowRebaseMerge bool `json:"allowRebaseMerge"`
} `json:"settings"`
}
Policy is a branch policy configuration.
type Provider ¶
type Provider struct {
C *Client
}
Provider adapts Client to protocol.Provider.
func (*Provider) CancelAutoMerge ¶
CancelAutoMerge turns auto-complete off.
func (*Provider) FindCRForBranch ¶
FindCRForBranch returns the active PR whose source is branch, else the most recently completed one, else nil. PRs from forks are ignored.
func (*Provider) GetBranch ¶
GetBranch reports whether name is the default branch, and whether a blocking branch policy applies to it.
func (*Provider) GetRepo ¶
func (p *Provider) GetRepo() (*protocol.RepoSettings, error)
GetRepo returns the default branch's preferred merge method: the first strategy its "Require a merge strategy" policy allows, else merge.
func (*Provider) ListCRsTargeting ¶
ListCRsTargeting returns active PRs, not from forks, whose target is branch.
func (*Provider) Merge ¶
Merge completes the pull request, if its source branch is still at sha. When Azure DevOps refuses (required reviewers, builds or other policies), it sets the PR to auto-complete instead, so it completes once the policies pass. az completes with a merge commit or a squash; a rebase goes to the REST API.
func (*Provider) SearchCRs ¶
SearchCRs returns active PRs whose description contains text. Azure DevOps cannot search descriptions, and lists cut them short, so long ones are fetched in full.
func (*Provider) SyncStack ¶
SyncStack is a no-op: Azure DevOps has no stack object; the description block is the stack.
type REST ¶
type REST struct {
HTTP *http.Client
// Auth returns the Authorization header value.
Auth func() (string, error)
}
REST calls the Azure DevOps REST API for what az cannot do.
type Repository ¶
type Repository struct {
OrgURL, Project, Name string
}
Repository locates a repository: the organization (or collection) URL, the project and the repository name.