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

Method rebaseCommits

packages/decap-cms-backend-github/src/API.ts:1153–1176  ·  view source on GitHub ↗

* Rebase an array of commits one-by-one, starting from a given base SHA

(baseCommit: GitHubCompareCommit, commits: GitHubCompareCommits)

Source from the content-addressed store, hash-verified

1151 * Rebase an array of commits one-by-one, starting from a given base SHA
1152 */
1153 async rebaseCommits(baseCommit: GitHubCompareCommit, commits: GitHubCompareCommits) {
1154 /**
1155 * If the parent of the first commit already matches the target base,
1156 * return commits as is.
1157 */
1158 if (commits.length === 0 || commits[0].parents[0].sha === baseCommit.sha) {
1159 const head = last(commits) as GitHubCompareCommit;
1160 return head;
1161 } else {
1162 /**
1163 * Re-create each commit over the new base, applying each to the previous,
1164 * changing only the parent SHA and tree for each, but retaining all other
1165 * info, such as the author/committer data.
1166 */
1167 const newHeadPromise = commits.reduce((lastCommitPromise, commit) => {
1168 return lastCommitPromise.then(newParent => {
1169 const parent = newParent;
1170 const commitToRebase = commit;
1171 return this.rebaseSingleCommit(parent, commitToRebase);
1172 });
1173 }, Promise.resolve(baseCommit));
1174 return newHeadPromise;
1175 }
1176 }
1177
1178 async rebaseBranch(branch: string) {
1179 try {

Callers 1

rebaseBranchMethod · 0.95

Calls 2

rebaseSingleCommitMethod · 0.95
resolveMethod · 0.80

Tested by

no test coverage detected