MCPcopy Index your code
hub / github.com/lingodotdev/lingo.dev / PullRequestFlow

Class PullRequestFlow

packages/cli/src/cli/cmd/ci/flows/pull-request.ts:5–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import { IIntegrationFlowOptions } from "./_base";
4
5export class PullRequestFlow extends InBranchFlow {
6 async preRun() {
7 const canContinue = await super.preRun?.();
8 if (!canContinue) {
9 return false;
10 }
11
12 this.ora.start("Calculating automated branch name");
13 this.i18nBranchName = this.calculatePrBranchName();
14 this.ora.succeed(
15 `Automated branch name calculated: ${this.i18nBranchName}`,
16 );
17
18 this.ora.start("Checking if branch exists");
19 const branchExists = await this.checkBranchExistance(this.i18nBranchName);
20 this.ora.succeed(branchExists ? "Branch exists" : "Branch does not exist");
21
22 if (branchExists) {
23 this.ora.start(`Checking out branch ${this.i18nBranchName}`);
24 this.checkoutI18nBranch(this.i18nBranchName);
25 this.ora.succeed(`Checked out branch ${this.i18nBranchName}`);
26
27 this.ora.start(
28 `Syncing with ${this.platformKit.platformConfig.baseBranchName}`,
29 );
30 this.syncI18nBranch();
31 this.ora.succeed(`Checked out and synced branch ${this.i18nBranchName}`);
32 } else {
33 this.ora.start(`Creating branch ${this.i18nBranchName}`);
34 this.createI18nBranch(this.i18nBranchName);
35 this.ora.succeed(`Created branch ${this.i18nBranchName}`);
36 }
37
38 return true;
39 }
40
41 override async run(options: IIntegrationFlowOptions) {
42 return super.run({
43 force: true,
44 ...options,
45 });
46 }
47
48 async postRun() {
49 if (!this.i18nBranchName) {
50 throw new Error(
51 "i18nBranchName is not set. Did you forget to call preRun?",
52 );
53 }
54
55 this.ora.start("Checking if PR already exists");
56 const pullRequestNumber = await this.ensureFreshPr(this.i18nBranchName);
57 // await this.createLabelIfNotExists(pullRequestNumber, 'lingo.dev/i18n', false);
58 this.ora.succeed(
59 `Pull request ready: ${this.platformKit.buildPullRequestUrl(
60 pullRequestNumber,
61 )}`,
62 );

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected