Documentation
¶
Index ¶
- Constants
- Variables
- func ActivityIgnoreFilter(cfg *IgnoreConfig, repo, eventName, author, eventDetail string) bool
- type Activity
- type ActivityCheckScheduler
- type ActivityDetected
- type ActivityType
- type Author
- type Closed
- type Event
- type FilterFn
- type IgnoreActorRule
- type IgnoreConfig
- type IgnoreRuleSet
- type IgnoreScope
- type Merged
- type NewPullRequestDetected
- type PRActivityData
- type PRIdentifier
- type PRStatus
- type PRTrackingRepository
- type PipelineStatus
- type PipelineStatusChanged
- type PullRequest
- func ClassifyPRs(prs []*PullRequest, since time.Time) (trulyNew, withActivity []*PullRequest)
- func NewPullRequest(url string, number int, title string, repository RepositoryInfo, author Author, ...) (*PullRequest, error)
- func ReconstitutePR(identifier PRIdentifier, title string, repository RepositoryInfo, ...) *PullRequest
- func (pr *PullRequest) Activities() []*Activity
- func (pr *PullRequest) ActivitiesSince(since time.Time) []*Activity
- func (pr *PullRequest) AddActivities(activities []*Activity) []Event
- func (pr *PullRequest) AddActivity(activity *Activity) []Event
- func (pr *PullRequest) AddReview(review *Review) []Event
- func (pr *PullRequest) AgeAt(now time.Time) time.Duration
- func (pr *PullRequest) Author() Author
- func (pr *PullRequest) AuthorLogin() string
- func (pr *PullRequest) ClearActivities()
- func (pr *PullRequest) Close() []Event
- func (pr *PullRequest) CreatedAt() time.Time
- func (pr *PullRequest) Equals(other *PullRequest) bool
- func (pr *PullRequest) HasActivitiesSince(since time.Time) bool
- func (pr *PullRequest) HeadCommitSHA() string
- func (pr *PullRequest) Identifier() PRIdentifier
- func (pr *PullRequest) IsDraft() bool
- func (pr *PullRequest) IsOpen() bool
- func (pr *PullRequest) IsSeen() bool
- func (pr *PullRequest) IsStaleAt(now time.Time, threshold time.Duration) bool
- func (pr *PullRequest) LastActivityAt() time.Time
- func (pr *PullRequest) LastActivityCheck() time.Time
- func (pr *PullRequest) MarkAsNewlyDetected() []Event
- func (pr *PullRequest) MarkAsSeen()
- func (pr *PullRequest) MarkAsUnseen()
- func (pr *PullRequest) Merge() []Event
- func (pr *PullRequest) Number() int
- func (pr *PullRequest) PipelineStatus() PipelineStatus
- func (pr *PullRequest) RecordHeadCommitUpdate(newHeadSHA string) []Event
- func (pr *PullRequest) RecordHeadCommitUpdateAt(newHeadSHA string, now time.Time) []Event
- func (pr *PullRequest) Repository() RepositoryInfo
- func (pr *PullRequest) RepositoryName() string
- func (pr *PullRequest) ReviewSummary() *ReviewSummary
- func (pr *PullRequest) Reviews() map[string]*Review
- func (pr *PullRequest) Seen() bool
- func (pr *PullRequest) SetHeadCommitSHA(sha string)
- func (pr *PullRequest) SetInitialActivities(activities []*Activity)
- func (pr *PullRequest) SetLastActivityCheck(t time.Time)
- func (pr *PullRequest) SetPipelineStatus(status PipelineStatus)
- func (pr *PullRequest) SetReviews(reviews map[string]*Review)
- func (pr *PullRequest) Status() PRStatus
- func (pr *PullRequest) Title() string
- func (pr *PullRequest) URL() string
- func (pr *PullRequest) UpdatePipelineStatus(newStatus PipelineStatus) []Event
- type PullRequestRepository
- type RepositoryInfo
- type Review
- type ReviewState
- type ReviewStateChanged
- type ReviewSummary
- type StatusChangeType
- type StatusChanged
Constants ¶
const ( EventNewPullRequestDetected = "NewPullRequestDetected" EventActivityDetected = "ActivityDetected" EventMerged = "Merged" EventClosed = "Closed" EventStatusChanged = "StatusChanged" EventReviewStateChanged = "ReviewStateChanged" EventPipelineStatusChanged = "PipelineStatusChanged" )
EventName constants for event type identification (used by event bus subscriptions)
Variables ¶
var ( // ErrInvalidPRIdentifier indicates an invalid PR identifier ErrInvalidPRIdentifier = errors.New("invalid pull request identifier") )
Functions ¶
func ActivityIgnoreFilter ¶
func ActivityIgnoreFilter(cfg *IgnoreConfig, repo, eventName, author, eventDetail string) bool
ActivityIgnoreFilter reports whether an event should be suppressed based on the provided IgnoreConfig. It returns true if the event should be ignored.
Parameters:
- cfg: the loaded ignore configuration; must not be nil.
- repo: the repository name in "owner/repo" form.
- eventName: the domain event name constant (e.g. EventPipelineStatusChanged).
- author: the GitHub login of the actor that triggered the event.
- eventDetail: an optional sub-type string (e.g. pipeline status, review state, activity type). Used for event:detail matching in Except lists.
Types ¶
type Activity ¶
type Activity struct {
// contains filtered or unexported fields
}
Activity represents an activity/event on a pull request
func NewActivity ¶
func NewActivity( prIdentifier PRIdentifier, activityType ActivityType, author Author, createdAt time.Time, body string, ) *Activity
NewActivity creates a new activity
func (*Activity) PRIdentifier ¶
func (a *Activity) PRIdentifier() PRIdentifier
PRIdentifier returns the PR identifier
type ActivityCheckScheduler ¶
type ActivityCheckScheduler struct {
// contains filtered or unexported fields
}
ActivityCheckScheduler is a thin stateful wrapper around the pure determineChecks and recordChecked functions. It owns lastCheckMap and supplies the current time so that call sites in use cases remain unchanged.
func NewActivityCheckScheduler ¶
func NewActivityCheckScheduler(recentThresholdHours int, staleCheckIntervalMin int) *ActivityCheckScheduler
NewActivityCheckScheduler creates a new activity check scheduler.
func (*ActivityCheckScheduler) DeterminePRsToCheck ¶
func (s *ActivityCheckScheduler) DeterminePRsToCheck(prs []*PullRequest) *scheduleResult
DeterminePRsToCheck calls determinePRsToCheckAt with the current time.
func (*ActivityCheckScheduler) MarkCheckedAt ¶
func (s *ActivityCheckScheduler) MarkCheckedAt(now time.Time, prs []*PullRequest)
MarkCheckedAt records that the given PRs were checked at the given time. Thin wrapper around recordChecked using the scheduler's owned state.
func (*ActivityCheckScheduler) SeedLastChecked ¶
func (s *ActivityCheckScheduler) SeedLastChecked(url string, t time.Time)
SeedLastChecked pre-populates the last-check timestamp for a single PR URL. Used to restore the scheduler's state after a process restart so that stale PRs that were recently checked are not immediately re-checked. Zero-value timestamps are ignored.
type ActivityDetected ¶
type ActivityDetected struct {
PullRequestID PRIdentifier
Repository RepositoryInfo
Activity *Activity
PullRequest *PullRequest // Full PR for notification purposes
// contains filtered or unexported fields
}
ActivityDetected is raised when new activity is detected on a PR
func NewActivityDetected ¶
func NewActivityDetected(pr *PullRequest, activity *Activity) ActivityDetected
NewActivityDetected creates a new event for a single activity
func NewActivityDetectedAt ¶
func NewActivityDetectedAt(pr *PullRequest, activity *Activity, at time.Time) ActivityDetected
NewActivityDetectedAt creates a new event with an explicit timestamp
func (*ActivityDetected) Name ¶
func (e *ActivityDetected) Name() string
Name returns the event name constant
func (ActivityDetected) OccurredAt ¶
func (e ActivityDetected) OccurredAt() time.Time
OccurredAt returns when the event occurred
type ActivityType ¶
type ActivityType string
ActivityType represents the type of activity
const ( ActivityTypeComment ActivityType = "comment" ActivityTypeReview ActivityType = "review" ActivityTypeCommit ActivityType = "commit" ActivityTypeReaction ActivityType = "reaction" ActivityTypePush ActivityType = "push" )
type Author ¶
type Author struct {
// contains filtered or unexported fields
}
Author represents a GitHub user
type Closed ¶
type Closed struct {
PullRequestID PRIdentifier
Repository RepositoryInfo
PullRequest *PullRequest // Full PR for notification purposes
// contains filtered or unexported fields
}
Closed is raised when a PR is closed
func NewClosedAt ¶
func NewClosedAt(pr *PullRequest, at time.Time) Closed
NewClosedAt creates a new event with an explicit timestamp
func (Closed) OccurredAt ¶
OccurredAt returns when the event occurred
type FilterFn ¶
type FilterFn func([]*PullRequest) []*PullRequest
FilterFn is a pure function from PR slice → filtered PR slice.
func NewDraftFilter ¶
NewDraftFilter returns the appropriate FilterFn based on configuration. When includeDrafts is true, the returned function is a no-op passthrough. When includeDrafts is false, the returned function strips all draft PRs.
type IgnoreActorRule ¶
IgnoreActorRule filters events from a specific actor (GitHub login). Events and Except narrow which event types are suppressed for this actor. If Events is empty, all event types from this actor are suppressed (subject to Except).
type IgnoreConfig ¶
type IgnoreConfig struct {
Ignore IgnoreRuleSet
}
IgnoreConfig holds user-defined rules for suppressing notifications. It is a pure domain type with no serialisation concerns; the infrastructure layer is responsible for loading it from storage (e.g. ignore.yaml) and mapping it to this type before injecting it into the application layer.
type IgnoreRuleSet ¶
type IgnoreRuleSet struct {
Global IgnoreScope
Repos map[string]IgnoreScope
}
IgnoreRuleSet contains the global and per-repository ignore rules.
type IgnoreScope ¶
type IgnoreScope struct {
Events []string
Except []string
Repos []string
AuthoredBy []IgnoreActorRule
}
IgnoreScope holds ignore rules that apply either globally or to a specific repository.
- Events: ignore all events of these types, regardless of author.
- Except: never ignore these specific event:detail combinations even when Events matches.
- Repos: (global scope only) ignore all events from these repositories.
- AuthoredBy: per-author rules; each entry can further restrict by events/except.
type Merged ¶
type Merged struct {
PullRequestID PRIdentifier
Repository RepositoryInfo
PullRequest *PullRequest // Full PR for notification purposes
// contains filtered or unexported fields
}
Merged is raised when a PR is merged
func NewMergedAt ¶
func NewMergedAt(pr *PullRequest, at time.Time) Merged
NewMergedAt creates a new event with an explicit timestamp
func (Merged) OccurredAt ¶
OccurredAt returns when the event occurred
type NewPullRequestDetected ¶
type NewPullRequestDetected struct {
PullRequestID PRIdentifier
Repository RepositoryInfo
Author Author
PullRequest *PullRequest // Full PR for notification purposes
// contains filtered or unexported fields
}
NewPullRequestDetected is raised when a new PR is detected
func NewNewPullRequestDetected ¶
func NewNewPullRequestDetected(pr *PullRequest) NewPullRequestDetected
NewNewPullRequestDetected creates a new event
func NewNewPullRequestDetectedAt ¶
func NewNewPullRequestDetectedAt(pr *PullRequest, at time.Time) NewPullRequestDetected
NewNewPullRequestDetectedAt creates a new event with an explicit timestamp
func (*NewPullRequestDetected) Name ¶
func (e *NewPullRequestDetected) Name() string
Name returns the event name constant
func (NewPullRequestDetected) OccurredAt ¶
func (e NewPullRequestDetected) OccurredAt() time.Time
OccurredAt returns when the event occurred
type PRActivityData ¶
type PRActivityData struct {
Activities []*Activity
HeadCommitSHA *string
PipelineStatus *PipelineStatus
}
PRActivityData contains fetch-only enrichment facts for a PR. It is keyed by PR URL in PullRequestRepository.FetchActivities results. Optional fields are represented as pointers so callers can distinguish between "not present in response" and a concrete value.
type PRIdentifier ¶
type PRIdentifier struct {
// contains filtered or unexported fields
}
PRIdentifier uniquely identifies a pull request
func NewPRIdentifier ¶
func NewPRIdentifier(url string, number int) (PRIdentifier, error)
NewPRIdentifier creates a new pull request identifier with validation
func (PRIdentifier) Equals ¶
func (id PRIdentifier) Equals(other PRIdentifier) bool
Equals compares two PR identifiers
func (PRIdentifier) Number ¶
func (id PRIdentifier) Number() int
Number returns the pull request number
func (PRIdentifier) String ¶
func (id PRIdentifier) String() string
String returns a string representation
type PRStatus ¶
type PRStatus int
PRStatus represents the status of a pull request
func (PRStatus) MarshalText ¶
MarshalText implements encoding.TextMarshaler so PRStatus serialises as a human-readable string ("open", "merged", "closed") in JSON and other text-based formats.
func (*PRStatus) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type PRTrackingRepository ¶
type PRTrackingRepository interface {
Fetch(prIdentifier PRIdentifier) (*PullRequest, error)
LoadAll() ([]*PullRequest, error)
Update(pullRequest *PullRequest) error
Save(pullRequests []*PullRequest) error
IsEmpty() bool
Clear() error
}
PRTrackingRepository is the port for persisting the locally-tracked state of open pull requests across process restarts. It stores the identity and mutable fields that cannot be cheaply re-derived from the GitHub API each cycle (head commit SHA, pipeline status, last activity check timestamp, reviews, etc.).
Adapters must treat Save as a full replacement of the stored set — it is not an upsert. Only open PRs are ever stored; closed/merged PRs are excluded before Save is called.
type PipelineStatus ¶
type PipelineStatus int
PipelineStatus represents the CI/CD pipeline (status check rollup) state of a PR
const ( // PipelineStatusUnknown means no pipeline data is available PipelineStatusUnknown PipelineStatus = iota // PipelineStatusRunning means one or more checks are pending/in progress PipelineStatusRunning // PipelineStatusSuccess means all checks passed PipelineStatusSuccess // PipelineStatusFailed means one or more checks failed PipelineStatusFailed )
func (PipelineStatus) Emoji ¶
func (p PipelineStatus) Emoji() string
Emoji returns a display emoji for the pipeline status
func (PipelineStatus) Label ¶
func (p PipelineStatus) Label() string
Label returns a human-readable label for the pipeline status (e.g. "Passed", "Failed")
func (PipelineStatus) MarshalText ¶
func (p PipelineStatus) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler so PipelineStatus serialises as a stable lowercase string in JSON and other text-based formats.
func (PipelineStatus) String ¶
func (p PipelineStatus) String() string
String returns a string representation of the pipeline status
func (*PipelineStatus) UnmarshalText ¶
func (p *PipelineStatus) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type PipelineStatusChanged ¶
type PipelineStatusChanged struct {
PullRequestID PRIdentifier
Repository RepositoryInfo
OldStatus PipelineStatus
NewStatus PipelineStatus
PullRequest *PullRequest // Full PR for notification purposes
// contains filtered or unexported fields
}
PipelineStatusChanged is raised when the CI/CD pipeline rollup status changes on a PR
func NewPipelineStatusChanged ¶
func NewPipelineStatusChanged(pr *PullRequest, oldStatus, newStatus PipelineStatus) PipelineStatusChanged
NewPipelineStatusChanged creates a new PipelineStatusChanged event
func NewPipelineStatusChangedAt ¶
func NewPipelineStatusChangedAt(pr *PullRequest, oldStatus, newStatus PipelineStatus, at time.Time) PipelineStatusChanged
NewPipelineStatusChangedAt creates a new PipelineStatusChanged event with an explicit timestamp
func (*PipelineStatusChanged) Name ¶
func (e *PipelineStatusChanged) Name() string
Name returns the event name constant
func (PipelineStatusChanged) OccurredAt ¶
func (e PipelineStatusChanged) OccurredAt() time.Time
OccurredAt returns when the event occurred
type PullRequest ¶
type PullRequest struct {
// contains filtered or unexported fields
}
PullRequest is the aggregate root for pull request domain
func ClassifyPRs ¶
func ClassifyPRs(prs []*PullRequest, since time.Time) (trulyNew, withActivity []*PullRequest)
ClassifyPRs separates PRs into two categories: - trulyNew: Brand new PRs without recent activity - withActivity: PRs that have activity since the given time
This classification is used to determine notification messages and tracking semantics
func NewPullRequest ¶
func NewPullRequest( url string, number int, title string, repository RepositoryInfo, author Author, createdAt time.Time, isDraft bool, ) (*PullRequest, error)
NewPullRequest creates a new pull request with validation
func ReconstitutePR ¶
func ReconstitutePR( identifier PRIdentifier, title string, repository RepositoryInfo, author Author, status PRStatus, createdAt time.Time, isDraft bool, activities []*Activity, lastActivityCheck time.Time, headCommitSHA string, reviews map[string]*Review, pipelineStatus PipelineStatus, seen bool, ) *PullRequest
func (*PullRequest) Activities ¶
func (pr *PullRequest) Activities() []*Activity
Activities returns all activities for this PR
func (*PullRequest) ActivitiesSince ¶
func (pr *PullRequest) ActivitiesSince(since time.Time) []*Activity
ActivitiesSince returns activities that occurred after the given time
func (*PullRequest) AddActivities ¶
func (pr *PullRequest) AddActivities(activities []*Activity) []Event
AddActivities adds multiple activities at once and returns all resulting events.
func (*PullRequest) AddActivity ¶
func (pr *PullRequest) AddActivity(activity *Activity) []Event
AddActivity adds a new activity to the PR and returns an ActivityDetected event. This maintains the aggregate's consistency boundary and follows the same pattern as Close/Merge which raise StatusChanged events. Returns nil for a nil activity.
func (*PullRequest) AddReview ¶
func (pr *PullRequest) AddReview(review *Review) []Event
AddReview adds or updates a review for a specific reviewer. If the reviewer already has a review with the same state, this is a no-op. If the state changed, it returns a ReviewStateChanged event. Returns nil for a nil review or when the state is unchanged.
func (*PullRequest) AgeAt ¶
func (pr *PullRequest) AgeAt(now time.Time) time.Duration
AgeAt returns how long ago the PR was created, relative to the given time.
func (*PullRequest) AuthorLogin ¶
func (pr *PullRequest) AuthorLogin() string
AuthorLogin returns the author's login
func (*PullRequest) ClearActivities ¶
func (pr *PullRequest) ClearActivities()
ClearActivities clears all activities (useful for testing or rebuilding state)
func (*PullRequest) Close ¶
func (pr *PullRequest) Close() []Event
Close marks the PR as closed and returns a Closed domain event. Returns nil if the PR is already closed.
func (*PullRequest) CreatedAt ¶
func (pr *PullRequest) CreatedAt() time.Time
CreatedAt returns when the PR was created
func (*PullRequest) Equals ¶
func (pr *PullRequest) Equals(other *PullRequest) bool
Equals compares two pull requests by their identifier
func (*PullRequest) HasActivitiesSince ¶
func (pr *PullRequest) HasActivitiesSince(since time.Time) bool
HasActivitiesSince returns true if there are any activities after the given time
func (*PullRequest) HeadCommitSHA ¶
func (pr *PullRequest) HeadCommitSHA() string
HeadCommitSHA returns the current head commit SHA
func (*PullRequest) Identifier ¶
func (pr *PullRequest) Identifier() PRIdentifier
Identifier returns the unique identifier for this PR
func (*PullRequest) IsDraft ¶
func (pr *PullRequest) IsDraft() bool
IsDraft returns whether the PR is a draft
func (*PullRequest) IsOpen ¶
func (pr *PullRequest) IsOpen() bool
IsOpen returns true if the PR is open
func (*PullRequest) IsSeen ¶
func (pr *PullRequest) IsSeen() bool
IsSeen returns true if the PR has been marked as seen
func (*PullRequest) IsStaleAt ¶
IsStaleAt returns true if the PR is older than the given threshold at the given time.
func (*PullRequest) LastActivityAt ¶
func (pr *PullRequest) LastActivityAt() time.Time
LastActivityAt returns when the last activity occurred
func (*PullRequest) LastActivityCheck ¶
func (pr *PullRequest) LastActivityCheck() time.Time
LastActivityCheck returns when we last checked for activities
func (*PullRequest) MarkAsNewlyDetected ¶
func (pr *PullRequest) MarkAsNewlyDetected() []Event
MarkAsNewlyDetected marks this PR as newly detected and returns the appropriate event.
func (*PullRequest) MarkAsSeen ¶
func (pr *PullRequest) MarkAsSeen()
func (*PullRequest) MarkAsUnseen ¶
func (pr *PullRequest) MarkAsUnseen()
func (*PullRequest) Merge ¶
func (pr *PullRequest) Merge() []Event
Merge marks the PR as merged and returns a Merged domain event. Returns nil if the PR is already merged.
func (*PullRequest) PipelineStatus ¶
func (pr *PullRequest) PipelineStatus() PipelineStatus
PipelineStatus returns the current CI/CD pipeline rollup status
func (*PullRequest) RecordHeadCommitUpdate ¶
func (pr *PullRequest) RecordHeadCommitUpdate(newHeadSHA string) []Event
RecordHeadCommitUpdate detects if the head commit has changed and, if so, creates a push activity on the aggregate and returns an ActivityDetected event. The aggregate records all domain facts; notification filtering (e.g. suppressing self-pushes) is handled by the notification event handler. First-time initialization (empty current SHA) records the SHA without creating activity.
func (*PullRequest) RecordHeadCommitUpdateAt ¶
func (pr *PullRequest) RecordHeadCommitUpdateAt(newHeadSHA string, now time.Time) []Event
RecordHeadCommitUpdateAt detects if the head commit has changed and, if so, creates a push activity on the aggregate and returns an ActivityDetected event. The aggregate records all domain facts; notification filtering (e.g. suppressing self-pushes) is handled by the notification event handler. First-time initialization (empty current SHA) records the SHA without creating activity.
func (*PullRequest) Repository ¶
func (pr *PullRequest) Repository() RepositoryInfo
Repository returns the repository this PR belongs to
func (*PullRequest) RepositoryName ¶
func (pr *PullRequest) RepositoryName() string
RepositoryName returns the repository name with owner
func (*PullRequest) ReviewSummary ¶
func (pr *PullRequest) ReviewSummary() *ReviewSummary
ReviewSummary returns a ReviewSummary for display purposes
func (*PullRequest) Reviews ¶
func (pr *PullRequest) Reviews() map[string]*Review
Reviews returns the current reviews map (copy)
func (*PullRequest) Seen ¶
func (pr *PullRequest) Seen() bool
func (*PullRequest) SetHeadCommitSHA ¶
func (pr *PullRequest) SetHeadCommitSHA(sha string)
SetHeadCommitSHA sets the head commit SHA without raising any events. Used to restore or reset the known baseline across cycles.
func (*PullRequest) SetInitialActivities ¶
func (pr *PullRequest) SetInitialActivities(activities []*Activity)
SetInitialActivities hydrates the PR with activities during reconstruction (e.g. from the GitHub API) without raising domain events. Use this for data loading; use AddActivity / AddActivities only when new activity is discovered during business logic.
func (*PullRequest) SetLastActivityCheck ¶
func (pr *PullRequest) SetLastActivityCheck(t time.Time)
SetLastActivityCheck sets the last-activity-check timestamp without raising any events. Used both to restore a prior cycle's baseline (hydration) and to stamp the current check time after enrichment.
func (*PullRequest) SetPipelineStatus ¶
func (pr *PullRequest) SetPipelineStatus(status PipelineStatus)
SetPipelineStatus sets the pipeline status without raising any events. Use this to restore or reset the baseline so that UpdatePipelineStatus can correctly detect changes vs. no-ops across check cycles.
func (*PullRequest) SetReviews ¶
func (pr *PullRequest) SetReviews(reviews map[string]*Review)
SetReviews replaces the reviews map without raising events. Defensive-copies the supplied map so callers cannot mutate aggregate state after the call. Use this to restore a prior baseline (hydration or rollback for change detection); use AddReview when a new review is discovered during a cycle.
func (*PullRequest) Status ¶
func (pr *PullRequest) Status() PRStatus
Status returns the current status
func (*PullRequest) Title ¶
func (pr *PullRequest) Title() string
Title returns the pull request title
func (*PullRequest) UpdatePipelineStatus ¶
func (pr *PullRequest) UpdatePipelineStatus(newStatus PipelineStatus) []Event
UpdatePipelineStatus updates the pipeline status and returns a PipelineStatusChanged event if the status has changed. Returns nil when the status is unchanged.
type PullRequestRepository ¶
type PullRequestRepository interface {
FetchRequestedReviews() ([]*PullRequest, error)
FetchUserCreated() ([]*PullRequest, error)
// FetchActivities fetches raw activity/enrichment facts for the given PRs
// since the provided time. Adapters return data only; aggregate mutation and
// domain event creation/publishing happen in the application/domain layers.
FetchActivities(prs []*PullRequest, since time.Time) (map[string]PRActivityData, error)
// FetchPRStatus fetches the current status of a specific PR (open, merged, closed).
FetchPRStatus(owner, repo string, number int) (PRStatus, error)
// AuthenticatedUser returns the login of the authenticated user.
AuthenticatedUser() string
}
PullRequestRepository is the port for fetching pull requests from external sources
type RepositoryInfo ¶
type RepositoryInfo struct {
// contains filtered or unexported fields
}
RepositoryInfo represents a GitHub repository
func NewRepository ¶
func NewRepository(nameWithOwner string) (RepositoryInfo, error)
NewRepository creates a new repository value object with validation
func (RepositoryInfo) Equals ¶
func (r RepositoryInfo) Equals(other RepositoryInfo) bool
Equals compares two repositories
func (RepositoryInfo) NameWithOwner ¶
func (r RepositoryInfo) NameWithOwner() string
NameWithOwner returns the full repository name (owner/repo)
func (RepositoryInfo) Owner ¶
func (r RepositoryInfo) Owner() string
Owner returns the repository owner
func (RepositoryInfo) String ¶
func (r RepositoryInfo) String() string
String returns a string representation
type Review ¶
type Review struct {
// contains filtered or unexported fields
}
Review represents a single reviewer's latest review state on a pull request
func NewReview ¶
func NewReview(reviewer Author, state ReviewState, submittedAt time.Time) *Review
NewReview creates a new review value object
func (*Review) SubmittedAt ¶
SubmittedAt returns when the review was submitted
type ReviewState ¶
type ReviewState int
ReviewState represents the state of a pull request review
const ( // ReviewStateApproved indicates the reviewer approved the PR ReviewStateApproved ReviewState = iota // ReviewStateChangesRequested indicates the reviewer requested changes ReviewStateChangesRequested // ReviewStateCommented indicates the reviewer left a comment without approving or requesting changes ReviewStateCommented // ReviewStateDismissed indicates a previous review was dismissed ReviewStateDismissed )
func (ReviewState) Emoji ¶
func (rs ReviewState) Emoji() string
Emoji returns a display emoji for the review state
func (ReviewState) Label ¶
func (rs ReviewState) Label() string
Label returns a human-readable label for the review state
func (ReviewState) MarshalText ¶
func (rs ReviewState) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler so ReviewState serialises as a stable lowercase string in JSON and other text-based formats.
func (ReviewState) String ¶
func (rs ReviewState) String() string
String returns a string representation of the review state
func (*ReviewState) UnmarshalText ¶
func (rs *ReviewState) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type ReviewStateChanged ¶
type ReviewStateChanged struct {
PullRequestID PRIdentifier
Repository RepositoryInfo
Reviewer Author
State ReviewState
PullRequest *PullRequest // Full PR for notification purposes
// contains filtered or unexported fields
}
ReviewStateChanged is raised when a reviewer's review state changes on a PR
func NewReviewStateChanged ¶
func NewReviewStateChanged(pr *PullRequest, reviewer Author, state ReviewState) ReviewStateChanged
NewReviewStateChanged creates a new event
func NewReviewStateChangedAt ¶
func NewReviewStateChangedAt(pr *PullRequest, reviewer Author, state ReviewState, at time.Time) ReviewStateChanged
NewReviewStateChangedAt creates a new event with an explicit timestamp
func (*ReviewStateChanged) Name ¶
func (e *ReviewStateChanged) Name() string
Name returns the event name constant
func (ReviewStateChanged) OccurredAt ¶
func (e ReviewStateChanged) OccurredAt() time.Time
OccurredAt returns when the event occurred
type ReviewSummary ¶
type ReviewSummary struct {
// contains filtered or unexported fields
}
ReviewSummary provides a formatted summary of all reviews on a PR
func NewReviewSummary ¶
func NewReviewSummary(reviews map[string]*Review) *ReviewSummary
NewReviewSummary creates a new review summary from a map of reviews
func (*ReviewSummary) IsEmpty ¶
func (rs *ReviewSummary) IsEmpty() bool
IsEmpty returns true if there are no reviews
func (*ReviewSummary) ReviewersByState ¶
func (rs *ReviewSummary) ReviewersByState(state ReviewState) []string
ReviewersByState returns reviewer logins for a given state
func (*ReviewSummary) Reviews ¶
func (rs *ReviewSummary) Reviews() map[string]*Review
Reviews returns the individual reviews
type StatusChangeType ¶
type StatusChangeType string
StatusChangeType represents the type of status change
const ( StatusChangeMerged StatusChangeType = "merged" StatusChangeClosed StatusChangeType = "closed" )
type StatusChanged ¶
type StatusChanged struct {
PullRequestID PRIdentifier
OldStatus PRStatus
NewStatus PRStatus
// contains filtered or unexported fields
}
StatusChanged is raised when a PR status changes
func NewStatusChanged ¶
func NewStatusChanged(pr *PullRequest, oldStatus, newStatus PRStatus) StatusChanged
NewStatusChanged creates a new event
func (*StatusChanged) Name ¶
func (e *StatusChanged) Name() string
Name returns the event name constant
func (StatusChanged) OccurredAt ¶
func (e StatusChanged) OccurredAt() time.Time
OccurredAt returns when the event occurred