MCPcopy Create free account
hub / github.com/decaporg/decap-cms / migratePullRequest

Method migratePullRequest

packages/decap-cms-backend-github/src/API.ts:832–872  ·  view source on GitHub ↗
(pullRequest: GitHubPull, countMessage: string)

Source from the content-addressed store, hash-verified

830 }
831
832 async migratePullRequest(pullRequest: GitHubPull, countMessage: string) {
833 const { number } = pullRequest;
834 console.log(`Migrating Pull Request '${number}' (${countMessage})`);
835 const contentKey = contentKeyFromBranch(pullRequest.head.ref);
836 let metadata = await this.retrieveMetadataOld(contentKey).catch(() => undefined);
837
838 if (!metadata) {
839 console.log(`Skipped migrating Pull Request '${number}' (${countMessage})`);
840 return;
841 }
842
843 let newNumber = number;
844 if (!metadata.version) {
845 console.log(`Migrating Pull Request '${number}' to version 1`);
846 // migrate branch from cms/slug to cms/collection/slug
847 try {
848 ({ metadata, pullRequest } = await this.migrateToVersion1(pullRequest, metadata));
849 } catch (e) {
850 console.log(`Failed to migrate Pull Request '${number}' to version 1. See error below.`);
851 console.error(e);
852 return;
853 }
854 newNumber = pullRequest.number;
855 console.log(
856 `Done migrating Pull Request '${number}' to version 1. New pull request '${newNumber}' created.`,
857 );
858 }
859
860 if (metadata.version === '1') {
861 console.log(`Migrating Pull Request '${newNumber}' to labels`);
862 // migrate branch from using orphan ref to store metadata to pull requests label
863 await this.migrateToPullRequestLabels(pullRequest, metadata);
864 console.log(`Done migrating Pull Request '${newNumber}' to labels`);
865 }
866
867 console.log(
868 `Done migrating Pull Request '${
869 number === newNumber ? newNumber : `${number} => ${newNumber}`
870 }'`,
871 );
872 }
873
874 async getOpenAuthoringBranches() {
875 const cmsBranches = await this.requestAllPages<

Callers 2

API.spec.jsFile · 0.80

Calls 4

retrieveMetadataOldMethod · 0.95
migrateToVersion1Method · 0.95
contentKeyFromBranchFunction · 0.90

Tested by

no test coverage detected