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

feat: allow to backport unmerged prs #411

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ inputs:
- For "Merged as a merge commit", the action cherry-picks the commits from the pull request.

By default, the action always cherry-picks the commits from the pull request.

#### `allow_unmerged`

...
default: >
{
"detect_merge_method": false
"detect_merge_method": false,
"allow_unmerged": false
}
github_token:
description: >
Expand Down
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const git_1 = __nccwpck_require__(3374);
const utils = __importStar(__nccwpck_require__(918));
const experimentalDefaults = {
detect_merge_method: false,
allow_unmerged: false,
};
exports.experimentalDefaults = experimentalDefaults;
var Output;
Expand All @@ -73,7 +74,8 @@ class Backport {
const repo = (_b = (_a = payload.repository) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : this.github.getRepo().repo;
const pull_number = this.github.getPullNumber();
const mainpr = yield this.github.getPullRequest(pull_number);
if (!(yield this.github.isMerged(mainpr))) {
if (!this.config.experimental.allow_unmerged &&
!(yield this.github.isMerged(mainpr))) {
const message = "Only merged pull requests can be backported.";
this.github.createComment({
owner,
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 @@ -37,9 +37,11 @@ export type Config = {

type Experimental = {
detect_merge_method: boolean;
allow_unmerged: boolean;
};
const experimentalDefaults: Experimental = {
detect_merge_method: false,
allow_unmerged: false,
};
export { experimentalDefaults };

Expand Down Expand Up @@ -68,7 +70,10 @@ export class Backport {
const pull_number = this.github.getPullNumber();
const mainpr = await this.github.getPullRequest(pull_number);

if (!(await this.github.isMerged(mainpr))) {
if (
!this.config.experimental.allow_unmerged &&
!(await this.github.isMerged(mainpr))
) {
const message = "Only merged pull requests can be backported.";
this.github.createComment({
owner,
Expand Down