commentpruner

package
v0.0.882 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package commentpruner facilitates efficiently deleting bot comments as a reaction to webhook events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventClient

type EventClient struct {
	// contains filtered or unexported fields
}

EventClient is a struct that provides bot comment deletion for an event related to an issue. A single client instance should be created for each event and shared by all consumers of the event. The client fetches the comments only once and filters that list repeatedly to find bot comments to delete. This avoids using lots of API tokens when fetching comments for each handler that wants to delete comments. (An HTTP cache only partially helps with this because deletions modify the list of comments so the next call requires GH to send the resource again.)

func NewEventClient

func NewEventClient(spc scmProviderClient, log *logrus.Entry, org, repo string, number int) *EventClient

NewEventClient creates an EventClient struct. This should be used once per webhook event.

func (*EventClient) PruneComments

func (c *EventClient) PruneComments(pr bool, shouldPrune func(*scm.Comment) bool)

PruneComments fetches issue comments if they have not yet been fetched for this webhook event and then deletes any bot comments indicated by the func 'shouldPrune'.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL