labeler

package
v0.0.0-...-2443087 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

SOMEWHAT DEPRECATED: labeler provides actions which add labels to issues based on criteria. It also has helper functions for labels. This package needs work.

Index

Constants

This section is empty.

Variables

View Source
var PendingRebaseNeedsWorkPRUnlabeler = func(context *ctx.Context, payload interface{}) error {
	event, ok := payload.(*github.PullRequestEvent)
	if !ok {
		return context.NewError("PendingRebaseUnlabeler: not a pull request event")
	}

	if *event.Action != "synchronize" {
		return nil
	}

	owner, repo, num := *event.Repo.Owner.Login, *event.Repo.Name, *event.Number

	log.Printf("checking the mergeability of %s/%s#%d in %d sec...", owner, repo, num, repoMergeabilityCheckWaitSec)
	time.Sleep(repoMergeabilityCheckWaitSec * time.Second)

	var err error
	if isMergeable(context, owner, repo, num) {
		err = RemoveLabelIfExists(context, owner, repo, num, "pending-rebase")
		if err != nil {
			log.Printf("error removing the pending-rebase label: %v", err)
		}
		err = RemoveLabelIfExists(context, owner, repo, num, "needs-work")
	} else {
		err = fmt.Errorf("%s/%s#%d is not mergeable", owner, repo, num)
	}

	if err != nil {
		log.Printf("error removing the pending-rebase & needs-work labels: %v", err)
	}
	return err
}

Functions

func AddLabels

func AddLabels(context *ctx.Context, owner, repo string, number int, labels []string) error

func IssueHasLabel

func IssueHasLabel(context *ctx.Context, owner, repo string, number int, label string) bool

func IssueHasPullRequestLabeler

func IssueHasPullRequestLabeler(context *ctx.Context, payload interface{}) error

func RemoveLabel

func RemoveLabel(context *ctx.Context, owner, repo string, number int, label string) error

func RemoveLabelIfExists

func RemoveLabelIfExists(context *ctx.Context, owner, repo string, number int, label string) error

func RemoveLabels

func RemoveLabels(context *ctx.Context, owner, repo string, number int, labels []string) error

Types

type LabelerHandler

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

func NewHandler

func NewHandler(context *ctx.Context, pushHandlers []PushHandler, pullRequestHandlers []PullRequestHandler) *LabelerHandler

NewHandler returns an HTTP handler which deprecates repositories by closing new issues with a comment directing attention elsewhere.

func (*LabelerHandler) HandlePayload

func (h *LabelerHandler) HandlePayload(w http.ResponseWriter, r *http.Request, payload []byte)

type PullRequestHandler

type PullRequestHandler func(context *ctx.Context, event github.PullRequestEvent) error

type PushHandler

type PushHandler func(context *ctx.Context, event github.PushEvent) error

Jump to

Keyboard shortcuts

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