Skip to content

Commit

Permalink
feat: remove branchName setting
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `branchName` setting is removed. Use `branches` instead.
  • Loading branch information
saitho committed Feb 12, 2023
1 parent 40ea366 commit 7a5772d
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 391 deletions.
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ In such cases the release workflow will fail, causing a red pipeline!
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

| Step | Description |
|--------------------|------------------------------------------------------------------------------------------------------------------------------------|
| `verifyConditions` | Verify the access to the remote Git repository, the ['branchName'](#branchName) option configuration. |
| `done` | Create a back-merge into the configured branch if the release is successful. |
| Step | Description |
|--------------------|---------------------------------------------------------------------------------------------------|
| `verifyConditions` | Verify the access to the remote Git repository, the ['branches'](#branches) option configuration. |
| `done` | Create a back-merge into the configured branch if the release is successful. |

## Install

Expand Down Expand Up @@ -97,22 +97,6 @@ The personal access token in `GITHUB_TOKEN` needs access to the `repo` scope.
| `restoreWorkspace` | Restore the stashed workspace after backmerge completed. See [restoreWorkspace](#restoreWorkspace). | false |
| `mergeMode` | Mode for merging (when `backmergeStrategy=merge`). See [mergeMode](#mergeMode). | none |

#### `branchName` (deprecated)

**Deprecated:** Use [`backmergeBranches`](#backmergeBranches) instead (e.g. `backmergeBranches: ["develop"]`)

Branch name of the branch that should receive the back-merge. If none is given, the default value is used.
You may use [Lodash template](https://lodash.com/docs#template) variables here. The following variables are available:

| Parameter | Description |
|---------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `branch` | The branch from which the release is done. |
| `branch.name` | The branch name. |
| `branch.type` | The [type of branch](https://github.com/semantic-release/semantic-release/blob/beta/docs/usage/workflow-configuration.md#branch-types). |
| `branch.channel` | The distribution channel on which to publish releases from this branch. |
| `branch.range` | The range of [semantic versions](https://semver.org) to support on this branch. |
| `branch.prerelease` | The prerelease detonation to append to [semantic versions](https://semver.org) released from this branch. |

#### `backmergeBranches`

Branch names that should receive the back-merge. If none is given, the default value is used.
Expand Down
1 change: 0 additions & 1 deletion src/definitions/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type BranchTypeStruct = {from: string; to: string}
type BranchType = string|BranchTypeStruct

export interface Config {
branchName: string; // deprecated
branches: BranchType[]; // deprecated
backmergeBranches: BranchType[];
backmergeStrategy: BackmergeStrategy;
Expand Down
7 changes: 0 additions & 7 deletions src/definitions/errors.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
const linkify = (file: string) => `https://github.com/saitho/semantic-release-backmerge/blob/master/${file}`;

export const ERROR_DEFINITIONS = {
// @ts-ignore
EINVALIDBRANCHNAME: ({branchName}) => ({
message: 'Invalid `branchName` option.',
details: `The [branchName option](${linkify(
'README.md#branchName'
)}) option must be a \`String\`. Your configuration for the \`branchName\` option is \`${branchName}\`.`,
}),
// @ts-ignore
EINVALIDBACKMERGEBRANCHES: ({backmergeBranches}) => ({
message: 'Invalid `backmergeBranches` option.',
Expand Down
4 changes: 1 addition & 3 deletions src/helpers/resolve-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ const {isNil} = lodash;
import {Config} from "../definitions/config.js";

export function resolveConfig(config: Partial<Config>): Config {
let {branchName, branches, backmergeBranches, backmergeStrategy, plugins, message, forcePush, allowSameBranchMerge, clearWorkspace, restoreWorkspace, mergeMode} = config
let {branches, backmergeBranches, backmergeStrategy, plugins, message, forcePush, allowSameBranchMerge, clearWorkspace, restoreWorkspace, mergeMode} = config
if (isNil(branches)) {
backmergeBranches = isNil(backmergeBranches) ? ['develop'] : backmergeBranches;
}
return {
// @deprecated branchName – todo: remove with next major release
branchName: isNil(branchName) ? '' : branchName,
branches: branches,
backmergeBranches: backmergeBranches,
backmergeStrategy: isNil(backmergeStrategy) ? 'rebase' : backmergeStrategy,
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export async function verifyConditions(pluginConfig: Config, context: Context) {
if (options.prepare) {
const preparePlugin = castArray(options.prepare)
.find(config => config.path && config.path === '@saithodev/semantic-release-backmerge') || {};
pluginConfig.branchName = defaultTo(realPluginConfig.branchName, preparePlugin.branchName);
pluginConfig.branches = defaultTo(realPluginConfig.branches, preparePlugin.branches);
pluginConfig.backmergeBranches = defaultTo(realPluginConfig.backmergeBranches, preparePlugin.backmergeBranches);
pluginConfig.backmergeStrategy = defaultTo(realPluginConfig.backmergeStrategy, preparePlugin.backmergeStrategy);
Expand Down
Loading

0 comments on commit 7a5772d

Please sign in to comment.