(to: string, from = this.branch)
| 782 | } |
| 783 | |
| 784 | async getDifferences(to: string, from = this.branch) { |
| 785 | if (to === from) { |
| 786 | return []; |
| 787 | } |
| 788 | const result: { diffs: GitLabCommitDiff[] } = await this.requestJSON({ |
| 789 | url: `${this.repoURL}/repository/compare`, |
| 790 | params: { |
| 791 | from, |
| 792 | to, |
| 793 | }, |
| 794 | }); |
| 795 | |
| 796 | if (result.diffs.length >= 1000) { |
| 797 | throw new APIError('Diff limit reached', null, API_NAME); |
| 798 | } |
| 799 | |
| 800 | return result.diffs.map(d => { |
| 801 | let status = 'modified'; |
| 802 | if (d.new_file) { |
| 803 | status = 'added'; |
| 804 | } else if (d.deleted_file) { |
| 805 | status = 'deleted'; |
| 806 | } else if (d.renamed_file) { |
| 807 | status = 'renamed'; |
| 808 | } |
| 809 | return { |
| 810 | status, |
| 811 | oldPath: d.old_path, |
| 812 | newPath: d.new_path, |
| 813 | newFile: d.new_file, |
| 814 | path: d.new_path || d.old_path, |
| 815 | binary: d.diff.startsWith('Binary') || /.svg$/.test(d.new_path), |
| 816 | }; |
| 817 | }); |
| 818 | } |
| 819 | |
| 820 | async retrieveUnpublishedEntryData(contentKey: string) { |
| 821 | const { collection, slug } = parseContentKey(contentKey); |
no test coverage detected