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

Method persistFiles

packages/decap-cms-backend-github/src/API.ts:922–944  ·  view source on GitHub ↗
(dataFiles: DataFile[], mediaFiles: AssetProxy[], options: PersistOptions)

Source from the content-addressed store, hash-verified

920 }
921
922 async persistFiles(dataFiles: DataFile[], mediaFiles: AssetProxy[], options: PersistOptions) {
923 const files = mediaFiles.concat(dataFiles);
924 const uploadPromises = files.map(file => this.uploadBlob(file));
925 await Promise.all(uploadPromises);
926
927 if (!options.useWorkflow) {
928 return this.getDefaultBranch()
929 .then(branchData =>
930 this.updateTree(branchData.commit.sha, files as { sha: string; path: string }[]),
931 )
932 .then(changeTree => this.commit(options.commitMessage, changeTree))
933 .then(response => this.patchBranch(this.branch, response.sha));
934 } else {
935 const mediaFilesList = (mediaFiles as { sha: string; path: string }[]).map(
936 ({ sha, path }) => ({
937 path: trimStart(path, '/'),
938 sha,
939 }),
940 );
941 const slug = dataFiles[0].slug;
942 return this.editorialWorkflowGit(files as TreeFile[], slug, mediaFilesList, options);
943 }
944 }
945
946 async getFileSha(path: string, { repoURL = this.repoURL, branch = this.branch } = {}) {
947 /**

Callers 3

persistEntryMethod · 0.45
persistMediaMethod · 0.45
API.spec.jsFile · 0.45

Calls 7

uploadBlobMethod · 0.95
getDefaultBranchMethod · 0.95
updateTreeMethod · 0.95
commitMethod · 0.95
patchBranchMethod · 0.95
editorialWorkflowGitMethod · 0.95
mapMethod · 0.80

Tested by

no test coverage detected