mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-07-06 17:43:48 +00:00
perf: use concurrent promises instead of awaiting them one by one (#59)
This commit is contained in:
parent
8c010b43e4
commit
49a7350406
7 changed files with 147 additions and 222 deletions
|
@ -82,45 +82,43 @@ export default class GitHubClient implements GitClient {
|
|||
throw new Error("Pull request creation failed");
|
||||
}
|
||||
|
||||
const promises = [];
|
||||
|
||||
if (backport.labels.length > 0) {
|
||||
try {
|
||||
await this.octokit.issues.addLabels({
|
||||
promises.push(
|
||||
this.octokit.issues.addLabels({
|
||||
owner: backport.owner,
|
||||
repo: backport.repo,
|
||||
issue_number: (data as PullRequest).number,
|
||||
labels: backport.labels,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error(`Error setting labels: ${error}`);
|
||||
}
|
||||
}).catch(error => this.logger.error(`Error setting labels: ${error}`))
|
||||
);
|
||||
}
|
||||
|
||||
if (backport.reviewers.length > 0) {
|
||||
try {
|
||||
await this.octokit.pulls.requestReviewers({
|
||||
promises.push(
|
||||
this.octokit.pulls.requestReviewers({
|
||||
owner: backport.owner,
|
||||
repo: backport.repo,
|
||||
pull_number: (data as PullRequest).number,
|
||||
reviewers: backport.reviewers,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error(`Error requesting reviewers: ${error}`);
|
||||
}
|
||||
}).catch(error => this.logger.error(`Error requesting reviewers: ${error}`))
|
||||
);
|
||||
}
|
||||
|
||||
if (backport.assignees.length > 0) {
|
||||
try {
|
||||
await this.octokit.issues.addAssignees({
|
||||
promises.push(
|
||||
this.octokit.issues.addAssignees({
|
||||
owner: backport.owner,
|
||||
repo: backport.repo,
|
||||
issue_number: (data as PullRequest).number,
|
||||
assignees: backport.assignees,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error(`Error setting assignees: ${error}`);
|
||||
}
|
||||
}).catch(error => this.logger.error(`Error setting assignees: ${error}`))
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
return data.html_url;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue