Documentation
¶
Index ¶
- func BeautifyInlineComment(ctx workflow.Context, comment *Comment, msg string) (string, []byte)
- func BitbucketToSlackIDs(ctx workflow.Context, accountIDs []string) []string
- func ChannelMembers(ctx workflow.Context, pr PullRequest) []string
- func DeleteSlackMsg(ctx workflow.Context, url string) error
- func Diffstat(ctx workflow.Context, event PullRequestEvent) []bitbucket.Diffstat
- func EditSlackMsg(ctx workflow.Context, url, msg string) error
- func HTMLURL(links map[string]Link) string
- func ImpersonateUserInMsg(ctx workflow.Context, url, channelID string, user Account, msg string, ...) error
- func ImpersonateUserInReply(ctx workflow.Context, url, parentURL string, user Account, msg string, ...) error
- func ImpersonationToMention(msg string) string
- func InitPRData(ctx workflow.Context, event PullRequestEvent, channelID string)
- func MapToStruct(m any, pr *PullRequest) error
- func MentionUserInMsg(ctx workflow.Context, channelID string, user Account, msg string)
- func MentionUserInReply(ctx workflow.Context, parentURL string, user Account, msg string) error
- func ReviewerMentions(ctx workflow.Context, added, removed []string) string
- func ReviewersDiff(prev, curr PullRequest) (added, removed []string)
- func SetChannelBookmarks(ctx workflow.Context, channelID, prURL string, pr PullRequest)
- func SlackDisplayName(ctx workflow.Context, user Account) string
- func UpdateChannelBookmarks(ctx workflow.Context, pr PullRequest, prURL, channelID string)
- func UpdateChannelBuildsBookmark(ctx workflow.Context, channelID, prURL string)
- type Account
- type Branch
- type Comment
- type Commit
- type CommitStatus
- type Inline
- type Link
- type Participant
- type Project
- type PullRequest
- type PullRequestEvent
- type Reference
- type Repository
- type RepositoryEvent
- type Review
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BeautifyInlineComment ¶ added in v1.0.0
BeautifyInlineComment adds an informative prefix to the comment's text. If the comment contains a suggestion code block, it removes that block and also generates a diff snippet to attach to the Slack message instead.
func BitbucketToSlackIDs ¶ added in v1.0.0
func ChannelMembers ¶ added in v1.1.0
func ChannelMembers(ctx workflow.Context, pr PullRequest) []string
ChannelMembers returns a list of opted-in Slack user IDs who are PR authors and reviewers. The output is guaranteed to be sorted, without repetitions, and not contain teams/apps.
func Diffstat ¶ added in v1.0.0
func Diffstat(ctx workflow.Context, event PullRequestEvent) []bitbucket.Diffstat
func ImpersonateUserInMsg ¶ added in v1.0.0
func ImpersonateUserInReply ¶ added in v1.0.0
func ImpersonationToMention ¶ added in v1.0.0
ImpersonationToMention converts a message that was meant to be used in ImpersonateUserInMsg or ImpersonateUserInReply into a message that can be used in MentionUserInMsg or MentionUserInReply, by adjusting the prefix.
This is potentially relevant only for file and inline comments: if the message includes a file (i.e. contains a Slack file permalink), we can't impersonate the user, because the Slack API won't allow us to update or delete the message later.
func InitPRData ¶ added in v1.0.0
func InitPRData(ctx workflow.Context, event PullRequestEvent, channelID string)
InitPRData saves the initial state of a new PR: snapshots of PR metadata, and a 2-way ID mapping for syncs between Bitbucket and Slack. If there are errors, they are logged but ignored, as we can try to recreate the data later.
func MapToStruct ¶ added in v1.0.0
func MapToStruct(m any, pr *PullRequest) error
MapToStruct converts a map-based representation of JSON data into a PullRequest struct.
func MentionUserInMsg ¶ added in v1.0.0
func MentionUserInReply ¶ added in v1.0.0
func ReviewerMentions ¶ added in v1.0.0
ReviewerMentions returns a Slack message mentioning all the newly added/removed reviewers.
func ReviewersDiff ¶ added in v1.0.0
func ReviewersDiff(prev, curr PullRequest) (added, removed []string)
ReviewerDiff returns the lists of added and removed reviewers, compared to the previous snapshot of the PR. The output is guaranteed to be sorted, without repetitions, and not contain teams/apps.
func SetChannelBookmarks ¶ added in v1.0.0
func SetChannelBookmarks(ctx workflow.Context, channelID, prURL string, pr PullRequest)
func SlackDisplayName ¶ added in v1.0.0
SlackDisplayName returns the Slack display name corresponding to the given Bitbucket user, linked to their Slack profile if possible. We use this instead of users.BitbucketIDToSlackRef in cases where we want to mention the user without actually spamming them with echoes of their own actions.
func UpdateChannelBookmarks ¶ added in v1.0.0
func UpdateChannelBookmarks(ctx workflow.Context, pr PullRequest, prURL, channelID string)
UpdateChannelBookmarks updates the bookmarks in the PR's Slack channel, based on the latest PR event. This is a deferred call that doesn't return an error, because handling the event itself is more important.
func UpdateChannelBuildsBookmark ¶ added in v1.0.0
UpdateChannelBuildsBookmark updates the "Builds" bookmark in the PR's Slack channel, based on the latest repository event. This is a deferred call that doesn't return an error, because handling the event itself is more important.
Types ¶
type CommitStatus ¶ added in v0.6.0
type CommitStatus struct {
Name string `json:"name"`
State string `json:"state"`
Description string `json:"description"`
Key string `json:"key"`
URL string `json:"url"`
Refname *string `json:"refname"`
Commit *Commit `json:"commit,omitempty"`
CreatedOn string `json:"created_on"`
UpdatedOn string `json:"updated_on"`
Links map[string]Link `json:"links"`
}
https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Build-status-created
type Participant ¶
type PullRequest ¶
type PullRequest struct {
ID int `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"` // "OPEN", "MERGED", "DECLINED".
Draft bool `json:"draft"`
Source Reference `json:"source"`
Destination Reference `json:"destination"`
CreatedOn string `json:"created_on"`
UpdatedOn string `json:"updated_on"`
CommentCount int `json:"comment_count"`
TaskCount int `json:"task_count"`
CommitCount int `json:"commit_count"` // Populated and used only in RevChat.
ChangeRequestCount int `json:"change_request_count"` // Populated and used only in RevChat.
Author Account `json:"author"`
Participants []Participant `json:"participants"`
Reviewers []Account `json:"reviewers"`
ClosedBy *Account `json:"closed_by"`
Reason string `json:"reason"`
CloseSourceBranch bool `json:"close_source_branch"`
MergeCommit *Commit `json:"merge_commit"`
Links map[string]Link `json:"links"`
}
func SwitchSnapshot ¶ added in v1.0.0
func SwitchSnapshot(ctx workflow.Context, prURL string, snapshot PullRequest) (*PullRequest, error)
SwitchSnapshot stores the given new PR snapshot, and returns the previous one (if there is one).
type PullRequestEvent ¶
type PullRequestEvent struct {
Type string `json:"type"` // Populated and used only in RevChat.
PullRequest PullRequest `json:"pullrequest"`
Repository Repository `json:"repository"`
Actor Account `json:"actor"`
Approval *Review `json:"approval,omitempty"`
ChangesRequest *Review `json:"changes_request,omitempty"`
Comment *Comment `json:"comment,omitempty"`
}
https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Pull-request-events https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Common-entities-for-event-payloads
type Reference ¶
type Reference struct {
Branch Branch `json:"branch"`
Commit Commit `json:"commit"`
Repository Repository `json:"repository"`
}
type Repository ¶
type Repository struct {
FullName string `json:"full_name"`
Name string `json:"name"`
UUID string `json:"uuid"`
SCM string `json:"scm,omitempty"`
IsPrivate bool `json:"is_private,omitempty"`
Website string `json:"website,omitempty"`
Workspace *Workspace `json:"workspace,omitempty"`
Project *Project `json:"project,omitempty"`
Owner *Account `json:"owner,omitempty"`
Links map[string]Link `json:"links"`
}
type RepositoryEvent ¶
type RepositoryEvent struct {
Type string `json:"type"` // Populated and used only in RevChat.
Repository Repository `json:"repository"`
Actor Account `json:"actor"`
Commit *Commit `json:"commit,omitempty"`
Comment *Comment `json:"comment,omitempty"`
CommitStatus *CommitStatus `json:"commit_status,omitempty"`
}
https://support.atlassian.com/bitbucket-cloud/docs/event-payloads/#Repository-events