Draft pull request plugin
The Bitbucket draft pull request plugin allows you to label a pull request as a draft. While a pull request is marked as a draft, the merge button is not available.
This is useful to signal that it is still a work in progress (WIP) - even if all other checks are passing, it is not ready to be merged yet.
This plugin supports the draft pull request workflow by:
- Using a label to identify draft pull requests
- Creating an extended check to prevent merging of draft pull requests
- Optionally add the draft label to new pull requests automatically
The simplest configuration is:
import {const configure: (config: Config | (() => Config)) => void
configure} from "flowie.app"
import {const draftPullRequest: OptionsPlugin<DraftPullRequestOptions, false>
Support for draft pull requestsdraftPullRequest, const merge: OptionsPlugin<MergePluginOptions, false>
merge} from "flowie.app/plugins"
function configure(config: Config | (() => Config)): void
configure({
Config.plugins?: PluginDef<unknown>[] | undefined
plugins: [
// Use merge plugin to enforce merge checks
function merge(): PluginDef<MergePluginOptions> (+2 overloads)
merge(),
function draftPullRequest(): PluginDef<DraftPullRequestOptions> (+2 overloads)
Support for draft pull requestsdraftPullRequest(),
],
})
Using the options:
function draftPullRequest(options: DraftPullRequestOptions): PluginDef<DraftPullRequestOptions> (+2 overloads)
Support for draft pull requestsdraftPullRequest({
DraftPullRequestOptions.draftOnCreate?: RulesOr<boolean | undefined>
Adds the label automatically to the pull request on creation, marking it as
a draft. Default: truedraftOnCreate: false,
DraftPullRequestOptions.label?: LabelRef | undefined
Existing label from the schema to be used for marking the pull request as
draft. Default: {name: "Draft"} and is created automatically if not present
in the schema.label: {LabelRef.name: string
name: "WIP"},
DraftPullRequestOptions.title?: string | undefined
Title for the merge check. It supports markdown for formatting. Default:
**No** work in progresstitle: "**No** draft",
})
Options:
draftOnCreate
- if true, it adds the label automatically to the pull request, marking it as a draft. Default: true
label
- the label to use to mark the pull request as draft. If you specify a
label, it must be defined in the label schema as well.
Default: {name: "Draft"}
and is created automatically if not present in the schema.
title
- the title of the check. It supports markdown for formatting. Default: **No** work in progress
Draft as part of workflow
If you are using LabelSets to model workflow you can use them together by setting draft pull request as one of the possible values:
import {const configure: (config: Config | (() => Config)) => void
configure} from "flowie.app"
import {const draftPullRequest: OptionsPlugin<DraftPullRequestOptions, false>
Support for draft pull requestsdraftPullRequest} from "flowie.app/plugins"
function configure(config: Config | (() => Config)): void
configure({
Config.labels?: {
schema?: Array<Label>;
} | undefined
labels: {
schema?: Label[] | undefined
schema: [
{
BasicLabel.name: string
name: "Status",
LabelSet.values: (string | [string, LabelValueOptions & {
valueColor?: Color;
}])[]
values: [
["Draft", {LabelValueOptions.color?: Color | undefined
color: "Yellow300"}],
"Ready to review",
["Ready to merge", {LabelValueOptions.color?: Color | undefined
color: "greenLight"}],
],
},
],
},
Config.plugins?: PluginDef<unknown>[] | undefined
plugins: [
function draftPullRequest(options: DraftPullRequestOptions): PluginDef<DraftPullRequestOptions> (+2 overloads)
Support for draft pull requestsdraftPullRequest({
DraftPullRequestOptions.label?: LabelRef | undefined
Existing label from the schema to be used for marking the pull request as
draft. Default: {name: "Draft"} and is created automatically if not present
in the schema.label: {LabelRef.name: string
name: "Status", LabelRef.value?: string | undefined
value: "Draft"},
}),
],
})
Results in: