Skip to content

Commit

Permalink
fix(ng-dev/pr): add timeout to wait before commenting on pr merge (#1038
Browse files Browse the repository at this point in the history
)

Adding a 5 second wait before updating the pull request with a comment to attempt to address potential rate limitting.

PR Close #1038
  • Loading branch information
josephperrott committed Feb 23, 2023
1 parent d3026e7 commit 1338115
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/local-actions/branch-manager/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70046,7 +70046,7 @@ var MergeStrategy = class {
const localTargetBranch = this.getLocalTargetBranchName(targetBranch);
return `${localTargetBranch}:refs/heads/${targetBranch}`;
});
this.git.run(["push", this.git.getRepoGitUrl(), ...pushRefspecs]);
this.git.run(["push", "--atomic", this.git.getRepoGitUrl(), ...pushRefspecs]);
}
async _assertMergeableOrThrow({ revisionRange }, targetBranches) {
const failedBranches = this.cherryPickIntoTargetBranches(revisionRange, targetBranches, {
Expand Down Expand Up @@ -70128,6 +70128,7 @@ var AutosquashMergeStrategy = class extends MergeStrategy {
this.pushTargetBranchesUpstream(targetBranches);
const localBranch = this.getLocalTargetBranchName(githubTargetBranch);
const sha = this.git.run(["rev-parse", localBranch]).stdout.trim();
await new Promise((resolve) => setTimeout(resolve, parseInt(process.env["AUTOSQUASH_TIMEOUT"] || "0")));
await this.git.github.issues.createComment({
...this.git.remoteParams,
issue_number: pullRequest.prNumber,
Expand Down
7 changes: 6 additions & 1 deletion ng-dev/pr/merge/strategies/autosquash-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ export class AutosquashMergeStrategy extends MergeStrategy {
const localBranch = this.getLocalTargetBranchName(githubTargetBranch);
/** The SHA of the commit pushed to github which represents closing the PR. */
const sha = this.git.run(['rev-parse', localBranch]).stdout.trim();
// Allow user to set an amount of time to wait to account for rate limiting of the token usage
// during merge otherwise just waits 0 seconds.
await new Promise((resolve) =>
setTimeout(resolve, parseInt(process.env['AUTOSQUASH_TIMEOUT'] || '0')),
);
// Github automatically closes PRs whose commits are merged into the main branch on Github.
// However, it does not note them as merged using the purple merge badge as occurs when done via
// the UI. To inform users that the PR was in fact merged, add a comment expressing the fact
// that the PR is merged.
// that the PR is merged
await this.git.github.issues.createComment({
...this.git.remoteParams,
issue_number: pullRequest.prNumber,
Expand Down

0 comments on commit 1338115

Please sign in to comment.