Documentation
¶
Overview ¶
Package pullmetrics provides functionality to analyze GitHub Pull Requests and generate comprehensive metrics and details.
This package allows you to analyze GitHub Pull Requests programmatically, extracting detailed information including review metrics, timestamps, and performance indicators.
Example usage:
config := pullmetrics.Config{
GitHubToken: "your_github_token",
}
analyzer, err := pullmetrics.NewAnalyzer(config)
if err != nil {
log.Fatal(err)
}
details, err := analyzer.AnalyzePR(context.Background(), "microsoft", "vscode", 12345)
if err != nil {
log.Fatal(err)
}
fmt.Printf("PR %d has %d comments and %d approvers\n",
details.PRNumber, details.NumComments, details.NumApprovers)
Package pullmetrics provides functionality to analyze GitHub Pull Requests and generate comprehensive metrics and details.
Index ¶
- func AnalyzePRToJSON(ctx context.Context, config Config, org, repo string, prNumber int) ([]byte, error)
- func AnalyzePRToJSONString(ctx context.Context, config Config, org, repo string, prNumber int) (string, error)
- type Analyzer
- type Config
- type PRDetails
- type PRMetrics
- type PRSize
- type PRTimestamps
- type ReleaseInfo
- type Timestamps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
Analyzer provides the core functionality for analyzing GitHub Pull Requests
func NewAnalyzer ¶
NewAnalyzer creates a new PR analyzer with the given configuration
type Config ¶
type Config struct {
GitHubToken string
}
Config represents the configuration for the PR analysis
type PRDetails ¶
type PRDetails struct {
OrganizationName string `json:"organization_name"`
RepositoryName string `json:"repository_name"`
PRNumber int `json:"pr_number"`
PRTitle string `json:"pr_title"`
PRWebURL string `json:"pr_web_url"`
PRNodeID string `json:"pr_node_id"`
AuthorUsername string `json:"author_username"`
ApproverUsernames []string `json:"approver_usernames"`
CommenterUsernames []string `json:"commenter_usernames"`
State string `json:"state"`
NumComments int `json:"num_comments"`
NumCommenters int `json:"num_commenters"`
NumApprovers int `json:"num_approvers"`
NumRequestedReviewers int `json:"num_requested_reviewers"`
ChangeRequestsCount int `json:"change_requests_count"`
LinesChanged int `json:"lines_changed"`
FilesChanged int `json:"files_changed"`
CommitsAfterFirstReview int `json:"commits_after_first_review"`
JiraIssue string `json:"jira_issue"`
IsBot bool `json:"is_bot"`
Metrics *PRMetrics `json:"metrics,omitempty"`
ReleaseName *string `json:"release_name,omitempty"`
Timestamps *PRTimestamps `json:"timestamps,omitempty"`
GeneratedAt string `json:"generated_at"`
}
PRDetails represents the complete analysis of a GitHub Pull Request
type PRMetrics ¶
type PRMetrics struct {
DraftTimeHours float64 `json:"draft_time_hours"`
TimeToFirstReviewRequestHours *float64 `json:"time_to_first_review_request_hours,omitempty"`
TimeToFirstReviewHours *float64 `json:"time_to_first_review_hours,omitempty"`
ReviewCycleTimeHours *float64 `json:"review_cycle_time_hours,omitempty"`
BlockingNonBlockingRatio *float64 `json:"blocking_non_blocking_ratio,omitempty"`
ReviewerParticipationRatio *float64 `json:"reviewer_participation_ratio,omitempty"`
}
PRMetrics represents calculated performance metrics for the PR review process
type PRTimestamps ¶
type PRTimestamps struct {
FirstCommit *string `json:"first_commit,omitempty"`
CreatedAt *string `json:"created_at,omitempty"`
FirstReviewRequest *string `json:"first_review_request,omitempty"`
FirstComment *string `json:"first_comment,omitempty"`
FirstApproval *string `json:"first_approval,omitempty"`
SecondApproval *string `json:"second_approval,omitempty"`
MergedAt *string `json:"merged_at,omitempty"`
ClosedAt *string `json:"closed_at,omitempty"`
ReleaseCreatedAt *string `json:"release_created_at,omitempty"`
}
PRTimestamps represents the JSON output structure for PR timestamps
type ReleaseInfo ¶
ReleaseInfo holds both the name and creation timestamp of a release