Branch sync plugin
This plugin has the same functionality of the basic check maximumCommitsBehind, but adds more options and features:
- Sync using rebase or merge
- Automatic sync
- A merge check that enforces linear history via rebase
- Support for preventing redundant builds
To enable it, use the following config:
import {const configure: (config: Config | (() => Config)) => void
configure} from "flowie.app"
import {const branchSync: OptionsPluginNoDefault<BranchSyncPluginOptions, false>
branchSync} from "flowie.app/plugins"
function configure(config: Config | (() => Config)): void
configure({
Config.plugins?: PluginDef<unknown>[] | undefined
plugins: [function branchSync(options: BranchSyncPluginOptions): PluginDef<BranchSyncPluginOptions> (+1 overload)
branchSync({BranchSyncPluginOptions.using: RulesCatchAllOr<"merge" | "rebase">
using: "merge"})],
})
Options:
using
- The strategy to be used: rebase
or merge
. Required.
maximumCommitsBehind
- Maximum number of commits behind the destination branch to enforce.
Default: 0
auto
- Automatically syncs the branch
when it gets behind by maximumCommitsBehind
commits.
Default: false
allow
- The groups that are allowed to perform the fix actions. Supports @author
. Default: Anyone that has write permissions is allowed.
enforceLinearHistory
- Requires that the branch has no merge commits and is not behind the destination branch. It also adds an action to rebase and fix the check. Default: false
preventRedundantBuilds
- Applies redundant builds prevention when performing the sync. Default: true
Enforcing linear history
Typically, when sharing a feature branch with other members of the team,
you will want to sync using merge
and then rebase
once it’s ready to merge into the destination.
Because b9e3da3
is a merge commit,
Flowie creates a failing merge check with a ‘Rebase’ action
to allow this to be fixed.
The enforceLinearHistory
option can enforce this workflow:
import {const configure: (config: Config | (() => Config)) => void
configure} from "flowie.app"
import {const branchSync: OptionsPluginNoDefault<BranchSyncPluginOptions, false>
branchSync} from "flowie.app/plugins"
function configure(config: Config | (() => Config)): void
configure({
Config.plugins?: PluginDef<unknown>[] | undefined
plugins: [
function branchSync(options: BranchSyncPluginOptions): PluginDef<BranchSyncPluginOptions> (+1 overload)
branchSync({
BranchSyncPluginOptions.using: RulesCatchAllOr<"merge" | "rebase">
using: "merge",
BranchSyncPluginOptions.enforceLinearHistory?: boolean | undefined
enforceLinearHistory: true,
}),
],
})
Keep in sync automatically
Flowie can keep your feature branch in sync with the destination automatically, so you and your team members can just pull from remote.
import {const configure: (config: Config | (() => Config)) => void
configure} from "flowie.app"
import {const branchSync: OptionsPluginNoDefault<BranchSyncPluginOptions, false>
branchSync} from "flowie.app/plugins"
function configure(config: Config | (() => Config)): void
configure({
Config.plugins?: PluginDef<unknown>[] | undefined
plugins: [
function branchSync(options: BranchSyncPluginOptions): PluginDef<BranchSyncPluginOptions> (+1 overload)
branchSync({
BranchSyncPluginOptions.using: RulesCatchAllOr<"merge" | "rebase">
using: "merge",
BranchSyncPluginOptions.auto?: RulesOr<boolean | undefined>
auto: true,
}),
],
})
Additionally, keep the branch in sync by rebasing it while it’s waiting to be merged. So it is always ready to be merged:
import {const configure: (config: Config | (() => Config)) => void
configure} from "flowie.app"
import {const branchSync: OptionsPluginNoDefault<BranchSyncPluginOptions, false>
branchSync} from "flowie.app/plugins"
import {const labels: Labels
labels, function otherwise(): true
otherwise} from "flowie.app/conditions"
function configure(config: Config | (() => Config)): void
configure({
Config.labels?: {
schema?: Array<Label>;
} | undefined
labels: {
schema?: Label[] | undefined
schema: [{BasicLabel.name: string
name: "Auto sync"}],
},
Config.plugins?: PluginDef<unknown>[] | undefined
plugins: [
function branchSync(options: BranchSyncPluginOptions): PluginDef<BranchSyncPluginOptions> (+1 overload)
branchSync({
BranchSyncPluginOptions.auto?: RulesOr<boolean | undefined>
auto: const labels: Labels
labels.Labels.has(label: string | LabelRef): ChainableCondition (+1 overload)
has("Auto sync"),
BranchSyncPluginOptions.using: RulesCatchAllOr<"rebase" | "merge">
using: [
[const labels: Labels
labels.Labels.has(label: string | LabelRef): ChainableCondition (+1 overload)
has("Draft"), "merge"],
[function otherwise(): true
otherwise, "rebase"],
],
BranchSyncPluginOptions.enforceLinearHistory?: boolean | undefined
enforceLinearHistory: true,
}),
],
})
With this config, Flowie will always keep the branch in sync by merging the destination into the feature branch, and once it is no longer a Draft pull request, it will start rebasing it.