Skip to content

Commit cd13022

Browse files
Alexandre Vermette LefebvreAlexandre Vermette Lefebvre
authored andcommitted
Added branch name input. Upgraded vulnerable packages.
1 parent 1081c49 commit cd13022

7 files changed

Lines changed: 30 additions & 14 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

action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ inputs:
8080
Please refer to this action's README for all available placeholders.
8181
default: >-
8282
[Backport ${target_branch}] ${pull_title}
83+
branch_name:
84+
description: >
85+
Branch name to use for automatically created branches.
86+
Placeholders can be used to define variable values.
87+
These are indicated by a dollar sign and curly braces (`${placeholder}`).
88+
Please refer to this action's README for all available placeholders.
89+
default: backport-${pull_number}-to-${target_branch}
8390
target_branches:
8491
description: >
8592
The action will backport the pull request to each specified target branch (space-delimited).

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.

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/backport.ts

Lines changed: 7 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,8 +235,13 @@ export class Backport {
234235
}
235236

236237
try {
237-
const branchname = `backport-${pull_number}-to-${target}`;
238238

239+
const branchname = utils.replacePlaceholders(
240+
this.config.pull.branch_name,
241+
mainpr,
242+
target,
243+
);
244+
239245
console.log(`Start backport to ${branchname}`);
240246
try {
241247
await this.git.checkout(

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)