shared

package
v2.49.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 32 Imported by: 2

Documentation

Index

Constants

View Source
const (
	IssueMetadata metadataStateType = iota
	PRMetadata
)

Variables

This section is empty.

Functions

func AddMetadataToIssueParams

func AddMetadataToIssueParams(client *api.Client, baseRepo ghrepo.Interface, params map[string]interface{}, tb *IssueMetadataState) error

func BodySurvey

func BodySurvey(p Prompt, state *IssueMetadataState, templateContent string) error

func ColorForIssueState added in v2.8.0

func ColorForIssueState(issue api.Issue) string

func ColorForPRState added in v2.8.0

func ColorForPRState(pr api.PullRequest) string

func CommentList

func CommentList(io *iostreams.IOStreams, comments api.Comments, reviews api.PullRequestReviews, preview bool) (string, error)

func CommentableConfirmSubmitSurvey

func CommentableConfirmSubmitSurvey(p Prompt) func() (bool, error)

func CommentableEditSurvey

func CommentableEditSurvey(cf func() (config.Config, error), io *iostreams.IOStreams) func(string) (string, error)

func CommentableInteractiveEditSurvey

func CommentableInteractiveEditSurvey(cf func() (config.Config, error), io *iostreams.IOStreams) func(string) (string, error)

func CommentablePreRun

func CommentablePreRun(cmd *cobra.Command, opts *CommentableOptions) error

func CommentableRun

func CommentableRun(opts *CommentableOptions) error

func EditFieldsSurvey

func EditFieldsSurvey(p EditPrompter, editable *Editable, editorCommand string) error

func FetchOptions

func FetchOptions(client *api.Client, repo ghrepo.Interface, editable *Editable) error

func FieldsToEditSurvey

func FieldsToEditSurvey(p EditPrompter, editable *Editable) error

func FillFromJSON

func FillFromJSON(io *iostreams.IOStreams, recoverFile string, state *IssueMetadataState) error

func ListHeader

func ListHeader(repoName string, itemName string, matchCount int, totalMatchCount int, hasFilters bool) string

func ListNoResults added in v2.9.0

func ListNoResults(repoName string, itemName string, hasFilters bool) error

func ListURLWithQuery

func ListURLWithQuery(listURL string, options FilterOptions) (string, error)

func MetadataSurvey

func MetadataSurvey(p Prompt, io *iostreams.IOStreams, baseRepo ghrepo.Interface, fetcher RepoMetadataFetcher, state *IssueMetadataState) error

func NewMockFinder

func NewMockFinder(selector string, pr *api.PullRequest, repo ghrepo.Interface) *mockFinder

func NewTemplateManager

func NewTemplateManager(httpClient *http.Client, repo ghrepo.Interface, p iprompter, dir string, allowFS bool, isPR bool) *templateManager

func PrCheckStatusSummaryWithColor added in v2.18.0

func PrCheckStatusSummaryWithColor(cs *iostreams.ColorScheme, checks api.PullRequestChecksStatus) string

func PreserveInput

func PreserveInput(io *iostreams.IOStreams, state *IssueMetadataState, createErr *error) func()

func PrintHeader

func PrintHeader(io *iostreams.IOStreams, s string)

func PrintMessage

func PrintMessage(io *iostreams.IOStreams, s string)

func QueryHasStateClause

func QueryHasStateClause(searchQuery string) bool

func RawCommentList

func RawCommentList(comments api.Comments, reviews api.PullRequestReviews) string

func ReactionGroupList

func ReactionGroupList(rgs api.ReactionGroups) string

func RequestableReviewersForCompletion added in v2.22.1

func RequestableReviewersForCompletion(httpClient *http.Client, repo ghrepo.Interface) ([]string, error)

func RunCommandFinder

func RunCommandFinder(selector string, pr *api.PullRequest, repo ghrepo.Interface) *mockFinder

RunCommandFinder is the NewMockFinder substitute to be used ONLY in runCommand-style tests.

func SearchQueryBuild

