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

Method migratePullRequest

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

Source from the content-addressed store, hash-verified

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