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

Method editorialWorkflowGit

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

Source from the content-addressed store, hash-verified

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