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

Method editorialWorkflowGit

packages/decap-cms-backend-forgejo/src/API.ts:967–1003  ·  view source on GitHub ↗
(
    files: (DataFile | AssetProxy)[],
    slug: string,
    collection: string,
    options: PersistOptions,
  )

Source from the content-addressed store, hash-verified

965 }
966
967 async editorialWorkflowGit(
968 files: (DataFile | AssetProxy)[],
969 slug: string,
970 collection: string,
971 options: PersistOptions,
972 ) {
973 const contentKey = this.generateContentKey(collection, slug);
974 const branch = branchFromContentKey(contentKey);
975
976 let branchExists = false;
977 try {
978 await this.getBranch(branch);
979 branchExists = true;
980 } catch (e) {
981 // Only treat a 404 "not found" as the branch not existing; rethrow other errors.
982 if (!(e instanceof APIError && e.status === 404)) {
983 throw e;
984 }
985 }
986
987 if (!branchExists) {
988 // Create the branch from the default branch
989 await this.createBranch(branch, this.branch);
990 }
991
992 // Persist files to the branch
993 const operations = await this.getChangeFileOperations(files, branch);
994 await this.changeFilesOnBranch(operations, options, branch);
995
996 // For open authoring, don't create a PR - entries start as branch-only (draft).
997 // PRs are created later via updateUnpublishedEntryStatus when moving to pending_review.
998 if (!branchExists && !this.useOpenAuthoring) {
999 const pr = await this.createPR(options.commitMessage, branch);
1000 const status = options.status || this.initialWorkflowStatus;
1001 await this.setPullRequestStatus(pr, status);
1002 }
1003 }
1004
1005 async changeFilesOnBranch(
1006 operations: ChangeFileOperation[],

Callers 2

persistEntryMethod · 0.45
API.spec.jsFile · 0.45

Calls 8

generateContentKeyMethod · 0.95
getBranchMethod · 0.95
createBranchMethod · 0.95
changeFilesOnBranchMethod · 0.95
createPRMethod · 0.95
setPullRequestStatusMethod · 0.95
branchFromContentKeyFunction · 0.90

Tested by

no test coverage detected