diff --git a/apps/github-cascading-app/src/cascading/cascading-probot.ts b/apps/github-cascading-app/src/cascading/cascading-probot.ts index 9b7c2a2816..e04a75d3da 100644 --- a/apps/github-cascading-app/src/cascading/cascading-probot.ts +++ b/apps/github-cascading-app/src/cascading/cascading-probot.ts @@ -142,8 +142,22 @@ export class CascadingProbot extends Cascading { /** @inheritdoc */ protected async getBranches() { this.logger.debug('List remote branches'); - const res = await this.options.octokit.repos.listBranches(this.options.repo); - return res.data.map(({name}) => name); + /* eslint-disable camelcase, @typescript-eslint/naming-convention */ + const per_page = 100; + let pageIndex = 1; + let getCurrentPage = true; + const branchNames: string[] = []; + while (getCurrentPage && pageIndex <= 20) { + const res = await this.options.octokit.repos.listBranches({ + ...this.options.repo, + per_page, + page: pageIndex++ + }); + branchNames.push(...res.data.map(({ name }) => name)); + getCurrentPage = res.data.length === per_page; + } + return branchNames; + /* eslint-enable camelcase, @typescript-eslint/naming-convention */ } /** @inheritdoc */ diff --git a/apps/github-cascading-app/src/cascading/cascading.ts b/apps/github-cascading-app/src/cascading/cascading.ts index 27fc9f25d5..1b92d0e6a5 100644 --- a/apps/github-cascading-app/src/cascading/cascading.ts +++ b/apps/github-cascading-app/src/cascading/cascading.ts @@ -254,6 +254,7 @@ export abstract class Cascading { const openPr = await this.findOpenPullRequest(cascadingBranch, targetBranch); if (!openPr) { + this.logger.debug(`Will recreate the branch ${cascadingBranch}`); try { await this.deleteBranch(cascadingBranch); await this.createBranch(cascadingBranch, currentBranch); @@ -263,6 +264,7 @@ export abstract class Cascading { } return this.createPullRequestWithMessage(cascadingBranch, currentBranch, targetBranch, config, true); } else { + this.logger.debug(`Updating the PR ${openPr.id}`); const message = await this.generatePullRequestBody({ ...(openPr.context || { bypassReviewers: config.bypassReviewers, currentBranch, targetBranch, isConflicting: false}), bypassReviewers: false @@ -352,6 +354,7 @@ export abstract class Cascading { return; } + let isConflicting = false; if (branches.includes(cascadingBranch)) { try { await this.merge(currentBranch.branch, cascadingBranch); @@ -372,10 +375,11 @@ export abstract class Cascading { this.logger.warn(`Fail to remove the cascading branch "${cascadingBranch}"`); } const conflictCascadingBranch = this.determineCascadingBranchName(currentBranch.semver?.format() || currentBranch.branch, targetBranch.semver?.format() || targetBranch.branch, true); + isConflicting = true; await this.createBranch(conflictCascadingBranch, currentBranch.branch); } } - await this.createPullRequestWithMessage(cascadingBranch, currentBranch.branch, targetBranch.branch, config); + await this.createPullRequestWithMessage(cascadingBranch, currentBranch.branch, targetBranch.branch, config, isConflicting); } /**