fix(open-authoring): properly delete open authoring branches (#3512)

This commit is contained in:
Erez Rokah 2020-04-01 12:42:32 +03:00 committed by GitHub
parent 49098de27f
commit cc89aa5c43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -712,16 +712,15 @@ export default class API {
filterOpenAuthoringBranches = async (branch: string) => {
try {
const contentKey = contentKeyFromBranch(branch);
const { pullRequest, collection, slug } = await this.retrieveMetadata(contentKey);
const pullRequest = await this.getBranchPullRequest(branch);
const { state: currentState, merged_at: mergedAt } = pullRequest;
if (
pullRequest.number !== MOCK_PULL_REQUEST &&
currentState === PullRequestState.Closed &&
mergedAt
) {
// pr was merged, delete entry
await this.deleteUnpublishedEntry(collection, slug);
// pr was merged, delete branch
await this.deleteBranch(branch);
return { branch, filter: false };
} else {
return { branch, filter: true };