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

Method editorialWorkflowGit

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

Source from the content-addressed store, hash-verified

879 }
880
881 async editorialWorkflowGit(
882 files: (DataFile | AssetProxy)[],
883 slug: string,
884 options: PersistOptions,
885 ) {
886 const contentKey = generateContentKey(options.collectionName as string, slug);
887 const branch = branchFromContentKey(contentKey);
888 const unpublished = options.unpublished || false;
889 const hasSubfolders = options.hasSubfolders !== false; // default to true
890 if (!unpublished) {
891 const items = await this.getCommitItems(files, this.branch, hasSubfolders);
892 await this.uploadAndCommit(items, {
893 commitMessage: options.commitMessage,
894 branch,
895 newBranch: true,
896 });
897 await this.createMergeRequest(
898 branch,
899 options.commitMessage,
900 options.status || this.initialWorkflowStatus,
901 );
902 } else {
903 const mergeRequest = await this.getBranchMergeRequest(branch);
904 await this.rebaseMergeRequest(mergeRequest);
905 const [items, diffs] = await Promise.all([
906 this.getCommitItems(files, branch, hasSubfolders),
907 this.getDifferences(branch),
908 ]);
909 // mark files for deletion
910 for (const diff of diffs.filter(d => d.binary)) {
911 if (!items.some(item => item.path === diff.path)) {
912 items.push({ action: CommitAction.DELETE, path: diff.newPath });
913 }
914 }
915
916 await this.uploadAndCommit(items, {
917 commitMessage: options.commitMessage,
918 branch,
919 });
920 }
921 }
922
923 async updateMergeRequestLabels(mergeRequest: GitLabMergeRequest, labels: string[]) {
924 await this.requestJSON({

Callers 1

persistFilesMethod · 0.95

Calls 10

getCommitItemsMethod · 0.95
uploadAndCommitMethod · 0.95
createMergeRequestMethod · 0.95
getBranchMergeRequestMethod · 0.95
rebaseMergeRequestMethod · 0.95
getDifferencesMethod · 0.95
generateContentKeyFunction · 0.90
branchFromContentKeyFunction · 0.90
filterMethod · 0.80
someMethod · 0.80

Tested by

no test coverage detected