func SearchQueryBuild(options FilterOptions) string

func StateTitleWithColor

func StateTitleWithColor(cs *iostreams.ColorScheme, pr api.PullRequest) string

func TitleSurvey

func TitleSurvey(p Prompt, state *IssueMetadataState) error

func UpdateIssue added in v2.3.0

func UpdateIssue(httpClient *http.Client, repo ghrepo.Interface, id string, isPR bool, options Editable) error

func ValidURL added in v2.16.0

func ValidURL(urlStr string) bool

Maximum length of a URL: 8192 bytes

func WithPrAndIssueQueryParams

func WithPrAndIssueQueryParams(client *api.Client, baseRepo ghrepo.Interface, baseURL string, state IssueMetadataState) (string, error)

Types

type Action

type Action int
const (
	SubmitAction Action = iota
	PreviewAction
	CancelAction
	MetadataAction
	EditCommitMessageAction
	EditCommitSubjectAction
	SubmitDraftAction
)

func ConfirmIssueSubmission added in v2.10.0

func ConfirmIssueSubmission(p Prompt, allowPreview bool, allowMetadata bool) (Action, error)

func ConfirmPRSubmission added in v2.10.0

func ConfirmPRSubmission(p Prompt, allowPreview, allowMetadata, isDraft bool) (Action, error)

type Comment

type Comment interface {
	Identifier() string
	AuthorLogin() string
	Association() string
	Content() string
	Created() time.Time
	HiddenReason() string
	IsEdited() bool
	IsHidden() bool
	Link() string
	Reactions() api.ReactionGroups
	Status() string
}

type Commentable

type Commentable interface {
	Link() string
	Identifier() string
	CurrentUserComments() []api.Comment
}

type CommentableOptions

type CommentableOptions struct {
	IO                    *iostreams.IOStreams
	HttpClient            func() (*http.Client, error)
	RetrieveCommentable   func() (Commentable, ghrepo.Interface, error)
	EditSurvey            func(string) (string, error)
	InteractiveEditSurvey func(string) (string, error)
	ConfirmSubmitSurvey   func() (bool, error)
	OpenInBrowser         func(string) error
	Interactive           bool
	InputType             InputType
	Body                  string
	EditLast              bool
	Quiet                 bool
	Host                  string
}

type EditPrompter added in v2.33.0

type EditPrompter interface {
	Select(string, string, []string) (int, error)
	Input(string, string) (string, error)
	MarkdownEditor(string, string, bool) (string, error)
	MultiSelect(string, []string, []string) ([]int, error)
	Confirm(string, bool) (bool, error)
}

type Editable

type Editable struct {
	Title     EditableString
	Body      EditableString
	Base      EditableString
	Reviewers EditableSlice
	Assignees EditableSlice
	Labels    EditableSlice
	Projects  EditableProjects
	Milestone EditableString
	Metadata  api.RepoMetadataResult
}

func (Editable) AssigneeIds

func (e Editable) AssigneeIds(client *api.Client, repo ghrepo.Interface) (*[]string, error)

func (Editable) BodyValue

func (e Editable) BodyValue() *string

func (*Editable) Clone added in v2.28.0

func (e *Editable) Clone() Editable

Clone creates a mostly-shallow copy of Editable suitable for use in parallel go routines. Fields that would be mutated will be copied.

func (Editable) Dirty

func (e Editable) Dirty() bool

func (Editable) MilestoneId

func (e Editable) MilestoneId() (*string, error)

func (Editable) ProjectIds

func (e Editable) ProjectIds() (*[]string, error)

ProjectIds returns a slice containing IDs of projects v1 that the issue or a PR has to be linked to.

func (Editable) ProjectV2Ids added in v2.22.0

func (e Editable) ProjectV2Ids() (*[]string, *[]string, error)

ProjectV2Ids returns a pair of slices. The first is the projects the item should be added to. The second is the projects the items should be removed from.

func (Editable) ReviewerIds

func (e Editable) ReviewerIds() (*[]string, *[]string, error)

func (Editable) TitleValue

