notes

package
v0.0.0-...-798368f Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasString

func HasString(a []string, x string) bool

func IsActionRequired

func IsActionRequired(pr *github.PullRequest) bool

IsActionRequired indicates whether or not the release-note-action-required label was set on the PR.

func LabelsWithPrefix

func LabelsWithPrefix(pr *github.PullRequest, prefix string) []string

LabelsWithPrefix is a helper for fetching all labels on a PR that start with a given string. This pattern is used often in the k/k repo and we can take advantage of this to contextualize release note generation with the kind, sig, area, etc labels.

func ListCommits

func ListCommits(client *github.Client, start, end string, opts ...githubApiOption) ([]*github.RepositoryCommit, error)

ListCommits lists all commits starting from a given commit SHA and ending at a given commit SHA.

func ListCommitsWithNotes

func ListCommitsWithNotes(
	client *github.Client,
	logger log.Logger,
	start,
	end string,
	opts ...githubApiOption,
) ([]*github.RepositoryCommit, error)

ListCommitsWithNotes list commits that have release notes starting from a given commit SHA and ending at a given commit SHA. This function is similar to ListCommits except that only commits with tagged release notes are returned.

func NoteTextFromString

func NoteTextFromString(s string) (string, error)

NoteTextFromString returns the text of the release note given a string which may contain the commit message, the PR description, etc. This is generally the content inside the ```release-note ``` stanza.

func PRFromCommit

func PRFromCommit(client *github.Client, commit *github.RepositoryCommit, opts ...githubApiOption) (*github.PullRequest, error)

PRFromCommit return an API Pull Request struct given a commit struct. This is useful for going from a commit log to the PR (which contains useful info such as labels).

func RenderMarkdown

func RenderMarkdown(doc *Document, w io.Writer) error

RenderMarkdown accepts a Document and writes a version of that document to supplied io.Writer in markdown format.

func WithBranch

func WithBranch(branch string) githubApiOption

WithBranch allows the caller to override the repo branch for the API request. By default, it is usually "master".

func WithContext

func WithContext(ctx context.Context) githubApiOption

WithContext allows the caller to inject a context into GitHub API requests

func WithOrg

func WithOrg(org string) githubApiOption

WithOrg allows the caller to override the GitHub organization for the API request. By default, it is usually "kubernetes".

func WithRepo

func WithRepo(repo string) githubApiOption

WithRepo allows the caller to override the GitHub repo for the API request. By default, it is usually "kubernetes".

Types

type Document

type Document struct {
	NewFeatures    []string            `json:"new_features"`
	ActionRequired []string            `json:"action_required"`
	APIChanges     []string            `json:"api_changes"`
	Duplicates     map[string][]string `json:"duplicate_notes"`
	SIGs           map[string][]string `json:"sigs"`
	BugFixes       []string            `json:"bug_fixes"`
	Uncategorized  []string            `json:"uncategorized"`
}

Document represents the underlying structure of a release notes document.

func CreateDocument

func CreateDocument(notes []*ReleaseNote) (*Document, error)

CreateDocument assembles an organized document from an unorganized set of release notes

type ReleaseNote

type ReleaseNote struct {
	// Commit is the SHA of the commit which is the source of this note. This is
	// also effectively a unique ID for release notes.
	Commit string `json:"commit"`

	// Text is the actual content of the release note
	Text string `json:"text"`

	// Markdown is the markdown formatted note
	Markdown string `json:"markdown"`

	// Author is the GitHub username of the commit author
	Author string `json:"author"`

	// AuthorUrl is the GitHub URL of the commit author
	AuthorUrl string `json:"author_url"`

	// PrUrl is a URL to the PR
	PrUrl string `json:"pr_url"`

	// PrNumber is the number of the PR
	PrNumber int `json:"pr_number"`

	// Areas is a list of the labels beginning with area/
	Areas []string `json:"areas,omitempty"`

	// Kinds is a list of the labels beginning with kind/
	Kinds []string `json:"kinds,omitempty"`

	// SIGs is a list of the labels beginning with sig/
	SIGs []string `json:"sigs,omitempty"`

	// Indicates whether or not a note will appear as a new feature
	Feature bool `json:"feature,omitempty"`

	// Indicates whether or not a note is duplicated across SIGs
	Duplicate bool `json:"duplicate,omitempty"`

	// ActionRequired indicates whether or not the release-note-action-required
	// label was set on the PR
	ActionRequired bool `json:"action_required,omitempty"`
}

ReleaseNote is the type that represents the total sum of all the information we've gathered about a single release note.

func ListReleaseNotes

func ListReleaseNotes(
	client *github.Client,
	logger log.Logger,
	start,
	end string,
	opts ...githubApiOption,
) ([]*ReleaseNote, error)

ListReleaseNotes produces a list of fully contextualized release notes starting from a given commit SHA and ending at starting a given commit SHA.

func ReleaseNoteFromCommit

func ReleaseNoteFromCommit(commit *github.RepositoryCommit, client *github.Client, opts ...githubApiOption) (*ReleaseNote, error)

ReleaseNoteFromCommit produces a full contextualized release note given a GitHub commit API resource.

Jump to

Keyboard shortcuts

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