prsanitizer

package
v0.0.0-...-a196a74 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TitleFailureMessage is a message used in GH Status as description when the PR title does not follow semantic message style
	TitleFailureMessage = "#### Semantic title\nThe PR title `%s` does not conform with the " +
		"[semantic message](https://seesparkbox.com/foundry/semantic_commit_messages) style. " +
		"The semantic message makes your changelog and git history clean. " +
		"Please, edit the PR by prefixing it with one of the type prefixes that are valid for your repository: %s."

	// DescriptionLengthShortMessage is a status message that is used in case of short PR description.
	DescriptionLengthShortMessage = "#### PR description length\nThe PR description is too short - it is expected that " +
		"the description should have more than %d characters, but it has %d. " +
		"More elaborated description is helpful for understanding the changes proposed " +
		"in this PR. (Any issue links and it's keywords are excluded when the description length is being measured)"

	// IssueLinkMissingMessage is a status message that is used in case of missing issue link.
	IssueLinkMissingMessage = "#### Issue link\nThe PR description is missing any issue link that would be used with any of the " +
		"[GitHub keywords](https://help.github.com/articles/closing-issues-using-keywords/). " +
		"Having it in the PR description ensures that the issue is automatically closed when the PR is merged."
)
View Source
const (
	// ProwPluginName is an external prow plugin name used to register this service
	ProwPluginName = "pr-sanitizer"

	// FailureDetailsPageName is a name of a documentation page that contains additional status details for title verification failure.
	FailureDetailsPageName = "pr-sanitizer-failed"

	// FailureMessage is a message used in GH Status as description when the PR title and description does not conform to the PR sanitizer checks.
	FailureMessage = "This PR doesn't comply with PR conventions :("

	// SuccessMessage is a message used in GH Status as description when the PR title and description conforms to the PR sanitizer checks.
	SuccessMessage = "This PR complies with PR conventions :)"

	// SuccessDetailsPageName is a name of a documentation page that contains additional status details for success state
	SuccessDetailsPageName = "pr-sanitizer-success"

	// FailureStatusMessageBeginning is a beginning of failure status message
	FailureStatusMessageBeginning = "This pull request doesn't comply with the conventions given by the `pr-sanitizer` plugin. " +
		"The following items are necessary to fix:\n\n"

	// SuccessStatusMessage is a status message used when the PR is good
	SuccessStatusMessage = "This pull request complies with the PR conventions given by the `pr-sanitizer` plugin. :)"
)

Variables

This section is empty.

Functions

func CheckDescriptionLength

func CheckDescriptionLength(pr *gogh.PullRequest, config PluginConfiguration, logger log.Logger) string

CheckDescriptionLength checks if the given PR's description contains enough number of arguments

func CheckIssueLinkPresence

func CheckIssueLinkPresence(pr *gogh.PullRequest, config PluginConfiguration, logger log.Logger) string

CheckIssueLinkPresence checks if the given PR's description contains an issue link

func CheckSemanticTitle

func CheckSemanticTitle(pr *gogh.PullRequest, config PluginConfiguration, logger log.Logger) string

CheckSemanticTitle checks if the given PR contains semantic title

func GetValidTitlePrefixes

func GetValidTitlePrefixes(config PluginConfiguration) []string

GetValidTitlePrefixes returns list of valid prefixes

func HasTitleWithValidType

func HasTitleWithValidType(prefixes []string, title string) bool

HasTitleWithValidType checks if title prefix conforms with semantic message style.

Types

type GitHubPRSanitizerEventsHandler

type GitHubPRSanitizerEventsHandler struct {
	Client  ghclient.Client
	BotName string
}

GitHubPRSanitizerEventsHandler is the event handler for the plugin. Implements server.GitHubEventHandler interface which contains the logic for incoming GitHub events

func (*GitHubPRSanitizerEventsHandler) HandleIssueCommentEvent

func (gh *GitHubPRSanitizerEventsHandler) HandleIssueCommentEvent(logger log.Logger, comment *gogh.IssueCommentEvent) error

HandleIssueCommentEvent is an entry point for the plugin logic. This method is invoked by the Server when issue comment event is dispatched from the /hook service

func (*GitHubPRSanitizerEventsHandler) HandlePullRequestEvent

func (gh *GitHubPRSanitizerEventsHandler) HandlePullRequestEvent(logger log.Logger, event *gogh.PullRequestEvent) error

HandlePullRequestEvent is an entry point for the plugin logic. This method is invoked by the Server when pull request event is dispatched from the /hook service

type PluginConfiguration

type PluginConfiguration struct {
	config.PluginConfiguration `yaml:",inline,omitempty"`
	TypePrefix                 []string `yaml:"type_prefixes,omitempty"`
	Combine                    bool     `yaml:"combine_defaults,omitempty"`
	DescriptionContentLength   int      `yaml:"description_content_length,omitempty"`
}

PluginConfiguration defines prefix patterns set against which PR titles will be matched It's unmarshaled from pr-sanitizer.yml configuration file

func LoadConfiguration

func LoadConfiguration(logger log.Logger, change scm.RepositoryChange) PluginConfiguration

LoadConfiguration loads a PluginConfiguration for the given change

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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