Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable branch_name input #416

Merged
merged 7 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
lib
.vscode/
.vs/

# Modified from https://www.toptal.com/developers/gitignore/api/node,intellij+all,visualstudiocode,macos,windows
#dist # removed because this action requires the dist to be available in the repo
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ inputs:
Please refer to this action's README for all available placeholders.
default: >-
[Backport ${target_branch}] ${pull_title}
branch_name:
description: >
Branch name to use for automatically created branches.
Placeholders can be used to define variable values.
These are indicated by a dollar sign and curly braces (`${placeholder}`).
Please refer to this action's README for all available placeholders.
default: backport-${pull_number}-to-${target_branch}
target_branches:
description: >
The action will backport the pull request to each specified target branch (space-delimited).
Expand Down
5 changes: 3 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class Backport {
}
}
try {
const branchname = `backport-${pull_number}-to-${target}`;
const branchname = utils.replacePlaceholders(this.config.pull.branch_name, mainpr, target);
console.log(`Start backport to ${branchname}`);
try {
yield this.git.checkout(branchname, `origin/${target}`, this.config.pwd);
Expand Down Expand Up @@ -932,6 +932,7 @@ function run() {
const pattern = core.getInput("label_pattern");
const description = core.getInput("pull_description");
const title = core.getInput("pull_title");
const branch_name = core.getInput("branch_name");
const copy_labels_pattern = core.getInput("copy_labels_pattern");
const target_branches = core.getInput("target_branches");
const merge_commits = core.getInput("merge_commits");
Expand All @@ -957,7 +958,7 @@ function run() {
const config = {
pwd,
labels: { pattern: pattern === "" ? undefined : new RegExp(pattern) },
pull: { description, title },
pull: { description, title, branch_name },
copy_labels_pattern: copy_labels_pattern === "" ? undefined : new RegExp(copy_labels_pattern),
target_branches: target_branches === "" ? undefined : target_branches,
commits: { merge_commits },
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type Config = {
pull: {
description: string;
title: string;
branch_name: string;
};
copy_labels_pattern?: RegExp;
target_branches?: string;
Expand Down Expand Up @@ -234,8 +235,13 @@ export class Backport {
}

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

const branchname = utils.replacePlaceholders(
this.config.pull.branch_name,
mainpr,
target,
);

console.log(`Start backport to ${branchname}`);
try {
await this.git.checkout(
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async function run(): Promise<void> {
const pattern = core.getInput("label_pattern");
const description = core.getInput("pull_description");
const title = core.getInput("pull_title");
const branch_name = core.getInput("branch_name");
const copy_labels_pattern = core.getInput("copy_labels_pattern");
const target_branches = core.getInput("target_branches");
const merge_commits = core.getInput("merge_commits");
Expand Down Expand Up @@ -44,7 +45,7 @@ async function run(): Promise<void> {
const config: Config = {
pwd,
labels: { pattern: pattern === "" ? undefined : new RegExp(pattern) },
pull: { description, title },
pull: { description, title, branch_name },
copy_labels_pattern:
copy_labels_pattern === "" ? undefined : new RegExp(copy_labels_pattern),
target_branches: target_branches === "" ? undefined : target_branches,
Expand Down