Documentation ¶
Overview ¶
Package cmd implements a command line interface for summarizing GitHub pull request metrics.
Index ¶
- Constants
- Variables
- func Execute()
- func WorkdayAllDays(d time.Time) bool
- func WorkdayEnd(d time.Time) time.Time
- func WorkdayOnlyWeekdays(d time.Time) bool
- func WorkdayStart(d time.Time) time.Time
- type Author
- type Comments
- type Commit
- type CommitNodes
- type Commits
- type MetricsGQLQuery
- type PageInfo
- type Participants
- type ReadyForReviewEvent
- type ReviewNodes
- type Reviews
- type TimelineItemNodes
- type TimelineItems
- type UI
Constants ¶
View Source
const ( // Extension version. Displayed when `--version` flag is used. Version = "1.1.0" // Default number of days in the past to look for pull requests // within a repository. DefaultDaysBack = 10 // Default date format to use when displaying dates. DefaultDateFormat = "2006-01-02" )
View Source
const ( // Default representation of an empty table cell. DefaultEmptyCell = "--" // Default number of search results per query. DefaultResultCount = 100 // Pull request review approved state. ReviewApprovedState = "APPROVED" )
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "gh-metrics", Short: "gh-metrics: provide summary pull request metrics", Run: func(cmd *cobra.Command, args []string) { owner, _ := cmd.Flags().GetString("owner") repository, _ := cmd.Flags().GetString("repo") startDate, _ := cmd.Flags().GetString("start") endDate, _ := cmd.Flags().GetString("end") onlyWeekdays, _ := cmd.Flags().GetBool("only-weekdays") csvFormat, _ := cmd.Flags().GetBool("csv") version, _ := cmd.Flags().GetBool("version") if version { fmt.Println("gh-metrics", Version) os.Exit(0) } var workdayFunc cal.WorkdayFn if onlyWeekdays { workdayFunc = WorkdayOnlyWeekdays } else { workdayFunc = WorkdayAllDays } calendar := &cal.BusinessCalendar{ WorkdayFunc: workdayFunc, WorkdayStartFunc: WorkdayStart, WorkdayEndFunc: WorkdayEnd, } ui := &UI{ Owner: owner, Repository: repository, StartDate: startDate, EndDate: endDate, CSVFormat: csvFormat, Calendar: calendar, } fmt.Println(ui.PrintMetrics()) }, }
Functions ¶
func WorkdayAllDays ¶ added in v0.3.0
WorkdayAllDays returns true regardless of the given day, as currently all days are considered workdays.
func WorkdayEnd ¶ added in v0.3.0
WorkdayEnd determines the end of a workday by returning the same day, but at the last second.
func WorkdayOnlyWeekdays ¶ added in v0.3.0
WorkdayOnlyWeekdays returns true if the given day is a weekday, otherwise returns false.
Types ¶
type CommitNodes ¶ added in v0.3.0
type CommitNodes []struct { Commit Commit }
type Commits ¶
type Commits struct { TotalCount int Nodes CommitNodes }
type MetricsGQLQuery ¶
type MetricsGQLQuery struct { Search struct { PageInfo PageInfo Nodes []struct { PullRequest struct { Author Author Additions int Deletions int Number int CreatedAt string ChangedFiles int IsDraft bool MergedAt string Participants Participants Comments Comments Reviews Reviews `graphql:"reviews(first: 50, states: [APPROVED, CHANGES_REQUESTED, COMMENTED])"` Commits Commits `graphql:"commits(first: 1)"` TimelineItems TimelineItems `graphql:"timelineItems(first: 1, itemTypes: [READY_FOR_REVIEW_EVENT])"` } `graphql:"... on PullRequest"` } } `graphql:"search(query: $query, type: ISSUE, last: $resultCount, after: $afterCursor)"` }
type Participants ¶
type Participants struct {
TotalCount int
}
type ReadyForReviewEvent ¶ added in v1.0.0
type ReadyForReviewEvent struct {
CreatedAt string
}
type ReviewNodes ¶ added in v0.3.0
type Reviews ¶
type Reviews struct { TotalCount int Nodes ReviewNodes }
type TimelineItemNodes ¶ added in v1.0.0
type TimelineItemNodes []struct { ReadyForReviewEvent ReadyForReviewEvent `graphql:"... on ReadyForReviewEvent"` }
type TimelineItems ¶ added in v1.0.0
type TimelineItems struct { TotalCount int Nodes TimelineItemNodes }
type UI ¶ added in v0.3.0
type UI struct { Owner string Repository string StartDate string EndDate string CSVFormat bool Calendar *cal.BusinessCalendar }
func (*UI) PrintMetrics ¶ added in v0.3.0
PrintMetrics returns a string representation of the metrics summary for a set of pull requests determined by the supplied date range, using DefaultResultCount.
Click to show internal directories.
Click to hide internal directories.