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