Documentation
¶
Index ¶
- Constants
- type BuildLog
- type BuildLogsResponse
- type ChangeItem
- type Client
- func (c *Client) AddPRCodeComment(repositoryID string, pullRequestID int, filePath string, line int, ...) (*Thread, error)
- func (c *Client) AddPRComment(repositoryID string, pullRequestID int, comment string) (*Thread, error)
- func (c *Client) GetBuildLogContent(buildID, logID int) (string, error)
- func (c *Client) GetBuildTimeline(buildID int) (*Timeline, error)
- func (c *Client) GetCurrentUserID() (string, error)
- func (c *Client) GetFileContent(repositoryID string, filePath string, branchName string) (string, error)
- func (c *Client) GetOrg() string
- func (c *Client) GetPRIterationChanges(repositoryID string, pullRequestID int, iterationID int) ([]IterationChange, error)
- func (c *Client) GetPRIterations(repositoryID string, pullRequestID int) ([]Iteration, error)
- func (c *Client) GetPRThreads(repositoryID string, pullRequestID int) ([]Thread, error)
- func (c *Client) GetProject() string
- func (c *Client) GetWorkItemTypeStates(workItemType string) ([]WorkItemTypeState, error)
- func (c *Client) GetWorkItems(ids []int) ([]WorkItem, error)
- func (c *Client) ListBuildLogs(buildID int) ([]BuildLog, error)
- func (c *Client) ListMyPullRequests(creatorID string, top int) ([]PullRequest, error)
- func (c *Client) ListMyWorkItems(top int) ([]WorkItem, error)
- func (c *Client) ListPipelineRuns(top int) ([]PipelineRun, error)
- func (c *Client) ListPullRequests(top int) ([]PullRequest, error)
- func (c *Client) ListPullRequestsAsReviewer(reviewerID string, top int) ([]PullRequest, error)
- func (c *Client) ListWorkItems(top int) ([]WorkItem, error)
- func (c *Client) QueryWorkItemIDs(query string, top int) ([]int, error)
- func (c *Client) ReplyToThread(repositoryID string, pullRequestID int, threadID int, content string) (*Comment, error)
- func (c *Client) SetBaseURL(url string)
- func (c *Client) SetUserID(id string)
- func (c *Client) UpdateThreadStatus(repositoryID string, pullRequestID int, threadID int, status string) error
- func (c *Client) UpdateWorkItemState(id int, state string) error
- func (c *Client) VotePullRequest(repositoryID string, pullRequestID int, vote int) error
- type Comment
- type FilePosition
- type Identity
- type Issue
- type Iteration
- type IterationChange
- type IterationChangesResponse
- type IterationsResponse
- type Link
- type Links
- type LogReference
- type MultiClient
- func (mc *MultiClient) ClientFor(project string) *Client
- func (mc *MultiClient) DisplayNameFor(project string) string
- func (mc *MultiClient) GetOrg() string
- func (mc *MultiClient) IsMultiProject() bool
- func (mc *MultiClient) ListMyPullRequests(top int) ([]PullRequest, error)
- func (mc *MultiClient) ListMyWorkItems(top int) ([]WorkItem, error)
- func (mc *MultiClient) ListPipelineRuns(top int) ([]PipelineRun, error)
- func (mc *MultiClient) ListPullRequests(top int) ([]PullRequest, error)
- func (mc *MultiClient) ListPullRequestsAsReviewer(top int) ([]PullRequest, error)
- func (mc *MultiClient) ListWorkItems(top int) ([]WorkItem, error)
- func (mc *MultiClient) Projects() []string
- type PartialError
- type PipelineDefinition
- type PipelineRun
- type PipelineRunsResponse
- type Project
- type PullRequest
- type PullRequestsResponse
- type Repository
- type Reviewer
- type Thread
- type ThreadContext
- type ThreadsResponse
- type Timeline
- type TimelineRecord
- type WIQLResponse
- type WorkItem
- type WorkItemFields
- type WorkItemReference
- type WorkItemTypeState
- type WorkItemTypeStatesResponse
- type WorkItemsResponse
Constants ¶
const ( VoteApprove = 10 // Approved VoteApproveWithSuggestions = 5 // Approved with suggestions VoteNoVote = 0 // No vote VoteWaitForAuthor = -5 // Waiting for author VoteReject = -10 // Rejected )
Vote values for pull request reviews
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildLog ¶
type BuildLog struct {
ID int `json:"id"`
Type string `json:"type"`
URL string `json:"url"`
LineCount int `json:"lineCount"`
CreatedOn *time.Time `json:"createdOn"`
LastChangedOn *time.Time `json:"lastChangedOn"`
}
BuildLog represents metadata about a build log
type BuildLogsResponse ¶
BuildLogsResponse represents the API response for listing build logs
type ChangeItem ¶
type ChangeItem struct {
ObjectID string `json:"objectId"`
Path string `json:"path"`
GitObjectType string `json:"gitObjectType,omitempty"` // "blob" for files, "tree" for folders
}
ChangeItem represents the item details in an iteration change
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an Azure DevOps API client
func (*Client) AddPRCodeComment ¶
func (c *Client) AddPRCodeComment(repositoryID string, pullRequestID int, filePath string, line int, content string) (*Thread, error)
AddPRCodeComment creates a new comment thread attached to a specific file and line repositoryID: the ID of the repository pullRequestID: the ID of the pull request filePath: the path of the file to comment on line: the line number in the new file to attach the comment to content: the comment text
func (*Client) AddPRComment ¶
func (c *Client) AddPRComment(repositoryID string, pullRequestID int, comment string) (*Thread, error)
AddPRComment adds a general comment thread to a pull request repositoryID: the ID of the repository pullRequestID: the ID of the pull request comment: the comment text
func (*Client) GetBuildLogContent ¶
GetBuildLogContent retrieves the content of a specific log
func (*Client) GetBuildTimeline ¶
GetBuildTimeline retrieves the timeline for a specific build The timeline contains all stages, jobs, and tasks with their status and logs
func (*Client) GetCurrentUserID ¶
GetCurrentUserID returns the authenticated user's ID, fetching and caching it on first call
func (*Client) GetFileContent ¶
func (c *Client) GetFileContent(repositoryID string, filePath string, branchName string) (string, error)
GetFileContent retrieves raw file content at a specific branch version repositoryID: the ID of the repository filePath: the path of the file in the repository branchName: the short branch name (e.g., "main", not "refs/heads/main")
func (*Client) GetPRIterationChanges ¶
func (c *Client) GetPRIterationChanges(repositoryID string, pullRequestID int, iterationID int) ([]IterationChange, error)
GetPRIterationChanges retrieves files changed in a specific PR iteration repositoryID: the ID of the repository pullRequestID: the ID of the pull request iterationID: the iteration to get changes for
func (*Client) GetPRIterations ¶
GetPRIterations retrieves iterations for a pull request repositoryID: the ID of the repository pullRequestID: the ID of the pull request
func (*Client) GetPRThreads ¶
GetPRThreads retrieves comment threads for a pull request repositoryID: the ID of the repository pullRequestID: the ID of the pull request
func (*Client) GetProject ¶
GetProject returns the project name
func (*Client) GetWorkItemTypeStates ¶
func (c *Client) GetWorkItemTypeStates(workItemType string) ([]WorkItemTypeState, error)
GetWorkItemTypeStates retrieves the available states for a work item type. States in the "Removed" category are excluded since they are not typical user transitions.
func (*Client) GetWorkItems ¶
GetWorkItems retrieves work items by their IDs Azure DevOps supports up to 200 IDs per request
func (*Client) ListBuildLogs ¶
ListBuildLogs retrieves all logs for a specific build
func (*Client) ListMyPullRequests ¶ added in v0.5.4
func (c *Client) ListMyPullRequests(creatorID string, top int) ([]PullRequest, error)
ListMyPullRequests retrieves active pull requests created by the given user. creatorID: the Azure DevOps user ID (UUID) of the creator to filter by. top: maximum number of pull requests to return.
func (*Client) ListMyWorkItems ¶
ListMyWorkItems retrieves work items assigned to the authenticated user using the @Me WIQL macro, which Azure DevOps resolves server-side from the PAT. top: maximum number of work items to return (max 50 enforced)
func (*Client) ListPipelineRuns ¶
func (c *Client) ListPipelineRuns(top int) ([]PipelineRun, error)
ListPipelineRuns retrieves the most recent pipeline runs (builds) for the project top: maximum number of runs to return (typically 25-100) Results are ordered by queue time descending (most recent first)
func (*Client) ListPullRequests ¶
func (c *Client) ListPullRequests(top int) ([]PullRequest, error)
ListPullRequests retrieves active pull requests across all repositories in the project top: maximum number of pull requests to return (typically 25-100) Results are ordered by creation date descending (most recent first)
func (*Client) ListPullRequestsAsReviewer ¶ added in v0.5.4
func (c *Client) ListPullRequestsAsReviewer(reviewerID string, top int) ([]PullRequest, error)
ListPullRequestsAsReviewer retrieves active pull requests where the given user is listed as a reviewer. reviewerID: the Azure DevOps user ID (UUID) of the reviewer to filter by. top: maximum number of pull requests to return.
func (*Client) ListWorkItems ¶
ListWorkItems retrieves work items assigned to the current user top: maximum number of work items to return (max 50 enforced)
func (*Client) QueryWorkItemIDs ¶
QueryWorkItemIDs executes a WIQL query and returns the work item IDs top: maximum number of results to return
func (*Client) ReplyToThread ¶
func (c *Client) ReplyToThread(repositoryID string, pullRequestID int, threadID int, content string) (*Comment, error)
ReplyToThread adds a reply comment to an existing thread repositoryID: the ID of the repository pullRequestID: the ID of the pull request threadID: the ID of the thread to reply to content: the reply text
func (*Client) SetBaseURL ¶ added in v0.5.0
SetBaseURL overrides the base URL for the client. This is used by the demo mode to point to a local mock server.
func (*Client) SetUserID ¶ added in v0.5.0
SetUserID sets the cached user ID, bypassing the connectionData API call. This is used by the demo mode.
func (*Client) UpdateThreadStatus ¶
func (c *Client) UpdateThreadStatus(repositoryID string, pullRequestID int, threadID int, status string) error
UpdateThreadStatus updates the status of a thread (e.g., resolve it) repositoryID: the ID of the repository pullRequestID: the ID of the pull request threadID: the ID of the thread to update status: the new status ("active", "fixed", "wontFix", "closed", "pending")
func (*Client) UpdateWorkItemState ¶
UpdateWorkItemState updates the state of a work item using JSON Patch.
func (*Client) VotePullRequest ¶
VotePullRequest sets the current user's vote on a pull request repositoryID: the ID of the repository pullRequestID: the ID of the pull request vote: the vote value (use VoteApprove, VoteReject, etc. constants)
type Comment ¶
type Comment struct {
ID int `json:"id"`
ParentCommentID int `json:"parentCommentId"`
Content string `json:"content"`
PublishedDate time.Time `json:"publishedDate"`
LastUpdatedDate time.Time `json:"lastUpdatedDate"`
CommentType string `json:"commentType"` // "text", "system"
Author Identity `json:"author"`
}
Comment represents a single comment in a thread
type FilePosition ¶
FilePosition represents a position in a file
type Identity ¶
type Identity struct {
ID string `json:"id"`
DisplayName string `json:"displayName"`
UniqueName string `json:"uniqueName"` // typically email
}
Identity represents a user identity in Azure DevOps
type Issue ¶
type Issue struct {
Type string `json:"type"` // "error", "warning"
Message string `json:"message"`
}
Issue represents an error or warning in a timeline record
type IterationChange ¶
type IterationChange struct {
ChangeID int `json:"changeId"`
Item ChangeItem `json:"item"`
ChangeType string `json:"changeType"` // "add", "edit", "delete", "rename"
OriginalPath string `json:"originalPath,omitempty"`
}
IterationChange represents a file changed in a PR iteration
type IterationChangesResponse ¶
type IterationChangesResponse struct {
ChangeEntries []IterationChange `json:"changeEntries"`
}
IterationChangesResponse represents the API response for iteration changes
type IterationsResponse ¶
IterationsResponse represents the API response for listing iterations
type LogReference ¶
LogReference contains metadata about a build log
type MultiClient ¶
type MultiClient struct {
// contains filtered or unexported fields
}
MultiClient wraps multiple project-scoped clients for concurrent fetching.
func NewMultiClient ¶
func NewMultiClient(org string, projects []string, pat string, displayNames map[string]string) (*MultiClient, error)
NewMultiClient creates clients for each project. displayNames is an optional map of API name → display name for UI rendering.
func (*MultiClient) ClientFor ¶
func (mc *MultiClient) ClientFor(project string) *Client
ClientFor returns the project-specific client (for detail views).
func (*MultiClient) DisplayNameFor ¶
func (mc *MultiClient) DisplayNameFor(project string) string
DisplayNameFor returns the display name for a project API name. If no display name is configured, returns the API name itself.
func (*MultiClient) GetOrg ¶
func (mc *MultiClient) GetOrg() string
GetOrg returns the organization name.
func (*MultiClient) IsMultiProject ¶
func (mc *MultiClient) IsMultiProject() bool
IsMultiProject returns true if more than one project is configured.
func (*MultiClient) ListMyPullRequests ¶ added in v0.5.4
func (mc *MultiClient) ListMyPullRequests(top int) ([]PullRequest, error)
ListMyPullRequests fetches PRs created by the authenticated user from all projects concurrently, tags each with ProjectName, merges and sorts by CreationDate descending.
func (*MultiClient) ListMyWorkItems ¶
func (mc *MultiClient) ListMyWorkItems(top int) ([]WorkItem, error)
ListMyWorkItems fetches work items assigned to the authenticated user (@Me) from all projects concurrently, tags each with ProjectName, merges and sorts by ChangedDate descending.
func (*MultiClient) ListPipelineRuns ¶
func (mc *MultiClient) ListPipelineRuns(top int) ([]PipelineRun, error)
ListPipelineRuns fetches pipeline runs from all projects concurrently, merges and sorts by QueueTime descending.
func (*MultiClient) ListPullRequests ¶
func (mc *MultiClient) ListPullRequests(top int) ([]PullRequest, error)
ListPullRequests fetches PRs from all projects concurrently, tags each with ProjectName, merges and sorts by CreationDate descending.
func (*MultiClient) ListPullRequestsAsReviewer ¶ added in v0.5.4
func (mc *MultiClient) ListPullRequestsAsReviewer(top int) ([]PullRequest, error)
ListPullRequestsAsReviewer fetches PRs where the authenticated user is a reviewer from all projects concurrently, tags each with ProjectName, merges and sorts by CreationDate descending.
func (*MultiClient) ListWorkItems ¶
func (mc *MultiClient) ListWorkItems(top int) ([]WorkItem, error)
ListWorkItems fetches work items from all projects concurrently, tags each with ProjectName, merges and sorts by ChangedDate descending.
func (*MultiClient) Projects ¶
func (mc *MultiClient) Projects() []string
Projects returns the list of project names.
type PartialError ¶
type PartialError struct {
Failed int // number of projects that failed
Total int // total number of projects
Errors []error // individual project errors
}
PartialError indicates that some (but not all) projects failed during a multi-project fetch. The caller receives valid data from the successful projects alongside this error.
func (*PartialError) Error ¶
func (e *PartialError) Error() string
type PipelineDefinition ¶
PipelineDefinition represents a pipeline definition
type PipelineRun ¶
type PipelineRun struct {
ID int `json:"id"`
BuildNumber string `json:"buildNumber"`
Status string `json:"status"` // "inProgress", "completed", "canceling", "postponed", "notStarted"
Result string `json:"result"` // "succeeded", "failed", "canceled", "partiallySucceeded", "none"
SourceBranch string `json:"sourceBranch"` // e.g., "refs/heads/main"
SourceVersion string `json:"sourceVersion"` // Git commit SHA
QueueTime time.Time `json:"queueTime"`
StartTime *time.Time `json:"startTime"`
FinishTime *time.Time `json:"finishTime"`
Definition PipelineDefinition `json:"definition"`
Project Project `json:"project"`
Links Links `json:"_links"`
ProjectName string `json:"-"` // Set by MultiClient, not from API
ProjectDisplayName string `json:"-"` // Set by MultiClient, display name for UI
}
PipelineRun represents a build/pipeline run in Azure DevOps
func (*PipelineRun) BranchShortName ¶
func (pr *PipelineRun) BranchShortName() string
BranchShortName returns the short branch name without the refs/heads/ prefix
func (*PipelineRun) Duration ¶
func (pr *PipelineRun) Duration() string
Duration returns a human-readable duration string for the pipeline run
func (*PipelineRun) Timestamp ¶
func (pr *PipelineRun) Timestamp() string
Timestamp returns a formatted timestamp for display in the pipeline table
type PipelineRunsResponse ¶
type PipelineRunsResponse struct {
Count int `json:"count"`
Value []PipelineRun `json:"value"`
}
PipelineRunsResponse represents the API response for listing pipeline runs
type PullRequest ¶
type PullRequest struct {
ID int `json:"pullRequestId"`
Title string `json:"title"`
Description string `json:"description"`
Status string `json:"status"` // "active", "completed", "abandoned"
CreationDate time.Time `json:"creationDate"`
SourceRefName string `json:"sourceRefName"` // e.g., "refs/heads/feature/my-feature"
TargetRefName string `json:"targetRefName"` // e.g., "refs/heads/main"
IsDraft bool `json:"isDraft"`
CreatedBy Identity `json:"createdBy"`
Repository Repository `json:"repository"`
Reviewers []Reviewer `json:"reviewers"`
ProjectName string `json:"-"` // Set by MultiClient, not from API
ProjectDisplayName string `json:"-"` // Set by MultiClient, display name for UI
}
PullRequest represents a pull request in Azure DevOps
func (*PullRequest) SourceBranchShortName ¶
func (pr *PullRequest) SourceBranchShortName() string
SourceBranchShortName returns the short branch name without the refs/heads/ prefix
func (*PullRequest) TargetBranchShortName ¶
func (pr *PullRequest) TargetBranchShortName() string
TargetBranchShortName returns the short branch name without the refs/heads/ prefix
type PullRequestsResponse ¶
type PullRequestsResponse struct {
Count int `json:"count"`
Value []PullRequest `json:"value"`
}
PullRequestsResponse represents the API response for listing pull requests
type Repository ¶
Repository represents a Git repository in Azure DevOps
type Reviewer ¶
type Reviewer struct {
ID string `json:"id"`
DisplayName string `json:"displayName"`
Vote int `json:"vote"` // 10: approved, 5: approved with suggestions, 0: no vote, -5: waiting, -10: rejected
}
Reviewer represents a reviewer on a pull request
func (*Reviewer) VoteDescription ¶
VoteDescription returns a human-readable description of the reviewer's vote
type Thread ¶
type Thread struct {
ID int `json:"id"`
PublishedDate time.Time `json:"publishedDate"`
LastUpdatedDate time.Time `json:"lastUpdatedDate"`
Status string `json:"status"` // "active", "fixed", "wontFix", "closed", "pending"
ThreadContext *ThreadContext `json:"threadContext"`
Comments []Comment `json:"comments"`
IsDeleted bool `json:"isDeleted"`
}
Thread represents a comment thread on a pull request
func FilterSystemThreads ¶
FilterSystemThreads filters out threads that are system-generated comments (e.g., threads whose first comment starts with "Microsoft.VisualStudio")
func (*Thread) IsCodeComment ¶
IsCodeComment returns true if this thread is attached to a specific code location
func (*Thread) StatusDescription ¶
StatusDescription returns a human-readable description of the thread status
type ThreadContext ¶
type ThreadContext struct {
FilePath string `json:"filePath"`
RightFileStart *FilePosition `json:"rightFileStart"`
RightFileEnd *FilePosition `json:"rightFileEnd"`
}
ThreadContext contains location information for code comments
type ThreadsResponse ¶
ThreadsResponse represents the API response for listing threads
type Timeline ¶
type Timeline struct {
ID string `json:"id"`
ChangeID int `json:"changeId"`
LastChangedBy string `json:"lastChangedBy"`
LastChangedOn *time.Time `json:"lastChangedOn"`
Records []TimelineRecord `json:"records"`
}
Timeline represents a build timeline containing stages, jobs, and tasks
type TimelineRecord ¶
type TimelineRecord struct {
ID string `json:"id"`
ParentID *string `json:"parentId"`
Type string `json:"type"` // "Stage", "Job", "Task", "Phase", "Checkpoint"
Name string `json:"name"`
State string `json:"state"` // "pending", "inProgress", "completed"
Result string `json:"result"` // "succeeded", "succeededWithIssues", "failed", "canceled", "skipped", "abandoned"
Order int `json:"order"`
StartTime *time.Time `json:"startTime"`
FinishTime *time.Time `json:"finishTime"`
Log *LogReference `json:"log"`
Issues []Issue `json:"issues"`
}
TimelineRecord represents a single record in the timeline (stage, job, or task)
type WIQLResponse ¶
type WIQLResponse struct {
WorkItems []WorkItemReference `json:"workItems"`
}
WIQLResponse represents the response from a WIQL query
type WorkItem ¶
type WorkItem struct {
ID int `json:"id"`
Rev int `json:"rev"`
Fields WorkItemFields `json:"fields"`
URL string `json:"url"`
ProjectName string `json:"-"` // Set by MultiClient, not from API
ProjectDisplayName string `json:"-"` // Set by MultiClient, display name for UI
}
WorkItem represents a work item in Azure DevOps
func (*WorkItem) AssignedToName ¶
AssignedToName returns the display name of the assigned user, or "-" if unassigned
func (*WorkItem) EffectiveDescription ¶
EffectiveDescription returns the appropriate description field based on work item type. Bugs use Microsoft.VSTS.TCM.ReproSteps; other types use System.Description.
type WorkItemFields ¶
type WorkItemFields struct {
Title string `json:"System.Title"`
State string `json:"System.State"`
WorkItemType string `json:"System.WorkItemType"`
AssignedTo *Identity `json:"System.AssignedTo"`
Priority int `json:"Microsoft.VSTS.Common.Priority"`
ChangedDate time.Time `json:"System.ChangedDate"`
IterationPath string `json:"System.IterationPath"`
Description string `json:"System.Description"`
ReproSteps string `json:"Microsoft.VSTS.TCM.ReproSteps"`
Tags string `json:"System.Tags"`
}
WorkItemFields represents the fields of a work item
type WorkItemReference ¶
WorkItemReference represents a reference to a work item from WIQL queries
type WorkItemTypeState ¶
type WorkItemTypeState struct {
Name string `json:"name"`
Color string `json:"color"`
Category string `json:"category"`
}
WorkItemTypeState represents a state available for a work item type
type WorkItemTypeStatesResponse ¶
type WorkItemTypeStatesResponse struct {
Count int `json:"count"`
Value []WorkItemTypeState `json:"value"`
}
WorkItemTypeStatesResponse represents the response from the work item type states API
type WorkItemsResponse ¶
WorkItemsResponse represents the response from getting work items