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

Method editorialWorkflowGit

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

Source from the content-addressed store, hash-verified

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