Documentation
¶
Overview ¶
Package data provides functions to manage persistent data storage. For the time being, storage is file-based on the local filesystem. Future implementations may include remote key-value stores and databases.
Index ¶
- func AddReviewerToPR(url, email string) error
- func DeleteBitbucketPR(url string) error
- func DeleteReminder(userID string) error
- func DeleteSlackBotIDs(botID string) error
- func DeleteTurn(url string) error
- func DeleteURLAndIDMapping(key string) error
- func GetCurrentTurn(url string) ([]string, error)
- func GetSlackBotUserID(botID string) (string, error)
- func InitTurn(url, author string, reviewers []string) error
- func IsOptedIn(email string) (bool, error)
- func ListReminders() (map[string]string, error)
- func LoadBitbucketPR(url string) (map[string]any, error)
- func LogSlackChannelArchived(channelID, url string) error
- func LogSlackChannelCreated(channelID, name, url string) error
- func LogSlackChannelDeleted(channelID string) error
- func LogSlackChannelRenamed(channelID, name string) error
- func MapURLAndID(url, id string) error
- func OptInBitbucketUser(slackUserID, accountID, email, linkID string) error
- func OptInGitHubUser(slackUserID, username, email, linkID string) error
- func OptOut(email string) error
- func RemoveFromTurn(url, email string) error
- func SetReminder(userID, kitchenTime, tz string) error
- func SetSlackBotUserID(botID, userID string) error
- func SetTurn(url string, emails []string) error
- func StoreBitbucketPR(url string, pr any) error
- func SwitchTurn(url, email string) error
- func SwitchURLAndID(key string) (string, error)
- func UpsertUser(email, bitbucketID, githubID, slackID, thrippyLink string) error
- func UserLinkID(email string) (string, error)
- type PRTurn
- type User
- type Users
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddReviewerToPR ¶ added in v0.6.0
AddReviewerToPR adds a new reviewer to the attention list of a specific PR. This function is idempotent: if a reviewer already exists, or is the PR author, it does nothing. It also ignores empty or "bot" email addresses.
func DeleteBitbucketPR ¶ added in v0.2.0
DeleteBitbucketPR deletes the snapshot of a Bitbucket pull request when it becomes obsolete (i.e. when the PR is merged, closed, or marked as a draft). This function is idempotent: it does not return an error if the snapshot does not exist.
func DeleteReminder ¶ added in v0.5.0
func DeleteSlackBotIDs ¶ added in v0.4.0
func DeleteTurn ¶ added in v0.6.0
DeleteTurn removes the attention state file of a specific PR. This is used when the PR is closed or marked as a draft.
func DeleteURLAndIDMapping ¶ added in v0.2.0
DeleteURLAndIDMapping deletes the 2-way mapping between PR URLs and chat channel and thread IDs when they become obsolete (i.e. when the PR is merged, closed, or marked as a draft).
func GetCurrentTurn ¶ added in v0.6.0
GetCurrentTurn returns the email addresses of all the users whose turn it is to pay attention to a specific PR. If the PR has no assigned reviewers, this function returns the PR author (as a reminder for them to assign reviewers). If any assigned reviewer has their turn flag set to false, we add the author to the list as well, unless the attention list was set explicitly using SetTurn.
func GetSlackBotUserID ¶ added in v0.4.0
func InitTurn ¶ added in v0.6.0
InitTurn initializes the attention state of a new PR. Users are specified using their email addresses.
func ListReminders ¶ added in v0.5.0
func LoadBitbucketPR ¶ added in v0.2.0
LoadBitbucketPR loads a snapshot of a Bitbucket pull request. This is used to detect changes in the pull request over time. This function returns nil if no snapshot is found.
func LogSlackChannelArchived ¶ added in v0.6.0
func LogSlackChannelCreated ¶ added in v0.6.0
func LogSlackChannelDeleted ¶ added in v0.6.0
func LogSlackChannelRenamed ¶ added in v0.6.0
func MapURLAndID ¶ added in v0.2.0
MapURLAndID saves a 2-way mapping between a PR URL and its dedicated chat channel or thread IDs.
func OptInBitbucketUser ¶
func OptInGitHubUser ¶
func RemoveFromTurn ¶ added in v0.6.0
RemoveFromTurn completely removes a reviewer from the attention list of a specific PR. This is used when that reviewer approves the PR, or is unassigned from the PR. This function is idempotent: if the reviewer does not exist, it does nothing. It also ignores empty or "bot" email addresses.
func SetReminder ¶ added in v0.5.0
func SetSlackBotUserID ¶ added in v0.4.0
func SetTurn ¶ added in v0.6.0
SetTurn overwrites the attention state of a specific PR to an explicit set of users. Missing users are added, which means the caller needs to ensure they *are* valid reviewers. Existing unmentioned users are not removed, but are marked as not their turn. If the input contains the PR author, they *are* added (temporarily, until SwitchTurn is called for them). It also ignores empty or "bot" email addresses.
func StoreBitbucketPR ¶ added in v0.2.0
StoreBitbucketPR saves a snapshot of a Bitbucket pull request. This is used to detect changes in the pull request over time.
func SwitchTurn ¶ added in v0.6.0
SwitchTurn switches the turn of a specific user in a specific PR. If the user is the PR author, it adds all reviewers to the attention list. If the user is a reviewer, it adds the author to the attention list. If the user is not found, this function does nothing.
func SwitchURLAndID ¶ added in v0.2.0
SwitchURLAndID converts a PR URL to its mapped chat channel or thread IDs, and vice versa.
func UpsertUser ¶ added in v0.6.0
func UserLinkID ¶ added in v0.5.0
Types ¶
type PRTurn ¶ added in v0.6.0
type PRTurn struct {
Author string `json:"author"` // Email address of the PR author.
Reviewers map[string]bool `json:"reviewers"` // Email address -> is it their turn?
Set bool `json:"set"` // Whether the attention state has been set explicitly.
}
PRTurn represents the attention state for a specific pull request.
The [Reviewers] map tracks which reviewers are assigned to the PR and whether it's currently their turn to pay attention to it.
Initial state:
- If the map is empty, the PR author is considered responsible for the PR's progress: they need to assign reviewers or merge the PR.
- When any number of reviewers are assigned, at the same time or separately, the initial state of their turn flag is set to true. Each one of them needs to pay attention to the PR.
State transitions for reviewers:
- When a reviewer approves the PR, or is unassigned from it, they are removed from the map. They will no longer need to pay attention to this PR, unless they are added again later.
- When a reviewer creates a new comment, reply, or code suggestion, their turn flag is set to false. It is no longer their turn to pay attention to the PR. This does not affect other reviewers.
- If a reviewer creates multiple-but-separate comments or code suggestions, their turn flag remains false.
State transitions for the author:
The author's state is USUALLY not tracked explicitly. They need to pay attention to the PR whenever at least one reviewer has their turn flag set to false.
When the author addresses review comments (i.e. creates a new comment or reply), the turn flags of all the reviewers are reset to true. It is their turn still/again to pay attention to the PR.
Pushing commits does not have the same effect for now, as it may be work in progress. Only discussions trigger state changes.
Manual state changes:
- Any participant (author or reviewers) may indicate that it is or isn't their turn to pay attention to the PR, by using a Slack slash command instead of interacting within the PR discussion.
- Any participant may also set the entire attention state explicitly, specifying exactly which reviewers need to pay attention to the PR. Unmentioned reviewers are not removed from the map, but their turn flags are set to false. If the author is mentioned, they are added temporarily until a regular state transition affects them.
type User ¶ added in v0.6.0
type User struct {
Created string `json:"created,omitempty"`
Updated string `json:"updated,omitempty"`
Deleted string `json:"deleted,omitempty"`
Email string `json:"email,omitempty"`
BitbucketID string `json:"bitbucket_id,omitempty"`
GitHubID string `json:"github_id,omitempty"`
SlackID string `json:"slack_id,omitempty"`
ThrippyLink string `json:"thrippy_link,omitempty"`
}
User represents a mapping between various user IDs and email addresses across different platforms (Bitbucket, GitHub, Slack).