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

Method persistFiles

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

Source from the content-addressed store, hash-verified

958 }
959
960 async persistFiles(dataFiles: DataFile[], mediaFiles: AssetProxy[], options: PersistOptions) {
961 const files = mediaFiles.concat(dataFiles);
962 const uploadPromises = files.map(file => this.uploadBlob(file));
963 await Promise.all(uploadPromises);
964
965 if (!options.useWorkflow) {
966 return this.getDefaultBranch()
967 .then(branchData =>
968 this.updateTree(branchData.commit.sha, files as { sha: string; path: string }[]),
969 )
970 .then(changeTree => this.commit(options.commitMessage, changeTree))
971 .then(response => this.patchBranch(this.branch, response.sha));
972 } else {
973 const mediaFilesList = (mediaFiles as { sha: string; path: string }[]).map(
974 ({ sha, path }) => ({
975 path: trimStart(path, '/'),
976 sha,
977 }),
978 );
979 const slug = dataFiles[0].slug;
980 return this.editorialWorkflowGit(files as TreeFile[], slug, mediaFilesList, options);
981 }
982 }
983
984 async getFileSha(path: string, { repoURL = this.repoURL, branch = this.branch } = {}) {
985 /**

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