(
files: (DataFile | AssetProxy)[],
slug: string,
options: PersistOptions,
)
| 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({ |
no test coverage detected