Skip to content

Commit 891b4f5

Browse files
authored
Merge pull request #416 from AlexVermette-Eaton/feature/branch_name
Add configurable `branch_name` input
2 parents 1081c49 + e0ada12 commit 891b4f5

7 files changed

Lines changed: 30 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
lib
22
.vscode/
3+
.vs/
34

45
# Modified from https://www.toptal.com/developers/gitignore/api/node,intellij+all,visualstudiocode,macos,windows
56
#dist # removed because this action requires the dist to be available in the repo

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ jobs:
105105
106106
The action can be configured with the following optional [inputs](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepswith):
107107
108+
### `branch_name`
109+
110+
Default: `backport-${pull_number}-to-${target_branch}`
111+
112+
Template used as the name for branches created by this action.
113+
114+
Placeholders can be used to define variable values.
115+
These are indicated by a dollar sign and curly braces (`${placeholder}`).
116+
Please refer to this action's README for all available [placeholders](#placeholders).
117+
108118
### `copy_assignees`
109119

110120
Default: `false` (disabled)

action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ description: >
33
Fast and flexible action to cherry-pick commits from labeled pull requests
44
author: korthout
55
inputs:
6+
branch_name:
7+
description: >
8+
Template used as the name for branches created by this action.
9+
Placeholders can be used to define variable values.
10+
These are indicated by a dollar sign and curly braces (`${placeholder}`).
11+
Please refer to this action's README for all available placeholders.
12+
default: backport-${pull_number}-to-${target_branch}
613
copy_assignees:
714
description: >
815
Controls whether to copy the assignees from the original pull request to the backport pull request.

dist/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class Backport {
187187
}
188188
}
189189
try {
190-
const branchname = `backport-${pull_number}-to-${target}`;
190+
const branchname = utils.replacePlaceholders(this.config.pull.branch_name, mainpr, target);
191191
console.log(`Start backport to ${branchname}`);
192192
try {
193193
yield this.git.checkout(branchname, `origin/${target}`, this.config.pwd);
@@ -932,6 +932,7 @@ function run() {
932932
const pattern = core.getInput("label_pattern");
933933
const description = core.getInput("pull_description");
934934
const title = core.getInput("pull_title");
935+
const branch_name = core.getInput("branch_name");
935936
const copy_labels_pattern = core.getInput("copy_labels_pattern");
936937
const target_branches = core.getInput("target_branches");
937938
const merge_commits = core.getInput("merge_commits");
@@ -957,7 +958,7 @@ function run() {
957958
const config = {
958959
pwd,
959960
labels: { pattern: pattern === "" ? undefined : new RegExp(pattern) },
960-
pull: { description, title },
961+
pull: { description, title, branch_name },
961962
copy_labels_pattern: copy_labels_pattern === "" ? undefined : new RegExp(copy_labels_pattern),
962963
target_branches: target_branches === "" ? undefined : target_branches,
963964
commits: { merge_commits },

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/backport.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type Config = {
2323
pull: {
2424
description: string;
2525
title: string;
26+
branch_name: string;
2627
};
2728
copy_labels_pattern?: RegExp;
2829
target_branches?: string;
@@ -234,7 +235,11 @@ export class Backport {
234235
}
235236

236237
try {
237-
const branchname = `backport-${pull_number}-to-${target}`;
238+
const branchname = utils.replacePlaceholders(
239+
this.config.pull.branch_name,
240+
mainpr,
241+
target,
242+
);
238243

239244
console.log(`Start backport to ${branchname}`);
240245
try {

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async function run(): Promise<void> {
1616
const pattern = core.getInput("label_pattern");
1717
const description = core.getInput("pull_description");
1818
const title = core.getInput("pull_title");
19+
const branch_name = core.getInput("branch_name");
1920
const copy_labels_pattern = core.getInput("copy_labels_pattern");
2021
const target_branches = core.getInput("target_branches");
2122
const merge_commits = core.getInput("merge_commits");
@@ -44,7 +45,7 @@ async function run(): Promise<void> {
4445
const config: Config = {
4546
pwd,
4647
labels: { pattern: pattern === "" ? undefined : new RegExp(pattern) },
47-
pull: { description, title },
48+
pull: { description, title, branch_name },
4849
copy_labels_pattern:
4950
copy_labels_pattern === "" ? undefined : new RegExp(copy_labels_pattern),
5051
target_branches: target_branches === "" ? undefined : target_branches,

0 commit comments

Comments
 (0)