(baseCommit: GitHubCompareCommit, commit: GitHubCompareCommit)
| 1106 | } |
| 1107 | |
| 1108 | async rebaseSingleCommit(baseCommit: GitHubCompareCommit, commit: GitHubCompareCommit) { |
| 1109 | // first get the diff between the commits |
| 1110 | const result = await this.getDifferences(commit.parents[0].sha, commit.sha); |
| 1111 | const files = getTreeFiles(result.files as GitHubCompareFiles); |
| 1112 | |
| 1113 | // only update the tree if changes were detected |
| 1114 | if (files.length > 0) { |
| 1115 | // create a tree with baseCommit as the base with the diff applied |
| 1116 | const tree = await this.updateTree(baseCommit.sha, files); |
| 1117 | const { message, author, committer } = commit.commit; |
| 1118 | |
| 1119 | // create a new commit from the updated tree |
| 1120 | const newCommit = await this.createCommit( |
| 1121 | message, |
| 1122 | tree.sha, |
| 1123 | [baseCommit.sha], |
| 1124 | author |
| 1125 | ? { name: author.name || '', email: author.email || '', date: author.date } |
| 1126 | : undefined, |
| 1127 | committer |
| 1128 | ? { name: committer.name || '', email: committer.email || '', date: committer.date } |
| 1129 | : undefined, |
| 1130 | ); |
| 1131 | return newCommit as unknown as GitHubCompareCommit; |
| 1132 | } else { |
| 1133 | return commit; |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | /** |
| 1138 | * Rebase an array of commits one-by-one, starting from a given base SHA |
no test coverage detected