in functions/src/plugins/merge.ts [128:149]
private async getPRLabels(context: Context, pr?: Github.PullRequestsGetResponse): Promise<GithubGQL.Labels['nodes']> {
const {owner, repo} = context.repo();
pr = pr || context.payload.pull_request;
const doc = this.pullRequests.doc(pr.id.toString());
const dbPR = await doc.get();
let labels: GithubGQL.Labels['nodes'];
// if the PR is already in Firebase
if(dbPR.exists) {
labels = dbPR.data().labels;
// if we have the labels listed in the PR
if(labels) {
return labels;
}
}
// otherwise get the labels from Github and update Firebase
labels = await getGhPRLabels(context.github, owner, repo, pr.number);
await this.updateDbPR(context.github, owner, repo, pr.number, context.payload.repository.id, {...pr, labels});
return labels;
}