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 all commits
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ jobs:

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):

### `branch_name`

Default: `backport-${pull_number}-to-${target_branch}`

Template used as the name for branches created by this action.

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](#placeholders).

### `copy_assignees`

Default: `false` (disabled)
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ description: >
Fast and flexible action to cherry-pick commits from labeled pull requests
author: korthout
inputs:
branch_name:
description: >
Template used as the name for branches created by this action.
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}
copy_assignees:
description: >
Controls whether to copy the assignees from the original pull request to the backport pull request.
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.

7 changes: 6 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,7 +235,11 @@ 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 {
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
Loading