func (e Editable) TitleValue() *string

type EditableProjects added in v2.22.0

type EditableProjects struct {
	EditableSlice
	ProjectItems map[string]string
}

ProjectsV2 mutations require a mapping of an item ID to a project ID. Keep that map along with standard EditableSlice data.

type EditableSlice

type EditableSlice struct {
	Value   []string
	Add     []string
	Remove  []string
	Default []string
	Options []string
	Edited  bool
	Allowed bool
}

type EditableString

type EditableString struct {
	Value   string
	Default string
	Options []string
	Edited  bool
}

type FilterOptions

type FilterOptions struct {
	Assignee   string
	Author     string
	BaseBranch string
	Draft      *bool
	Entity     string
	Fields     []string
	HeadBranch string
	Labels     []string
	Mention    string
	Milestone  string
	Repo       string
	Search     string
	State      string
}

func (*FilterOptions) IsDefault

func (opts *FilterOptions) IsDefault() bool

type FindOptions

type FindOptions struct {
	// Selector can be a number with optional `#` prefix, a branch name with optional `<owner>:` prefix, or
	// a PR URL.
	Selector string
	// Fields lists the GraphQL fields to fetch for the PullRequest.
	Fields []string
	// BaseBranch is the name of the base branch to scope the PR-for-branch lookup to.
	BaseBranch string
	// States lists the possible PR states to scope the PR-for-branch lookup to.
	States []string
}

type InputType

type InputType int
const (
	InputTypeEditor InputType = iota
	InputTypeInline
	InputTypeWeb
)

type IssueMetadataState

type IssueMetadataState struct {
	Type metadataStateType

	Draft bool

	Body  string
	Title string

	Metadata   []string
	Reviewers  []string
	Assignees  []string
	Labels     []string
	Projects   []string
	Milestones []string

	MetadataResult *api.RepoMetadataResult
	// contains filtered or unexported fields
}

func (*IssueMetadataState) HasMetadata

func (tb *IssueMetadataState) HasMetadata() bool

func (*IssueMetadataState) IsDirty

func (tb *IssueMetadataState) IsDirty() bool

func (*IssueMetadataState) MarkDirty

func (tb *IssueMetadataState) MarkDirty()

type MeReplacer

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

MeReplacer resolves usages of `@me` to the handle of the currently logged in user.

func NewMeReplacer

func NewMeReplacer(apiClient *api.Client, hostname string) *MeReplacer

func (*MeReplacer) Replace

func (r *MeReplacer) Replace(handle string) (string, error)

func (*MeReplacer) ReplaceSlice

func (r *MeReplacer) ReplaceSlice(handles []string) ([]string, error)

type MetadataFetcher

type MetadataFetcher struct {
	IO        *iostreams.IOStreams
	APIClient *api.Client
	Repo      ghrepo.Interface
	State     *IssueMetadataState
}

func (*MetadataFetcher) RepoMetadataFetch

func (mf *MetadataFetcher) RepoMetadataFetch(input api.RepoMetadataInput) (*api.RepoMetadataResult, error)

type NotFoundError

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

func (*NotFoundError) Unwrap

func (err *NotFoundError) Unwrap() error

type PRFinder

type PRFinder interface {
	Find(opts FindOptions) (*api.PullRequest, ghrepo.Interface, error)
}

func NewFinder

func NewFinder(factory *cmdutil.Factory) PRFinder

type Prompt added in v2.21.0

type Prompt interface {
	Input(string, string) (string, error)
	Select(string, string, []string) (int, error)
	MarkdownEditor(string, string, bool) (string, error)
	Confirm(string, bool) (bool, error)
	MultiSelect(string, []string, []string) ([]int, error)
}

type RepoMetadataFetcher

type RepoMetadataFetcher interface {
	RepoMetadataFetch(api.RepoMetadataInput) (*api.RepoMetadataResult, error)
}

type Template

type Template interface {
	Name() string
	NameForSubmit() string
	Body() []byte
}

Jump to

Keyboard shortcuts

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