Skip to content

Commit 7d2290f

Browse files
authored
Fix standalone pull requests creating (#36)
1 parent a9dbf38 commit 7d2290f

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/actions.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,25 @@ import { processCherryPickRequest } from './processCherryPickRequest';
77
import { pushAndCreatePullRequests } from './processPullRequests';
88
import Git from './git/client';
99

10+
async function preparePayload (
11+
treeDataProvider: TreeDataProvider,
12+
options: { skipBaseUpstream: boolean } = { skipBaseUpstream: false }
13+
): Promise<TreePayload> {
14+
const branch = await Git.getBranchName();
15+
const [localBranch, baseUpstreamBranch] = Git.parseBranch(branch);
16+
Git.setBranches(localBranch, baseUpstreamBranch);
17+
18+
const payload = await getTreePayload(treeDataProvider) as TreePayload;
19+
if (options.skipBaseUpstream) {
20+
payload.upstreams = payload.upstreams.filter((upstream) => upstream !== baseUpstreamBranch);
21+
}
22+
Logger.logInfo(`branch: ${branch}, localBranch: ${localBranch}, baseUpstreamBranch: ${baseUpstreamBranch}, upstreams: ${payload.upstreams}`);
23+
24+
return payload;
25+
}
1026
export class Action {
1127
static async onPullRequest (treeDataProvider: TreeDataProvider) {
12-
const payload = await getTreePayload(treeDataProvider);
28+
const payload = await preparePayload(treeDataProvider);
1329

1430
if (!payload) {
1531
Logger.logError('no payload');
@@ -70,13 +86,7 @@ export class Action {
7086
}
7187

7288
static async onCherryPick (treeDataProvider: TreeDataProvider) {
73-
const branch = await Git.getBranchName();
74-
const [localBranch, baseUpstreamBranch] = Git.parseBranch(branch);
75-
Git.setBranches(localBranch, baseUpstreamBranch);
76-
77-
const payload = await getTreePayload(treeDataProvider) as TreePayload;
78-
payload.upstreams = payload.upstreams.filter((upstream) => upstream !== baseUpstreamBranch);
79-
Logger.logInfo(`branch: ${branch}, localBranch: ${localBranch}, baseUpstreamBranch: ${baseUpstreamBranch}, upstreams: ${payload.upstreams}`);
89+
const payload = await preparePayload(treeDataProvider, { skipBaseUpstream: true });
8090
await processCherryPickRequest(payload as TreePayload);
8191
}
8292
}

0 commit comments

Comments
 (0)