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) => { filterOpenAuthoringBranches = async (branch: string) => {
try { try {
const contentKey = contentKeyFromBranch(branch); const pullRequest = await this.getBranchPullRequest(branch);
const { pullRequest, collection, slug } = await this.retrieveMetadata(contentKey);
const { state: currentState, merged_at: mergedAt } = pullRequest; const { state: currentState, merged_at: mergedAt } = pullRequest;
if ( if (
pullRequest.number !== MOCK_PULL_REQUEST && pullRequest.number !== MOCK_PULL_REQUEST &&
currentState === PullRequestState.Closed && currentState === PullRequestState.Closed &&
mergedAt mergedAt
) { ) {
// pr was merged, delete entry // pr was merged, delete branch
await this.deleteUnpublishedEntry(collection, slug); await this.deleteBranch(branch);
return { branch, filter: false }; return { branch, filter: false };
} else { } else {
return { branch, filter: true }; return { branch, filter: true };